:root {
  --night: #050816;
  --night-soft: #0a1029;
  --cream: #e9f7ff;
  --paper: #bcecff;
  --paper-dark: #6086ad;
  --rust: #9a5cff;
  --gold: #49e6ff;
  --sage: #58f3b7;
  --line: rgba(112, 181, 255, .24);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--night); }
body { min-height: 100%; margin: 0; overflow-x: hidden; background: var(--night); color: var(--cream); font-family: "Space Mono", monospace; }
button, a { color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .72;
  background: radial-gradient(circle at 14% 9%, #d8f7ff 0 1px, transparent 1.4px), radial-gradient(circle at 81% 52%, #8ba9ff 0 1px, transparent 1.4px), radial-gradient(circle at 43% 72%, rgba(255,255,255,.7) 0 .7px, transparent 1px);
  background-size: 71px 67px, 109px 101px, 47px 53px;
}
.grain { position: fixed; z-index: 0; inset: 0; pointer-events: none; opacity: .52; background: radial-gradient(ellipse at 18% 38%, rgba(97,42,177,.28), transparent 31%), radial-gradient(ellipse at 83% 67%, rgba(0,155,219,.17), transparent 32%), radial-gradient(ellipse at 60% -12%, rgba(71,55,180,.2), transparent 34%); }

.topbar { position: relative; z-index: 5; height: 76px; padding: 0 34px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 37px; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold); font: 17px "Orbitron", sans-serif; box-shadow: inset 0 0 12px rgba(73,230,255,.18), 0 0 14px rgba(73,230,255,.15); }
.brand > span:last-child { display: flex; align-items: baseline; gap: 8px; }
.brand b { font: 700 13px "Orbitron", sans-serif; letter-spacing: .14em; }
.brand small { color: var(--rust); font-size: 8px; letter-spacing: .16em; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.icon-button, .pause-button { height: 38px; border: 1px solid var(--line); background: transparent; transition: .2s; }
.icon-button { width: 38px; padding: 8px; display: grid; place-items: center; }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-button .sound-off { display: none; }
.icon-button[aria-pressed="true"] .sound-on { display: none; }
.icon-button[aria-pressed="true"] .sound-off { display: block; }
.pause-button { min-width: 105px; font-size: 9px; letter-spacing: .12em; }
.pause-button span { color: var(--gold); margin-right: 10px; font-family: sans-serif; font-weight: 700; }
.icon-button:hover, .pause-button:hover { background: var(--cream); color: var(--night); }

main { position: relative; z-index: 1; width: min(1200px, calc(100% - 64px)); min-height: calc(100svh - 122px); margin: 0 auto; padding: clamp(38px, 6vh, 68px) 0; display: grid; grid-template-columns: minmax(310px, .72fr) minmax(520px, 1fr); gap: clamp(55px, 9vw, 130px); align-items: center; }
.game-copy { align-self: center; }
.kicker { margin: 0 0 24px; color: var(--paper-dark); font-size: 9px; letter-spacing: .16em; }
.kicker span { display: inline-block; width: 30px; height: 1px; margin: 0 9px 3px 0; background: var(--rust); }
h1, h2 { margin: 0; font-family: "Orbitron", sans-serif; font-weight: 800; line-height: .88; letter-spacing: -.055em; text-transform: uppercase; }
h1 { font-size: clamp(55px, 6.4vw, 92px); text-shadow: 0 0 32px rgba(73,230,255,.1); }
h1 em, h2 em { color: var(--rust); font-style: normal; }
.tagline { margin: 29px 0 43px; color: var(--paper); font-size: 14px; line-height: 1.65; }
.rules-strip { padding: 17px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 92px 1fr; gap: 20px; }
.rules-strip span, .desktop-keys > span { color: var(--gold); font-size: 8px; letter-spacing: .14em; }
.rules-strip p { margin: 0; color: #7f94aa; font-size: 10px; line-height: 1.65; }
.desktop-keys { margin-top: 22px; display: flex; align-items: center; gap: 18px; }
.desktop-keys div { width: 67px; text-align: center; line-height: 24px; }
kbd { display: inline-grid; place-items: center; width: 20px; height: 20px; margin: 1px; border: 1px solid #496786; border-radius: 2px; color: var(--paper); font: 10px sans-serif; box-shadow: inset 0 0 8px rgba(73,230,255,.08); }
.desktop-keys small { color: #807968; font-size: 7px; letter-spacing: .12em; }

.game-shell { min-width: 0; width: 100%; max-width: 600px; justify-self: end; }
.scoreboard { display: grid; grid-template-columns: 105px 105px 1fr; min-height: 64px; border: 1px solid var(--paper-dark); border-bottom: 0; background: rgba(0,0,0,.12); }
.score-block { padding: 11px 15px 8px; border-right: 1px solid rgba(169,142,98,.55); display: flex; flex-direction: column; justify-content: space-between; }
.score-block span { color: var(--paper-dark); font-size: 7px; letter-spacing: .13em; }
.score-block strong { font: 700 21px "Orbitron", sans-serif; }
.trail-status { padding: 0 18px; display: flex; align-items: center; justify-content: flex-end; gap: 9px; color: var(--sage); font-size: 8px; letter-spacing: .13em; }
.trail-status i { width: 7px; aspect-ratio: 1; border-radius: 50%; background: var(--sage); box-shadow: 0 0 0 5px rgba(88,243,183,.08), 0 0 12px var(--sage); }
.trail-status.danger { color: #d66f4d; }
.trail-status.danger i { background: #d66f4d; }

.board-frame { position: relative; padding: 25px 25px 29px; border: 1px solid #426083; background: linear-gradient(135deg, #111b3a, #080d22 52%, #121939); box-shadow: 0 0 0 1px rgba(73,230,255,.08), 0 20px 70px rgba(0,0,0,.38), 0 0 36px rgba(85,61,186,.12); }
.board-frame::before, .board-frame::after { content: ""; position: absolute; left: 9px; right: 9px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: .35; }
.board-frame::before { top: 8px; }.board-frame::after { bottom: 8px; }
.frame-nail { position: absolute; z-index: 3; width: 6px; aspect-ratio: 1; border-radius: 50%; background: var(--gold); box-shadow: 0 0 9px var(--gold); }
.frame-nail.n1 { left: 10px; top: 11px; }.frame-nail.n2 { right: 10px; top: 11px; }.frame-nail.n3 { left: 10px; bottom: 11px; }.frame-nail.n4 { right: 10px; bottom: 11px; }
.board { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border: 1px solid #293d69; outline: 0; background: #040713; touch-action: none; user-select: none; box-shadow: inset 0 0 50px rgba(0,0,0,.8), 0 0 22px rgba(73,230,255,.08); }
.board:focus-visible { box-shadow: inset 0 0 40px rgba(0,0,0,.5), 0 0 0 3px var(--gold); }
canvas { display: block; width: 100%; height: 100%; }
.board-caption { position: absolute; right: 25px; bottom: 10px; left: 25px; display: flex; justify-content: space-between; color: #6086ad; font-size: 6px; letter-spacing: .17em; }

.start-card, .game-card { position: absolute; z-index: 4; inset: 0; padding: 10%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(3,6,20,.76); text-align: center; backdrop-filter: blur(7px); transition: opacity .3s, visibility .3s; }
.start-card.hidden, .game-card { opacity: 0; visibility: hidden; pointer-events: none; }
.game-card.visible { opacity: 1; visibility: visible; pointer-events: auto; }
.wanted { width: 105px; padding: 5px 0 4px; border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold); color: var(--gold); font: 600 9px "Orbitron", sans-serif; letter-spacing: .13em; }
.start-card > p { margin: 17px 0 27px; font: 700 clamp(21px, 2.6vw, 34px)/1.25 "Orbitron", sans-serif; letter-spacing: -.03em; }
.start-card > small { margin-top: 18px; color: #8e8979; font-size: 6px; letter-spacing: .15em; }
.primary-button { min-width: 185px; height: 50px; padding: 0 9px 0 19px; border: 1px solid var(--gold); background: rgba(73,230,255,.1); color: var(--cream); font-size: 9px; letter-spacing: .13em; display: flex; align-items: center; justify-content: space-between; transition: .2s; box-shadow: inset 0 0 20px rgba(73,230,255,.08); }
.primary-button span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: var(--night); font: 18px sans-serif; box-shadow: 0 0 15px rgba(73,230,255,.4); }
.primary-button:hover { background: rgba(73,230,255,.22); transform: translateY(-2px); box-shadow: 0 0 24px rgba(73,230,255,.2); }
.game-card > p { margin: 0 0 15px; color: var(--gold); font-size: 8px; letter-spacing: .16em; }
.game-card h2 { font-size: clamp(48px, 7vw, 74px); }
.final-score { margin: 23px 0 20px; display: flex; align-items: center; gap: 12px; }
.final-score span { color: #9a927f; font-size: 7px; letter-spacing: .13em; }
.final-score strong { color: var(--gold); font: 700 22px "Orbitron", sans-serif; }

.mobile-controls { display: none; }
footer { min-height: 46px; padding: 0 34px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; color: #777263; font-size: 7px; letter-spacing: .14em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 900px) {
  .topbar { height: 64px; padding: 0 18px; }
  .pause-button { min-width: 90px; }
  main { width: min(620px, calc(100% - 28px)); padding: 28px 0 42px; grid-template-columns: 1fr; gap: 26px; }
  .game-copy { display: grid; grid-template-columns: 1fr auto; align-items: end; }
  .kicker { grid-column: 1 / -1; margin-bottom: 15px; }
  h1 { font-size: clamp(58px, 16vw, 90px); }
  .tagline { text-align: right; margin: 0 0 8px; font-size: 12px; }
  .rules-strip, .desktop-keys { display: none; }
  .game-shell { justify-self: center; }
  .mobile-controls { margin-top: 19px; display: block; }
  .mobile-controls > p { margin: 0 0 12px; color: #777263; text-align: center; font-size: 7px; letter-spacing: .13em; }
  .mobile-controls > p span { color: var(--gold); }
  .dpad { width: min(288px, 88vw); margin: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .dpad button, .dpad-center { height: 54px; border: 1px solid #334f78; background: rgba(38,86,140,.08); display: grid; place-items: center; color: var(--cream); font: 21px sans-serif; box-shadow: inset 0 0 18px rgba(73,230,255,.035); }
  .dpad button:active { background: var(--rust); transform: scale(.96); }
  .dpad button[data-direction="up"] { grid-column: 2; }
  .dpad button[data-direction="left"] { grid-row: 2; grid-column: 1; }
  .dpad-center { grid-row: 2; grid-column: 2; color: var(--gold); text-shadow: 0 0 10px var(--gold); }
  .dpad button[data-direction="right"] { grid-row: 2; grid-column: 3; }
  .dpad button[data-direction="down"] { grid-row: 3; grid-column: 2; }
}

@media (max-width: 520px) {
  .brand b { font-size: 12px; }.brand-mark { width: 32px; }.brand small { display: none; }
  .top-actions { gap: 7px; }.pause-button { min-width: 78px; font-size: 7px; }.pause-button span { margin-right: 5px; }
  main { width: calc(100% - 20px); padding-top: 20px; gap: 19px; }
  .kicker { font-size: 7px; margin-bottom: 11px; }
  h1 { font-size: clamp(48px, 15vw, 72px); }
  .tagline { font-size: 10px; }
  .scoreboard { grid-template-columns: 82px 82px 1fr; min-height: 55px; }
  .score-block { padding: 9px 10px 6px; }.score-block strong { font-size: 19px; }.trail-status { padding: 0 10px; font-size: 6px; }
  .board-frame { padding: 15px 15px 23px; box-shadow: 0 14px 45px rgba(0,0,0,.4), 0 0 28px rgba(85,61,186,.12); }
  .board-caption { left: 16px; right: 16px; bottom: 8px; }
  .start-card > p { font-size: clamp(21px, 7vw, 29px); margin: 14px 0 20px; }
  .primary-button { min-width: 175px; height: 46px; }
  .start-card > small { margin-top: 13px; }
  .mobile-controls { margin-top: 14px; }
  .dpad { width: 245px; }.dpad button, .dpad-center { height: 46px; }
  footer { min-height: 39px; padding: 0 18px; justify-content: center; } footer span:first-child { display: none; }
}

@media (max-height: 780px) and (max-width: 900px) {
  .game-copy { display: none; }
  main { padding-top: 16px; }
  .dpad { grid-template-columns: repeat(3, 62px); width: max-content; }
  .dpad button, .dpad-center { height: 42px; }
  .mobile-controls > p { display: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; } }
