/* The whole look in one file: tokens first, then the shell, then the shared
   pieces every challenge builds from. Challenge-specific styles live in
   css/modes/<id>.css and should only use the tokens and classes defined here. */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #FFF5E4;
  --bg-dot: rgba(36, 27, 20, .07);
  --paper: #FFFFFF;
  --ink: #241B14;
  --ink-2: #5E5044;
  --ink-3: #9A8B7C;
  --rule: #EADBC3;

  --tangerine: #FF8A34;  --tangerine-soft: #FFE3CC;
  --grape: #8B5CF6;      --grape-soft: #E9DFFF;
  --mint: #19B89A;       --mint-soft: #CFF5EA;
  --pink: #FF5C8A;       --pink-soft: #FFDCE6;
  --blue: #3B82F6;       --blue-soft: #DBE8FF;

  /* feedback: colder to hotter, then right / wrong */
  --cold: #4DA3FF;  --cold-soft: #DCEBFF;
  --warm: #FF9F2E;  --warm-soft: #FFE8C9;
  --hot: #FF5A4E;   --hot-soft: #FFDAD6;
  --hit: #2FBF71;   --hit-soft: #D2F5E1;
  --miss: #3A322B;  --miss-soft: #E7E0D6;

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --stroke: 2.5px;
  --lift: 0 4px 0 var(--ink);
  --lift-sm: 0 3px 0 var(--ink);
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Nunito", "Varela Round",
          "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;

  --accent: var(--tangerine);
  --accent-soft: var(--tangerine-soft);
}
.accent-tangerine { --accent: var(--tangerine); --accent-soft: var(--tangerine-soft); }
.accent-grape     { --accent: var(--grape);     --accent-soft: var(--grape-soft); }
.accent-mint      { --accent: var(--mint);      --accent-soft: var(--mint-soft); }
.accent-pink      { --accent: var(--pink);      --accent-soft: var(--pink-soft); }
.accent-blue      { --accent: var(--blue);      --accent-soft: var(--blue-soft); }

