:root {
  color-scheme: dark;
  --ink: #201918;
  --paper: #fff2d9;
  --muted: #d4bca5;
  --line: #583b32;
  --panel: #302422;
  --gold: #ffc06a;
  --red: #ff8a6e;
  --green: #aee6b8;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--ink);
  color: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; }
button, select, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .53; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
a { color: var(--gold); }
h1, h2, p, figure { margin: 0; }
h1, h2, .brand, .overline { letter-spacing: -.02em; }

.arcade {
  width: min(100%, 76rem);
  margin-inline: auto;
  padding: 0 max(1rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

body.embedded .arcade { padding-inline: max(.85rem, env(safe-area-inset-left), env(safe-area-inset-right)); }
body.expanded { overflow: hidden; }
body.expanded .arcade {
  position: fixed;
  inset: 0;
  z-index: 4;
  max-width: 100%;
  min-height: 100dvh;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--ink);
}
body.expanded .bar, html:fullscreen .bar {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--ink);
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: max(1rem, env(safe-area-inset-top)) .85rem;
  border-bottom: 1px solid var(--line);
  gap: 1rem;
}
.top-controls, .brand-marks { display: flex; align-items: center; gap: .5rem; }
.top-controls { justify-content: flex-end; flex-wrap: wrap; }
.brand-marks { flex: none; gap: .6rem; }
.brand-marks img {
  display: block;
  width: clamp(34px, 5vw, 54px);
  height: auto;
  border-radius: .55rem;
  border: 1px solid #965f48;
  background: #fff5e9;
}
.brand-marks img[alt="Cowboy Lounge"] { background: #080707; }
body[data-shop="butcher"] { --gold: #ffc1c7; --red: #ff879b; }
body[data-shop="lounge"] { --gold: #ffc279; --red: #f59051; --line: #5c4432; --panel: #30251e; }
.brand {
  color: var(--paper);
  font-size: .93rem;
  font-weight: 850;
  text-decoration: none;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.quiet, .primary, .secondary, select {
  border: 1px solid #8a5f4e;
  border-radius: .48rem;
  min-height: 44px;
  padding: .48rem .8rem;
  background: transparent;
  color: var(--paper);
  font-weight: 700;
}
.quiet:hover:not(:disabled), .secondary:hover, select:hover { background: #422e28; }
.primary { color: #291711; background: var(--gold); border-color: var(--gold); }
.primary:hover:not(:disabled) { background: #ffd391; }
.secondary { border-color: #b27e69; }

.lobby, .result {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  gap: clamp(1.5rem, 5vw, 5rem);
  align-items: center;
  padding-block: clamp(1.25rem, 5vw, 4rem);
}
.lobby {
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  align-items: start;
  padding-block: clamp(1.55rem, 3.5vw, 3.2rem);
}
.intro h1, .result h1 {
  font-family: Impact, 'Arial Narrow', system-ui, sans-serif;
  font-weight: 950;
  font-size: clamp(4.6rem, 10vw, 9.4rem);
  line-height: .87;
  letter-spacing: -.055em;
}
.intro h1 { text-shadow: 3px 4px #6a382d; }
.intro h1 span, .result h1 span { color: var(--red); }
.intro > p:not(.status) { font-size: clamp(1rem, 1.7vw, 1.3rem); margin-top: 1.1rem; max-width: 28ch; line-height: 1.4; }
.selection { margin-top: 1.35rem; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: .45rem; font-size: .9rem; font-weight: 780; }
.shop-switch, .crew-switch > div { display: flex; flex-wrap: wrap; gap: .38rem; }
.crew-switch { margin-top: .85rem; }
.level-switch { margin-top: .85rem; }
#levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.1rem), 1fr));
  gap: .36rem;
}
.level-card { position: relative; min-width: 0; cursor: pointer; }
.level-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.level-card > span {
  display: grid;
  align-content: center;
  gap: .2rem;
  height: 100%;
  min-height: 54px;
  padding: .45rem .5rem;
  background: #2d221e;
  border: 1px solid var(--line);
  border-radius: .43rem;
  font-size: .88rem;
}
.level-card small { color: var(--muted); font-size: .76rem; }
.level-card input:checked + span { border-color: var(--gold); background: #4d3226; color: var(--gold); }
.level-card input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.shop-switch label, .crew-switch label { display: inline-grid; position: relative; cursor: pointer; }
.shop-switch input, .crew-switch input { opacity: 0; position: absolute; width: 1px; height: 1px; }
.shop-switch span, .crew-switch span {
  display: flex;
  align-items: center;
  gap: .32rem;
  border: 1px solid var(--line);
  border-radius: .38rem;
  min-height: 44px;
  padding: .35rem .58rem;
  color: var(--paper);
  font-size: .87rem;
  font-weight: 650;
}
.shop-switch input:checked + span, .crew-switch input:checked + span { border-color: var(--gold); background: #4d3226; }
.shop-switch input:focus-visible + span, .crew-switch input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.crew-switch canvas { width: 23px; height: 23px; image-rendering: pixelated; }
.crew-switch i { width: .52rem; height: .52rem; border-radius: 50%; background: var(--crew); }
.start-controls { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.1rem; }
.status:not(:empty) { color: var(--gold); font-size: .94rem; margin-top: .65rem; }
.preview { min-width: 0; }
.preview-stage { position: relative; }
.preview figure { border: 1px solid #8a5f4e; border-radius: 1.05rem; background: #110d0d; overflow: hidden; box-shadow: 0 1.3rem 4rem #100a0866; }
.scene-kicker {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .9rem;
  padding: .62rem .9rem;
  background: linear-gradient(110deg, #201416, #392722);
  color: var(--gold);
  font-weight: 760;
  font-size: .93rem;
}
.scene-kicker span:last-child { color: var(--paper); font-size: .81rem; }
.crew-preview {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: .8rem;
  margin-top: .65rem;
  padding: .65rem .75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .6rem;
}
.crew-preview canvas { display: block; width: clamp(55px, 9vw, 94px); height: auto; border-radius: .43rem; }
.crew-preview h2 { font-size: 1.15rem; }
#crew-role, #crew-boost { color: var(--gold); font-size: .84rem; font-weight: 740; }
#crew-perk { font-size: .89rem; margin-block: .18rem; }
.preview canvas, .map canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; }
figcaption { padding: .8rem 1rem; background: #302422; }
.controls-copy { color: var(--muted); margin-top: .8rem; line-height: 1.5; }
.controls-copy strong { color: var(--paper); }

.hud { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: .65rem clamp(.75rem, 3vw, 2rem); padding-block: .75rem; }
.hud h1 { font-size: clamp(1.25rem, 3vw, 2.1rem); }
.overline, .hud-stat span { display: block; color: var(--muted); font-size: .8rem; }
.hud-stat strong { display: block; font-size: clamp(1rem, 2.4vw, 1.42rem); font-variant-numeric: tabular-nums; }
.hud-stat.phase strong { color: var(--gold); }
.game-grid { display: grid; grid-template-columns: minmax(0, 2.35fr) minmax(15rem, 1fr); gap: .85rem; }
.floor, .operations { min-width: 0; }
.brief { color: var(--paper); font-size: .92rem; min-height: 2.55rem; padding: .45rem .65rem; background: #382922; border: 1px solid var(--line); border-radius: .4rem .4rem 0 0; }
.map { position: relative; container-type: inline-size; overflow: hidden; border-inline: 1px solid var(--line); background: #110d0d; }
.map #stations { position: absolute; inset: 0; pointer-events: none; }
.map #bubbles { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.speech {
  position: absolute;
  visibility: hidden;
  inline-size: max-content;
  max-inline-size: min(9.4rem, 34%);
  padding: .26rem .4rem;
  border: 1px solid #392620;
  border-radius: .4rem .4rem .4rem .1rem;
  background: #fff3d8;
  color: #38231a;
  font-weight: 750;
  line-height: 1.15;
  font-size: clamp(.68rem, 1.65vw, .86rem);
  text-align: center;
  box-shadow: 0 2px 6px #08050480;
}
.speech::after {
  content: '';
  position: absolute;
  left: var(--speech-pointer, 50%);
  bottom: -4px;
  width: 6px;
  height: 6px;
  transform: translateX(-50%) rotate(45deg);
  background: inherit;
  border-inline-end: 1px solid #392620;
  border-block-end: 1px solid #392620;
}
.speech.manager { background: #ffd183; outline: 2px solid #c36236; }
.speech.influencer, .speech.reviewer { background: #fde5f2; color: #64214c; }
.speech.dog { background: #e3f2ce; }
.map .station.urgent-station { border-color: #ffda80; box-shadow: 0 0 0 2px #000; }
.map .station.urgent-station span { background: #f9c471; color: #211510; }
#event-banner { padding: .48rem .66rem; color: #311c13; background: #ffc779; font-size: .9rem; font-weight: 750; }
#event-banner[data-type="outage"] { background: #fde3a5; }
#event-banner[data-type="slammed"] { background: #f99a80; }
.map .station {
  pointer-events: auto;
  position: absolute;
  transform: translate(-50%, -50%);
  width: calc(100% / 9);
  height: calc(100% / 6);
  padding: 0;
  background: transparent;
  color: #fff5e7;
  border-radius: .25rem;
  border: 2px solid transparent;
}
.map .station:hover, .map .station[aria-pressed="true"] { border-color: var(--gold); background: #ffe29217; }
.map .station span {
  position: absolute;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  pointer-events: none;
  width: max-content;
  max-width: 100%;
  font-size: clamp(.59rem, 2.65cqi, .85rem);
  font-weight: 810;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  overflow-wrap: anywhere;
  text-wrap: balance;
  border-radius: .25rem;
  padding: .12rem clamp(.13rem, .75cqi, .24rem);
  background: #241914ed;
  line-height: 1.05;
}
.station-tray, .operations section {
  padding: .65rem .7rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .4rem;
}
.station-tray { border-radius: 0 0 .4rem .4rem; min-height: 8rem; }
.restroom-room-picker { display: inline-flex; align-items: center; gap: .5rem; margin-top: .5rem; }
.restroom-room-picker select { min-height: 44px; }
.station-title, .play-footer { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.station-boosts { display: flex; justify-content: flex-end; gap: .35rem; flex-wrap: wrap; }
.station-boosts .quiet { padding-inline: .52rem; font-size: .88rem; }
.station-boosts .quiet:not(:disabled) { color: var(--gold); border-color: var(--gold); }
#tasks { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
#tasks button {
  color: var(--paper);
  background: #44312b;
  border: 1px solid #88614e;
  border-radius: .38rem;
  min-height: 44px;
  text-align: left;
  padding: .35rem .55rem;
}
#tasks button:hover:not(:disabled) { background: #644639; }
#tasks kbd { color: var(--gold); font-size: .88em; }
.job-status, .play-help, .play-footer, .empty { color: var(--muted); font-size: .87rem; line-height: 1.38; }
.job-status { display: flex; flex-wrap: wrap; gap: 0 .65rem; }
.job-status:not(:empty) { margin-block: .15rem .3rem; }
.play-help, .play-footer { margin-top: .55rem; }
.operations { display: grid; gap: .65rem; align-content: start; }
.operations h2 { font-size: 1rem; margin-bottom: .45rem; }
#tickets, #stock { display: grid; grid-template-columns: minmax(0, 1fr); gap: .35rem; }
.ticket {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .15rem .4rem;
  background: #fff0d8;
  color: #30211d;
  border-left: 4px solid #ca8660;
  border-radius: .23rem;
  padding: .35rem .45rem;
  font-size: .86rem;
}
.ticket.ready { border-color: #528b5b; }
.ticket.vip { background: #f9e3ef; border-color: #902b65; }
.ticket.urgent { border-color: #b23426; }
.ticket .timer { font-weight: 800; font-variant-numeric: tabular-nums; }
.ticket small { grid-column: 1 / -1; font-size: .78rem; }
.stock-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-block: .25rem; gap: .4rem; font-size: .88rem; }
.stock-row span { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.stock-row strong { color: var(--paper); }
.stock-name { display: flex; gap: .25rem; align-items: center; min-width: 0; }
.stock-name canvas { width: 24px; height: 24px; flex: none; }

.result h1 { font-family: system-ui, sans-serif; font-size: clamp(2rem, 6vw, 5rem); line-height: 1; }
.scoreline { color: var(--gold); margin-block: 1rem; font-size: 1.2rem; }
.scoreline strong { font-size: clamp(2rem, 9vw, 5rem); line-height: .9; font-variant-numeric: tabular-nums; }
#achievements, #again { margin-top: 1rem; }
#achievements { display: flex; flex-wrap: wrap; gap: .45rem; }
#achievements span { border: 1px solid #b98353; border-radius: 2rem; color: var(--gold); padding: .3rem .65rem; }
#achievements span { display: inline-flex; align-items: center; gap: .35rem; }
#achievements canvas { width: 1.8rem; height: 1.8rem; }
.result-stars { color: var(--gold); margin-block: .8rem .25rem; font-weight: 800; }
.claim { padding: clamp(.85rem, 3vw, 1.5rem); border: 1px solid #845747; background: var(--panel); border-radius: .65rem; }
.claim h2 { margin-bottom: .65rem; }
.claim fieldset { border-top: 1px solid var(--line); margin-block: .9rem; padding-top: .45rem; }
.claim legend { margin: 0; padding-right: .4rem; }
.claim label:not(.opt-in) { display: block; margin-block: .35rem .25rem; }
.claim input:not([type="checkbox"]) { width: 100%; border: 1px solid #a27664; border-radius: .3rem; background: #231b19; color: var(--paper); min-height: 44px; padding: .4rem .6rem; }
.claim small { color: var(--muted); }
.claim .opt-in { display: flex; align-items: start; gap: .5rem; margin-block: .7rem .45rem; line-height: 1.35; cursor: pointer; }
.claim input[type="checkbox"] { accent-color: var(--gold); width: 1.15rem; height: 1.15rem; flex: none; }
.claim select { width: 100%; min-height: 44px; padding: .4rem .6rem; border: 1px solid #a27664; border-radius: .3rem; background: #231b19; color: var(--paper); }
.player-profile { border-block: 1px solid var(--line); padding: .55rem 0; margin: .8rem 0; }
.player-profile summary { cursor: pointer; }
.player-profile select:last-child { margin-bottom: .4rem; }
.holiday-links { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin: .8rem 0; }
.holiday-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--gold); text-underline-offset: .18rem; }
.holiday-links span { color: #c5e2be; align-self: center; }
.holiday-offer { margin-bottom: .6rem; padding: .5rem .65rem; background: #243b32; border: 1px solid #759377; border-radius: .45rem; }
.holiday-offer p { margin: .28rem 0 0; color: #dfedda; }
body[data-level="christmas-preorders"] .brief { border-color: #a67961; }
.board { padding: 1rem 0 .5rem; border-top: 1px solid var(--line); }
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.board-head p, #scores > p { color: var(--muted); margin-top: .25rem; }
.board ol { margin: 0; padding: 0; list-style-position: inside; }
.board li { border-bottom: 1px solid var(--line); padding: .5rem; }
.board .board-score { float: right; color: var(--gold); font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 48rem) {
  .lobby, .result { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .intro h1 { font-size: clamp(3.15rem, 11vw, 5.5rem); }
  .game-grid { grid-template-columns: minmax(0, 1fr); }
  .operations { grid-template-columns: minmax(0, 1.06fr) minmax(0, 1fr); gap: .5rem; }
  .play-help { display: none; }
}
@media (max-width: 25rem) {
  .top-controls { gap: .28rem; }
  .top-controls .quiet { padding-inline: .42rem; font-size: .79rem; }
  .brand-marks { gap: .25rem; }
  .bar { gap: .38rem; }
  .station-title { align-items: flex-start; }
  .stock-name canvas { width: 18px; height: 18px; }
  .hud { gap: .4rem; }
  .hud .overline, .hud-stat span { font-size: .75rem; }
  .hud-stat.phase strong { max-width: 5.5rem; }
  .stock-row { font-size: .75rem; padding-block: .3rem; }
}
@media (orientation: landscape) and (max-height: 33rem) {
  .bar { padding-block: max(.3rem, env(safe-area-inset-top)) .3rem; }
  .game-grid { grid-template-columns: minmax(0, 1.5fr) minmax(11rem, 1fr); }
  .operations { grid-template-columns: minmax(0, 1fr); }
  .map { max-width: min(32rem, max(16rem, calc((100dvh - 9rem) * 1.5))); }
}
