:root {
  --bg: #0f1217;
  --bg-2: #151a21;
  --card: #1a2029;
  --card-2: #202733;
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --text: #e8ebf0;
  --muted: #8b95a5;
  --amber: #f2b544;
  --amber-2: #e08e1b;
  --amber-soft: rgba(242, 181, 68, 0.12);
  --green: #34d399;
  --green-2: #10b981;
  --green-soft: rgba(52, 211, 153, 0.1);
  --red: #f87171;
  --radius: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(242, 181, 68, 0.08), transparent 70%),
    radial-gradient(800px 500px at 100% 100%, rgba(16, 185, 129, 0.05), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15, 18, 23, 0.82);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
}
.topbar-inner, .progress { max-width: 640px; margin: 0 auto; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 12px; color: #1a1205;
  background: linear-gradient(135deg, var(--amber), var(--amber-2));
  box-shadow: 0 4px 16px rgba(242, 181, 68, 0.25);
}
.brand-sub { margin: 0; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); font-weight: 600; }
.brand-title { margin: 2px 0 0; font-family: "Cinzel", serif; font-size: 19px; font-weight: 700; letter-spacing: 0.02em; }

.progress { margin-top: 12px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.progress-meta strong { color: var(--text); font-variant-numeric: tabular-nums; }
#progressPct { font-variant-numeric: tabular-nums; }
.progress-track { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%; border-radius: inherit;
  background: linear-gradient(90deg, var(--amber-2), var(--amber));
  transition: width 0.5s var(--ease), background 0.4s;
  box-shadow: 0 0 12px rgba(242, 181, 68, 0.5);
}
.progress.done .progress-fill { background: linear-gradient(90deg, var(--green-2), var(--green)); box-shadow: 0 0 12px rgba(52, 211, 153, 0.5); }
.progress.done #progressPct { color: var(--green); }

/* ---------- Buttons ---------- */
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: 12px; border: 1px solid var(--border-2);
  background: rgba(255, 255, 255, 0.03); color: var(--text);
  font: 600 14px "Inter", sans-serif; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.07); border-color: var(--amber); }
.btn-ghost:active { transform: scale(0.96); }
.btn-ghost.lg { padding: 14px 22px; font-size: 15px; }

/* ---------- Layout ---------- */
.container { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 120px); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }

