* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a0a14; color: #fff; font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 999px; padding: 10px 18px; background: rgba(255,255,255,.14); color: #fff; }
button:hover { background: rgba(255,255,255,.24); }
button.primary { background: #fff; color: #7a1d36; font-weight: 800; }
button.primary:hover { background: #ffe1e8; }
button:disabled { opacity: .5; cursor: default; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Landing */
.brand { position: absolute; top: 2.5vh; left: 0; right: 0; text-align: center; pointer-events: none; }
.brand h1 { margin: 0; font-size: clamp(30px, 5vw, 60px); font-weight: 900; letter-spacing: -.03em; line-height: .9; color: #fff; text-shadow: 0 4px 0 #8c2440, 0 10px 30px rgba(60,0,20,.4); }
.brand h1 span { color: #fff3c4; }
.brand p { margin: 14px 0 0; font-size: clamp(14px, 2vw, 18px); color: #ffe9ee; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.landing-fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .45s; }
.landing-fade.on { opacity: 1; }
.you-marker { position: absolute; left: 0; top: 0; font-size: 12px; font-weight: 900; letter-spacing: .1em; color: #fff3a0; text-shadow: 0 1px 4px #000; pointer-events: none; transition: opacity .2s; }
.hole-label { position: absolute; transform: translate(-50%, -100%); text-align: center; pointer-events: auto; cursor: pointer; transition: transform .2s, opacity .2s; opacity: .8; width: 240px; }
.hole-label b { display: block; font-size: 20px; font-weight: 900; text-shadow: 0 2px 0 #8c2440; }
.hole-label span { display: block; font-size: 13px; margin-top: 4px; color: #ffe9ee; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.hole-label.hot { opacity: 1; transform: translate(-50%, -100%) scale(1.1); }
.door-clock { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; padding: 6px 12px 6px 8px; border-radius: 999px; background: rgba(30,2,10,.72); border: 1px solid rgba(255,210,87,.45); box-shadow: 0 4px 18px rgba(0,0,0,.35); }
.door-clock.hidden { display: none; }
.door-clock .clock-face { position: relative; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #ffd257; flex: none; }
.door-clock .hand { position: absolute; left: 50%; top: 50%; width: 2px; height: 8px; margin-left: -1px; background: #ffd257; border-radius: 1px; transform-origin: 50% 0; transform: rotate(180deg); }
.door-clock .dc-time { font-style: normal; font-weight: 900; font-size: 20px; color: #ffd257; font-variant-numeric: tabular-nums; }
.door-clock .dc-meta { font-size: 12px; color: #ffe9ee; opacity: .85; text-align: left; line-height: 1.2; }
.door-clock.urgent { border-color: #ff6b7d; }
.door-clock.urgent .dc-time, .door-clock.urgent .clock-face { color: #ff6b7d; border-color: #ff6b7d; }
.door-clock.urgent .hand { background: #ff6b7d; }
.landing-foot { position: absolute; bottom: 3vh; left: 0; right: 0; display: flex; gap: 18px; justify-content: center; align-items: center; flex-wrap: wrap; font-size: 13px; color: #ffe9ee; }
.landing-foot input { margin-left: 6px; background: rgba(60,0,20,.35); border: 1px solid rgba(255,255,255,.3); color: #fff; padding: 6px 10px; border-radius: 8px; font: inherit; width: 170px; }
.landing-foot .hint { opacity: .75; }

/* Panels */
#lobby, #results { background: radial-gradient(ellipse at 50% 30%, #b8475c, #3a0d1c 75%); overflow: auto; }
.panel { position: relative; max-width: 560px; margin: 6vh auto; padding: 28px; background: rgba(30,4,12,.55); border: 1px solid rgba(255,255,255,.12); border-radius: 22px; backdrop-filter: blur(6px); }
.panel h2 { margin: 6px 0 4px; font-size: 30px; font-weight: 900; }
.panel .back { position: absolute; top: 16px; right: 16px; padding: 6px 12px; font-size: 13px; }
.lobby-sub, .res-sub { color: #ffd6df; margin: 0 0 16px; }
.countdown { font-size: 54px; font-weight: 900; font-variant-numeric: tabular-nums; margin: 6px 0 10px; }
.players { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.players li { background: rgba(255,255,255,.12); padding: 6px 12px; border-radius: 999px; font-size: 14px; }
.players li.me { background: #fff; color: #7a1d36; font-weight: 700; }
.players li.bot { opacity: .7; }
.players .tag { font-size: 10px; font-weight: 800; letter-spacing: .08em; padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,.15); margin-left: 6px; }
.pot-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.pot-row div { background: rgba(255,255,255,.08); border-radius: 14px; padding: 10px 12px; }
.pot-row small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #ffc2cf; }
.pot-row b { font-size: 22px; }
.join-btn { width: 100%; padding: 14px; font-size: 17px; }
.wallet-line, .status { font-size: 13px; color: #ffd6df; min-height: 1em; word-break: break-all; }
.howto { margin-top: 18px; font-size: 14px; color: #ffe2e8; }
.howto summary { cursor: pointer; font-weight: 700; }
.howto li { margin: 6px 0; }

/* Intro */
#intro { background: #1c050d; }
.intro-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.anatomy { width: min(96vw, 900px); height: auto; max-height: 72vh; }
.anatomy .lbl text { fill: #ffe3e8; font-size: 15px; font-weight: 600; }
.anatomy .lbl path { stroke: rgba(255,227,232,.55); stroke-width: 1; fill: none; }
.anatomy .isp { stroke: #fff; stroke-width: 1.3; fill: none; stroke-linecap: round; }
.anatomy .isp.hero { stroke: #fff3a0; stroke-width: 2.2; filter: drop-shadow(0 0 3px #fff3a0); }
.intro-caption { font-size: clamp(18px, 3vw, 28px); font-weight: 800; text-align: center; min-height: 1.4em; padding: 0 16px; }
.intro-caption.pop { animation: pop .45s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.intro-cond { margin-top: 10px; font-size: 13px; color: #ffbfcc; text-align: center; padding: 0 16px; max-width: 760px; }
.intro-you { margin-top: 8px; font-size: 15px; font-weight: 700; }

/* Race HUD */
#race { background: #0d0105; }
.race-overlay { position: absolute; inset: 0; overflow: hidden; }
.race-overlay .vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, transparent 60%, rgba(40,0,8,.35) 85%, rgba(20,0,4,.7) 100%); }
.race-overlay .hit-flash { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(255,40,70,.0) 30%, rgba(255,30,60,.9)); opacity: 0; transition: opacity .08s; }
.sperm-label { position: absolute; left: 0; top: 0; font-size: 12px; font-weight: 700; text-shadow: 0 1px 3px #000; white-space: nowrap; }
.zone-banner { position: absolute; top: 16%; left: 0; right: 0; text-align: center; opacity: 0; text-shadow: 0 2px 12px rgba(0,0,0,.7); }
.zone-banner h2 { margin: 0; font-size: clamp(30px, 6vw, 54px); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.zone-banner p { margin: 4px 0 0; font-size: clamp(14px, 2vw, 19px); opacity: .85; }
.zone-banner.show { animation: zone 2.4s ease-out forwards; }
@keyframes zone { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 65% { opacity: 1; } 100% { opacity: 0; } }
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top { position: absolute; top: 12px; left: 12px; right: 60px; display: flex; gap: 16px; align-items: center; }
.atp { display: flex; gap: 8px; align-items: center; }
.atp small { font-weight: 800; font-size: 12px; }
.atp-bar { width: 160px; height: 12px; border-radius: 6px; background: rgba(0,0,0,.4); overflow: hidden; }
.atp-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ffcf4a, #fff3a0); transition: width .1s; }
.pos { font-size: 40px; font-weight: 900; line-height: 1; text-shadow: 0 2px 8px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.pos small { font-size: 18px; font-weight: 700; opacity: .7; margin-left: 6px; }
.pos sup { font-size: 18px; font-weight: 800; vertical-align: top; margin-left: 1px; }
.clock { font-variant-numeric: tabular-nums; opacity: .85; }
.minimap-wrap { position: absolute; right: 14px; top: 12px; bottom: 90px; width: 28px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.minimap { position: relative; flex: 1; width: 6px; background: rgba(255,255,255,.2); border-radius: 3px; }
.minimap i { position: absolute; left: -4px; width: 14px; height: 14px; border-radius: 50%; transform: translateY(50%); border: 2px solid rgba(0,0,0,.4); }
.minimap i.me { border-color: #fff; z-index: 2; }
.keys-hint { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 13px; opacity: .7; }
.touch { position: absolute; bottom: 18px; left: 12px; right: 12px; display: none; justify-content: space-between; pointer-events: auto; }
.touch .pad { display: grid; grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(3, 62px); gap: 4px; }
.touch .pad .up { grid-area: 1 / 2; } .touch .pad .left { grid-area: 2 / 1; } .touch .pad .right { grid-area: 2 / 3; } .touch .pad .dn { grid-area: 3 / 2; }
.touch .pad button { width: 62px; height: 62px; font-size: 24px; }
.touch { align-items: flex-end; }
.touch button { width: 84px; height: 84px; font-size: 30px; background: rgba(255,255,255,.18); user-select: none; touch-action: none; }
.touch button.boost { width: 120px; font-size: 16px; font-weight: 900; background: rgba(255,220,100,.35); }
.touch button.down { background: rgba(255,255,255,.45); }
@media (pointer: coarse) { .touch { display: flex; } .keys-hint { display: none; } }

/* Results */
.standings { padding-left: 22px; }
.standings li { margin: 6px 0; }
.standings li.me { font-weight: 800; color: #fff3a0; }
.standings .meta { opacity: .65; font-size: 13px; margin-left: 6px; }
.payout-box { background: rgba(255,255,255,.08); border-radius: 14px; padding: 12px 14px; margin: 12px 0; font-size: 14px; word-break: break-all; }
.payout-box:empty { display: none; }
.payout-box a, .verify a { color: #fff3a0; }
.verify { font-size: 13px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.verify button { padding: 6px 12px; font-size: 13px; }
.verify-out { flex-basis: 100%; margin: 0; color: #b4f8a0; min-height: 1em; word-break: break-all; }
.res-actions { display: flex; gap: 10px; margin-top: 18px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: #fff; color: #7a1d36; font-weight: 700; padding: 12px 18px; border-radius: 12px; transition: transform .25s; max-width: 92vw; z-index: 10; }
#toast.show { transform: translateX(-50%); }
#start-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 9; display: flex; align-items: baseline; justify-content: center; gap: 14px; padding: 10px 16px; background: linear-gradient(180deg, rgba(40,4,14,.92), rgba(40,4,14,.7)); border-bottom: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(6px); font-weight: 700; }
#start-banner.hidden { display: none; }
#start-banner .sb-label { opacity: .85; text-transform: uppercase; letter-spacing: .1em; font-size: 13px; }
#start-banner .sb-time { font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; color: #ffd257; }
#start-banner .sb-meta { opacity: .75; font-size: 14px; }
#start-banner.urgent .sb-time { color: #ff6b7d; animation: sb-pulse 1s infinite; }
@keyframes sb-pulse { 50% { opacity: .55; } }
#lobby .panel { margin-top: 64px; }
.door-clock.joined { border-color: #7dffa8; }
.door-clock.joined .dc-time { color: #7dffa8; }
.door-clock.joined .clock-face { border-color: #7dffa8; }
.door-clock.joined .hand { background: #7dffa8; }