@property --p { syntax: '<number>'; inherits: false; initial-value: 0; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1.2px, transparent 1.3px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body.modal-open { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.app {
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.main { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.boot { text-align: center; color: var(--ink-2); padding: 48px 0; font-weight: 700; }

/* ---------- helpers ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.muted { color: var(--ink-2); }
.small { font-size: 14.5px; }
.kicker { font-size: 12.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.big-number { font-size: 40px; font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- icons ---------- */
.icon { width: 22px; height: 22px; flex: none; display: block; }
.icon-lg { width: 30px; height: 30px; }
.icon-food { width: 40px; height: 40px; }
.icon-hero { width: 64px; height: 64px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; min-width: 0; }
.descriptor { font-size: 12.5px; font-weight: 700; line-height: 1.25; color: var(--ink-2); }
.wordmark {
  display: inline-block;
  background: var(--ink);
  color: var(--bg);
  font-weight: 900;
  font-size: 23px;
  letter-spacing: -.01em;
  line-height: 1;
  padding: 9px 14px 10px;
  border-radius: 14px;
  text-decoration: none;
  transform: rotate(-2deg);
  box-shadow: 4px 4px 0 var(--tangerine);
  max-width: 62vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  appearance: none;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: var(--paper);
  border: var(--stroke) solid var(--ink);
  border-radius: 13px;
  box-shadow: var(--lift-sm);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s, box-shadow .06s;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800;
  font-size: 17px;
  color: var(--ink);
  background: var(--accent);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--r-md);
  padding: 12px 18px;
  box-shadow: var(--lift);
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s, box-shadow .06s, background-color .12s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: var(--paper); }
.btn-dark { background: var(--ink); color: var(--bg); box-shadow: 0 4px 0 var(--accent); }
.btn-dark:active:not(:disabled) { box-shadow: 0 1px 0 var(--accent); }
.btn-small { padding: 7px 12px; font-size: 15px; border-radius: 11px; box-shadow: var(--lift-sm); }
.btn-block { display: flex; width: 100%; }

/* ---------- cards, chips ---------- */
.card {
  background: var(--paper);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--lift);
  padding: 16px;
}
.card-flat { box-shadow: none; }
.card-accent { background: var(--accent-soft); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--bg);
  font-size: 13.5px;
  font-weight: 800;
  white-space: nowrap;
}
.chip-accent { background: var(--accent); }
.chip-soft { background: var(--accent-soft); }
.chip .icon { width: 15px; height: 15px; }

/* ---------- home ---------- */
.daybar { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 2px; }
.daybar .day { font-weight: 900; font-size: 18px; }
.daybar .countdown { font-size: 14px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.tray { display: flex; flex-direction: column; gap: 12px; }
.tray-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tray-score { font-size: 38px; font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.tray-score small { font-size: 17px; font-weight: 800; color: var(--ink-2); letter-spacing: 0; }
.tray-standing { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tray-standing .headline { font-size: 22px; font-weight: 900; line-height: 1.1; }
.tray-dots { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.tray-dot { height: 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--bg); overflow: hidden; }
.tray-dot > span { display: block; height: 100%; background: var(--accent); border-right: 2px solid var(--ink); }
.tray-dot > span[data-full] { border-right: 0; }

.mode-list { display: flex; flex-direction: column; gap: 12px; }
.mode-card {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s, box-shadow .06s;
}
.mode-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.bubble {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  border: var(--stroke) solid var(--ink);
  border-radius: 16px;
  flex: none;
}
.mode-card h3 { font-size: 19px; font-weight: 900; line-height: 1.15; }
.mode-card p { font-size: 14.5px; color: var(--ink-2); line-height: 1.3; margin-top: 2px; }
.mode-state { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.mode-state .score { font-size: 26px; font-weight: 900; line-height: 1; }
.mode-state .score small { font-size: 13px; color: var(--ink-2); font-weight: 800; }
.mode-state .standing { font-size: 13px; font-weight: 800; color: var(--ink-2); white-space: nowrap; }
.pill {
  display: inline-block;
  padding: 6px 13px;
  border: var(--stroke) solid var(--ink);
  border-radius: 999px;
  background: var(--accent);
  font-weight: 900;
  font-size: 15px;
  box-shadow: var(--lift-sm);
  white-space: nowrap;
}
.pill-resume { background: var(--paper); }

/* ---------- challenge screen ---------- */
.play-head { display: flex; align-items: center; gap: 10px; }
.play-head h1 { font-size: 22px; font-weight: 900; line-height: 1.1; flex: 1; min-width: 0; }
.play-head .chip { flex: none; }
.stage { display: flex; flex-direction: column; gap: 14px; }

.intro { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 22px 18px; }
.intro .bubble { width: 92px; height: 92px; border-radius: 26px; }
.intro h2 { font-size: 26px; font-weight: 900; }
.intro ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; text-align: left; width: 100%; counter-reset: step; }
.intro li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; font-size: 16px; }
.intro li::before {
  counter-increment: step; content: counter(step);
  width: 26px; height: 26px; display: grid; place-items: center;
  background: var(--accent); border: 2px solid var(--ink); border-radius: 50%;
  font-weight: 900; font-size: 14px;
}

/* result card */
.result { display: flex; flex-direction: column; gap: 14px; }
.result-top { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.score-ring {
  --p: 0;
  transition: --p .9s cubic-bezier(.2, .8, .2, 1);
  width: 98px; height: 98px;
  border-radius: 50%;
  border: var(--stroke) solid var(--ink);
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--paper) 0);
  display: grid; place-items: center;
  flex: none;
}
.score-ring > div {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: var(--stroke) solid var(--ink);
  background: var(--paper);
  display: grid; place-items: center;
  font-size: 30px; font-weight: 900; line-height: 1;
}
.result .headline { font-size: 25px; font-weight: 900; line-height: 1.1; }
.result .squares { font-size: 20px; letter-spacing: 2px; line-height: 1.3; word-break: break-all; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-actions .btn { padding-left: 10px; padding-right: 10px; }
.note { font-size: 13.5px; color: var(--ink-2); }

.verdict {
  align-self: flex-start;
  padding: 2px 10px;
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 12.5px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase;
  white-space: nowrap;
}
.mascot { width: 60px; height: 60px; flex: none; display: block; }
.mascot.bob { animation: bob 2.6s ease-in-out infinite; }

/* ---------- shared challenge pieces ---------- */
.item-card { display: flex; align-items: center; gap: 12px; }
.item-card .item-name { font-size: 21px; font-weight: 900; line-height: 1.15; }
.item-card .item-meta { font-size: 14.5px; color: var(--ink-2); font-weight: 700; margin-top: 2px; }
.item-card.compact .bubble { width: 44px; height: 44px; border-radius: 13px; }
.item-card.compact .icon-food { width: 30px; height: 30px; }
.item-card.compact .item-name { font-size: 17px; }

.field {
  width: 100%; min-width: 0;
  font: inherit; font-size: 20px; font-weight: 800;
  color: var(--ink);
  background: var(--paper);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--r-md);
  padding: 11px 14px;
  box-shadow: inset 0 3px 0 rgba(36, 27, 20, .07);
}
.field::placeholder { color: var(--ink-3); font-weight: 700; }
.field:focus { outline: 3px solid var(--accent); outline-offset: 1px; }
.form-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: stretch; }

/* a tappable answer */
.option {
  appearance: none;
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left;
  font-weight: 800; font-size: 16.5px;
  background: var(--paper);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--r-md);
  padding: 12px 14px;
  box-shadow: var(--lift-sm);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s, box-shadow .06s, background-color .12s;
}
.option:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.option:disabled { cursor: default; }
.option.is-picked { background: var(--accent-soft); }
.option.is-right { background: var(--hit-soft); }
.option.is-wrong { background: var(--hot-soft); }
.option.is-dim { opacity: .55; }

