﻿/* Apex Run — full-screen canvas game with DOM overlays */
:root { --text: #f4ecdc; --muted: #c9bba0; --panel: rgba(28, 24, 18, .88); --line: rgba(255, 240, 210, .14); --accent: #f0b54a; --accent-2: #e2763a; font-family: Inter, system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a241b; color: var(--text); overscroll-behavior: none; }
h1, h2 { font-family: 'Space Grotesk', Inter, sans-serif; margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

.game { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- HUD ---------- */
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); pointer-events: none;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .55); }
.hud b { font-family: 'Space Grotesk', sans-serif; }
.dist b { font-size: 34px; line-height: 1; } .dist span { font-size: 15px; margin-left: 3px; color: var(--muted); }
.score { font-size: 14px; color: var(--muted); } .score b { color: var(--text); font-size: 17px; }
.mom { display: flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 4px; }
.mom i { width: 90px; height: 8px; border-radius: 5px; background: rgba(0, 0, 0, .35); overflow: hidden; border: 1px solid rgba(255, 255, 255, .15); }
.mom i b { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f0b54a, #e2763a); transition: width .25s; }
.mom em { font-style: normal; font-weight: 700; color: var(--accent); font-size: 14px; }
.hud-r { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.spd b { font-size: 24px; } .spd span { font-size: 12px; margin-left: 3px; color: var(--muted); }
.best { font-size: 13px; color: var(--muted); } .best b { color: var(--text); }
.env { font-size: 12px; color: var(--muted); white-space: nowrap; }
.rival { margin-top: 5px; font-size: 13px; font-weight: 700; color: #ffb19a; background: rgba(60, 14, 8, .45); border-radius: 8px; padding: 2px 8px; display: inline-block; }
.rival.close { animation: blink .45s ease-in-out infinite alternate; }
.btns { display: flex; gap: 6px; margin-top: 4px; pointer-events: auto; }
.hb { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: rgba(20, 17, 12, .55); font-size: 15px; font-weight: 700; display: grid; place-items: center; }

/* bonus pop-ups and tutorial hints */
.pops { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pop { font: 700 20px 'Space Grotesk', sans-serif; color: #ffe1a1; text-shadow: 0 2px 8px rgba(0, 0, 0, .7); animation: pop 1.3s ease-out forwards; white-space: nowrap; }
.pop.bad { color: #ffb19a; }
.hint { position: absolute; left: 50%; top: 34%; transform: translateX(-50%); background: rgba(20, 17, 12, .78); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 18px; font-weight: 700; font-size: 17px; pointer-events: none; text-align: center; animation: hint-in .25s ease-out; max-width: 90vw; }
.hint small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }

/* touch zones */
.touch { position: absolute; inset: 0; display: grid; grid-template-columns: 38% 1fr; pointer-events: none; }
.tz { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: max(18px, env(safe-area-inset-bottom)); color: rgba(255, 245, 225, .5); text-align: center; }
.tz span { font-size: 22px; } .tz b { font-size: 13px; letter-spacing: .12em; } .tz small { font-size: 11px; }
.tz.duck { border-right: 1px dashed rgba(255, 245, 225, .12); }
.touch.fade .tz { opacity: .35; transition: opacity 2s; }

/* ---------- panels ---------- */
.panel { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; background: radial-gradient(ellipse at center, rgba(20, 16, 10, .35), rgba(20, 16, 10, .7)); z-index: 10; overflow: auto; }
.card { width: min(520px, 100%); max-height: calc(100dvh - 28px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 22px 22px 16px; box-shadow: 0 30px 70px rgba(0, 0, 0, .5); backdrop-filter: blur(4px); text-align: center; animation: rise .3s ease-out; touch-action: pan-y; }
.card.small { width: min(320px, 100%); display: grid; gap: 10px; }
.kicker { margin: 0; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
#title h1 { font-size: clamp(40px, 9vw, 60px); line-height: 1; letter-spacing: .01em; background: linear-gradient(180deg, #ffe2a6, #e88a3c); -webkit-background-clip: text; background-clip: text; color: transparent; margin: 4px 0 2px; }
.tagline { margin: 0 0 10px; font: 600 18px 'Space Grotesk', sans-serif; color: var(--accent); }
.lead { color: #e1d5bf; line-height: 1.5; margin: 0 0 12px; font-size: 15px; }
.controls { display: grid; gap: 6px; text-align: left; background: rgba(0, 0, 0, .22); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.controls div { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.controls span { color: #e1d5bf; }
kbd { display: inline-block; min-width: 26px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 3px; background: #3a3226; font: 600 12px Inter, sans-serif; text-align: center; }
.touch-only { display: none !important; }
@media (pointer: coarse) { .touch-only { display: flex !important; } }
.portrait-only { display: none !important; }
@media (pointer: coarse) and (orientation: portrait) { .portrait-only { display: flex !important; color: var(--accent); } }
.btn { border: 1px solid var(--line); background: #3a3226; border-radius: 12px; padding: 11px 18px; font-weight: 700; }
.btn.primary { background: linear-gradient(135deg, #f0b54a, #e2763a); color: #2a1a06; border: 0; }
.btn.big { font-size: 19px; padding: 14px 34px; }
.best-line { color: var(--muted); font-size: 14px; margin: 8px 0 0; min-height: 1em; }
.science { text-align: left; margin-top: 12px; font-size: 13px; color: #d9ccb2; line-height: 1.5; }
.science summary { cursor: pointer; font-weight: 700; color: var(--text); }
.science ul { padding-left: 18px; margin: 8px 0 0; } .science li { margin: 5px 0; }
.links { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
#over h2 { font-size: 30px; }
.cause { color: #f1c9a8; margin: 6px 0 12px; line-height: 1.45; }
.o-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.o-stats div { background: rgba(0, 0, 0, .25); border-radius: 12px; padding: 8px 4px; }
.o-stats span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.o-stats b { font: 700 21px 'Space Grotesk', sans-serif; }
.new-best { color: var(--accent); font-weight: 700; margin: 4px 0 8px; }
.fact { font-size: 13px; color: #d9ccb2; line-height: 1.5; background: rgba(0, 0, 0, .2); border-radius: 12px; padding: 8px 12px; margin: 12px 0 0; text-align: left; }
.fact::before { content: '🦴 Field note: '; font-weight: 700; color: var(--accent); }
.ad-wrap { width: 100%; text-align: center; margin-top: 10px; }
.ad-wrap.ad-on { min-height: 100px; }
.ad-wrap:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

/* small / short screens */
@media (max-height: 460px) {
  .card { padding: 14px 18px 10px; }
  #title h1 { font-size: 38px; } .lead { display: none; } .tagline { margin-bottom: 6px; }
  .controls { margin-bottom: 8px; padding: 8px 10px; font-size: 13px; }
  .btn.big { padding: 10px 28px; font-size: 17px; }
  .dist b { font-size: 26px; } .spd b { font-size: 19px; }
  .hint { top: 26%; font-size: 15px; }
}
@media (max-width: 420px) { .mom i { width: 64px; } .dist b { font-size: 28px; } }

@keyframes pop { 0% { opacity: 0; transform: translateY(8px) scale(.9); } 15% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-18px); } }
@keyframes blink { to { background: rgba(170, 30, 15, .75); color: #fff; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 8px); } }