.fields { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.field-label em { font-weight: 400; font-style: normal; opacity: 0.7; }
input, textarea {
  width: 100%; font: 500 16px "Inter", sans-serif; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 12px;
  padding: 14px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
textarea { resize: vertical; min-height: 100px; }
input::placeholder, textarea::placeholder { color: #566072; }
input:focus, textarea:focus { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
#pin { letter-spacing: 0.3em; }

/* ---------- Sections ---------- */
.section { margin-bottom: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 10px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0; font-family: "Cinzel", serif; font-size: 15px; font-weight: 700; letter-spacing: 0.04em; color: var(--amber); }
.section-num {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px;
  font: 700 12px "Inter", sans-serif; color: var(--amber); background: var(--amber-soft); border: 1px solid rgba(242, 181, 68, 0.3);
}
.section-count { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; padding: 4px 8px; border-radius: 99px; background: rgba(255,255,255,0.04); transition: color 0.3s, background 0.3s; }
.section.complete .section-count { color: var(--green); background: var(--green-soft); }
.items { display: grid; gap: 10px; }

/* ---------- Checklist rows ---------- */
.item {
  position: relative; display: flex; align-items: flex-start; gap: 14px;
  padding: 16px; min-height: 64px; cursor: pointer; user-select: none;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  transition: background 0.25s, border-color 0.25s, transform 0.12s var(--ease);
}
.item:hover { border-color: var(--border-2); }
.item:active { transform: scale(0.985); }
.item input { position: absolute; opacity: 0; pointer-events: none; }
.item:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--amber-soft); border-color: var(--amber); }

.box {
  flex: none; width: 28px; height: 28px; margin-top: 1px; border-radius: 9px;
  display: grid; place-items: center;
  border: 2px solid #3a4352; background: var(--bg-2);
  transition: background 0.25s, border-color 0.25s, transform 0.3s var(--ease);
}
.box svg { width: 16px; height: 16px; stroke: #062b1f; stroke-width: 3.5; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset 0.3s 0.05s var(--ease); }
.item-text { flex: 1; min-width: 0; }
.item-label { position: relative; display: inline; font-size: 16px; font-weight: 500; line-height: 1.4; transition: color 0.25s; background: linear-gradient(currentColor, currentColor) no-repeat 0 55% / 0% 1.5px; transition: background-size 0.35s var(--ease), color 0.25s; }
.item-note { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }

.item.checked { background: linear-gradient(0deg, var(--green-soft), var(--green-soft)), var(--card); border-color: rgba(52, 211, 153, 0.45); }
.item.checked .box { background: var(--green); border-color: var(--green); transform: scale(1.08); }
.item.checked .box svg { stroke-dashoffset: 0; }
.item.checked .item-label { color: #9aa5b5; background-size: 100% 1.5px; }
.item.checked .item-note { opacity: 0.6; }
.item.pop .box { animation: pop 0.35s var(--ease); }
@keyframes pop { 50% { transform: scale(1.25); } }

/* Chucky callout */
.item.chucky {
  border: 1.5px solid rgba(242, 181, 68, 0.6);
  background: linear-gradient(135deg, rgba(242, 181, 68, 0.1), rgba(242, 181, 68, 0.02)), var(--card);
  box-shadow: 0 0 0 4px rgba(242, 181, 68, 0.06), 0 8px 24px rgba(0, 0, 0, 0.25);
  padding-top: 26px;
}
.chucky-badge {
  position: absolute; top: -11px; left: 14px;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: #1a1205; background: linear-gradient(135deg, var(--amber), var(--amber-2));
  box-shadow: 0 4px 12px rgba(242, 181, 68, 0.35);
}
.item.chucky:not(.checked) .chucky-badge { animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.item.chucky.checked { border-color: rgba(52, 211, 153, 0.55); box-shadow: none; }
.item.chucky.checked .chucky-badge { background: linear-gradient(135deg, var(--green), var(--green-2)); color: #062b1f; box-shadow: none; }

/* ---------- Error & submit ---------- */
.error {
  display: flex; gap: 10px; align-items: flex-start;
  margin-bottom: 16px; padding: 14px 16px; border-radius: 12px;
  color: #fecaca; background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.4);
  font-size: 14px; font-weight: 500; animation: shake 0.4s;
}
.error[hidden] { display: none; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.submit-wrap {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(to top, var(--bg) 60%, rgba(15, 18, 23, 0));
}
.btn-primary {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 608px; margin: 0 auto; min-height: 58px;
  border: 0; border-radius: 16px; cursor: pointer;
  font: 700 16px "Inter", sans-serif; letter-spacing: 0.01em;
  color: #062b1f; background: linear-gradient(135deg, var(--green), var(--green-2));
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.3);
  transition: transform 0.12s, box-shadow 0.25s, opacity 0.25s, background 0.25s;
}
.btn-primary:not(:disabled):active { transform: scale(0.98); }
.btn-primary:disabled { cursor: not-allowed; color: var(--muted); background: var(--card-2); box-shadow: none; border: 1px solid var(--border); }
.spinner { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(6, 43, 31, 0.3); border-top-color: #062b1f; animation: spin 0.7s linear infinite; }
.btn-primary.loading .spinner { display: block; }
.btn-primary.loading:disabled { color: #062b1f; background: linear-gradient(135deg, var(--green), var(--green-2)); opacity: 0.8; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Success ---------- */
.success { display: grid; place-items: center; min-height: calc(100dvh - 140px); padding-bottom: 40px; }
.success-card {
  width: 100%; text-align: center; padding: 40px 24px;
  background: radial-gradient(400px 200px at 50% 0, rgba(52, 211, 153, 0.12), transparent 70%), var(--card);
  border: 1px solid rgba(52, 211, 153, 0.3); border-radius: 24px;
  animation: rise 0.6s var(--ease);
}
.success-card h2 { margin: 20px 0 8px; font-family: "Cinzel", serif; font-size: 26px; color: var(--green); }
.success-card p { margin: 0 0 6px; color: var(--muted); line-height: 1.5; }
.success-time { color: var(--text) !important; font-weight: 600; font-variant-numeric: tabular-nums; }
.success-sub { margin: 18px 0 26px !important; }
.success-badge { width: 88px; height: 88px; margin: 0 auto; border-radius: 50%; background: var(--green-soft); display: grid; place-items: center; box-shadow: 0 0 0 10px rgba(52, 211, 153, 0.05); }
.success-badge svg { width: 64px; height: 64px; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.success-badge circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 0.7s 0.15s var(--ease) forwards; }
.success-badge path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.4s 0.7s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(20px) scale(0.97); } }

body.is-success .progress { display: none; }

/* ---------- Desktop ---------- */
@media (min-width: 720px) {
  .container { padding-top: 28px; }
  .brand-title { font-size: 22px; }
  .item { padding: 18px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .success-badge circle, .success-badge path { stroke-dashoffset: 0; }
}
