/* California E-Bike Rush — bike-computer UI */
:root {
  --teal: #19b3a6;
  --teal-dark: #0e7c73;
  --poppy: #ff8c42;
  --gold: #ffb020;
  --redwood: #2e5d4b;
  --fog: #cfd8dc;
  --ink: #17242b;
  --paper: #fdf6e9;
  --panel: rgba(16, 32, 38, 0.92);
  --panel-edge: #35545c;
  --danger: #ff5252;
  --ok: #7ddb8a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: #0b1418; color: var(--paper); font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif; overflow: hidden; }
body.contrast { --panel: rgba(0,0,0,0.97); --panel-edge: #ffffff; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#game-wrap { position: relative; line-height: 0; box-shadow: 0 10px 60px rgba(0,0,0,.6); border-radius: 12px; overflow: hidden; max-width: 100vw; max-height: calc(100vh - 64px); }
#game { display: block; width: min(96vw, calc((100vh - 72px) * 1.6)); aspect-ratio: 960/600; background: #9adcf0; border-radius: 12px; touch-action: none; }

.hidden { display: none !important; }

/* ---------- Screens ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 40; text-align: center; padding: 18px; line-height: 1.4; }
#screen-boot { background: linear-gradient(180deg, #0b2a30, #123f3a); z-index: 90; }
.boot-logo { font-size: clamp(28px, 6vw, 54px); font-weight: 900; letter-spacing: 2px; color: var(--gold); animation: pulse 1.2s ease-in-out infinite alternate; }
.boot-logo span { color: var(--teal); }
.boot-hint { opacity: .6; margin-top: 8px; font-size: 13px; }
@keyframes pulse { from { opacity: .55; transform: scale(.985);} to { opacity: 1; transform: scale(1);} }

#screen-title { background: linear-gradient(180deg, rgba(11,26,32,.25), rgba(11,26,32,.78)); justify-content: flex-end; padding-bottom: 34px; gap: 10px; }
.title-art { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.title-art .sun { position: absolute; left: 50%; top: 16%; width: 120px; height: 120px; margin-left: -60px; border-radius: 50%; background: radial-gradient(circle at 50% 50%, #ffe27a, #ff9e42 70%, transparent 71%); filter: blur(1px); animation: sunbob 6s ease-in-out infinite alternate; }
@keyframes sunbob { from { transform: translateY(0);} to { transform: translateY(-12px);} }
.title-art .ridge { position: absolute; left: -10%; right: -10%; height: 180px; bottom: -40px; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.title-art .r1 { background: #14524a; bottom: 46px; opacity: .9; }
.title-art .r2 { background: #0d3b36; bottom: 0; }
.title-art .palms i { position: absolute; bottom: 130px; width: 10px; height: 90px; background: linear-gradient(#5a4632, #3d2f22); border-radius: 6px; }
.title-art .palms i::before { content: ""; position: absolute; top: -26px; left: -22px; width: 54px; height: 34px; background: radial-gradient(ellipse at 50% 100%, #2e8f5b 55%, transparent 56%); border-radius: 50%; }
.title-art .palms i::after { content: ""; position: absolute; top: -26px; left: -32px; width: 54px; height: 34px; background: radial-gradient(ellipse at 50% 100%, #37a76a 55%, transparent 56%); border-radius: 50%; transform: scaleX(-1); }
.title-art .palms i:nth-child(1) { left: 8%; } .title-art .palms i:nth-child(2) { left: 84%; height: 110px; } .title-art .palms i:nth-child(3) { left: 15%; height: 70px; opacity:.85; }
.logo { position: relative; font-size: clamp(34px, 7vw, 68px); font-weight: 900; letter-spacing: 3px; color: var(--paper); text-shadow: 0 4px 0 #0d3b36, 0 10px 30px rgba(0,0,0,.5); margin: 4vh 0 0; }
.logo span { color: var(--gold); }
.tagline { position: relative; color: #ffe9c4; font-style: italic; min-height: 22px; }
.menu-stack { display: flex; flex-direction: column; gap: 10px; z-index: 2; width: min(340px, 86vw); }
.best-chip { align-self: center; background: var(--panel); border: 2px solid var(--panel-edge); border-radius: 999px; padding: 6px 16px; font-weight: bold; color: var(--gold); letter-spacing: 1px; }
.foot-note { position: relative; z-index: 2; font-size: 11px; opacity: .65; }

.big-btn { display: block; width: 100%; padding: 13px 18px; font-size: 17px; font-weight: 800; letter-spacing: 1px; color: var(--paper); background: linear-gradient(180deg, #23545c, #16393f); border: 3px solid var(--teal); border-radius: 14px; cursor: pointer; transition: transform .06s ease, filter .12s; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.big-btn:hover { filter: brightness(1.15); }
.big-btn:active { transform: translateY(2px) scale(.99); }
.big-btn.primary { background: linear-gradient(180deg, #ffab5e, #ff7f33); border-color: #ffd9a8; color: #3a1c05; text-shadow: none; }
.link-btn { background: none; border: none; color: #9fd8cf; cursor: pointer; font-size: 13px; text-decoration: underline; margin-top: 6px; }
.back-btn { width: auto; align-self: center; padding: 10px 34px; }

.screen-title { font-size: 30px; letter-spacing: 2px; color: var(--gold); margin: 0; text-shadow: 0 3px 0 rgba(0,0,0,.5); }
.screen:not(#screen-boot)::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(10,20,24,.55), rgba(10,20,24,.88)); z-index: -1; }

.howto-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; max-width: 720px; width: 94%; max-height: 52vh; overflow-y: auto; }
.howto-card { background: var(--panel); border: 2px solid var(--panel-edge); border-radius: 10px; padding: 8px 10px; text-align: left; }
.howto-card b { color: var(--gold); display: block; font-size: 14px; }
.howto-card span { font-size: 12.5px; opacity: .92; }
.safety-strip { background: var(--poppy); color: #331500; font-weight: 800; padding: 8px 16px; border-radius: 999px; font-size: 13.5px; }

.intro-card { max-width: 560px; background: var(--panel); border: 3px solid var(--panel-edge); border-radius: 16px; padding: 26px; font-size: 17px; }
.intro-card p { white-space: pre-line; }

.stage-card { max-width: 600px; width: 94%; background: var(--panel); border: 3px solid var(--gold); border-radius: 18px; padding: 22px; }
.stage-kicker { color: var(--teal); font-weight: 900; letter-spacing: 3px; font-size: 13px; }
.stage-card h2 { margin: 6px 0 10px; font-size: 24px; color: var(--paper); }
.si-rule { background: rgba(255,176,32,.14); border: 2px dashed var(--gold); border-radius: 10px; padding: 8px 12px; font-size: 14px; color: #ffe9c4; margin-bottom: 10px; }
.si-list { list-style: none; margin: 0 0 12px; padding: 0; font-size: 14px; text-align: left; }
.si-list li { padding: 3px 0 3px 22px; position: relative; }
.si-list li::before { content: "★"; position: absolute; left: 2px; color: var(--poppy); }
.bike-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 12px; }
.bike-opt { border: 2px solid var(--panel-edge); background: #10262c; color: var(--paper); border-radius: 10px; padding: 6px 10px; cursor: pointer; font-size: 13px; font-weight: 700; }
.bike-opt.sel { border-color: var(--gold); background: #3a2c10; color: var(--gold); }
.bike-opt.locked { opacity: .38; cursor: not-allowed; }

.dlg-box { display: flex; gap: 14px; align-items: stretch; max-width: 640px; width: 94%; background: var(--panel); border: 3px solid var(--panel-edge); border-radius: 16px; padding: 14px; text-align: left; cursor: pointer; }
#dlg-portrait { border-radius: 12px; background: #0d2228; border: 2px solid var(--panel-edge); flex: 0 0 auto; }
.dlg-name { color: var(--gold); font-weight: 900; letter-spacing: 1px; margin-bottom: 4px; }
.dlg-text { font-size: 15.5px; min-height: 60px; }
.dlg-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.dlg-choices button { text-align: left; }
.dlg-hint { font-size: 11px; opacity: .55; margin-top: 6px; }

.inter-card, .clear-card, .go-card, .pause-card, .settings-card, .win-card, .hurt-card, .quiz-card, .sparky-card { max-width: 580px; width: 94%; background: var(--panel); border: 3px solid var(--panel-edge); border-radius: 18px; padding: 22px; }
.inter-head { font-weight: 900; letter-spacing: 2px; color: #9fb8bd; font-size: 13px; margin-bottom: 10px; }
.ad-badge { background: var(--gold); color: #3a2500; border-radius: 6px; padding: 1px 8px; font-size: 11px; vertical-align: middle; }
.inter-creative { border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.inter-note { font-size: 11.5px; opacity: .6; margin-top: 10px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; text-align: left; font-size: 14px; margin: 10px 0; }
.stats-grid b { color: var(--gold); float: right; }
.rank-line { font-size: 20px; font-weight: 900; color: var(--poppy); margin: 6px 0 12px; letter-spacing: 1px; }

.hurt-card h2 { color: var(--danger); }
.hurt-card { border-color: var(--danger); }
.win-card .cone { font-size: 44px; }

.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 4px; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.08); }
.set-row input[type=range] { width: 160px; accent-color: var(--teal); }
.set-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--teal); }

.credits-roll { position: absolute; inset: 0; overflow: hidden; }
.credits-inner { position: absolute; width: 100%; text-align: center; will-change: transform; }
.credits-inner h3 { color: var(--gold); letter-spacing: 3px; margin: 26px 0 6px; font-size: 15px; }
.credits-inner div { opacity: .95; font-size: 15px; padding: 2px; }
#btn-credits-skip { position: absolute; bottom: 20px; right: 20px; width: auto; z-index: 2; }

.reality-card { max-width: 680px; max-height: 88%; overflow-y: auto; text-align: left; }
.reality-card h2 { color: var(--poppy); text-align: center; }
.rc-lede { font-style: italic; }
.rc-list li { margin: 10px 0; font-size: 14px; }
.rc-list a { color: #7fe0d4; }
.rc-fine { font-size: 11.5px; opacity: .6; }
.reality-card .big-btn { width: auto; align-self: center; }

.quiz-q { font-size: 17px; margin: 10px 0 14px; }
.quiz-opts { display: flex; flex-direction: column; gap: 8px; }
.quiz-feedback { min-height: 44px; margin-top: 12px; font-weight: 700; color: var(--gold); }
.quiz-kicker { color: var(--teal); font-weight: 900; letter-spacing: 2px; font-size: 12px; }
.sparky-steps { text-align: left; font-size: 14px; min-height: 90px; }
.sparky-steps li.done { color: var(--ok); }
.sparky-pad { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }

/* ---------- HUD-ish DOM layers ---------- */
#toast-layer { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 30; pointer-events: none; width: 80%; }
.toast { background: var(--panel); border: 2px solid var(--panel-edge); color: var(--paper); padding: 6px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 700; animation: toastIn .18s ease-out; max-width: 100%; }
.toast.good { border-color: var(--ok); color: #d9ffe0; }
.toast.bad { border-color: var(--danger); color: #ffd9d9; }
.toast.gold { border-color: var(--gold); color: #ffedbf; }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0;} to { transform: none; opacity: 1;} }

#tutorial-layer { position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 30; pointer-events: none; }
.tut-bubble { background: rgba(255,236,190,.97); color: #33230a; border: 3px solid #b97b1e; padding: 8px 16px; border-radius: 12px; font-size: 14px; font-weight: 800; box-shadow: 0 6px 18px rgba(0,0,0,.35); animation: toastIn .2s ease-out; max-width: 480px; text-align: center; }

#boss-banner { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); z-index: 29; text-align: center; pointer-events: none; }
#boss-name { display: block; font-size: 26px; font-weight: 900; color: var(--danger); text-shadow: 0 3px 0 #300, 0 0 24px rgba(255,80,80,.6); letter-spacing: 2px; animation: bossIn .5s cubic-bezier(.2,1.6,.4,1); }
#boss-sub { font-size: 12px; color: #ffcaca; letter-spacing: 1px; }
@keyframes bossIn { from { transform: scale(3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Touch controls ---------- */
#touch-ui { position: absolute; inset: 0; z-index: 35; }
#stick-zone { position: absolute; left: 0; bottom: 0; width: 46%; height: 62%; touch-action: none; }
#stick-base { position: absolute; width: 108px; height: 108px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); background: rgba(0,0,0,.25); left: 40px; bottom: 36px; opacity: .75; }
#stick-nub { position: absolute; width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.55); left: 30px; top: 30px; }
#pad-buttons { position: absolute; right: 8px; bottom: 8px; display: grid; grid-template-columns: repeat(2, 84px); gap: 8px; }
.tbtn { height: 52px; border-radius: 12px; border: 2px solid rgba(255,255,255,.4); background: rgba(10,30,36,.6); color: #fff; font-weight: 900; font-size: 12.5px; letter-spacing: 1px; touch-action: none; user-select: none; }
.tbtn:active { background: rgba(25,179,166,.75); }
.tb-pedal { grid-column: span 2; height: 58px !important; background: rgba(255,140,66,.55); }
.tb-brake { background: rgba(255,82,82,.45); }

/* ---------- Ads ---------- */
.ad-slot { width: min(96vw, 920px); min-height: 60px; margin: 4px 0 0; background: repeating-linear-gradient(45deg, #101f24, #101f24 12px, #14262c 12px, #14262c 24px); border: 2px dashed #3d5c63; border-radius: 10px; overflow: hidden; position: relative; }
.ad-slot[hidden] { display: none; }
.house-ad { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; color: #fff; cursor: default; }
.house-ad .ha-mark { font-size: 24px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.5)); }
.house-ad .ha-copy { flex: 1; text-align: left; }
.house-ad .ha-brand { font-weight: 900; letter-spacing: 1px; font-size: 14px; }
.house-ad .ha-tag { font-size: 12px; opacity: .92; }
.house-ad .ha-cta { border: 2px solid rgba(255,255,255,.75); border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: 12px; white-space: nowrap; }
.house-ad .ha-label { position: absolute; top: 2px; right: 6px; font-size: 9px; letter-spacing: 2px; opacity: .65; }
.ad-tall .house-ad { flex-direction: column; text-align: center; padding: 22px 16px; gap: 8px; }
.ad-tall .house-ad .ha-tag { font-size: 15px; }
.ad-tall .house-ad .ha-brand { font-size: 20px; }

@media (max-height: 520px) {
  #game-wrap { max-height: 100vh; }
  #game { width: min(96vw, calc(100vh * 1.6)); }
  .menu-stack { gap: 6px; }
  .big-btn { padding: 9px 14px; font-size: 15px; }
}

body.reduced-motion * { animation-duration: .001s !important; transition-duration: .001s !important; }
