/* Serpent Quest: neon arcade cabinet, single dark theme by design.
   Layout: arena then board panel on phones; arena | board panel from 880px. */
:root {
  color-scheme: dark;
  --void: #0a0014;
  --deep: #14002a;
  --panel: #12002499;
  --panel-solid: #140028;
  --violet: #6a00ff;
  --orchid: #a200ff;
  --magenta: #ff3df2;
  --crystal: #00f0ff;
  --ink: #f1e9ff;
  --mist: #a596c8;
  --dim: #6f6194;
  --line: #a200ff52;
  --line-soft: #a200ff26;
  --gold: #ffd25a;
  --danger: #ff5c8a;
  --brass-hi: #fff1c2;
  --brass-deep: #1c1404;
  --f-display: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --f-ui: "Chakra Petch", "Trebuchet MS", system-ui, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse 90% 70% at 50% 28%, #23003f 0%, #12001f 48%, var(--void) 100%) fixed, var(--void);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.45;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button, input { font: inherit; color: inherit; }
a { color: var(--crystal); }
:focus-visible { outline: 2px solid var(--crystal); outline-offset: 2px; }

.shell {
  max-width: 1040px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; }
.brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; text-decoration: none; }
.eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: .28em; text-transform: uppercase;
  color: var(--crystal); text-shadow: 0 0 10px #00f0ff66;
}
.wordmark {
  font-family: var(--f-display); font-weight: 900; line-height: 1.05;
  font-size: clamp(30px, 5.4vw, 48px); letter-spacing: .02em;
  color: #f4e8ff; text-shadow: 0 0 10px #a200ff, 0 0 28px #a200ff88;
}
.btn {
  display: inline-flex; align-items: center; height: 38px; padding: 0 14px; border-radius: 6px;
  border: 1px solid var(--orchid); background: linear-gradient(180deg, #7a12ff, #5200c9);
  color: #fff; font-weight: 600; letter-spacing: .04em; text-decoration: none;
  cursor: pointer; box-shadow: 0 0 14px #6a00ff66;
}
.btn:hover { filter: brightness(1.12); }

/* Grid */
.layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "arena" "board"; align-items: start; }
.arena { grid-area: arena; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.board { grid-area: board; }
@media (min-width: 880px) {
  .layout { grid-template-columns: minmax(0, 432px) minmax(0, 1fr); grid-template-areas: "arena board"; }
}

/* HUD */
.hud { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-left: 2px solid var(--line); min-width: 0; }
.stat .k { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--mist); }
.stat .v { font-family: var(--f-num); font-weight: 600; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .by { font-size: 12px; color: var(--mist); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.score .v { color: var(--crystal); text-shadow: 0 0 12px #00f0ff88; }
.stat.record .v { color: var(--gold); text-shadow: 0 0 12px #ffd25a55; }
.bump { animation: bump .22s ease-out; }
@keyframes bump { 40% { transform: scale(1.22); } }

/* Stage */
.stage { position: relative; width: 100%; max-width: 406px; margin-inline: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
#game {
  display: block; width: 100%; height: auto; aspect-ratio: 1 / 1;
  border: 3px solid var(--violet); border-radius: 4px; background: #0e001a;
  box-shadow: 0 0 20px var(--violet), 0 0 60px #6a00ff33;
  transition: box-shadow .2s, border-color .2s;
}
.stage.hit #game { border-color: var(--magenta); box-shadow: 0 0 26px var(--magenta), 0 0 70px #ff3df244; }
.overlay {
  position: absolute; inset: 3px; display: grid; place-items: center; padding: 18px;
  background: #08001299; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); text-align: center;
}
.overlay[data-kind="ready"] { background: #08001266; }
.ov-box { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 320px; }
.ov-box p { margin: 0; }
.ov-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--crystal); }
.ov-title { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: 26px; line-height: 1.1; text-wrap: balance; color: #ffe8ff; }
.overlay[data-kind="over"] .ov-title { color: #ff66ff; text-shadow: 0 0 10px #ff00ff; }
.ov-score { font-family: var(--f-num); font-weight: 600; font-size: 54px; line-height: 1; color: var(--crystal); text-shadow: 0 0 18px #00f0ff99; font-variant-numeric: tabular-nums; }
.ov-unit { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--mist); margin-top: -4px; }
.ov-text { color: var(--ink); font-size: 14px; text-wrap: pretty; }
.ov-text.muted { color: var(--mist); font-size: 13px; }
.ov-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.badge {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
}
.badge.gold { background: #ffd25a22; color: var(--gold); border: 1px solid #ffd25a88; box-shadow: 0 0 14px #ffd25a44; }
.badge.cyan { background: #00f0ff18; color: var(--crystal); border: 1px solid #00f0ff77; }
.kbd { font-family: var(--f-num); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--mist); }

.hint { margin: 0; text-align: center; font-size: 12px; color: var(--mist); }
.pad { display: none; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 56px); gap: 6px; justify-content: center; }
.pad button {
  border-radius: 10px; border: 1px solid var(--line); background: #1a0036; color: var(--ink);
  font-size: 22px; cursor: pointer; touch-action: manipulation;
}
.pad button:active { background: #2b0058; border-color: var(--crystal); }
.pad .up { grid-column: 2; grid-row: 1; }
.pad .left { grid-column: 1; grid-row: 2; }
.pad .down { grid-column: 2; grid-row: 2; }
.pad .right { grid-column: 3; grid-row: 2; }
@media (hover: none) and (pointer: coarse) {
  .pad { display: grid; }
  .hint.keys { display: none; }
}

/* Skins */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
h2 { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: 18px; letter-spacing: .03em; color: #f0e2ff; }
.count { font-size: 12px; color: var(--mist); font-variant-numeric: tabular-nums; }
.skins { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.skin {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 9px 8px 8px; min-width: 0;
  border-radius: 8px; border: 1px solid var(--line-soft); background: #0d001b; cursor: pointer; text-align: left;
}
.skin:hover { border-color: var(--line); }
.skin.on { border-color: var(--crystal); box-shadow: 0 0 0 1px var(--crystal), 0 0 16px #00f0ff33; }
.skin.locked { cursor: not-allowed; }
.skin.locked .skin-preview { opacity: .3; filter: grayscale(.7); }
.skin-preview { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 6 / 1; }
.skin-name { font-size: 12px; font-weight: 600; line-height: 1.15; overflow-wrap: break-word; }
.skin-req { margin-top: auto; font-size: 11px; color: var(--mist); font-variant-numeric: tabular-nums; }
.skin.locked .skin-req { color: var(--dim); }
.skin.on .skin-req { color: var(--crystal); }

/* Panels */
.panel {
  display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px;
  border: 1px solid var(--line-soft); border-radius: 10px; background: var(--panel);
}
.note { margin: 0; font-size: 13px; color: var(--mist); padding: 8px 10px; border-radius: 6px; background: #ffffff08; border: 1px solid var(--line-soft); }

/* Hall of Fame plaque: an engraved brass plate, the only gold object besides records */
.plaque {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "eyebrow eyebrow" "name score" "note score" "status status";
  align-items: center; gap: 2px 14px; padding: 16px 20px 14px; border-radius: 8px;
  background: linear-gradient(160deg, #3d2c08 0%, var(--brass-deep) 55%, #2f2106 100%);
  border: 1px solid #ffd25a99;
  box-shadow: inset 0 0 0 3px var(--brass-deep), inset 0 0 0 4px #ffd25a55, 0 0 22px #ffd25a1f;
}
.plaque p { margin: 0; }
.screw { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--brass-hi), #8a6a1c 70%); box-shadow: 0 0 0 1px #00000088; }
.screw.tl { top: 8px; left: 8px; } .screw.tr { top: 8px; right: 8px; }
.screw.bl { bottom: 8px; left: 8px; } .screw.br { bottom: 8px; right: 8px; }
.plq-eyebrow { grid-area: eyebrow; font-family: var(--f-display); font-weight: 700; font-size: 12px; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); padding-bottom: 4px; }
.plq-name { grid-area: name; font-family: var(--f-display); font-weight: 900; font-size: 26px; line-height: 1.1; color: var(--brass-hi); text-shadow: 0 1px 0 #000, 0 0 12px #ffd25a55; overflow-wrap: anywhere; }
.plq-note { grid-area: note; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #c9a95a; }
.plq-score { grid-area: score; display: flex; flex-direction: column; align-items: flex-end; }
.plq-num { font-family: var(--f-num); font-weight: 600; font-size: 40px; line-height: 1; color: var(--gold); text-shadow: 0 1px 0 #000, 0 0 14px #ffd25a66; font-variant-numeric: tabular-nums; }
.plq-unit { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: #c9a95a; }
.plaque .plq-status { grid-area: status; margin-top: 10px; padding-top: 8px; border-top: 1px solid #ffd25a33; font-size: 12.5px; color: #e9d7a6; }
.plq-status:empty { display: none; }

/* 404 */
.lost { max-width: 560px; }
.lost p { margin: 0; color: var(--mist); }

/* Footer */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--dim); border-top: 1px solid var(--line-soft); padding-top: 14px; }

/* Toasts */
.toasts {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.toast {
  max-width: 420px; padding: 10px 14px; border-radius: 8px; background: var(--panel-solid);
  border: 1px solid var(--line); box-shadow: 0 8px 30px #000a, 0 0 16px #6a00ff44; font-size: 14px;
  animation: toastIn .25s ease-out;
}
.toast.gold { border-color: #ffd25a99; box-shadow: 0 8px 30px #000a, 0 0 18px #ffd25a44; }
.toast.cyan { border-color: #00f0ff88; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .bump, .toast { animation: none; }
  #game { transition: none; }
}
@media (max-width: 420px) {
  .stat .v { font-size: 20px; }
  .skins { gap: 5px; }
  .skin { padding: 7px 5px 6px; gap: 5px; }
  .skin-name { font-size: 11px; }
  .skin-req { font-size: 10px; }
}
