:root {
  color-scheme: dark;
  --ink: #172b32;
  --cream: #fff5df;
  --mint: #b6d5c7;
  --gold: #f2bd67;
  --coral: #f17f70;
  --panel: rgba(19, 40, 47, .88);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #172c34; font-family: Nunito, system-ui, sans-serif; overscroll-behavior: none; }
button { font: inherit; }
#game { position: relative; width: 100%; height: 100%; height: 100dvh; overflow: hidden; isolation: isolate; touch-action: none; background: #9ebbb1; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; z-index: 2; inset: max(15px, env(safe-area-inset-top)) 20px auto; height: 52px; display: flex; align-items: center; color: var(--cream); pointer-events: none; }
.brand { display: flex; align-items: center; gap: 9px; width: 170px; font-size: 10px; line-height: 1; letter-spacing: .13em; opacity: .9; }
.brand b { font-size: 13px; letter-spacing: .18em; }
.brand-mark { width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid rgba(255,245,223,.44); border-radius: 50%; color: var(--gold); font-size: 19px; }
.readouts { display: flex; gap: 24px; margin-left: auto; margin-right: 20px; }
.scorebox { min-width: 60px; display: flex; flex-direction: column; gap: 1px; }
.scorebox small, .stamina-caption, .route-status, .weather b, .weather small, .helper, .stick-label, .card-eyebrow, .tiny-note, .run-score>span, .run-score small { font-family: 'DM Mono', monospace; }
.scorebox small { font-size: 8px; letter-spacing: .12em; color: #d2e0d6; }
.scorebox strong { font-size: 22px; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.scorebox i { font-size: 10px; font-style: normal; color: #d2e0d6; margin-left: 3px; }
.icon-button { pointer-events: auto; border: 1px solid rgba(255,245,223,.38); border-radius: 50%; width: 37px; height: 37px; color: var(--cream); background: rgba(19,40,47,.34); cursor: pointer; font-size: 21px; line-height: 1; }
.icon-button.muted { color: #f4a090; }
.vitals { z-index: 2; position: absolute; top: max(82px, calc(env(safe-area-inset-top) + 76px)); left: 20px; width: min(255px, 54vw); pointer-events: none; }
.stamina-caption { display: flex; justify-content: space-between; color: #f5f0df; font-size: 9px; letter-spacing: .12em; text-shadow: 0 1px 2px #253c3b; margin-bottom: 5px; }
.stamina-track { position: relative; height: 10px; border: 1px solid rgba(255,255,255,.45); border-radius: 10px; background: rgba(18,39,44,.5); overflow: hidden; box-shadow: 0 2px 6px #354b47aa; }
.stamina-fill { height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg,#f3bc63,#ffe5a1); transition: width .14s linear, background .25s; }
.stamina-fill.low { background: linear-gradient(90deg,#ea736b,#ffb185); }
.stamina-shine { position: absolute; left: 3px; right: 3px; top: 1px; height: 2px; border-radius: 3px; background: #fff9de99; pointer-events: none; }
.route-status { margin-top: 8px; min-height: 19px; color: #fff7e5; font-size: 9px; letter-spacing: .025em; display: flex; gap: 7px; align-items: center; text-shadow: 0 1px 3px #253c3b; }
.route-dot { width: 7px; height: 7px; border: 1px solid #ffe1a2; background: #e9b860; border-radius: 50%; box-shadow: 0 0 8px #f2bd6780; flex: 0 0 auto; }
.route-status.safe .route-dot { background: #a9e0c1; border-color: #d2ffe2; box-shadow: 0 0 9px #a9e0c1; }
.weather { position: absolute; z-index: 2; top: max(82px, calc(env(safe-area-inset-top) + 76px)); right: 20px; display: flex; align-items: center; gap: 9px; color: var(--cream); opacity: .88; text-shadow: 0 1px 3px #233a3b; text-align: right; }
.weather-icon { color: #ffdc9d; font-size: 25px; line-height: 1; }
.weather b, .weather small { display: block; }
.weather b { font-size: 9px; letter-spacing: .09em; }
.weather small { margin-top: 2px; font-size: 8px; color: #e0e9df; }
.weather.warning { color: #ffe5a9; animation: weatherPulse .8s infinite alternate; }
.weather.active .weather-icon { color: #aee6eb; }
@keyframes weatherPulse { to { transform: scale(1.05); opacity: 1; } }
.helper { position: absolute; z-index: 2; left: 22px; bottom: max(24px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 5px; color: #fff3da; font-size: 9px; text-shadow: 0 1px 3px #253d3c; pointer-events: none; }
kbd { font: 10px 'DM Mono', monospace; letter-spacing: .2em; }
.stick-wrap { position: absolute; z-index: 4; right: max(22px, env(safe-area-inset-right)); bottom: max(17px, env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 5px; touch-action: none; user-select: none; }
.stick-label { color: #fff4db; font-size: 8px; letter-spacing: .2em; text-shadow: 0 1px 4px #233c3e; pointer-events: none; }
.stick { width: clamp(112px, 16vw, 146px); height: clamp(112px, 16vw, 146px); position: relative; display: grid; place-items: center; border-radius: 50%; touch-action: none; cursor: grab; outline: none; background: radial-gradient(circle,rgba(244,221,177,.22),rgba(23,45,49,.14) 64%,rgba(17,35,41,.24)); border: 1px solid rgba(255,245,221,.38); box-shadow: inset 0 2px 10px #1d353633, 0 3px 12px #203b3d30; }
.stick:active { cursor: grabbing; }
.stick-ring { position: absolute; inset: 12%; border: 1px solid rgba(255,245,221,.18); border-radius: 50%; }
.direction { position: absolute; color: rgba(255,245,221,.54); font-size: 15px; line-height: 1; }
.direction.n { top: -5px; left: calc(50% - 4px); } .direction.s { bottom: -5px; left: calc(50% - 4px); }
.direction.e { right: -4px; top: calc(50% - 7px); } .direction.w { left: -4px; top: calc(50% - 7px); }
.stick-knob { position: absolute; width: 42%; height: 42%; display: grid; place-items: center; border-radius: 50%; border: 1px solid #fff6e4aa; color: #ffedc5; font-size: 20px; background: radial-gradient(circle at 35% 28%,#f3cb81,#a17e4f 83%); box-shadow: 0 4px 12px #1b303855,inset 0 1px 2px #fff7dc; transition: transform .07s linear; pointer-events: none; }
.toast { position: absolute; z-index: 5; top: 24%; left: 50%; transform: translate(-50%,-8px); color: #fff6df; font-size: 13px; font-weight: 900; letter-spacing: .08em; text-shadow: 0 2px 6px #243c3d; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.screen-card { position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%,-47%); width: min(395px, calc(100vw - 36px)); max-height: calc(100dvh - 190px); overflow-y: auto; padding: 27px 30px 22px; border-radius: 19px; color: var(--cream); background: linear-gradient(145deg,rgba(25,51,57,.96),rgba(19,39,46,.94)); border: 1px solid rgba(245,224,183,.32); box-shadow: 0 22px 80px #162e36aa, inset 0 1px 0 #fff1d21c; text-align: center; }
.screen-card::before { content: ''; position: absolute; z-index: -1; inset: 6px; border: 1px solid #f4dfb11a; border-radius: 13px; pointer-events: none; }
.screen-card.hidden, .hidden { display: none !important; }
.card-eyebrow { color: #e7bc78; font-size: 8px; letter-spacing: .17em; }
.screen-card h1 { margin: 9px 0 8px; font-size: clamp(36px, 7vh, 53px); line-height: .9; letter-spacing: -.045em; font-weight: 900; }
.screen-card h1 em { color: #f2bd67; font-style: normal; }
.screen-card>p { max-width: 300px; margin: 13px auto 16px; color: #d1dfd5; font-size: 13px; line-height: 1.45; }
.howto { text-align: left; display: grid; gap: 11px; margin: 17px 0 20px; }
.howto>div { display: flex; align-items: center; gap: 11px; }
.how-icon { flex: 0 0 auto; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; font-size: 16px; }
.crawl-icon { background: #71938b4d; color: #c3e0ce; } .fly-icon { background: #ba89514a; color: #f5c969; } .hole-icon { background: #617f8a50; color: #b3dde1; }
.howto b { display: block; font: 9px 'DM Mono', monospace; letter-spacing: .1em; }
.howto small { display: block; margin-top: 3px; color: #b9cbc3; font-size: 10px; line-height: 1.2; }
.primary-button { min-height: 45px; width: 100%; border: 0; border-radius: 8px; cursor: pointer; color: #203a3d; background: linear-gradient(105deg,#f6cb7a,#f5b96d); box-shadow: 0 4px 0 #ad7e4c, 0 8px 16px #101e2466; font: 500 11px 'DM Mono', monospace; letter-spacing: .12em; }
.primary-button span { margin-left: 8px; font-size: 16px; vertical-align: -1px; }
.primary-button:active { transform: translateY(2px); box-shadow: 0 2px 0 #ad7e4c, 0 5px 12px #101e2466; }
.tiny-note { margin-top: 13px; color: #9eb3ad; font-size: 8px; }
#endScreen { padding-top: 31px; }
#endScreen h2 { margin: 11px 0 2px; font-size: 39px; letter-spacing: .03em; }
.run-score { margin: 18px auto 21px; padding: 12px; display: grid; justify-items: center; gap: 3px; max-width: 165px; border-radius: 11px; background: #ffffff0b; }
.run-score>span { color: #a8beb5; font-size: 8px; letter-spacing: .15em; }
.run-score strong { font-size: 37px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.run-score i { font-size: 13px; font-style: normal; color: #b5c6bc; margin-left: 3px; }
.run-score small { color: #f2c76e; font-size: 8px; letter-spacing: .05em; }
.milestone { position: absolute; z-index: 3; top: 26%; left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 2px; color: #fff3cd; text-shadow: 0 2px 8px #334842; pointer-events: none; animation: milestone 1.8s ease both; }
.milestone>span { font-size: 22px; color: #ffd172; }
.milestone b { font-size: 18px; letter-spacing: .12em; }
.milestone small { font: 8px 'DM Mono', monospace; letter-spacing: .1em; }
@keyframes milestone { 0% { opacity: 0; transform: translate(-50%,10px) scale(.9); } 15%,70% { opacity: 1; transform: translate(-50%,0) scale(1); } 100% { opacity: 0; transform: translate(-50%,-8px) scale(1.06); } }
.rain-flash { position: absolute; inset: 0; z-index: 1; background: #d0f1ff22; opacity: 0; pointer-events: none; }
.rain-flash.active { animation: rainFlash .36s infinite alternate; }
@keyframes rainFlash { to { opacity: .25; } }

@media (max-width: 600px) {
  .hud { inset-inline: 13px; top: max(12px, env(safe-area-inset-top)); height: 43px; }
  .brand { gap: 6px; width: 111px; font-size: 8px; }
  .brand-mark { width: 26px; height: 26px; font-size: 16px; }
  .brand b { font-size: 10px; }
  .readouts { gap: 12px; margin-right: 10px; }
  .scorebox { min-width: 43px; }
  .scorebox small { font-size: 7px; }
  .scorebox strong { font-size: 18px; }
  .icon-button { width: 34px; height: 34px; }
  .vitals { top: max(68px, calc(env(safe-area-inset-top) + 64px)); left: 14px; width: min(205px, 53vw); }
  .weather { top: max(69px, calc(env(safe-area-inset-top) + 65px)); right: 13px; gap: 5px; }
  .weather-icon { font-size: 21px; }
  .weather b { font-size: 8px; } .weather small { font-size: 7px; }
  .helper { left: 14px; bottom: max(26px, env(safe-area-inset-bottom)); max-width: 140px; font-size: 8px; }
  .stick-wrap { right: max(13px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
  .stick { width: clamp(116px, 34vw, 143px); height: clamp(116px, 34vw, 143px); }
  .stick-label { font-size: 8px; }
  .screen-card { padding: 23px 23px 19px; max-height: calc(100dvh - 172px); }
  .screen-card h1 { font-size: clamp(34px, 6.2vh, 46px); }
  .screen-card>p { font-size: 12px; margin: 11px auto 13px; }
  .howto { gap: 8px; margin: 13px 0 17px; }
  .how-icon { width: 27px; height: 27px; }
  .howto small { font-size: 9px; }
  .primary-button { min-height: 43px; }
  .tiny-note { font-size: 7px; }
  .toast { top: 20%; }
}
@media (max-height: 650px) and (min-width: 601px) {
  .screen-card { padding: 19px 25px 16px; }
  .screen-card h1 { font-size: 37px; }
  .howto { gap: 7px; margin: 12px 0 15px; }
  .screen-card>p { margin: 9px auto 12px; }
}
