:root {
  --bg: #2a241e; --panel: rgba(30, 28, 26, 0.88); --panel2: rgba(52, 48, 44, 0.92); --line: rgba(255, 255, 255, 0.14);
  --ink: #f6f3ee; --muted: #c8c0b4; --sky: #8ec5f0; --mint: #3ddc84; --smog: #a89474; --warn: #ff9a3c; --red: #e0533d; --water: #5fd4ff;
  --sat: env(safe-area-inset-top); --sab: env(safe-area-inset-bottom); --sal: env(safe-area-inset-left); --sar: env(safe-area-inset-right);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body.touch { -webkit-user-select: none; user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 12px; }
body.touch .key-only, body:not(.touch) .touch-only { display: none; }
#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--bg); z-index: 50; }
#loading b { font-size: 38px; font-weight: 900; letter-spacing: 3px; } #loading span { color: var(--muted); }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
.aqi { position: absolute; top: max(10px, var(--sat)); left: 50%; transform: translateX(-50%); text-align: center; background: var(--panel); border-radius: 16px; padding: 4px 18px 6px; border: 2px solid var(--c, var(--smog)); min-width: 150px; }
.aqi small { display: block; font-size: 10px; letter-spacing: 3px; color: var(--muted); font-weight: 800; }
.aqi b { display: block; font-size: 40px; line-height: 1; font-weight: 900; color: var(--c, var(--ink)); font-variant-numeric: tabular-nums; transition: color 0.4s; }
.aqi span { display: block; font-size: 12px; font-weight: 800; color: var(--c); text-transform: uppercase; letter-spacing: 1px; }
.aqi em { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); }
.aqi em.ok { color: var(--mint); }
.aqi.alarm { animation: alarm 0.6s infinite; } @keyframes alarm { 50% { box-shadow: 0 0 0 4px rgba(224, 83, 61, 0.6); } }
.clock { position: absolute; top: max(10px, var(--sat)); left: max(12px, var(--sal)); background: var(--panel); border-radius: 12px; padding: 6px 10px; min-width: 170px; }
.clock span { font-size: 12px; color: var(--muted); font-weight: 800; display: block; white-space: nowrap; }
.sunbar { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #ffd27a, #ff9a3c, #b04a6a); margin: 4px 0; overflow: hidden; } .sunbar u { display: block; height: 100%; width: 0; background: rgba(0, 0, 0, 0.55); margin-left: auto; }
.clock b { font-size: 15px; font-variant-numeric: tabular-nums; }
.bars { position: absolute; left: max(12px, var(--sal)); top: calc(max(10px, var(--sat)) + 64px); display: flex; flex-direction: column; gap: 5px; background: var(--panel); border-radius: 12px; padding: 7px 10px; }
.bar { display: flex; align-items: center; gap: 7px; } .bar i { font-style: normal; font-size: 14px; width: 18px; }
.bar span { width: 120px; height: 9px; border-radius: 5px; background: rgba(255, 255, 255, 0.12); overflow: hidden; display: block; } .bar u { display: block; height: 100%; width: 0; background: var(--smog); transition: width 0.15s; }
.bar.water u { background: var(--water); } .bar.boost u { background: #ffd23f; }
.bar.full span { box-shadow: 0 0 0 2px var(--warn); animation: alarm 0.8s infinite; }
.cred { font-weight: 900; font-size: 14px; } .cred i { font-style: normal; margin-right: 4px; }
#radar { position: absolute; right: max(12px, var(--sar)); top: max(10px, var(--sat)); width: 150px; height: 150px; border-radius: 50%; background: rgba(20, 18, 16, 0.6); border: 2px solid var(--line); }
.pause { position: absolute; right: calc(max(12px, var(--sar)) + 158px); top: max(10px, var(--sat)); width: 40px; height: 40px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); pointer-events: auto; }
.marker { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); text-align: center; font-weight: 900; font-size: 12px; text-shadow: 0 1px 3px #000; }
.marker i { display: block; width: 0; height: 0; margin: 0 auto 2px; border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 14px solid var(--mc, var(--water)); filter: drop-shadow(0 1px 2px #000); }
.prompt { position: absolute; left: 50%; bottom: calc(max(14px, var(--sab)) + 10px); transform: translateX(-50%); background: var(--panel); border-radius: 12px; padding: 6px 14px; font-weight: 800; font-size: 14px; border: 1px solid var(--line); white-space: nowrap; }
.coach { position: absolute; left: 50%; top: calc(max(10px, var(--sat)) + 96px); transform: translateX(-50%); max-width: min(460px, 70vw); background: rgba(246, 243, 238, 0.95); color: #2a241e; border-radius: 12px; padding: 9px 14px; font-weight: 800; font-size: 14.5px; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.tpad { display: none; }
body.touch.flying .tpad { display: block; }
.stick { position: absolute; left: calc(max(14px, var(--sal)) + 8px); bottom: calc(max(14px, var(--sab)) + 6px); width: 124px; height: 124px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.3); pointer-events: auto; touch-action: none; }
.stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); border: 2px solid rgba(255, 255, 255, 0.6); }
.lift { position: absolute; left: calc(max(14px, var(--sal)) + 146px); bottom: calc(max(14px, var(--sab)) + 6px); width: 46px; height: 124px; border-radius: 23px; background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.3); pointer-events: auto; touch-action: none; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 12px; color: rgba(255, 255, 255, 0.6); }
.lift i { position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); }
.tb { position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.5); font-weight: 900; font-size: 13px; letter-spacing: 1px; color: #fff; }
.tb.suck { right: calc(max(14px, var(--sar)) + 10px); bottom: calc(max(14px, var(--sab)) + 14px); width: 92px; height: 92px; background: rgba(168, 148, 116, 0.55); }
.tb.spray { right: calc(max(14px, var(--sar)) + 112px); bottom: calc(max(14px, var(--sab)) + 6px); width: 72px; height: 72px; background: rgba(95, 212, 255, 0.4); }
.tb.boost { right: calc(max(14px, var(--sar)) + 70px); bottom: calc(max(14px, var(--sab)) + 112px); width: 56px; height: 56px; background: rgba(255, 210, 63, 0.4); font-size: 20px; }
.tb.on { filter: brightness(1.5); transform: scale(1.06); }
body.touch .prompt { bottom: calc(max(14px, var(--sab)) + 136px); }
#rotate { display: none; position: fixed; inset: 0; z-index: 40; background: var(--bg); flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 24px; }
#rotate b { font-size: 54px; } #rotate p { font-size: 17px; max-width: 280px; }
@media (orientation: portrait) and (pointer: coarse) { body.flying #rotate { display: flex; } }

/* ------------------------------------------------------------ screens */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.screen { position: absolute; inset: 0; display: none; pointer-events: auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: max(16px, var(--sat)) max(16px, var(--sar)) max(16px, var(--sab)) max(16px, var(--sal)); background: rgba(30, 26, 22, 0.5); }
.screen.active { display: flex; } .screen > * { margin: auto; }
#title.screen { background: linear-gradient(90deg, rgba(30, 26, 22, 0.88) 0%, rgba(30, 26, 22, 0.55) 46%, rgba(30, 26, 22, 0) 100%); gap: 24px; align-items: center; }
.t-main { max-width: 500px; width: 100%; margin: auto auto auto clamp(0px, 5vw, 80px); }
.kicker { color: var(--warn); letter-spacing: 1.5px; text-transform: uppercase; font-size: 12.5px; font-weight: 800; margin: 0; }
.logo { margin: 6px 0 10px; font-size: clamp(56px, 9vw, 104px); line-height: 0.9; font-weight: 900; letter-spacing: 2px; color: #f6f3ee; text-shadow: 0 6px 30px rgba(0, 0, 0, 0.45); }
.logo span { color: var(--red); text-shadow: 0 0 30px rgba(224, 83, 61, 0.5); }
.lead { color: #efe8de; font-size: 15.5px; line-height: 1.5; margin: 0 0 16px; }
.challenge:empty { display: none; } .challenge { background: rgba(255, 154, 60, 0.14); border: 1px solid rgba(255, 154, 60, 0.5); padding: 8px 12px; border-radius: 10px; margin-bottom: 12px; }
.menu { display: flex; flex-direction: column; gap: 8px; } .menu .row { display: flex; gap: 8px; } .menu .row button { flex: 1; }
.menu button, .buttons button { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-size: 17px; font-weight: 800; text-align: left; }
.menu button:hover, .buttons button:hover { border-color: var(--sky); }
button.primary { background: linear-gradient(90deg, #8ec5f0, #3ddc84) !important; color: #10221a !important; border-color: transparent !important; }
button.ghost { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; color: var(--muted); }
.disclaimer { color: var(--muted); font-size: 12px; margin-top: 14px; line-height: 1.45; } .disclaimer a { color: var(--muted); }
.t-side { width: 320px; max-width: 100%; margin: auto clamp(0px, 4vw, 60px) auto auto; display: flex; flex-direction: column; gap: 10px; } .t-side > div:empty { display: none; }
.aq-board { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px 20px; width: 100%; max-width: 760px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.sheet.wide { max-width: 980px; } .sheet.narrow { max-width: 420px; }
.sheet header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; } .sheet header h2 { flex: 1; }
.sheet h2 { margin: 0; font-size: 26px; font-weight: 900; } .sheet h4 { margin: 14px 0 8px; font-size: 12.5px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--warn); }
.wallet { font-weight: 900; font-size: 18px; }
.daylist { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.dayc { text-align: left; border-radius: 12px; padding: 10px; border: 1px solid var(--line); background: linear-gradient(170deg, rgba(168, 148, 116, 0.25), rgba(0, 0, 0, 0.2)); min-height: 120px; display: flex; flex-direction: column; gap: 3px; }
.dayc small { color: var(--warn); font-weight: 900; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; } .dayc b { font-size: 15px; line-height: 1.2; } .dayc span { font-size: 12px; color: var(--muted); }
.dayc .st { margin-top: auto; color: #ffd23f; letter-spacing: 2px; } .dayc:disabled { opacity: 0.45; }
.dayc.endless { background: linear-gradient(170deg, rgba(224, 83, 61, 0.3), rgba(0, 0, 0, 0.2)); }
.ups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.up { text-align: left; display: grid; grid-template-columns: 30px 1fr auto; column-gap: 8px; align-items: center; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.up i { font-style: normal; font-size: 22px; grid-row: span 2; } .up b { font-size: 14px; } .up b em { font-style: normal; color: var(--mint); font-size: 11px; letter-spacing: 2px; } .up small { grid-column: 2; color: var(--muted); font-size: 11.5px; } .up span { grid-row: 1; grid-column: 3; font-weight: 900; color: #ffd23f; }
.up:disabled { opacity: 0.5; }
.target { background: rgba(255, 255, 255, 0.06); border-radius: 12px; padding: 10px 12px; font-size: 15px; margin-top: 6px; line-height: 1.5; } .target b { color: var(--mint); }
.big { width: 100%; margin-top: 14px; padding: 14px !important; font-size: 19px !important; text-align: center !important; border-radius: 12px; font-weight: 900; border: 0; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); } .srow input[type=range] { flex: 1; max-width: 170px; accent-color: var(--sky); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; } .chip { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; font-weight: 800; font-size: 13.5px; } .chip.on { background: var(--sky); color: #10221a; border-color: var(--sky); }
.help { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; } .help p { font-size: 14px; line-height: 1.5; color: #efe8de; margin: 0 0 10px; }
.res-top { display: flex; align-items: center; gap: 18px; } .res-aqi { text-align: center; min-width: 120px; } .res-aqi small { color: var(--muted); font-size: 11px; letter-spacing: 2px; } .res-aqi b { display: block; font-size: 54px; font-weight: 900; line-height: 1; }
.rh { margin: 0 0 4px; font-size: 30px; font-weight: 900; } .stars { color: #ffd23f; font-size: 26px; letter-spacing: 4px; }
.near { color: #ffd23f; font-size: 14px; margin: 4px 0 0; }
.kv { list-style: none; padding: 0; margin: 12px 0 0; font-size: 14px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; }
.kv li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 4px 0; color: var(--muted); } .kv li b { color: var(--ink); }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; position: sticky; bottom: -20px; background: var(--panel); padding: 6px 0; } .buttons button { flex: 1 1 140px; text-align: center; }
.e-board:empty { display: none; } .e-board { margin: 12px 0 0; }

@media (max-width: 900px) { .daylist { grid-template-columns: repeat(4, 1fr); } .ups { grid-template-columns: repeat(2, 1fr); } }
@media (max-height: 460px) {
  .aqi { padding: 2px 12px 4px; min-width: 120px; } .aqi b { font-size: 28px; } .aqi em { font-size: 10.5px; }
  .clock { min-width: 130px; padding: 4px 8px; } .clock span { font-size: 11px; } .clock b { font-size: 13px; }
  .bars { top: calc(max(8px, var(--sat)) + 50px); padding: 5px 8px; gap: 3px; } .bar span { width: 80px; height: 7px; }
  #radar { width: 96px; height: 96px; } .pause { right: calc(max(10px, var(--sar)) + 104px); width: 34px; height: 34px; }
  .stick { width: 100px; height: 100px; } .stick i { width: 42px; height: 42px; margin: -21px 0 0 -21px; } .lift { height: 100px; left: calc(max(14px, var(--sal)) + 120px); }
  .tb.suck { width: 76px; height: 76px; } .tb.spray { width: 60px; height: 60px; right: calc(max(14px, var(--sar)) + 94px); } .tb.boost { width: 48px; height: 48px; bottom: calc(max(14px, var(--sab)) + 96px); right: calc(max(14px, var(--sar)) + 56px); }
  body.touch .prompt { bottom: calc(max(10px, var(--sab)) + 112px); font-size: 12.5px; } .coach { top: calc(max(8px, var(--sat)) + 84px); font-size: 12.5px; padding: 6px 10px; max-width: 46vw; }
  #title.screen { gap: 14px; } .logo { font-size: 52px; } .lead { font-size: 13px; margin-bottom: 10px; line-height: 1.4; } .menu button { padding: 8px 14px; font-size: 15px; } .menu { gap: 6px; } .disclaimer { margin-top: 8px; font-size: 11px; }
  .t-side { width: 260px; } .t-side .aq-board { max-height: 62vh; overflow: auto; }
  .sheet { padding: 12px 14px; } .sheet h2 { font-size: 21px; } .daylist { grid-template-columns: repeat(7, 1fr); gap: 5px; } .dayc { min-height: 84px; padding: 6px; } .dayc b { font-size: 12.5px; } .dayc span { display: none; } .ups { grid-template-columns: repeat(3, 1fr); gap: 5px; } .up { padding: 5px 7px; } .up small { display: none; }
  .help p { font-size: 12.5px; } .rh { font-size: 21px; } .res-aqi b { font-size: 36px; } .kv { font-size: 12.5px; margin-top: 6px; }
}
@media (max-width: 760px) { .help { grid-template-columns: 1fr; } }
@media (orientation: landscape) and (max-height: 460px) { .help { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) and (orientation: portrait) {
  #title.screen { flex-direction: column; align-items: stretch; background: linear-gradient(180deg, rgba(30, 26, 22, 0.2), rgba(30, 26, 22, 0.9) 38%); }
  .t-main { margin: 30vh 0 0; } .t-side { width: 100%; margin: 0; } .daylist { grid-template-columns: repeat(2, 1fr); } .ups { grid-template-columns: 1fr; }
}
