/* Breadbox: every style for the game page (the dev panel has its own dev.css). Dark theme only.
   Calm and flat: no gradients, glows or 3D shadows. Color carries meaning (the answers, gold for a win); everything
   else is ink on a plain background. Bold is 700: Segoe UI has no 800, so 800 renders as Black on Windows. */

/* ---------- tokens ---------- */
:root {
  /* surfaces and text (every text color here is 4.5:1 or better on every surface) */
  --bg: #15122b; --sheet: #1d1a36;
  --ink: #f4f1fb; --dim: #aaa3c9; --faint: #9d96c4; --line: rgba(255,255,255,.1);
  --surface: rgba(255,255,255,.05); --surface-2: rgba(255,255,255,.09); --well: rgba(0,0,0,.2);
  /* roles: gold means a win, nothing else; blue means focus; pink is the brand */
  --gold: #ffd166; --blue: #6ea8ff; --pink: #ff5ca8;
  /* the answer scale, from Yes to No, plus "depends" */
  --yes: #3ddc84; --prob: #9be36b; --maybe: #ff9f5a; --probnot: #ff8c96; --no: #ff5470; --neutral: #c3b8f0;
  /* the solved card */
  --card: #fbf6ea; --card-win: #ffe29a; --card-ink: #1d1636;
  /* shape, space, motion */
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-pill: 999px;
  --gap: 16px; --pad: 22px; --tap: 44px;
  --t-fast: .15s; --t-med: .25s; --ease: cubic-bezier(.2, .8, .3, 1);
}
/* Colorblind colors (Settings): blue for yes, orange for no. The words always stay. */
:root[data-cb] { --yes: #3d9bff; --prob: #8fc2ff; --maybe: #ece6ff; --probnot: #ffb36b; --no: #ff8a1f; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); background: var(--bg); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
b, strong { font-weight: 700; } /* not "bolder", which turns bold text inside bold into Black */
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }

/* ---------- header: the name, the puzzle number, the streak, the menu ---------- */
header { display: flex; align-items: center; gap: 8px; padding: 10px var(--pad); max-width: 760px; margin: 0 auto; }
.brand { font-weight: 800; font-size: 21px; letter-spacing: -.02em; white-space: nowrap; }
.brand em { font-style: normal; color: var(--pink); }
#tag { min-height: var(--tap); padding: 0 8px; border: none; border-radius: var(--r-sm); background: none; color: var(--dim); font-weight: 700; font-size: 15px;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
#tag:disabled { cursor: default; }
#tag.practice { color: var(--blue); }
#tag.practice:hover { background: var(--surface-2); }
.hud { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.stat { display: flex; align-items: baseline; gap: 6px; padding: 0 8px; font-size: 15px; }
.stat .lbl { color: var(--dim); font-weight: 600; }
.stat b { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.updated b { animation: fade .6s var(--ease); }
.icon { display: inline-grid; place-items: center; min-width: var(--tap); min-height: var(--tap); background: none; border: none; border-radius: var(--r-md); line-height: 1; }
.icon:hover { background: var(--surface-2); }
.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- the page's states ----------
   body.start:   nothing asked yet; the question box sits in the middle of the screen.
   body.playing: the box at the top, answers underneath, newest first.
   body.done:    the result panel instead of the box.
   body.fresh:   no question asked in this game yet (the example chips show).
   body.returning: has played before, so the start screen is slimmer. */
main { display: flex; flex-direction: column; gap: var(--gap); padding: 0 var(--pad) 28px; max-width: 760px; margin: 0 auto; }
body.start main { min-height: calc(100dvh - 72px); justify-content: center; padding-bottom: 14dvh; text-align: center; }
#prompt { font-size: clamp(21px, 4vw, 28px); font-weight: 700; letter-spacing: -.015em; line-height: 1.15; margin: 4px 0 0; }
body.start #prompt { font-size: clamp(32px, 7.5vw, 52px); line-height: 1.1; margin: 0; }
#prompt em { font-style: normal; color: var(--pink); } /* the same pink as "box" in the name */
#sub { color: var(--dim); margin: -4px 0 0; font-size: 17px; }
body:not(.start) #sub, body.returning #sub { display: none; }
body.start #left, body.start #log { display: none; }

/* ---------- questions left ---------- */
#left { display: flex; align-items: center; gap: 12px; }
#pips { display: grid; grid-template-columns: repeat(20, 1fr); gap: 4px; flex: 1; }
#pips i { height: 8px; border-radius: 4px; background: rgba(255,255,255,.12); transition: background .3s, transform .3s; }
#pips i.yes { background: var(--yes); }
#pips i.prob { background: var(--prob); }
#pips i.maybe { background: var(--maybe); }
#pips i.probnot { background: var(--probnot); }
#pips i.no { background: var(--no); }
#pips i.neutral { background: var(--neutral); }
#pips i.win { background: var(--gold); }
#pips i.now { transform: scaleY(1.5); }
#count { font-weight: 700; color: var(--dim); font-variant-numeric: tabular-nums; min-width: 5.5em; text-align: right; }
#count.low { color: var(--no); }

/* ---------- the question box ---------- */
.ask { position: relative; }
#form { display: flex; gap: 10px; }
body.done #form { display: none; }
#input { flex: 1; min-width: 0; font: 600 20px/1.2 system-ui, sans-serif; color: var(--ink); padding: 15px 18px; border-radius: var(--r-md);
  border: 2px solid rgba(255,255,255,.16); background: var(--surface); outline: none; transition: border-color .2s, box-shadow .2s; }
#input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(110,168,255,.25); }
#input::placeholder { color: var(--faint); }
body.start #input { font-size: 22px; padding: 17px 20px; }
/* a rejected question: the box's border glows red for a moment, nothing moves */
#form.nope #input { animation: nope .9s var(--ease); }
@keyframes nope { from { border-color: var(--no); } }
#go { min-width: 80px; border: none; border-radius: var(--r-md); padding: 0 22px; font-weight: 700; font-size: 18px; color: var(--bg); background: var(--ink);
  transition: opacity var(--t-fast); }
