@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Silkscreen:wght@400;700&display=swap');

:root {
  --ink: #f5f3eb;
  --muted: #a8b7bd;
  --night: #071c2c;
  --panel: rgba(7, 20, 29, .92);
  --line: rgba(255, 255, 255, .16);
  --lime: #c8f45b;
  --coral: #ff8a66;
  --blue: #58d3dc;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--night); color: var(--ink); font-family: 'DM Sans', system-ui, sans-serif; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, a { color: inherit; font: inherit; }
button { touch-action: manipulation; }
.game-shell, #game { position: fixed; inset: 0; width: 100%; height: 100%; }
#game { display: block; outline: 0; }
#game:focus-visible { outline: 3px solid var(--lime); outline-offset: -5px; }

.game-header { position: fixed; z-index: 5; left: 24px; right: 24px; top: 20px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.game-header > * { pointer-events: auto; }
.back-link { min-height: 40px; display: inline-flex; align-items: center; gap: 8px; padding: 0 13px; border: 2px solid #4d765b; border-radius: 4px; background: rgba(4,15,22,.82); box-shadow: 3px 3px 0 rgba(0,0,0,.3); color: var(--ink); text-decoration: none; font: 700 9px/1 'Silkscreen', monospace; }
.back-link:hover { color: var(--lime); transform: translate(1px, 1px); box-shadow: 2px 2px 0 rgba(0,0,0,.3); }
.game-brand { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; }
.game-brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 2px solid var(--line); border-radius: 4px; color: var(--lime); font: 700 10px/1 'Silkscreen', monospace; box-shadow: 3px 3px 0 rgba(0,0,0,.25); }
.game-brand > span:last-child { display: grid; line-height: 1.2; }
.game-brand strong { font: 700 11px/1.2 'Silkscreen', monospace; }
.game-brand small { color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 4px; background: rgba(4, 15, 22, .72); backdrop-filter: blur(10px); box-shadow: 3px 3px 0 rgba(0,0,0,.3); cursor: pointer; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-button[aria-pressed="false"] .sound-on, .icon-button[aria-pressed="true"] .sound-off { display: none; }

.hud { position: fixed; z-index: 4; left: 24px; bottom: 24px; width: min(330px, calc(100vw - 48px)); padding: 14px 16px; border: 3px solid #4d765b; border-radius: 3px; background: rgba(4, 15, 22, .84); box-shadow: 5px 5px 0 rgba(0,0,0,.3), inset 0 0 0 2px #152f31; backdrop-filter: blur(8px); transition: opacity .3s ease; }
.hud-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.hud-label strong { color: var(--ink); }
.progress-track { height: 4px; margin: 9px 0 12px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.12); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--lime); transition: width .2s linear; }
.token-count { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.token-count strong { color: var(--ink); font-size: 14px; }
.token-icon { color: var(--lime); }

.overlay-card { position: fixed; z-index: 10; left: 50%; top: 50%; width: min(520px, calc(100vw - 36px)); max-height: calc(100vh - 130px); overflow-x: hidden; overflow-y: auto; transform: translate(-50%, -50%); padding: clamp(28px, 5vw, 52px); border: 4px solid #53735f; border-radius: 5px; background: var(--panel); box-shadow: 9px 9px 0 rgba(2,9,12,.58), inset 0 0 0 3px #142f32; backdrop-filter: blur(18px); }
.overlay-card[hidden] { display: none; }
.overlay-card::before { content: ''; position: absolute; width: 160px; height: 160px; right: -70px; top: -80px; border-radius: 50%; background: rgba(200,244,91,.14); filter: blur(4px); }
.card-kicker { margin: 0 0 18px; color: var(--lime); font: 700 9px/1.4 'Silkscreen', monospace; letter-spacing: .08em; text-transform: uppercase; }
.overlay-card h1, .overlay-card h2 { margin: 0; font: 700 clamp(28px, 4.8vw, 46px)/1.15 'Silkscreen', monospace; letter-spacing: -.045em; }
.overlay-card h2 { font-size: clamp(25px, 4vw, 38px); }
.overlay-card em { color: var(--lime); font-style: normal; }
.overlay-card > p:not(.card-kicker) { margin: 23px 0; color: var(--muted); line-height: 1.65; }
.game-button { min-height: 50px; display: inline-flex; align-items: center; justify-content: space-between; gap: 26px; padding: 0 20px; border: 3px solid #e4ff9c; border-radius: 3px; background: var(--lime); color: #07110b; box-shadow: 4px 4px 0 #54731b; font: 700 9px/1 'Silkscreen', monospace; text-decoration: none; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.game-button:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #54731b; }
.controls-hint { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 26px; color: var(--muted); font-size: 10px; }
kbd { min-width: 25px; height: 25px; display: inline-grid; place-items: center; margin-right: 3px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,.06); color: var(--ink); font: inherit; }
.touch-hint { display: none; }
.checkpoint-card { border-color: #839b53; }
.checkpoint-topline { display: flex; justify-content: space-between; margin-bottom: 28px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.checkpoint-card ul { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 26px; padding: 0; list-style: none; }
.checkpoint-card li { padding: 7px 11px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 10px; }
.finish-card { text-align: center; }
.finish-score { width: 110px; height: 110px; display: grid; place-content: center; gap: 3px; margin: 0 auto 28px; border: 1px solid rgba(200,244,91,.4); border-radius: 50%; color: var(--lime); }
.finish-score span { font: 700 22px/1 'Silkscreen', monospace; }
.finish-score small { color: var(--muted); font-size: 8px; text-transform: uppercase; }
.finish-actions { display: flex; justify-content: center; align-items: center; gap: 20px; flex-wrap: wrap; }
.home-button { background: #ffcb62; border-color: #ffe5a5; box-shadow: 4px 4px 0 #8b5d22; }
.text-button { padding: 8px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.text-button:hover { color: var(--ink); }

.touch-controls { position: fixed; z-index: 6; right: 20px; bottom: 20px; display: none; gap: 9px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
.touch-controls button { width: 58px; height: 58px; border: 3px solid #4d765b; border-radius: 4px; background: rgba(4,15,22,.84); box-shadow: 4px 4px 0 rgba(0,0,0,.3); color: var(--ink); font-size: 22px; backdrop-filter: blur(8px); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; cursor: pointer; }
.touch-controls .jump-control { margin-left: 12px; background: rgba(200,244,91,.85); color: #07110b; }
.touch-controls button:active { transform: scale(.94); }
.rotate-message { display: none; }

@media (pointer: coarse), (max-width: 800px) {
  .touch-controls { display: flex; }
  .touch-hint { display: inline; }
  .hud { bottom: 92px; width: 240px; }
  .controls-hint span:not(.touch-hint) { display: none; }
}

@media (max-width: 600px) {
  .game-header { left: 14px; right: 14px; top: 12px; }
  .game-brand > span:last-child { display: none; }
  .game-brand-mark { width: 34px; height: 34px; }
  .hud { left: 14px; bottom: 84px; width: 180px; padding: 10px 12px; }
  .token-count { font-size: 9px; }
  .touch-controls { right: 12px; bottom: 12px; }
  .touch-controls button { width: 50px; height: 50px; }
  .overlay-card { max-height: calc(100vh - 90px); padding: 28px; border-radius: 22px; }
}

@media (orientation: portrait) and (max-width: 500px) and (max-height: 760px) {
  .rotate-message { position: fixed; z-index: 20; inset: auto 50% 14px auto; display: block; transform: translateX(50%); margin: 0; color: var(--muted); font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
