:root { --font: "Trebuchet MS", sans-serif; --cyan: #5ef2ff; --pink: #ff4fd8; --ink: #0b0826; --gold: #ffd77a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0b0826; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; overflow: hidden; font-family: var(--font); color: #fff; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.outl { text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink), 1.5px 1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink), 1.5px -1.5px 0 var(--ink), -1.5px -1.5px 0 var(--ink), 0 4px 0 rgba(11,8,38,0.85); }

/* Glass panels and crystal buttons drawn in CSS only (no stretched pictures: they showed as white blocks on some browsers) */
.panel { position: relative; padding: 14px 18px; border-radius: 14px;
  background: linear-gradient(160deg, rgba(34, 30, 92, 0.86), rgba(14, 11, 46, 0.86));
  border: 2px solid rgba(94, 242, 255, 0.75);
  box-shadow: 0 0 12px rgba(94, 242, 255, 0.28), inset 0 0 18px rgba(94, 242, 255, 0.10), 0 6px 16px rgba(0, 0, 0, 0.45); }
.panel::before, .panel::after { content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none; border: 3px solid #9ff7ff; }
.panel::before { left: -3px; top: -3px; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.panel::after { right: -3px; bottom: -3px; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }
.btn { position: relative; font-family: var(--font); font-weight: 900; color: #fff; padding: 0 20px; min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-size: 17px; transition: transform .12s, filter .12s;
  border-radius: 12px; border: 2px solid rgba(160, 248, 255, 0.95);
  background: linear-gradient(170deg, #3fd2ff 0%, #2a7cf0 48%, #2c3fc8 52%, #26209a 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.45), inset 0 -3px 0 rgba(10,8,60,.45), 0 3px 0 #120d4a, 0 0 10px rgba(94,242,255,.35);
  text-shadow: 0 2px 0 var(--ink), 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink); }
.btn.ghost { background: rgba(16, 12, 52, 0.75); border-color: rgba(94, 242, 255, .6); }
.btn:hover, .btn.focus { filter: brightness(1.2) drop-shadow(0 0 6px rgba(94,242,255,.7)); transform: scale(1.04); }
.btn:active { transform: scale(0.93); }
.btn.small { font-size: 15px; min-height: 44px; }
.btn.dim { filter: grayscale(.7) brightness(.7); }

/* vignette + flash */
#vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(255,40,90,.55) 100%); transition: opacity .2s; }
#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: #fff; }

/* note tag */
#tag { position: absolute; left: 0; top: 0; width: 120px; height: 120px; margin: -60px 0 0 -60px; pointer-events: none; will-change: transform; }
#tag svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
#tag .ring-bg { fill: rgba(16,12,52,.72); stroke: rgba(94,242,255,.35); stroke-width: 5; }
#tag .ring-fill { fill: none; stroke: var(--gold); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 283; stroke-dashoffset: 283; }
#tag.match .ring-bg { stroke: #7dffb0; fill: rgba(20,60,50,.75); }
#tag.danger .ring-bg { stroke: #ff5577; }
#tag .tag-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
#tag .solf { font-size: 40px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); }
#tag .letter { font-size: 22px; font-weight: 900; color: var(--cyan); margin-top: 4px; text-shadow: 0 2px 0 var(--ink); }
#tag .seq { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 4px; white-space: nowrap; font-size: 16px; font-weight: 900; }
#tag .seq span { padding: 0 3px; color: rgba(255,255,255,.45); text-shadow: 0 2px 0 var(--ink); }
#tag .seq span.done { color: #7dffb0; text-decoration: line-through; }
#tag .seq span.cur { color: var(--gold); }
#tag .dist { position: absolute; left: 15px; right: 15px; top: -12px; height: 6px; border-radius: 3px; background: rgba(0,0,0,.5); overflow: hidden; }
#tag .dist i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff5577, #ffd77a, #7dffb0); }
#tag.pop { animation: tagpop .25s ease-out; }
@keyframes tagpop { 0% { opacity: 0; } 100% { opacity: 1; } }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hudLeft { position: absolute; left: calc(10px + env(safe-area-inset-left)); top: calc(10px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
#hudPanel { min-width: 150px; padding: 12px 18px; }
#score { font-size: 30px; font-weight: 900; line-height: 1.05; color: #fff; }
.hud-row { display: flex; align-items: center; gap: 10px; margin-top: 2px; min-height: 22px; }
#shields { display: flex; gap: 3px; }
#shields img { width: 22px; height: 22px; object-fit: contain; filter: drop-shadow(0 0 3px rgba(94,242,255,.8)); }
#shields img.lost { filter: grayscale(1) brightness(.4); opacity: .6; }
#waveLbl { font-size: 16px; font-weight: 900; color: var(--cyan); }
#goldBox { display: inline-flex; align-items: center; gap: 3px; }
#goldBox img { width: 22px; height: 22px; object-fit: contain; }
#gold { font-size: 16px; font-weight: 900; color: #c9f8ff; }
#combo { order: 3; margin-left: 6px; font-size: 20px; font-weight: 900; color: var(--gold); opacity: 0; transition: opacity .2s; }
#combo.show { opacity: 1; }
#combo.bump { animation: bump .25s ease-out; }
@keyframes bump { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }
#hintBtn { order: 2; pointer-events: auto; }
#hintBtn svg { color: var(--gold); }

/* microphone help (waiting for permission, or nothing heard) */
#micHelp { position: absolute; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(330px, 86vw); text-align: center; z-index: 25; animation: popin .25s cubic-bezier(.2,1.5,.4,1); }
#micHelp .msg { font-size: 15px; font-weight: 800; line-height: 1.4; color: #e6f3ff; }
#micHelp .row { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
#micHelp .btn { flex: 1; font-size: 15px; padding: 0 10px; }

/* first-wave guide (sits low, under the incoming ship's tag and clear of the HUD and the pause corner) */
#guide { position: absolute; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); width: min(340px, 86vw); text-align: center; z-index: 18; pointer-events: none;
  opacity: 0; transform: translate(-50%, 16px) scale(.96); transition: opacity .45s ease, transform .45s cubic-bezier(.2,1.4,.4,1); padding: 12px 16px; }
#guide.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#guide.keys { bottom: calc(176px + env(safe-area-inset-bottom)); }
#guide.show.keys ~ #toast { bottom: 290px; }
#guide .g1 { font-size: 17px; font-weight: 900; color: var(--cyan); line-height: 1.3; }
#guide .g2 { font-size: 14px; font-weight: 700; color: #e6f3ff; line-height: 1.4; margin-top: 4px; }
#guide .mic { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; margin-right: 6px; color: var(--pink); }
.popup.big { font-size: 46px; color: #fff; text-shadow: 0 0 14px var(--cyan), 0 3px 0 var(--ink), 0 0 2px var(--ink); animation-duration: 1.3s; }

/* piano */
#piano { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); width: min(380px, 96vw); height: 150px; }
#piano .wk, #piano .bk { position: absolute; border-radius: 0 0 10px 10px; cursor: pointer; display: flex; align-items: flex-end; justify-content: center; font-weight: 900; transition: transform .06s, filter .06s; touch-action: none; }
#piano .wk { top: 62px; height: 88px; border-radius: 10px; background: linear-gradient(#f4f8ff, #c9d6f5); border: 2px solid #1b1546; color: #2c2672; font-size: 15px; padding-bottom: 8px; flex-direction: column; justify-content: flex-end; align-items: center; line-height: 1.1; }
#piano .wk small { font-size: 12px; color: #6b67a8; }
#piano .bk { top: 0; height: 56px; border-radius: 10px; align-items: center; background: linear-gradient(#3a3478, #14113a); border: 2px solid #0b0826; color: #bfe9ff; font-size: 14px; padding-bottom: 0; z-index: 2; }
#piano .down { filter: brightness(.8); transform: translateY(3px); }
#piano .good { box-shadow: 0 0 16px #7dffb0 inset; }
#piano .bad { box-shadow: 0 0 16px #ff5577 inset; }
#piano .cursor { outline: 3px solid var(--gold); outline-offset: -4px; }

/* banner, popups, toast */
#banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; opacity: 0; }
#banner .big { font-size: 46px; font-weight: 900; color: #fff; letter-spacing: 1px; }
#banner .sub { font-size: 18px; font-weight: 700; color: var(--cyan); margin-top: 8px; padding: 0 24px; }
#banner.show { animation: slam 2.2s ease-out forwards; }
@keyframes slam { 0% { opacity: 0; transform: scale(1.8); } 12% { opacity: 1; transform: scale(.95); } 18% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1); } }
#popups { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.popup { position: absolute; font-weight: 900; font-size: 24px; color: var(--gold); transform: translate(-50%, -50%); animation: rise .9s ease-out forwards; white-space: nowrap; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
#toast { position: absolute; left: 50%; bottom: 215px; transform: translateX(-50%); width: max-content; max-width: 86vw; text-align: center; font-size: 16px; font-weight: 800; color: #fff; background: rgba(16,12,52,.8); border: 2px solid rgba(94,242,255,.6); border-radius: 12px; padding: 8px 14px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 30; }
#toast.show { opacity: 1; }

/* title */
#title { position: absolute; inset: 0; background: #120f33 url(assets/cover-bg.webp) center / cover no-repeat; cursor: pointer; z-index: 20; }
#logo { position: absolute; left: 50%; top: 9%; width: 84%; max-height: 30%; object-fit: contain; transform: translateX(-50%); animation: logoIn .7s cubic-bezier(.2,1.6,.4,1) both, float 3.5s ease-in-out .7s infinite; filter: drop-shadow(0 6px 10px rgba(0,0,0,.5)); }
@keyframes logoIn { 0% { opacity: 0; transform: translateX(-50%) translateY(-60px) scale(.7); } 100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@keyframes float { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-7px); } }
#titleBottom { position: absolute; left: 0; right: 0; bottom: 9%; text-align: center; padding: 0 20px; }
#startPrompt { font-size: 24px; font-weight: 900; color: #fff; animation: pulse 1.6s ease-in-out infinite; }
#micNote { font-size: 14px; font-weight: 700; color: #bfe9ff; margin-top: 10px; }
@keyframes pulse { 0%,100% { opacity: .65; transform: scale(1); } 50% { opacity: 1; transform: scale(1.05); } }
.corner { position: absolute; top: calc(12px + env(safe-area-inset-top)); width: 48px; height: 48px; border-radius: 50%; border: 2px solid rgba(94,242,255,.45); background: rgba(16,12,52,.6); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.corner.left { left: calc(12px + env(safe-area-inset-left)); }
.corner.right { right: calc(12px + env(safe-area-inset-right)); }
.corner img { width: 30px; height: 30px; object-fit: contain; }
.corner:active { transform: scale(.9); }
.corner .keyhint { position: absolute; bottom: -18px; font-size: 11px; font-weight: 800; color: #bfe9ff; font-family: var(--font); }
body.touch .keyhint { display: none; }

/* modal */
#modal { position: absolute; inset: 0; z-index: 40; background: rgba(5,3,20,.6); display: flex; align-items: center; justify-content: center; }
.modal-panel { width: min(340px, 90%); max-height: 80%; overflow: visible; padding: 18px 22px; animation: popin .25s cubic-bezier(.2,1.5,.4,1); }
@keyframes popin { 0% { transform: scale(.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.modal-title { font-size: 26px; font-weight: 900; text-align: center; color: var(--cyan); margin: 4px 0 6px; }
.modal-body { font-size: 15px; line-height: 1.5; color: #e6f3ff; white-space: pre-line; }
.modal-body .sub { text-align: center; color: #bfe9ff; margin-bottom: 8px; }
.modal-btns { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 4px; }
.modal-btns .btn { width: 100%; }
.modal-btns .btn img { width: 26px; height: 26px; object-fit: contain; }
.bag-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(94,242,255,.15); font-weight: 800; }
.bag-row img { width: 40px; height: 40px; object-fit: contain; }
.bag-row .n { margin-left: auto; color: var(--gold); font-size: 18px; }

/* intro */
#introLayer { position: absolute; inset: 0; z-index: 50; background: #000 url(assets/cover-bg.webp) center / cover; }
#introVid { width: 100%; height: 100%; object-fit: cover; }
#skipBtn { position: absolute; right: calc(12px + env(safe-area-inset-right)); top: calc(12px + env(safe-area-inset-top)); padding: 0 14px; }
