:root { --ink: #16234a; --snow: #f6faff; --sky: #3f8ff0; --ice: #7fd6ff; --berry: #e2475a; --gold: #ffc247; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9cc8f2; color: var(--ink); font-family: "Avenir Next", "Nunito", "Segoe UI", system-ui, sans-serif; -webkit-user-select: none; user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
body.playing #game { cursor: crosshair; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#bars { position: absolute; left: max(18px, env(safe-area-inset-left)); top: max(16px, env(safe-area-inset-top)); width: min(250px, 42vw); }
.who { display: flex; gap: 9px; align-items: center; font-weight: 600; letter-spacing: 0.08em; color: #fff; text-shadow: 0 2px 0 rgba(22, 35, 74, 0.55); font-size: 15px; margin-bottom: 6px; }
.who > div { flex: 1; } .who b { font-weight: 900; letter-spacing: 0.08em; }
#level { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--ink); font-weight: 900; font-size: 19px; text-shadow: none; box-shadow: 0 0 0 2.5px #fff, 0 3px 0 rgba(22, 35, 74, 0.4); }
.bar.xp { height: 6px; margin: 3px 0 0; border-width: 1.5px; } .bar.xp i { background: var(--gold); }
.bar { position: relative; height: 13px; margin-bottom: 6px; border-radius: 8px; background: rgba(22, 35, 74, 0.42); border: 2px solid rgba(255, 255, 255, 0.92); overflow: hidden; }
.bar.hp { height: 17px; }
.bar i { position: absolute; inset: 0; transform-origin: left center; border-radius: 5px; transition: transform 0.12s linear; }
.bar.hp i { background: linear-gradient(#8fe0ff, #3fa2ff); }
.bar.hp.low i { background: linear-gradient(#ff9aa6, var(--berry)); }
.bar.breath i { background: linear-gradient(#ffffff, #bfeaff); }
.bar.boost i { background: linear-gradient(#ffe08a, var(--gold)); }
.bar em { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 9px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); opacity: 0.75; }
#wave { position: absolute; top: max(18px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 6px 16px; border-radius: 999px; font-weight: 800; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; background: rgba(22, 35, 74, 0.5); white-space: pre; }
#wave:empty { display: none; }

#cross { position: absolute; left: 0; top: 0; width: 0; height: 0; --charge: 0; }
#cross i { position: absolute; left: -15px; top: -15px; width: 30px; height: 30px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 1.5px rgba(22, 35, 74, 0.35); transition: transform 0.12s, border-color 0.12s; }
#cross b { position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 calc(var(--charge) * 14px) rgba(127, 214, 255, 0.55); }
#cross.lock i { border-color: var(--gold); transform: scale(0.72) rotate(45deg); border-radius: 7px; }
#cross.hit i { animation: hit 0.16s; }
#cross.heavy i { animation: heavy 0.3s; }
@keyframes hit { 0% { transform: scale(1.5); border-color: #fff; background: rgba(255, 255, 255, 0.35); } }
@keyframes heavy { 0% { transform: scale(2.4); border-color: var(--gold); background: rgba(255, 194, 71, 0.5); } }

.mk { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.mk i { position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; border: 2px solid rgba(255, 110, 120, 0.9); border-radius: 6px; clip-path: polygon(0 0, 32% 0, 32% 8%, 68% 8%, 68% 0, 100% 0, 100% 32%, 92% 32%, 92% 68%, 100% 68%, 100% 100%, 68% 100%, 68% 92%, 32% 92%, 32% 100%, 0 100%, 0 68%, 8% 68%, 8% 32%, 0 32%); }
.mk b { position: absolute; left: -17px; top: 21px; width: 34px; height: 4px; border-radius: 2px; background: #ff6e78; transform-origin: left center; }
.mk.lock i { border-color: var(--gold); }
.mk.atk i { border-color: #fff; background: rgba(255, 110, 120, 0.22); }
.mk.off i { left: -9px; top: -9px; width: 0; height: 0; border: 9px solid transparent; border-left: 15px solid #ff6e78; border-radius: 0; clip-path: none; background: none; }
.mk.off.atk i { border-left-color: #fff; }
.mk.off b { display: none; }

#msg { position: absolute; left: 50%; top: 21%; transform: translate(-50%, 8px); max-width: 86vw; text-align: center; font-weight: 900; font-size: clamp(18px, 3.2vw, 30px); color: #fff; text-shadow: 0 3px 0 rgba(22, 35, 74, 0.55), 0 0 18px rgba(22, 35, 74, 0.35); opacity: 0; transition: opacity 0.25s, transform 0.25s; }
#msg.on { opacity: 1; transform: translate(-50%, 0); }
#edge { position: absolute; left: 50%; bottom: 20%; transform: translateX(-50%); padding: 8px 18px; border-radius: 10px; background: var(--berry); color: #fff; font-weight: 800; opacity: 0; transition: opacity 0.2s; }
#edge.on { opacity: 1; }
#vignette { position: absolute; inset: 0; box-shadow: inset 0 0 140px 30px rgba(226, 71, 90, 0.75); opacity: 0; }
#vignette.on { animation: hurt 0.5s; }
@keyframes hurt { 0% { opacity: 1; } 100% { opacity: 0; } }
#pause { position: absolute; inset: 0; display: none; place-items: center; font-size: 44px; font-weight: 900; color: #fff; background: rgba(22, 35, 74, 0.4); }
body.paused #pause { display: grid; }

/* title and result cards */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: flex-start; padding: 5vmin 6vw; pointer-events: none; }
#end.overlay { justify-content: center; background: rgba(22, 35, 74, 0.28); }
.card { pointer-events: auto; max-width: 460px; text-align: left; color: #fff; text-shadow: 0 2px 0 rgba(22, 35, 74, 0.45); }
#end .card { text-align: center; background: rgba(246, 250, 255, 0.94); color: var(--ink); text-shadow: none; border-radius: 26px; padding: 28px 38px 30px; box-shadow: 0 10px 0 rgba(22, 35, 74, 0.25); min-width: min(380px, 86vw); }
.kicker { font-size: 12px; font-weight: 800; letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.92; }
h1 { margin: 4px 0 6px; font-size: clamp(54px, 10.5vw, 118px); line-height: 0.92; font-weight: 900; letter-spacing: -0.02em; color: #fff; -webkit-text-stroke: 0; text-shadow: 0 5px 0 #1f58b8, 0 10px 0 rgba(22, 35, 74, 0.5); }
h2 { margin: 6px 0 0; font-size: 28px; font-weight: 900; }
.sub { margin: 0 0 20px; font-size: clamp(15px, 2vw, 19px); font-weight: 600; max-width: 26em; }
button { font: inherit; }
#btn-again, .modes button.primary { cursor: pointer; border: 0; border-radius: 999px; padding: 15px 34px; font-size: 19px; font-weight: 900; letter-spacing: 0.04em; color: var(--ink); background: var(--gold); box-shadow: 0 6px 0 #c9861a, 0 12px 18px rgba(22, 35, 74, 0.3); transition: transform 0.08s, box-shadow 0.08s; }
#btn-again:hover, .modes button:hover { transform: translateY(-2px); }
#btn-again:active, .modes button.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #c9861a; }
.keys { margin: 24px 0 8px; padding: 12px 14px; border-radius: 14px; background: rgba(22, 35, 74, 0.42); text-shadow: none; width: fit-content; display: grid; grid-template-columns: 1fr; gap: 3px; font-size: 13px; }
.keys div { display: flex; gap: 10px; }
.keys dt { font-weight: 800; min-width: 13.5em; }
.keys dd { margin: 0; opacity: 0.95; }
.fine { font-size: 12px; opacity: 0.85; margin: 6px 0 0; }
#end-rank { font-size: 104px; line-height: 1; font-weight: 900; margin: 6px 0 2px; color: var(--sky); text-shadow: 0 5px 0 rgba(22, 35, 74, 0.18); }
#end-rank[data-rank="S"] { color: var(--gold); }
#end-rank[data-rank="D"] { color: var(--berry); }
#end-stats { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin: 6px 0 22px; font-size: 14px; }
#end-stats b { display: block; font-size: 20px; }

/* touch */
#touch { display: none; }
body.touch.playing #touch { display: block; }
body.touch .keys { display: none; }
#stick-zone { position: fixed; left: 0; top: 18%; bottom: 0; width: 50%; }
#stick-base { position: fixed; left: 110px; top: calc(100% - 120px); width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.75); background: rgba(22, 35, 74, 0.22); pointer-events: none; opacity: 0.6; }
#stick-base.on { opacity: 1; }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255, 255, 255, 0.92); box-shadow: 0 3px 0 rgba(22, 35, 74, 0.3); }
#pads { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: auto auto; gap: 12px; align-items: end; justify-items: end; }
#pads button { width: 84px; height: 84px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.85); background: rgba(22, 35, 74, 0.38); color: #fff; font-weight: 800; font-size: 13px; }
#pads button.sm { width: 68px; height: 68px; font-size: 12px; }
#pads button.lg { width: 100px; height: 100px; background: rgba(63, 143, 240, 0.7); font-size: 15px; }
#pads button.on { background: rgba(255, 194, 71, 0.9); color: var(--ink); transform: scale(0.94); }

@media (max-height: 520px) { .keys, .fine { display: none; } .sub { margin-bottom: 12px; } }

/* tall or square windows: title card on top, Pom below it */
@media (max-aspect-ratio: 5/4) { #title.overlay { align-items: flex-start; } #title .keys, #title .fine { display: none; } }

/* title screen: the Runway key art fills the screen behind the card */
#title.overlay { background: linear-gradient(90deg, rgba(10, 30, 80, 0.55), rgba(10, 30, 80, 0) 62%), url(assets/keyart.jpg) center / cover no-repeat; }
@media (max-aspect-ratio: 5/4) { #title.overlay { background: linear-gradient(180deg, rgba(10, 30, 80, 0.6), rgba(10, 30, 80, 0) 55%), url(assets/keyart.jpg) 38% center / cover no-repeat; } }

/* round 2 and 3 HUD */
#flymode { display: inline-block; margin-top: 2px; padding: 3px 10px; border-radius: 999px; font-size: 10px; font-weight: 900; letter-spacing: 0.14em; color: var(--ink); background: #fff; }
#flymode.hover { background: var(--ice); }
#boss { position: absolute; left: 50%; top: max(52px, calc(env(safe-area-inset-top) + 40px)); transform: translateX(-50%); width: min(560px, 62vw); text-align: center; }
#boss-name { font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; font-size: 13px; color: #fff; text-shadow: 0 2px 0 rgba(22, 35, 74, 0.6); margin-bottom: 4px; }
#boss .bar { height: 15px; } #boss .bar i { background: linear-gradient(#ffb36b, #e2475a); }
#boss.open .bar { border-color: var(--gold); box-shadow: 0 0 18px rgba(255, 194, 71, 0.9); } #boss.open #boss-name { color: var(--gold); }
#banner { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%) scale(0.9); text-align: center; color: #fff; opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none; white-space: nowrap; }
#banner.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#banner b { display: block; font-size: clamp(30px, 6vw, 62px); font-weight: 900; letter-spacing: 0.02em; text-shadow: 0 4px 0 #1f58b8, 0 8px 0 rgba(22, 35, 74, 0.45); }
#banner span { display: block; margin-top: 6px; font-size: clamp(13px, 2vw, 18px); font-weight: 800; text-shadow: 0 2px 0 rgba(22, 35, 74, 0.6); }
#msg { top: 44%; font-size: clamp(15px, 2.4vw, 22px); }
.word { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); font-weight: 900; font-size: 20px; color: #fff; text-shadow: 0 2px 0 rgba(22, 35, 74, 0.7); opacity: 0; white-space: nowrap; pointer-events: none; }
.word.go { animation: word 0.7s ease-out; }
.word.heavy { font-size: 30px; color: var(--gold); } .word.zap { color: #fff27a; } .word.kill { font-size: 38px; color: #fff; text-shadow: 0 3px 0 var(--berry); } .word.weak { font-size: 30px; color: #ffb36b; }
@keyframes word { 0% { opacity: 1; transform: translate(-50%, -30%) scale(0.6); } 25% { transform: translate(-50%, -70%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }
.mk.hard i { border-color: var(--gold); border-width: 3px; transform: rotate(45deg) scale(0.9); }
.mk.ace i { border-color: #ffb36b; } .mk.ace b { background: #ffb36b; }
.mk.big:not(.off) i { left: -34px; top: -34px; width: 68px; height: 68px; } .mk.big b { display: none; }
.modes { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; }
.modes button { cursor: pointer; border: 0; border-radius: 18px; padding: 12px 20px; font-size: 17px; font-weight: 900; color: #fff; background: rgba(22, 35, 74, 0.55); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85) inset; text-align: left; transition: transform 0.08s; }
.modes button.primary { font-size: 20px; border-radius: 18px; padding: 13px 26px; }
.modes button small { display: block; font-size: 11px; font-weight: 700; opacity: 0.8; letter-spacing: 0.04em; }
.keys { grid-template-columns: 1fr; font-size: 12px; }
.keys dt { min-width: 11.5em; }
#end-best { font-size: 13px; font-weight: 800; color: var(--sky); margin: -10px 0 18px; min-height: 1em; }
button.ghost { cursor: pointer; margin-left: 10px; border: 0; background: none; font-weight: 800; font-size: 15px; color: var(--ink); opacity: 0.7; text-decoration: underline; }
#pads { grid-template-columns: auto auto auto; }
#pads button.sm.on[data-toggle] { background: rgba(127, 214, 255, 0.9); }
@media (max-height: 640px) { .keys, .fine { display: none; } }

.controls { margin-top: 18px; } .controls summary { cursor: pointer; display: inline-block; padding: 6px 14px; border-radius: 999px; background: rgba(22, 35, 74, 0.5); font-weight: 800; font-size: 13px; list-style: none; text-shadow: none; }
.controls summary::-webkit-details-marker { display: none; } .controls .keys { margin-top: 8px; display: grid !important; }
body.touch .controls { display: none; }