#go:hover { opacity: .9; }
#go:disabled { opacity: .5; cursor: default; }

/* example questions for a first game */
#chips { display: none; flex-wrap: wrap; gap: 8px; }
body.fresh:not(.returning) #chips { display: flex; }
body.start #chips { justify-content: center; }
.chip { min-height: var(--tap); padding: 10px 16px; border: 1px solid var(--line); border-radius: var(--r-pill); background: none;
  font-weight: 600; color: var(--ink); transition: background var(--t-fast), border-color var(--t-fast); }
.chip:hover { background: var(--surface); border-color: rgba(255,255,255,.24); }

/* messages sit just under the box, where the phone keyboard can't cover them */
#toast { position: absolute; left: 50%; top: calc(100% + 10px); transform: translate(-50%, -4px); opacity: 0; width: max-content; max-width: min(92vw, 640px);
  background: #0e0c1f; border: 1px solid var(--line); padding: 10px 18px; border-radius: var(--r-pill); font-weight: 600; text-align: center;
  transition: opacity var(--t-med), transform var(--t-med) var(--ease); z-index: 50; pointer-events: none; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.gold { background: #2a2210; border-color: rgba(255,209,102,.6); color: #fff3c4; }
body.done #toast { position: fixed; top: auto; bottom: 26px; }

/* ---------- the answers, newest first ---------- */
#log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.qa { position: relative; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 12px 14px 15px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid transparent; overflow: hidden; text-align: left; }
.qa .num { font-weight: 700; color: var(--faint); text-align: center; font-variant-numeric: tabular-nums; }
.qa .q { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.qa .a { display: flex; align-items: baseline; gap: 6px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.qa .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.06); }
.qa .bar i { display: block; height: 100%; width: 0; transition: width .5s var(--ease); background: currentColor; }
.qa.yes .a, .qa.yes .bar { color: var(--yes); }
.qa.prob .a, .qa.prob .bar { color: var(--prob); }
.qa.maybe .a, .qa.maybe .bar { color: var(--maybe); }
.qa.probnot .a, .qa.probnot .bar { color: var(--probnot); }
.qa.no .a, .qa.no .bar { color: var(--no); }
/* opinion and personal questions: "Depends on you", with a hint */
.qa.neutral .a, .qa.neutral .bar { color: var(--neutral); }
.qa.neutral .a { flex-wrap: wrap; white-space: normal; }
.qa.win { background: rgba(255,209,102,.1); border-color: rgba(255,209,102,.45); }
.qa.win .a, .qa.win .bar { color: var(--gold); }
/* while the answer comes: three dots */
.dots { display: inline-flex; gap: 5px; align-self: center; padding: 7px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); opacity: .6; animation: dot 1.1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .18s; }
.dots i:nth-child(3) { animation-delay: .36s; }
@keyframes dot { 0%, 70%, 100% { opacity: .25; } 35% { opacity: 1; } }
.qa.new { animation: slide var(--t-med) var(--ease); }
.qa.flash { animation: flash .6s; }
@keyframes flash { 50% { background: rgba(110,168,255,.25); } }

