@font-face { font-family: "Space Grotesk"; src: url("/fonts/space-grotesk-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("/fonts/space-grotesk-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* Dust Up's pair: a hot teal field, coral-red buttons, the desert pack's own ink for outlines */
:root {
  --field: #00a19a;
  --field-deep: #006b67;
  --field-deeper: #004e4b;
  --btn: #ff4a3d;
  --btn-deep: #c22a20;
  --ink: #2b1d3a;
  --sand: #ffd9a8;
  --cream: #fff4e3;
  --gold: #ffd23f;
  --topH: 56px;
  --deckH: 184px;
  --sideW: 340px;
  --safeB: env(safe-area-inset-bottom, 0px);
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--field);
  color: var(--cream);
  font: 500 16px/1.35 "Space Grotesk", system-ui, sans-serif;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: 700 16px "Space Grotesk", sans-serif; }

#board { position: fixed; inset: 0; width: 100vw; height: 100svh; display: block; touch-action: none; image-rendering: pixelated; }

.screen { position: fixed; inset: 0; display: none; z-index: 2; }
.screen.on { display: flex; }

/* ---- buttons ---- */
.big {
  display: block; width: 100%; min-height: 60px; padding: 12px 18px;
  background: var(--btn); color: #fff; border: 3px solid var(--ink); border-radius: 6px;
  font-weight: 700; font-size: 22px; letter-spacing: 0.02em;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.06s, box-shadow 0.06s;
}
.big:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.big.alt { background: var(--cream); color: var(--ink); }
.big.ghost { background: var(--field-deep); color: var(--cream); }
.big:disabled { opacity: 0.45; }
.back { background: var(--field-deeper); border: 3px solid var(--ink); border-radius: 6px; color: var(--cream); font-weight: 700; padding: 8px 14px; min-height: 44px; }
.link { background: none; border: 0; color: var(--cream); font-weight: 700; text-decoration: underline; text-underline-offset: 4px; padding: 10px 12px; min-height: 44px; }

/* ---- home: the live fight behind, everything big over it ---- */
#home { flex-direction: column; align-items: center; justify-content: space-between; padding: max(18px, env(safe-area-inset-top)) 18px calc(14px + var(--safeB)); pointer-events: none; }
#home > * { pointer-events: auto; }
.homeTop { text-align: center; width: 100%; }
.word { display: block; margin: 8px auto 0; width: min(94vw, 640px); height: auto; filter: drop-shadow(0 6px 0 rgba(43, 29, 58, 0.6)); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-1deg); } }
.lede { display: inline-block; margin: 10px 0 0; padding: 4px 14px; font-weight: 700; font-size: clamp(18px, 4.6vw, 26px); color: #fff; text-shadow: 0 3px 0 var(--ink); background: rgba(0, 78, 75, 0.78); border-radius: 6px; }
.homeButtons { width: min(100%, 420px); display: grid; gap: 14px; }
.links { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; text-shadow: 0 2px 0 var(--ink); background: rgba(0, 78, 75, 0.7); border-radius: 6px; padding: 0 8px; }
.shelf { width: 100%; max-width: 640px; }

/* ---- full panels ---- */
.panel { flex-direction: column; background: var(--field); overflow-y: auto; }
.bar { display: flex; align-items: center; gap: 14px; padding: max(12px, env(safe-area-inset-top)) 16px 12px; background: var(--field-deep); border-bottom: 3px solid var(--ink); position: sticky; top: 0; z-index: 1; }
.bar h2 { margin: 0; font-size: 26px; flex: 1; }
.starCount { font-weight: 700; color: var(--gold); font-size: 20px; }

.levelGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; padding: 16px; }
.lvl { position: relative; text-align: left; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px; padding: 10px; box-shadow: 0 5px 0 var(--ink); min-height: 120px; display: flex; flex-direction: column; gap: 6px; }
.lvl canvas { width: 100%; aspect-ratio: 1; image-rendering: pixelated; border: 2px solid var(--ink); }
.lvl b { font-size: 17px; }
.lvl .n { position: absolute; top: 4px; left: 6px; background: var(--btn); color: #fff; font-weight: 700; padding: 0 7px; border: 2px solid var(--ink); border-radius: 4px; }
.lvl .st { color: #e0a000; font-size: 20px; letter-spacing: 2px; }
.lvl.locked { opacity: 0.5; }

.briefBody { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 560px; width: 100%; margin: 0 auto; }
#briefMap { width: min(100%, 360px); aspect-ratio: 1; margin: 0 auto; image-rendering: pixelated; border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink); }
.idea { margin: 0; font-size: 21px; font-weight: 700; color: #fff; }
.goal { margin: 0; font-size: 18px; background: var(--field-deep); border: 3px solid var(--ink); border-radius: 6px; padding: 10px 14px; }

/* ---- play: top bar and the deck sit in space the board never uses ---- */
#play { pointer-events: none; }
#play > * { pointer-events: auto; }
.hudTop { position: fixed; left: 0; right: 0; top: 0; height: var(--topH); display: flex; align-items: center; gap: 10px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top)); background: var(--field-deep); border-bottom: 3px solid var(--ink); }
.goalChip { flex: 1; font-weight: 700; font-size: 16px; line-height: 1.2; }
.clock { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-weight: 700; font-size: 22px; min-width: 76px; font-variant-numeric: tabular-nums; }
.clock svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.clock.late { color: #ff4a3d; text-shadow: 0 2px 0 var(--ink); animation: tick 1s steps(1) infinite; }
@keyframes tick { 0% { transform: scale(1.18); } 30% { transform: scale(1); } }
.timebar { position: absolute; left: 0; right: 0; bottom: -3px; height: 6px; background: var(--field-deeper); border-top: 2px solid var(--ink); }
.timebar i { display: block; height: 100%; width: 100%; background: var(--gold); transition: width 0.25s linear; }
.timebar.late i { background: #ff4a3d; }
.deck { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--deckH) + var(--safeB)); padding: 8px 10px calc(8px + var(--safeB)); background: var(--field-deep); border-top: 3px solid var(--ink); display: grid; grid-template-rows: 1fr auto auto; gap: 8px; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; min-height: 0; }
.card { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); grid-template-rows: auto auto; grid-template-areas: "name name" "pic hp"; row-gap: 4px; align-items: center; column-gap: 6px; padding: 6px; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px; text-align: left; min-height: 0; }
.card canvas { grid-area: pic; width: 30px; height: 30px; image-rendering: pixelated; background: var(--role, transparent); border: 2px solid var(--ink); border-radius: 50%; }
.card { border-left: 8px solid var(--role, var(--ink)); }
.card b { grid-area: name; font-size: 14px; line-height: 1.1; letter-spacing: -0.01em; }
.card .mo { white-space: nowrap; }
.card .hp { grid-area: hp; height: 8px; background: var(--ink); border-radius: 2px; overflow: hidden; }
.card .hp i { display: block; height: 100%; background: #41e06b; }
.card .mo { position: absolute; top: -10px; right: -6px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.card .key { position: absolute; top: -10px; left: -6px; }
.card.sel { background: var(--gold); transform: translateY(-4px); box-shadow: 0 4px 0 var(--ink); }
.card.dead { opacity: 0.4; }
.coach { animation: coach 0.9s ease-in-out infinite; z-index: 1; }
@keyframes coach { 50% { box-shadow: 0 0 0 6px var(--gold), 0 0 22px 8px rgba(255, 210, 63, 0.75); } }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mode { min-height: 54px; background: var(--btn); color: #fff; border: 3px solid var(--ink); border-radius: 6px; font-weight: 700; font-size: 19px; box-shadow: 0 4px 0 var(--ink); display: flex; align-items: center; justify-content: center; gap: 8px; }
.mode[data-mode="run"] { background: var(--cream); color: var(--ink); }
.mode[data-mode="guard"] { background: #3b6bff; }
.mode.armed { outline: 4px solid var(--gold); outline-offset: 2px; transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.key { display: none; min-width: 26px; padding: 0 6px; height: 26px; line-height: 22px; text-align: center; font-size: 14px; font-weight: 700; background: #fff; color: var(--ink); border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 5px; }
.desk .key { display: inline-block; }
/* a mouse and keyboard get no order buttons: the keys, as glyphs, and the order lit when it is armed */
.prompts { display: none; }
.desk .modes { display: none; }
.desk .prompts { display: grid; gap: 8px; }
.prompts .order { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 20px; padding: 8px 10px; border: 3px solid transparent; border-radius: 6px; }
.prompts .order.armed { border-color: var(--ink); background: var(--gold); color: var(--ink); }
.prompts .also { display: flex; flex-wrap: wrap; gap: 6px 14px; font-weight: 700; font-size: 14px; margin-top: 4px; }
.prompts .also span { display: flex; align-items: center; gap: 6px; }
kbd { display: inline-block; min-width: 30px; padding: 0 7px; height: 30px; line-height: 25px; text-align: center; font: 700 15px "Space Grotesk", sans-serif; background: #fff; color: var(--ink); border: 2px solid var(--ink); border-bottom-width: 5px; border-radius: 6px; }
.prompts .also kbd { min-width: 24px; height: 24px; line-height: 19px; font-size: 12px; }
kbd.mouse { width: 18px; min-width: 18px; padding: 0; border-radius: 9px 9px 9px 9px; font-size: 0; position: relative; }
kbd.mouse::after { content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 7px; background: var(--btn); border-radius: 0 6px 0 0; }
.hint { margin: 0; height: 20px; font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: clip; }

/* wide screens: the deck becomes a column on the right */
.wide .deck { top: var(--topH); left: auto; width: var(--sideW); height: auto; border-top: 0; border-left: 3px solid var(--ink); grid-template-rows: auto auto 1fr; align-content: start; padding: 14px; }
.wide .cards { grid-template-columns: 1fr; }
.wide .card { min-height: 66px; grid-template-columns: 52px minmax(0, 1fr); grid-template-areas: "pic name" "pic hp"; }
.wide .card canvas { width: 52px; height: 52px; }
.desk.wide .card { min-height: 92px; grid-template-columns: 72px minmax(0, 1fr); }
.desk.wide .card canvas { width: 72px; height: 72px; }
.desk.wide .card b { font-size: 20px; }
.desk.wide .card .hp { height: 12px; }
.wide .modes { grid-template-columns: 1fr; }
.wide .hint { height: auto; white-space: normal; }

/* ---- sheets: summary and result, they wait for OK ---- */
.sheet { align-items: center; justify-content: center; background: rgba(0, 78, 75, 0.72); padding: 16px; }
.sheetBody { width: min(100%, 460px); max-height: 100%; overflow-y: auto; background: var(--field); border: 4px solid var(--ink); border-radius: 8px; box-shadow: 0 8px 0 var(--ink); padding: 22px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; animation: rise 0.28s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes rise { from { transform: translateY(40px) scale(0.92); opacity: 0; } }
.sheetBody h2 { margin: 0; font-size: 34px; text-align: center; text-shadow: 0 3px 0 var(--ink); }
.stars { display: flex; justify-content: center; gap: 10px; min-height: 64px; }
.stars span { font-size: 58px; line-height: 1; color: var(--field-deeper); text-shadow: 0 4px 0 var(--ink); }
.stars span.got { color: var(--gold); animation: pop 0.4s cubic-bezier(.2, 1.8, .4, 1) both; }
.stars span.got:nth-child(2) { animation-delay: 0.15s; }
.stars span.got:nth-child(3) { animation-delay: 0.3s; }
@keyframes pop { from { transform: scale(0) rotate(-40deg); } }
.resultLine { margin: 0; text-align: center; font-size: 19px; font-weight: 700; }
.cta { display: grid; gap: 12px; }

.togetherBody, .lobbyBody { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 480px; width: 100%; margin: 0 auto; }
.joinForm { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.joinForm input { width: 100%; min-width: 0; min-height: 60px; font-size: 28px; text-align: center; letter-spacing: 0.3em; text-transform: uppercase; border: 3px solid var(--ink); border-radius: 6px; background: var(--cream); color: var(--ink); }
.joinForm .big { width: auto; }
.why { margin: 0; min-height: 22px; font-weight: 700; color: #fff; }
#lobbyCode { color: var(--gold); letter-spacing: 0.12em; }
.invite { background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px; padding: 12px; font-weight: 700; font-size: 18px; min-height: 52px; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seat { display: flex; gap: 8px; align-items: center; background: var(--field-deep); border: 3px solid var(--ink); border-radius: 6px; padding: 8px; font-weight: 700; min-height: 64px; }
.seat canvas { width: 44px; height: 44px; image-rendering: pixelated; }
.seat.you { background: var(--gold); color: var(--ink); }
.seat small { display: block; font-weight: 500; opacity: 0.85; }
.pick { display: grid; gap: 6px; font-weight: 700; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { min-height: 46px; background: var(--field-deep); color: var(--cream); border: 3px solid var(--ink); border-radius: 6px; font-weight: 700; }
.seg button.on { background: var(--gold); color: var(--ink); }

.howBody { width: min(100%, 520px); }
.slide { display: grid; gap: 12px; text-align: center; min-height: 300px; align-content: center; }
.slide h3 { margin: 0; font-size: 28px; }
.slide p { margin: 0; font-size: 19px; font-weight: 700; }
.slide .row { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.slide .row div { display: grid; justify-items: center; gap: 4px; font-weight: 700; }
.slide canvas { width: 72px; height: 72px; image-rendering: pixelated; background: var(--role, transparent); border: 3px solid var(--ink); border-radius: 50%; }
.dots { display: flex; gap: 8px; justify-content: center; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--field-deeper); border: 2px solid var(--ink); }
.dots i.on { background: var(--gold); }

.creditsBody { padding: 18px; max-width: 640px; width: 100%; margin: 0 auto; display: grid; gap: 10px; }
.creditsBody h3 { margin: 12px 0 0; }
.creditsBody p { margin: 0; }
.creditsBody a { color: #fff; }

.tw { display: flex; gap: 12px; align-items: center; font-weight: 700; font-size: 18px; min-height: 44px; }
.tw input { width: 24px; height: 24px; }

.toast { position: fixed; left: 50%; top: calc(var(--topH) + 10px); transform: translate(-50%, -20px); opacity: 0; z-index: 20; background: var(--ink); color: #fff; font-weight: 700; padding: 10px 16px; border-radius: 6px; pointer-events: none; transition: 0.2s; max-width: 92vw; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

#resultShelf { min-width: 0; overflow: hidden; }

/* a phone on its side: the door's buttons sit in a row so nothing falls off the bottom */
@media (max-height: 520px) {
  .word { width: min(60vw, 420px); margin-top: 0; }
  .lede { margin-top: 4px; font-size: 17px; }
  .homeButtons { width: min(100%, 760px); grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .homeButtons #rejoin { grid-column: span 3; }
  .big { min-height: 50px; font-size: 19px; }
  #home .links .link { min-height: 40px; padding: 6px 10px; }
}
.short.wide .deck { padding: 8px; gap: 6px; }
.short.wide .card { min-height: 44px; padding: 4px 6px; grid-template-columns: 30px minmax(0, 1fr); }
.short.wide .card canvas { width: 30px; height: 30px; }
.short.wide .cards, .short.wide .modes { gap: 6px; }
.short.wide .mode { min-height: 44px; font-size: 17px; }
.short.wide .hint { display: none; }
.short { --topH: 48px; }
