:root {
  color-scheme: light;
  --ink: #1b1626;
  --stone: #f4efe4;
  --stone-2: #e7dfcf;
  --stone-3: #cfc6b2;
  --gold: #f2c230;
  --gold-d: #b8860b;
  --blue: #2a4f8f;
  --blue-d: #16284d;
  --red: #c0283a;
  --green: #5c8a3a;
  --purple: #8a5cc2;
  --ice: #4f86b0;
  --px: 3px;
  --t-frosh: #5c8a3a; --t-keener: #8a5cc2; --t-upper: #2a4f8f; --t-grad: #c0283a; --t-deep: #4f86b0; --t-bell: #b8860b; --t-timeout: #6e6a7a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--stone-2); color: var(--ink); }
body {
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  background-image: repeating-linear-gradient(0deg, transparent 0 23px, rgba(27,22,38,.05) 23px 24px),
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(27,22,38,.04) 47px 48px);
}
#app { max-width: 560px; margin: 0 auto; padding: 12px 12px 28px; min-height: 100svh; display: flex; flex-direction: column; gap: 12px; }

/* pixel-cut panels: hard outline + offset shadow, no blur */
.panelish, #panel, #stage, dialog {
  background: var(--stone);
  box-shadow: 0 0 0 var(--px) var(--ink), var(--px) var(--px) 0 var(--px) var(--ink);
  border-radius: 2px;
}

header.top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { flex: 0 0 100%; display: flex; justify-content: center; padding: 2px 0 4px; }
#logo { image-rendering: pixelated; display: block; }
.meta { display: flex; flex-direction: column; font-size: 12px; line-height: 1.2; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
#dayno { color: var(--blue); }
#datestr { color: #6b6372; }
.actions { margin-left: auto; display: flex; gap: 8px; }
button { font: inherit; color: inherit; }
.icon { width: 34px; height: 34px; border: 0; background: var(--stone); cursor: pointer; font-weight: 800;
  box-shadow: 0 0 0 2px var(--ink), 2px 2px 0 2px var(--ink); }
.icon:active { transform: translate(2px, 2px); box-shadow: 0 0 0 2px var(--ink); }
.icon.off { opacity: .45; }

#stage { overflow: hidden; line-height: 0; background: #1a1d45; }
#scene { width: 100%; image-rendering: pixelated; display: block; }

#panel { padding: 16px 16px 18px; position: relative; min-height: 290px; }
.screen[hidden], .btn[hidden], .tracks[hidden], .tracks-h[hidden] { display: none !important; }

#pips { display: flex; gap: 6px; margin-bottom: 12px; }
.pip { flex: 1; height: 10px; background: var(--stone-3); box-shadow: 0 0 0 2px var(--ink); }
.pip.now { background: var(--gold); animation: pulse 1s steps(2) infinite; }
.pip[data-tier] { background: var(--tc); }
@keyframes pulse { 50% { background: var(--stone); } }

.title { font-size: 26px; line-height: 1.1; margin: 4px 0 8px; letter-spacing: -.01em; }
.lede { margin: 0 0 16px; }
.kicker { margin: 0 0 4px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); display: flex; gap: 8px; }
#prompt-mode { color: var(--purple); }
#prompt-text { font-size: 25px; line-height: 1.15; margin: 0 0 12px; min-height: 2.3em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.fine { font-size: 13px; color: #5c5566; margin: 12px 0 0; }

.btn { border: 0; padding: 11px 16px; font-weight: 800; cursor: pointer; background: var(--stone);
  box-shadow: 0 0 0 var(--px) var(--ink), var(--px) var(--px) 0 var(--px) var(--ink); text-transform: uppercase; letter-spacing: .04em; font-size: 14px; }
.btn.primary { background: var(--gold); }
.btn.wide { width: 100%; margin-top: 14px; }
.btn:active { transform: translate(var(--px), var(--px)); box-shadow: 0 0 0 var(--px) var(--ink); }
.btn:focus-visible, .icon:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
.btn:disabled { opacity: .5; cursor: default; }

