:root {
  color-scheme: light;
  --paper: #fff9ef;
  --surface: #fffdf8;
  --ink: #111a48;
  --muted: #545972;
  --line: #d9d9e4;
  --blue: #024ddf;
  --blue-dark: #0139a7;
  --ice: #e5ecff;
  --gold: #ffdd6d;
  --pink: #ffd9e6;
  --mint: #bcf5d9;
  --body: "Inter", system-ui, sans-serif;
  --display: "Workbench", "Inter", system-ui, sans-serif;
  --shadow: 0 4px var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper) radial-gradient(#cbcdef 1px, transparent 1px) 0 0 / 16px 16px;
  color: var(--ink);
  font: .92rem/1.55 var(--body);
}

button, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
h1, h2, h3, p { margin-top: 0; }
.wrap { width: min(1080px, calc(100% - 64px)); margin-inline: auto; }

.sprite, #seat-marks i, .final-seats i {
  --icon-size: 24px;
  display: inline-block;
  flex: none;
  width: var(--icon-size);
  height: var(--icon-size);
  background: url("/arcade-icons.png") var(--icon-x, 0%) 0 / 500% 100% no-repeat;
  image-rendering: pixelated;
}
.sprite-coin { --icon-x: 25%; }
.sprite-clock { --icon-x: 50%; }
.sprite-fan { --icon-x: 75%; }
.sprite-star { --icon-x: 100%; }

.masthead { background: var(--paper); border-bottom: 2px solid var(--ink); }
.nav { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  text-decoration: none;
  font: 400 clamp(1.65rem, 3vw, 2.1rem)/1 var(--display);
  text-transform: uppercase;
  white-space: nowrap;
}
.brand .sprite { --icon-size: 38px; }
.help {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 42px;
  padding: .35rem .7rem;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 0 2px var(--ink);
  font-size: .76rem;
  font-weight: 800;
  white-space: nowrap;
}
.help:hover { background: var(--ice); }
.help span { display: grid; place-items: center; width: 1rem; height: 1rem; background: var(--gold); font-size: .68rem; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: center;
  margin-top: 25px;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: var(--blue);
  color: var(--surface);
}
.hero-copy { padding: 30px 0 33px 38px; }
.eyebrow { font: 800 .72rem/1.45 var(--body); text-transform: uppercase; letter-spacing: .105em; }
.hero .eyebrow {
  display: inline-block;
  margin: 0 0 1rem;
  padding: .35rem .63rem;
  background: var(--gold);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px var(--ink);
}
h1 {
  max-width: 9ch;
  margin: 0;
  font: 400 clamp(3.25rem, 6.7vw, 6rem)/1.03 var(--display);
  text-transform: uppercase;
  text-shadow: 4px 4px var(--ink);
}
#story { max-width: 38ch; margin: 1.1rem 0 0; font-weight: 500; }
.hero-art { display: block; align-self: end; width: 100%; height: auto; image-rendering: pixelated; }
.message { margin: 1rem 0 0; padding: .55rem .8rem; border: 2px solid var(--ink); background: var(--ice); font-weight: 650; }
.message:empty { display: none; }
#retry { margin-top: .75rem; }

.score-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-block: 20px; }
.stat {
  display: flex;
  align-items: center;
  gap: .85rem;
  min-width: 0;
  min-height: 96px;
  padding: 14px 18px;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}
.stat > .sprite { --icon-size: 48px; }
.ticket-stat { background: var(--pink); }
.coin-stat { background: var(--gold); }
.turn-stat { background: var(--mint); }
.stat-label { display: block; font-size: .68rem; font-weight: 800; line-height: 1.3; text-transform: uppercase; letter-spacing: .055em; }
.stat strong { display: inline-block; margin-top: .22rem; font: 400 2.65rem/.92 var(--display); white-space: nowrap; }
.stat small { display: inline-block; font-size: .73rem; font-weight: 700; }
.stat small:empty { display: none; }
#seat-marks, #move-marks { display: inline-flex; align-items: center; gap: 3px; margin-inline-start: .65rem; vertical-align: .2rem; }
#seat-marks i { --icon-size: 16px; }
#seat-marks i:not(.filled) { opacity: .42; filter: grayscale(1); }
#move-marks i { width: 9px; height: 11px; border: 2px solid var(--ink); box-shadow: inset 0 -2px var(--ink); opacity: .36; }
#move-marks .filled { background: var(--blue); opacity: 1; }
.new-ticket { animation: ticket-pop .35s steps(4, end); }
@keyframes ticket-pop { 45% { transform: translateY(-5px) scale(1.25); } }
@media (prefers-reduced-motion: reduce) {
  .new-ticket { animation: none; }
}