/* ---------- buttons ---------- */
.btn { min-height: var(--tap); border: none; border-radius: var(--r-md); padding: 12px 18px; font-weight: 700; font-size: 16px; }
.btn.main { color: var(--bg); background: var(--ink); }
.btn.main:hover { opacity: .9; }
.btn.alt { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }
.btn.alt:hover { background: rgba(255,255,255,.13); }
.btn.danger { background: rgba(255,84,112,.12); border: 1px solid rgba(255,84,112,.5); color: #ffc7d0; }
.btn.danger.armed { background: #c2334f; border-color: #c2334f; color: #fff; }

/* ---------- the end ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
#end[hidden] { display: none; }
#end.reveal { animation: slide .35s var(--ease); }
.outcome { display: flex; gap: 18px; align-items: center; }
.card { flex: none; width: 112px; height: 124px; background: var(--card); color: var(--card-ink); border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10px; }
.card .emoji { font-size: 54px; line-height: 1.1; }
.card .name { font-weight: 700; font-size: 15px; line-height: 1.1; margin-top: 4px; }
.card.gold { background: var(--card-win); }
/* the win moment: the card settles in (and app.js sends a little gold confetti off it) */
#end.reveal .card.gold { animation: won .5s var(--ease) .1s both; }
@keyframes won { from { opacity: 0; transform: scale(.92); } }
.outcome .big { font-size: 24px; font-weight: 700; line-height: 1.15; }
.outcome .small { color: var(--dim); margin-top: 6px; }
/* exactly what Share sends */
#grid { margin: 16px 0 0; padding: 12px 14px; background: var(--well); border-radius: var(--r-md); white-space: pre-wrap; font-size: 15px; line-height: 1.45; }
#grid .sq { font-size: 22px; line-height: 1.25; letter-spacing: 2px; }
#grid .link { color: var(--dim); }
.row2 { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
#stats { margin-top: 18px; }
.tiles div { background: var(--surface); border-radius: var(--r-md); padding: 10px 4px; }
.tiles b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tiles span { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
#next { color: var(--faint); font-size: 14px; margin-top: 14px; }
#next b { color: var(--dim); font-variant-numeric: tabular-nums; }

/* ---------- bottom sheet: menu, how to play, stats, settings ---------- */
#sheet { position: fixed; inset: 0; z-index: 80; display: grid; align-items: end; justify-items: center; }
#sheet[hidden] { display: none; }
#sheet .scrim { position: absolute; inset: 0; background: rgba(6,4,18,.6); animation: fade var(--t-med) var(--ease); }
.sheet-card { position: relative; width: min(560px, 100%); max-height: min(88dvh, 760px); overflow: auto; padding: 6px 20px 28px;
  background: var(--sheet); border: 1px solid var(--line); border-bottom: none; border-radius: var(--r-lg) var(--r-lg) 0 0;
  animation: rise var(--t-med) var(--ease); }
@media (min-width: 700px) {
  #sheet { align-items: center; }
  .sheet-card { border-radius: var(--r-lg); border-bottom: 1px solid var(--line); }
}
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 6px; padding: 8px 0; background: var(--sheet); }
.sheet-head h2 { flex: 1; margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.sheet-head .back[hidden] { display: none; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
/* the menu: a plain list, a chevron on the rows that open another page of the sheet */
.menu-list { display: grid; margin-top: 4px; }
.row-btn { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 12px 10px; background: none; border: none; border-bottom: 1px solid var(--line);
  border-radius: 0; text-align: left; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.row-btn:last-child { border-bottom: none; }
.row-btn:hover { background: var(--surface); }
.row-btn > span { flex: 1; }
.row-btn small { display: block; color: var(--dim); font-weight: 500; font-size: 14px; }
.row-btn[data-view]::after { content: ""; flex: none; width: 8px; height: 8px; margin-right: 4px; border: solid var(--dim); border-width: 2px 2px 0 0; transform: rotate(45deg); }
.howto p { margin: 10px 0; font-size: 17px; }
.howto ol { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 8px; }
.howto .note { color: var(--dim); font-size: 15px; }
.dist { display: grid; gap: 6px; margin-top: 18px; }
.dist h3 { margin: 0 0 4px; font-size: 15px; color: var(--dim); font-weight: 700; }
.dist .bar-row { display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.dist .fill { height: 26px; min-width: 30px; border-radius: 8px; background: var(--surface-2); display: flex; align-items: center; justify-content: flex-end;
  padding: 0 9px; font-variant-numeric: tabular-nums; }
.dist .fill.hi { background: var(--yes); color: #0b2416; }
.empty-note { color: var(--dim); margin-top: 16px; }
.setting { display: flex; align-items: center; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting .what { flex: 1; }
.setting .what b { display: block; font-size: 17px; font-weight: 700; }
.setting .what small { color: var(--dim); font-size: 14px; }
.switch { appearance: none; flex: none; margin: 0; width: 54px; height: 32px; border-radius: var(--r-pill); background: rgba(255,255,255,.2); position: relative;
  cursor: pointer; transition: background var(--t-fast); }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform var(--t-fast) var(--ease); }
.switch:checked { background: var(--blue); }
.switch:checked::after { transform: translateX(22px); }

/* ---------- phones ---------- */
@media (max-width: 520px) {
  :root { --pad: 16px; }
  .brand { font-size: 19px; } #tag .long { display: none; }
  #input, body.start #input { font-size: 18px; padding: 14px; } #go { min-width: 68px; padding: 0 16px; }
  #pips { gap: 3px; }
  .qa { grid-template-columns: 24px 1fr; } .qa .a { grid-column: 2; font-size: 16px; }
  .card { width: 96px; height: 108px; } .card .emoji { font-size: 46px; }
  .outcome .big { font-size: 21px; }
  #grid .sq { font-size: 19px; }
}
/* Reduced motion: everything ends at once, and nothing loops (the thinking dots sit still). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}