/* feedback colours for tiles, rows and badges */
.tone-hit  { background: var(--hit);  color: #fff; }
.tone-hot  { background: var(--hot);  color: #fff; }
.tone-warm { background: var(--warm); color: var(--ink); }
.tone-cold { background: var(--cold); color: var(--ink); }
.tone-miss { background: var(--miss); color: #fff; }
.tone-idle { background: var(--bg);   color: var(--ink-3); }
.badge {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 34px;
  padding: 3px 9px;
  border: 2px solid var(--ink);
  border-radius: 9px;
  font-weight: 900; font-size: 14px;
  white-space: nowrap;
}

.facts { display: flex; flex-wrap: wrap; gap: 6px; }
.meter { height: 14px; border: 2px solid var(--ink); border-radius: 999px; background: var(--bg); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); transition: width .2s linear; }

/* ---------- modal + toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(36, 27, 20, .55);
  display: grid; align-items: end; justify-items: center;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 500px;
  max-height: 86dvh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  animation: rise .2s cubic-bezier(.2, .9, .3, 1.2);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.modal-head h2 { font-size: 23px; font-weight: 900; }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-body ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
@media (min-width: 620px) { .modal-backdrop { align-items: center; } }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px);
  max-width: min(440px, calc(100vw - 32px));
  background: var(--ink); color: var(--bg);
  font-weight: 800; font-size: 15.5px; text-align: center;
  padding: 11px 16px;
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--tangerine);
  opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { border: 2px solid var(--ink); border-radius: var(--r-md); background: var(--bg); padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 26px; font-weight: 900; line-height: 1.1; }
.stat span { font-size: 12.5px; font-weight: 800; color: var(--ink-2); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: right; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); padding: 4px 6px; }
.table th:first-child, .table td:first-child { text-align: left; }
.table td { padding: 8px 6px; border-top: 2px solid var(--rule); text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- footer + text pages ---------- */
.footer { margin-top: auto; padding-top: 10px; text-align: center; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; }
.footer a { font-weight: 800; }
.prose { display: flex; flex-direction: column; gap: 12px; }
.prose h1 { font-size: 28px; font-weight: 900; line-height: 1.15; }
.prose h2 { font-size: 19px; font-weight: 900; margin-top: 8px; }
.prose ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.prose a { font-weight: 800; }

/* ---------- motion ---------- */
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes pop { 0% { transform: scale(.92); opacity: 0; } 60% { transform: scale(1.03); } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-3deg); } }
@keyframes confetti { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
.pop { animation: pop .28s cubic-bezier(.2, .9, .3, 1.2) both; }
.shake { animation: shake .3s linear; }
.confetti { position: fixed; left: 50%; top: 32%; z-index: 70; pointer-events: none; }
.confetti i {
  position: absolute; width: 10px; height: 14px;
  border: 2px solid var(--ink); border-radius: 3px;
  animation: confetti 1.1s cubic-bezier(.1, .7, .3, 1) forwards;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .confetti { display: none; }
}

/* ---------- wider screens ---------- */
@media (min-width: 620px) {
  .app { max-width: 600px; padding-top: 22px; }
}
@media (min-width: 940px) {
  .app { max-width: 1020px; padding: 28px 28px 28px; gap: 24px; }
  .wordmark { font-size: 31px; padding: 11px 19px 13px; border-radius: 17px; box-shadow: 5px 5px 0 var(--tangerine); }
  .descriptor { font-size: 14px; }
  .icon-btn { width: 46px; height: 46px; }
  .main.is-home { display: grid; grid-template-columns: 372px 1fr; gap: 22px 24px; align-items: start; }
  .main.is-home .daybar { grid-column: 1 / -1; }
  .main.is-home .tray { position: sticky; top: 24px; padding: 22px; gap: 16px; }
  .main.is-home .tray-score { font-size: 54px; }
  .main.is-home .mascot { width: 84px; height: 84px; }
  .main.is-home .mode-card { padding: 16px 18px; grid-template-columns: 60px 1fr auto; gap: 16px; }
  .main.is-home .mode-card .bubble { width: 60px; height: 60px; }
  .main.is-home .mode-card h3 { font-size: 21px; }
  .main.is-home .mode-card p { font-size: 15.5px; }
  .mode-card:hover, .btn:hover:not(:disabled), .icon-btn:hover, .option:hover:not(:disabled) { filter: brightness(1.03); }
  .mode-card:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
  .main.is-play, main.prose { width: 100%; max-width: 620px; margin-left: auto; margin-right: auto; }
  .footer { font-size: 13.5px; }
}