.layout { display: grid; grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr); gap: 18px; align-items: start; }
.panel { min-width: 0; background: var(--surface); border: 2px solid var(--ink); box-shadow: var(--shadow); }
.panel-heading {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0;
  padding: .6rem 1rem;
  background: var(--ice);
  border-bottom: 2px solid var(--ink);
  font: 400 1.75rem/1.2 var(--display);
}
.market .panel-heading { background: var(--pink); }
.panel-body { padding: 16px 20px 18px; }
.list-group + .list-group { margin-top: .9rem; padding-top: .85rem; border-top: 1px dashed var(--muted); }
.list-group h3 { margin: 0 0 .45rem; font: 800 .7rem/1.5 var(--body); text-transform: uppercase; letter-spacing: .08em; }
.levels { margin: 0; padding: 0; list-style: none; }
.levels li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .35rem 0; }
.levels li + li { border-top: 1px solid var(--line); }
.level-price {
  padding: .15rem .45rem;
  background: var(--gold);
  border: 1px solid var(--ink);
  font-size: .74rem;
  font-weight: 800;
  white-space: nowrap;
}

.scene { display: flex; align-items: center; gap: .65rem; margin-bottom: .95rem; }
.scene .sprite { --icon-size: 44px; background-color: var(--mint); }
.scene-copy { flex: 1; min-width: 0; padding: .48rem .65rem; background: var(--ice); border-left: 3px solid var(--blue); }
.scene .eyebrow { display: block; margin-bottom: .12rem; color: var(--blue-dark); }
.scene p { margin: 0; font-size: .84rem; }
.fields, .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
label { display: grid; min-width: 0; gap: .28rem; font-size: .77rem; font-weight: 700; }
select, textarea {
  width: 100%;
  padding: .55rem .6rem;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 0;
}
select { min-height: 42px; font-size: .89rem; font-weight: 700; }
.caption { color: var(--muted); font-size: .79rem; }
#order-note { margin: .55rem 0 .65rem; min-height: 1.55em; }
.primary, .secondary, .plain { min-height: 44px; padding: .5rem .45rem; font-size: .82rem; font-weight: 800; }
.primary, .secondary { color: var(--ink); border: 2px solid var(--ink); box-shadow: 0 3px var(--ink); }
.primary { color: var(--surface); background: var(--blue); }
.primary:hover:enabled { background: var(--blue-dark); }
.secondary { background: var(--gold); }
.secondary:hover:enabled { background: #ffe999; }
.primary:active:enabled, .secondary:active:enabled, .help:active { transform: translateY(2px); box-shadow: 0 1px var(--ink); }
.minor { margin-top: .5rem; }
.plain { color: var(--blue-dark); background: transparent; border: 0; }
.plain:hover:enabled { text-decoration: underline; }

.history { grid-column: 1 / -1; }
.history h2, dialog h2 { margin-bottom: .5rem; font: 400 1.75rem/1.1 var(--display); }
.history ol { margin: 0; padding-inline-start: 1.45rem; font-size: .83rem; }
.history li { padding: .32rem .3rem; }
.history li + li { border-top: 1px dashed var(--line); }
.history .caption { margin: 0; }
.result { background: var(--ice); }
.result.won { background: var(--mint); }
.result .eyebrow { margin-bottom: .5rem; color: var(--blue-dark); }
.result h2 { margin-bottom: .55rem; scroll-margin-block: 1rem; font: 400 clamp(2.1rem, 5vw, 3.5rem)/.98 var(--display); }
.result-stage {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  gap: .25rem;
  margin-block: .85rem;
  padding: .65rem;
  min-height: 68px;
  background: repeating-linear-gradient(0deg, #19295d 0 5px, #1d306a 5px 7px);
  border: 2px solid var(--ink);
}
.final-seats { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem; }
.final-seats i { --icon-size: clamp(30px, 6vw, 48px); }
.final-seats i:not(.filled) { opacity: .5; filter: grayscale(1); }
.result-star { --icon-size: clamp(20px, 4vw, 32px); visibility: hidden; }
.result.won .result-star { visibility: visible; }
@media (prefers-reduced-motion: no-preference) {
  .revealing .result-stage::before,
  .revealing .result-stage::after {
    content: "";
    position: absolute;
    z-index: 1;
    inset-block: 0;
    width: 51%;
    background: repeating-linear-gradient(90deg, var(--blue-dark) 0 12px, var(--blue) 12px 19px);
    pointer-events: none;
    animation: curtain-open .55s steps(10, end) both;
  }
  .revealing .result-stage::before {
    --curtain-travel: -101%;
    inset-inline-start: 0;
    border-inline-end: 3px solid var(--gold);
  }
  .revealing .result-stage::after {
    --curtain-travel: 101%;
    inset-inline-end: 0;
    border-inline-start: 3px solid var(--gold);
  }
  .revealing .final-seats .filled { animation: score-pop .32s .28s steps(6, end) both; }
  .revealing.won .result-star { animation: score-pop .35s .5s steps(6, end) both; }
  @keyframes curtain-open { to { transform: translateX(var(--curtain-travel)); } }
  @keyframes score-pop {
    from { opacity: 0; transform: translateY(8px) scale(.75); }
    65% { opacity: 1; transform: translateY(-3px) scale(1.12); }
  }
}
.result #streak { font-weight: 800; }
#copy-fallback, #reset { margin: .85rem 0 0; }
#reset { color: var(--muted); font-size: .76rem; }
footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.25rem; padding-block: 24px; color: var(--muted); font-size: .79rem; font-weight: 700; }
footer nav { display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
footer a { text-underline-offset: 3px; }
footer a[aria-current="page"] { color: var(--blue-dark); }
.nav a.help { text-decoration: none; }
.info { max-width: 760px; margin-top: 25px; }
.info h1 {
  max-width: none;
  padding: .7em .45em;
  background: var(--blue);
  border-bottom: 2px solid var(--ink);
  color: var(--surface);
  font-size: clamp(2.5rem, 7vw, 4.75rem);
}
.info .panel-body { padding: clamp(1rem, 4vw, 2rem); }
.info h2 { margin: 1.2rem 0 .35rem; font: 400 1.7rem/1.12 var(--display); }
.info p:last-child { margin-bottom: 0; }
.info a { color: var(--blue-dark); font-weight: 700; text-underline-offset: 3px; }
.info details + details { border-top: 1px dashed var(--line); }
.info summary { padding-block: .8rem; color: var(--blue-dark); font-weight: 800; cursor: pointer; }
.info details p { margin: 0 0 1rem; }
.ad-slot {
  display: grid;
  justify-items: center;
  gap: .2rem;
  padding: .65rem .9rem;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
  overflow-wrap: anywhere;
}
.ad-slot:empty { display: none; }
.ad-slot span { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.ad-slot a { color: var(--blue-dark); font-size: .88rem; font-weight: 700; text-underline-offset: 3px; }
.ad-board { grid-column: 1 / -1; width: min(100%, 728px); justify-self: center; }
.ad-footer { width: min(100%, 320px); margin: 20px auto 0; }
dialog { width: min(520px, calc(100% - 28px)); border: 2px solid var(--ink); box-shadow: var(--shadow); background: var(--surface); color: var(--ink); padding: 24px; font-size: .87rem; }
dialog::backdrop { background: rgb(17 26 72 / .76); }
dialog dt { font-weight: 800; color: var(--blue-dark); }
dialog dd { margin: .2rem 0 .8rem; }

@media (max-width: 900px) {
  .wrap { width: calc(100% - 44px); }
  .hero-copy { padding-left: 25px; }
  .stat { align-items: flex-start; padding: 12px; gap: .55rem; }
  .stat > .sprite { --icon-size: 36px; }
  .stat-label { min-height: 2.6em; }
  #seat-marks, #move-marks { display: flex; margin: .35rem 0 0; }
  .stat small { display: block; }
}

@media (max-width: 630px) {
  .wrap { width: calc(100% - 28px); }
  .nav { min-height: 60px; }
  .brand { gap: .45rem; font-size: clamp(1.25rem, 6vw, 1.65rem); }
  .brand .sprite { --icon-size: 27px; }
  .help { gap: .35rem; padding-inline: .45rem; font-size: .72rem; }
  .hero { grid-template-columns: 1fr; margin-top: 15px; }
  .hero-copy { padding: 18px 17px 4px; }
  .hero .eyebrow { margin-bottom: .8rem; }
  h1 { max-width: 15ch; font-size: clamp(2.75rem, 10vw, 4.4rem); text-shadow: 3px 3px var(--ink); }
  #story { margin-top: .7rem; font-size: .84rem; }
  .hero-art { max-width: 445px; justify-self: end; }
  .score-strip { margin-block: 15px; gap: 6px; }
  .stat { flex-direction: column; align-items: flex-start; justify-content: flex-start; padding: 8px 7px 9px; gap: .18rem; }
  .stat > .sprite { --icon-size: 28px; }
  .stat-label { min-height: 0; font-size: .57rem; letter-spacing: 0; }
  .stat strong { font-size: 2rem; }
  .stat small { font-size: .65rem; }
  #seat-marks { gap: 2px; }
  #seat-marks i { --icon-size: 13px; }
  #move-marks i { width: 7px; height: 9px; }
  .layout { grid-template-columns: 1fr; gap: 15px; }
  .panel-heading { padding: .5rem .75rem; }
  .panel-body { padding: 12px 13px 15px; }
}

@media (max-width: 360px) {
  .stat-label { min-height: 2.6em; }
}