#timer { display: grid; grid-template-columns: repeat(25, 1fr); gap: 2px; height: 12px; margin-bottom: 14px; }
#timer i { background: var(--blue); }
#timer i.gone { background: var(--stone-3); }
#timer.low i:not(.gone) { background: var(--red); animation: pulse .5s steps(2) infinite; }

#answer-form { display: flex; gap: 10px; }
#answer { flex: 1; min-width: 0; font: inherit; font-size: 18px; padding: 10px 12px; border: 0; background: #fff;
  color: var(--ink); -webkit-text-fill-color: var(--ink); caret-color: var(--ink); opacity: 1;
  box-shadow: 0 0 0 var(--px) var(--ink); border-radius: 0; }
#answer::placeholder { color: #8a8392; -webkit-text-fill-color: #8a8392; }
#answer:disabled { background: var(--stone-2); }
button, select, input, textarea { color: var(--ink); }
#answer.shake { animation: shake .3s steps(6); }
@keyframes shake { 0%,100% { transform: none } 25% { transform: translateX(-6px) } 50% { transform: translateX(5px) } 75% { transform: translateX(-3px) } }

#feedback { min-height: 24px; margin-top: 10px; font-weight: 700; font-size: 15px; }
#feedback.bad { color: var(--red); }
#feedback.info { color: var(--blue); }
#choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip { border: 0; background: #fff; padding: 8px 10px; cursor: pointer; text-align: left; box-shadow: 0 0 0 2px var(--ink), 2px 2px 0 2px var(--ink); }
.chip b { display: block; }
.chip span { font-size: 12px; color: #6b6372; }

.result-head { display: flex; align-items: center; gap: 14px; }
#result-badge { image-rendering: pixelated; width: 72px; height: 72px; background: var(--stone-2); box-shadow: 0 0 0 var(--px) var(--ink); }
#result-badge.pop { animation: pop .45s steps(4); }
@keyframes pop { 0% { transform: scale(.4) } 60% { transform: scale(1.2) } 100% { transform: scale(1) } }
.tier { margin: 0; font-size: 26px; font-weight: 900; line-height: 1.05; color: var(--tc, var(--ink)); }
.points { margin: 2px 0 0; font-weight: 800; color: #5c5566; }
.answer { margin: 14px 0 6px; font-size: 16px; }
.answer .canon { display: block; font-size: 13px; color: #6b6372; }
.reveal { font-size: 14px; background: var(--stone-2); padding: 10px 12px; box-shadow: inset 0 0 0 2px var(--stone-3); }
.reveal p { margin: 0 0 4px; }
.reveal p:last-child { margin: 0; }
.reveal b { color: var(--gold-d); }

#sum-title { font-size: 28px; margin: 0 0 10px; }
#sum-rows { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
#sum-rows li { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; background: #fff; padding: 6px 10px 6px 6px; box-shadow: 0 0 0 2px var(--ink); }
#sum-rows canvas { image-rendering: pixelated; width: 36px; height: 36px; }
#sum-rows .q { font-size: 12px; color: #6b6372; line-height: 1.2; }
#sum-rows .a { font-weight: 800; line-height: 1.2; }
#sum-rows .pts { font-weight: 900; color: var(--tc); }

dialog { border: 0; max-width: 420px; width: calc(100% - 32px); padding: 18px; color: var(--ink); }
dialog::backdrop { background: rgba(27, 22, 38, .6); }
dialog h2 { margin-top: 0; }
dialog ul { padding-left: 18px; margin: 0 0 10px; }
#help-tiers { display: grid; gap: 6px; }
.help-tier { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; font-size: 14px; }
.help-tier canvas { image-rendering: pixelated; width: 24px; height: 24px; }
.help-tier b { color: var(--tc); }

.foot { font-size: 12px; color: #6b6372; text-align: center; margin-top: auto; }

@media (min-width: 700px) {
  #app { max-width: 980px; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr auto; align-items: start; column-gap: 20px; }
  header.top { grid-column: 1 / -1; }
  #stage { grid-row: 2; }
  #panel { grid-row: 2; }
  .foot { grid-column: 1 / -1; }
  #prompt-text { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}

.chipbtn { border: 0; background: #fff; font-weight: 800; font-size: 12px; padding: 0 10px; height: 34px; max-width: 150px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; box-shadow: 0 0 0 2px var(--ink), 2px 2px 0 2px var(--ink); }
.chipbtn:disabled { opacity: .6; cursor: default; }
.size { margin: -6px 0 10px; font-size: 13px; font-weight: 700; color: #6b6372; }
.kicker .program { color: var(--red); }
.field { display: grid; gap: 6px; font-weight: 800; font-size: 14px; margin: 12px 0; }
.field select { font: inherit; font-weight: 600; padding: 10px; background: #fff; border: 0; box-shadow: 0 0 0 var(--px) var(--ink); border-radius: 0; }
.field-label { font-weight: 800; font-size: 14px; margin: 4px 0 6px; }
.years { display: flex; flex-wrap: wrap; gap: 8px; }
.years button { border: 0; background: #fff; padding: 9px 12px; font-weight: 800; cursor: pointer; box-shadow: 0 0 0 2px var(--ink); }
.years button[aria-pressed="true"] { background: var(--gold); box-shadow: 0 0 0 2px var(--ink), 2px 2px 0 2px var(--ink); }
.placement { background: #fff; box-shadow: 0 0 0 2px var(--ink); padding: 12px; margin: 0 0 14px; }
.placement .big { font-size: 22px; font-weight: 900; margin: 0; }
.placement .sub { margin: 2px 0 10px; font-size: 13px; color: #5c5566; font-weight: 700; }
.placement .fine { margin: -6px 0 10px; font-size: 12px; color: #5c5566; font-weight: 600; }
.hist { display: grid; grid-template-columns: repeat(11, 1fr); align-items: end; gap: 3px; height: 70px; }
.hist i { display: block; background: var(--stone-3); min-height: 2px; }
.hist i.me { background: var(--gold); box-shadow: 0 0 0 2px var(--ink); }
.hist-axis { display: flex; justify-content: space-between; font-size: 11px; color: #6b6372; margin-top: 4px; }
.reveal .live { color: var(--blue); font-weight: 800; }
.owner { margin-top: 14px; font-size: 13px; background: var(--stone-2); padding: 10px 12px; box-shadow: inset 0 0 0 2px var(--stone-3); }
.owner h3 { margin: 0 0 6px; font-size: 14px; }
.owner table { width: 100%; border-collapse: collapse; }
.owner td { padding: 2px 0; }
.owner td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; }
#logo { height: 48px; width: auto; }
@media (max-width: 440px) {
  header.top { gap: 8px; flex-wrap: wrap; }
  #logo { height: 32px; }
  .meta { font-size: 10px; letter-spacing: .03em; }
  #datestr { display: none; }
  .actions { gap: 6px; }
  .icon { width: 30px; height: 30px; }
  .chipbtn { height: 30px; padding: 0 7px; font-size: 11px; }
}
.flaglink { border: 0; background: none; padding: 4px 0; font-weight: 800; font-size: 13px; color: var(--blue); text-decoration: underline; cursor: pointer; }
.flaglink:disabled { color: #6b6372; text-decoration: none; cursor: default; }
.settle { color: var(--blue); font-weight: 700; margin-top: 8px; }
.testrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.testsel { font: inherit; padding: 4px 6px; border: 2px solid var(--ink); background: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.why { margin: 4px 0 0; color: #5d5566; }

.tracks-h { margin: 14px 0 6px; font-size: 14px; }
.tracks { display: grid; gap: 6px; margin-bottom: 12px; }
.track { text-align: left; border: 0; background: var(--stone); padding: 8px 10px; cursor: pointer; font: inherit; box-shadow: 0 0 0 2px var(--ink); }
.track b { display: block; font-size: 13px; }
.track span { display: block; font-size: 12px; opacity: .8; }
.track.on { background: var(--gold, #f2c200); }
.track:active { transform: translate(2px, 2px); }
