﻿/* Faraway Drive — full-screen WebGL canvas with DOM overlays */
:root { --text: #f3f5fb; --muted: #b7c2d8; --panel: rgba(16, 22, 38, .84); --line: rgba(220, 230, 255, .16);
  --accent: #ffc477; --accent-2: #ff8a5c; font-family: Inter, system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d2a44; 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, select { 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; }
.game.photo .hud-l, .game.photo .clock, .game.photo .touch, .game.photo .offroad, .game.photo .banner, .game.photo .hb:not(#btn-photo) { visibility: hidden; }
.game.photo #btn-photo { opacity: .45; }

/* ---------- 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 8px rgba(0, 0, 0, .55); transition: opacity .4s; }
.hud b { font-family: 'Space Grotesk', sans-serif; }
.spd b { font-size: 38px; line-height: 1; } .spd span { font-size: 14px; margin-left: 4px; color: var(--muted); }
.trip { font-size: 14px; color: var(--muted); } .trip b { color: var(--text); font-size: 17px; }
.region { font: 600 13px 'Space Grotesk', sans-serif; color: var(--accent); letter-spacing: .04em; margin-top: 2px; }
.assist { font-size: 12px; color: var(--muted); margin-top: 2px; }
.advise { position: absolute; left: 50%; top: max(18px, calc(env(safe-area-inset-top) + 8px)); transform: translateX(-50%); pointer-events: none; }
.advise span { width: 60px; height: 60px; display: grid; place-content: center; text-align: center; background: #f6c431; color: #1b1b1b; border: 3px solid #1b1b1b;
  border-radius: 8px; transform: rotate(45deg); box-shadow: 0 0 0 2px #f6c431, 0 4px 14px rgba(0, 0, 0, .4); }
.advise b, .advise small { display: block; transform: rotate(-45deg); line-height: 1; }
.advise b { font: 700 20px 'Space Grotesk', sans-serif; }
.advise small { font-size: 9px; font-weight: 700; }
.advise.over span { background: #ff5a3c; box-shadow: 0 0 0 2px #ff5a3c, 0 0 22px rgba(255, 90, 60, .8); animation: pulse .5s ease-in-out infinite alternate; }
.controls .note { color: var(--accent); font-size: 12.5px; }
.game.photo .advise, .game.photo .assist { visibility: hidden; }
.hud-r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.clock { font-size: 13px; color: var(--muted); }
.btns { display: flex; gap: 6px; pointer-events: auto; }
.hb { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: rgba(12, 18, 32, .5); font-size: 15px; font-weight: 700;
  display: grid; place-items: center; padding: 0; backdrop-filter: blur(3px); }
.hb.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #2a1606; border-color: transparent; }

.offroad { position: absolute; left: 50%; bottom: max(110px, calc(env(safe-area-inset-bottom) + 110px)); transform: translateX(-50%); background: rgba(12, 18, 32, .72);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 14px; white-space: nowrap; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-weight: 700; }

/* region banner */
.banner { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; white-space: nowrap;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .55); }
.banner small { display: block; font-size: 12px; letter-spacing: .32em; text-transform: uppercase; color: rgba(255, 255, 255, .85); }
.banner b { display: block; font: 700 clamp(28px, 6vw, 52px) 'Space Grotesk', sans-serif; letter-spacing: .02em; }
.banner.show { animation: banner 5.5s ease-in-out forwards; }
.toast { position: absolute; left: 50%; bottom: max(170px, calc(env(safe-area-inset-bottom) + 170px)); transform: translateX(-50%); background: rgba(12, 18, 32, .8);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 600; pointer-events: none; opacity: 0; transition: opacity .3s; white-space: nowrap; }
.toast.show { opacity: 1; }

/* touch controls */
.touch { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); pointer-events: none; }
.tgroup { display: flex; gap: 12px; pointer-events: auto; }
.tb { width: 74px; height: 74px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25); background: rgba(12, 18, 32, .38); font-size: 26px;
  color: rgba(255, 255, 255, .85); display: grid; place-items: center; padding: 0; backdrop-filter: blur(3px); }
.tb.down { background: rgba(255, 196, 119, .55); color: #2a1606; }
.tb.gas { width: 84px; height: 84px; }

/* ---------- panels ---------- */
.panel { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; z-index: 10; overflow: auto;
  background: radial-gradient(ellipse at center, rgba(10, 14, 26, .05), rgba(10, 14, 26, .5)); }
#pause { background: rgba(10, 14, 26, .45); }
.card { width: min(540px, 100%); max-height: calc(100dvh - 28px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: 22px 22px 16px; box-shadow: 0 30px 70px rgba(0, 0, 0, .45); backdrop-filter: blur(8px); text-align: center; animation: rise .35s ease-out; touch-action: pan-y; }
.kicker { margin: 0; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
#title h1 { font-size: clamp(40px, 9vw, 62px); line-height: 1.02; letter-spacing: .01em; background: linear-gradient(180deg, #ffe7b8, #ff9a62); -webkit-background-clip: text;
  background-clip: text; color: transparent; margin: 4px 0 2px; }
.card h2 { font-size: 30px; margin-bottom: 12px; }
.tagline { margin: 0 0 10px; font: 600 18px 'Space Grotesk', sans-serif; color: var(--accent); }
.lead { color: #d9e0ee; line-height: 1.5; margin: 0 0 14px; font-size: 15px; }
.pick { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.swatches { display: flex; gap: 8px; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); padding: 0; }
.sw.sel { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }
.start-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.controls { display: grid; gap: 6px; text-align: left; background: rgba(0, 0, 0, .22); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.controls div { display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
.controls span { color: #d9e0ee; margin-right: 6px; }
kbd { display: inline-block; min-width: 24px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 3px; background: #26304a;
  font: 600 12px Inter, sans-serif; text-align: center; color: var(--text); }
.touch-only { display: none !important; }
@media (pointer: coarse) { .touch-only { display: flex !important; } }
.btn { border: 1px solid var(--line); background: #26304a; border-radius: 12px; padding: 11px 18px; font-weight: 700; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #2a1606; border: 0; }
.btn.big { font-size: 19px; padding: 14px 30px; }
.best-line { color: var(--muted); font-size: 14px; margin: 10px 0 0; min-height: 1em; }
.links { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.o-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.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 20px 'Space Grotesk', sans-serif; }
.settings { display: grid; gap: 8px; margin: 14px 0; text-align: left; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.settings select { background: #26304a; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-width: 170px; }
.seed { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.ad-wrap { width: 100%; text-align: center; margin-top: 12px; }
.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; }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; }

/* small / short screens */
@media (max-height: 520px) {
  .card { padding: 14px 18px 10px; }
  #title h1 { font-size: 36px; } .lead { display: none; } .tagline { margin-bottom: 8px; }
  .btn.big { padding: 10px 24px; font-size: 17px; } .start-row { margin-bottom: 8px; } .pick { margin-bottom: 8px; }
  .spd b { font-size: 28px; } .tb { width: 60px; height: 60px; } .tb.gas { width: 68px; height: 68px; }
  .banner { top: 12%; }
}
@media (max-width: 520px) { .hb { width: 36px; height: 36px; font-size: 13px; } .btns { gap: 4px; } .settings select { min-width: 140px; } }

@keyframes pulse { to { transform: rotate(45deg) scale(1.1); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 10px); letter-spacing: .1em; } 15% { opacity: 1; transform: translate(-50%, 0); } 75% { opacity: 1; } 100% { opacity: 0; } }
