:root {
  --bg: #04121f;
  --panel: rgba(8, 36, 66, 0.86);
  --edge: rgba(80, 200, 255, 0.35);
  --ink: #eaf7ff;
  --dim: #8fb7d0;
  --green: #3ddc84;
  --lime: #b6ff5c;
  --blue: #2f7bff;
  --cyan: #3fd0ff;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: 'Fredoka', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; touch-action: none; user-select: none; }
canvas { position: fixed; inset: 0; display: block; }
[hidden] { display: none !important; }

#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: 18px; padding: 10px 16px; align-items: flex-start; pointer-events: none; z-index: 2; }
.hud-block { min-width: 80px; }
.hud-block.grow { flex: 1; max-width: 520px; margin: 0 auto; }
.hud-block.right { text-align: right; }
.label { font-size: 12px; letter-spacing: 0.12em; color: var(--dim); font-weight: 600; }
.label.dim { opacity: 0.8; }
.big { font-size: 30px; font-weight: 700; color: var(--lime); line-height: 1; }
.bar { height: 14px; border-radius: 8px; background: rgba(255,255,255,0.1); border: 1px solid var(--edge); overflow: hidden; margin-top: 4px; }
#bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); transition: width 0.15s linear; }
#bar.low { background: linear-gradient(90deg, #ff5d73, #ffb347); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { opacity: 0.55; } }
.powers { display: flex; gap: 6px; margin-top: 4px; min-height: 20px; }
.powers span { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: rgba(63,208,255,0.2); border: 1px solid var(--cyan); }

.banner { position: fixed; left: 0; right: 0; top: 36%; text-align: center; font-size: clamp(36px, 9vw, 84px); font-weight: 700; color: var(--lime); text-shadow: 0 0 24px rgba(61,220,132,0.7); opacity: 0; pointer-events: none; z-index: 3; transform: scale(0.9); transition: opacity 0.3s, transform 0.3s; }
.banner.show { opacity: 1; transform: scale(1); }

.coach { position: fixed; left: 50%; bottom: 14px; transform: translate(-50%, 20px); width: min(640px, calc(100vw - 24px)); display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--edge); opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; z-index: 4; }
.coach.show { opacity: 1; transform: translate(-50%, 0); }
.coach-face { flex: none; width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #7dffb0, var(--green) 60%, #1f9b5c); position: relative; box-shadow: 0 0 0 3px var(--blue); }
.coach-face .eye { position: absolute; top: 15px; width: 7px; height: 9px; border-radius: 50%; background: #06304a; }
.coach-face .eye:nth-child(1) { left: 12px; } .coach-face .eye:nth-child(2) { right: 12px; }
.coach-face .mouth { position: absolute; left: 14px; right: 14px; bottom: 11px; height: 8px; border-bottom: 3px solid #06304a; border-radius: 0 0 12px 12px; }
.coach.talking .mouth { animation: talk 0.22s infinite alternate; }
@keyframes talk { to { height: 3px; } }
.coach-name { font-size: 11px; letter-spacing: 0.12em; color: var(--green); font-weight: 700; }
.coach-name span { color: var(--dim); font-weight: 400; }
.coach-text { font-size: 17px; line-height: 1.25; min-height: 22px; }

.overlay { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; background: radial-gradient(ellipse at center, rgba(6, 40, 74, 0.82), rgba(2, 10, 20, 0.96)); z-index: 5; overflow-y: auto; touch-action: pan-y; }
.kicker { letter-spacing: 0.3em; color: var(--cyan); font-size: 13px; font-weight: 600; }
.logo { font-size: clamp(44px, 11vw, 110px); line-height: 0.95; font-weight: 700; background: linear-gradient(180deg, var(--lime), var(--green) 45%, var(--blue)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 22px rgba(61,220,132,0.35)); }
.logo.small { font-size: clamp(34px, 8vw, 64px); }
.tag { max-width: 520px; color: var(--dim); font-size: 18px; }
.btn { font: inherit; font-weight: 700; letter-spacing: 0.08em; font-size: 20px; padding: 12px 30px; border-radius: 30px; border: 0; cursor: pointer; color: #02223a; background: linear-gradient(180deg, var(--lime), var(--green)); box-shadow: 0 4px 0 #1b8a52, 0 0 24px rgba(61,220,132,0.35); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #1b8a52; }
.btn.ghost { background: transparent; color: var(--cyan); border: 2px solid var(--cyan); box-shadow: none; }
.btn.small { font-size: 15px; padding: 8px 18px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.cols { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 16px; padding: 14px 18px; min-width: 250px; text-align: left; }
.panel h2 { font-size: 13px; letter-spacing: 0.14em; color: var(--cyan); margin-bottom: 8px; }
.panel h2:not(:first-child) { margin-top: 12px; }
.board { list-style: none; padding: 0; counter-reset: r; font-size: 16px; }
.board li { counter-increment: r; display: flex; gap: 8px; padding: 2px 0; }
.board li::before { content: counter(r) "."; width: 24px; color: var(--dim); }
.board li b { flex: 1; font-weight: 600; }
.board li em { font-style: normal; color: var(--lime); }
.board li small { color: var(--dim); }
dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 15px; }
dt { color: var(--lime); font-weight: 600; } dd { color: var(--dim); }
.legend { list-style: none; padding: 0; font-size: 15px; color: var(--dim); }
.legend li { display: flex; gap: 10px; align-items: center; padding: 2px 0; }
.k { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.k.cell { background: var(--green); border-radius: 50%; width: 10px; height: 10px; margin: 3px; box-shadow: 0 0 8px var(--green); }
.k.bat { background: var(--cyan); } .k.turbo { background: #ffd23f; } .k.mag { background: #b46bff; }
.k.mud { background: #3a5a3c; border-radius: 50%; } .k.crate { background: #2bb6a3; } .k.gate { background: #ff5d73; }
.final { display: flex; flex-direction: column; }
.final span { font-size: clamp(48px, 10vw, 84px); font-weight: 700; color: var(--lime); line-height: 1; }
.final small { color: var(--dim); letter-spacing: 0.2em; text-transform: uppercase; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; color: var(--dim); font-size: 17px; }
.stats b { color: var(--ink); }
.entry label { display: block; margin-bottom: 8px; color: var(--lime); }
.entry-row { display: flex; gap: 10px; justify-content: center; }
.entry input { font: inherit; font-size: 20px; padding: 8px 14px; border-radius: 20px; border: 2px solid var(--cyan); background: #021a2e; color: var(--ink); width: 190px; text-align: center; text-transform: uppercase; user-select: text; }

.dpad { position: fixed; right: 14px; bottom: 16px; width: 168px; height: 168px; z-index: 4; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 4px; }
.dpad button { border-radius: 16px; border: 1px solid var(--edge); background: var(--panel); color: var(--ink); font-size: 24px; touch-action: none; }
.dpad button.on { background: var(--green); color: #02223a; }
.dpad .u { grid-area: 1 / 2; } .dpad .l { grid-area: 2 / 1; } .dpad .r { grid-area: 2 / 3; } .dpad .d { grid-area: 3 / 2; }
.mute { position: fixed; right: 14px; top: 78px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); color: var(--ink); font-size: 18px; cursor: pointer; z-index: 6; }
body.touchy .coach { bottom: auto; top: 74px; transform: translate(-50%, -10px); }
body.touchy .coach.show { transform: translate(-50%, 0); }
body.touchy .coach-text { font-size: 15px; }
@media (max-width: 560px) { .big { font-size: 24px; } #hud { gap: 10px; padding: 8px 10px; } .tag { font-size: 16px; } }
