:root {
  --font: "Trebuchet MS", system-ui, sans-serif;
  --gold: #ffd56b;
  --magenta: #ff3fa4;
  --cyan: #52f3ff;
  --plum: #2a1240;
  --ink: #1a0b2b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #120822; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; overflow: hidden; font-family: var(--font); color: #fff4dc; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

.outline { text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0 4px 0 var(--ink); }

/* HUD */
#hud { position: absolute; left: 0; right: 0; top: 0; height: 120px; pointer-events: none; padding: calc(10px + env(safe-area-inset-top)) 12px 0; }
#hud-left { position: absolute; left: calc(12px + env(safe-area-inset-left)); top: calc(10px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 6px; }
#hearts { display: flex; gap: 2px; }
#hearts img { width: 28px; height: 28px; filter: drop-shadow(0 2px 0 var(--ink)); transition: transform .2s, opacity .2s; }
#hearts img.off { opacity: .25; filter: grayscale(1) drop-shadow(0 2px 0 var(--ink)); transform: scale(.8); }
#hearts img.pop { animation: pop .35s ease-out; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 4px; border-radius: 999px; background: rgba(26, 11, 43, .72); border: 2px solid rgba(255, 213, 107, .6); font-weight: 900; font-size: 16px; color: var(--gold); width: max-content; }
.pill img { width: 22px; height: 22px; }
#hud-center { position: absolute; left: 50%; top: calc(6px + env(safe-area-inset-top)); transform: translateX(-50%); text-align: center; display: flex; flex-direction: column; align-items: center; }
#score { font-size: 38px; font-weight: 900; line-height: 1; color: #fff; letter-spacing: 1px;
  text-shadow: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 0 5px 0 var(--ink), 0 0 18px var(--magenta); }
#score.bump { animation: bump .25s ease-out; }
#combo { font-size: 16px; font-weight: 900; color: var(--gold); min-height: 20px; margin-top: 2px; white-space: nowrap;
  text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink); }
#charges { display: flex; gap: 3px; margin-top: 3px; padding: 3px 8px; border-radius: 999px; background: rgba(26, 11, 43, .6); border: 2px solid rgba(82, 243, 255, .5); }
#charges img { width: 22px; height: 22px; }
#charges img.off { opacity: .22; filter: grayscale(1); }
#charges img.pop { animation: pop .4s ease-out; }
@keyframes pop { 0% { transform: scale(.4); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

#subtitle, #introSub { position: absolute; left: 50%; transform: translateX(-50%); top: 22%; max-width: 86%; width: max-content; padding: 8px 14px; border-radius: 12px; background: rgba(20, 8, 34, .78); border: 2px solid rgba(255, 63, 164, .55); font-size: 15px; font-weight: 800; text-align: center; pointer-events: none; z-index: 30; }
#introSub { top: auto; bottom: 14%; }
#toasts { position: absolute; left: 0; right: 0; top: 30%; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 25; }
.toast { font-size: 24px; font-weight: 900; color: var(--gold); animation: toast 1.2s ease-out forwards; max-width: 90%; text-align: center;
  text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0 0 14px var(--magenta); }
.toast.cyan { color: var(--cyan); }
.toast.red { color: #ff6b6b; }
@keyframes toast { 0% { transform: scale(.3); opacity: 0; } 15% { transform: scale(1.2); opacity: 1; } 30% { transform: scale(1); } 80% { opacity: 1; transform: translateY(-14px); } 100% { opacity: 0; transform: translateY(-30px); } }

/* rewind: VHS scanlines, a colour wash and a big ◀◀ counter */
#vhs { position: absolute; inset: 0; pointer-events: none; z-index: 20; background: linear-gradient(180deg, rgba(82,243,255,.10), rgba(255,63,164,.12)); }
#vhs .scan { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(10,4,20,.22) 0 2px, transparent 2px 5px); animation: scan .25s linear infinite; }
#vhs .bar { position: absolute; left: 0; right: 0; height: 18%; background: linear-gradient(180deg, transparent, rgba(255,255,255,.08), transparent); animation: vbar 1.1s linear infinite; }
@keyframes scan { from { background-position: 0 0; } to { background-position: 0 10px; } }
@keyframes vbar { from { top: 110%; } to { top: -20%; } }
#vhsText { position: absolute; left: 0; right: 0; top: 44%; text-align: center; font-size: 46px; font-weight: 900; color: #fff; letter-spacing: 2px; text-shadow: 3px 0 0 var(--magenta), -3px 0 0 var(--cyan), 0 4px 0 var(--ink); animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .6; } }

#lastChance { position: absolute; left: 50%; top: 36%; transform: translateX(-50%); z-index: 22; text-align: center; pointer-events: none; width: 90%; }
.lc-title { font-size: 40px; font-weight: 900; color: var(--cyan); animation: pulse .5s ease-in-out infinite alternate;
  text-shadow: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 0 0 24px var(--cyan); }
.lc-sub { font-size: 18px; font-weight: 900; margin-top: 4px; text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink); }
.lc-bar { width: 60%; height: 10px; margin: 10px auto 0; border-radius: 6px; background: rgba(0,0,0,.5); border: 2px solid var(--ink); overflow: hidden; }
#lcFill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--magenta), var(--cyan)); }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.1); } }

/* title */
#title { position: absolute; inset: 0; background: #1a0b2b url(assets/cover-bg.webp) center / cover no-repeat; z-index: 40; cursor: pointer; }
#title::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 100%, rgba(10,4,20,.55), transparent 55%); pointer-events: none; }
#logo { position: absolute; left: 50%; top: 9%; width: 82%; max-height: 30%; object-fit: contain; transform: translateX(-50%); filter: drop-shadow(0 6px 0 rgba(20,8,34,.6)); animation: logoIn .7s cubic-bezier(.3,1.6,.5,1) both, float 3.2s ease-in-out .7s infinite; z-index: 1; }
@keyframes logoIn { from { transform: translateX(-50%) translateY(-60px) scale(.6); opacity: 0; } to { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; } }
@keyframes float { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-8px); } }
#startPrompt { position: absolute; left: 10%; right: 10%; bottom: 11%; text-align: center; font-size: 22px; font-weight: 900; z-index: 1; color: #fff; animation: pulse .9s ease-in-out infinite alternate;
  text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0 0 16px var(--magenta); }
.corner-btn { position: absolute; top: calc(12px + env(safe-area-inset-top)); width: 48px; height: 48px; border-radius: 50%; border: 2px solid rgba(255, 213, 107, .7); background: rgba(42, 18, 64, .7); color: var(--gold); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2; padding: 0; font-family: var(--font); transition: transform .12s; }
.corner-btn:active { transform: scale(.9); }
.corner-btn svg { width: 26px; height: 26px; }
.corner-btn.right { right: calc(12px + env(safe-area-inset-right)); }
.corner-btn.left { left: calc(12px + env(safe-area-inset-left)); width: auto; min-width: 48px; border-radius: 999px; padding: 0 12px 0 6px; gap: 4px; font-weight: 900; font-size: 16px; }
.corner-btn.left img { width: 30px; height: 30px; }

/* intro */
#introWrap { position: absolute; inset: 0; z-index: 60; background: #1a0b2b url(assets/cover-bg.webp) center / cover no-repeat; }
#introVideo { width: 100%; height: 100%; object-fit: cover; display: block; }
#btnSkip { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); z-index: 2; }

/* panels & buttons */
#panelLayer { position: absolute; inset: 0; z-index: 50; background: rgba(12, 4, 24, .6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.panel { position: relative; width: min(94%, 400px); max-height: 92%; overflow: hidden auto; padding: 22px 20px 20px;
  border: 40px solid transparent; border-image: url(assets/ui-panel.webp) 120 fill / 40px stretch; animation: panelIn .28s cubic-bezier(.3,1.5,.5,1) both; }
@keyframes panelIn { from { transform: scale(.6) translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel h2 { margin: -18px 0 10px; font-size: 26px; font-weight: 900; text-align: center; color: var(--gold);
  text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0 4px 0 var(--ink); }
.panel p { margin: 6px 0; font-size: 15px; line-height: 1.45; font-weight: 700; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; margin: 8px 0 0; padding: 4px 18px; font-family: var(--font); font-size: 17px; font-weight: 900; color: #fff; cursor: pointer; background: none;
  border: 18px solid transparent; border-image: url(assets/ui-button.webp) 70 110 fill / 18px 28px stretch; transition: transform .1s, filter .1s;
  text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink); }
.btn:hover, .btn:focus-visible, .btn.focus { filter: brightness(1.2); transform: scale(1.03); outline: none; }
.btn:active { transform: scale(.94); }
.btn img { width: 26px; height: 26px; margin: -6px 0; }
.btn.small { width: auto; min-height: 44px; font-size: 15px; padding: 2px 10px; margin: 0; }
.btn.ghost { filter: saturate(.3) brightness(.85); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px; margin-top: 8px; border-radius: 14px; background: rgba(12, 4, 24, .45); border: 2px solid rgba(255, 213, 107, .25); }
.row > img { width: 52px; height: 52px; flex: 0 0 auto; }
.row .info { flex: 1 1 auto; min-width: 0; font-weight: 800; font-size: 15px; }
.row .info small { display: block; font-size: 12px; opacity: .8; font-weight: 700; }
.row .btn { width: auto; min-width: 96px; margin: 0; min-height: 46px; font-size: 15px; padding: 2px 8px; }
.balance { display: flex; justify-content: center; margin-bottom: 4px; }
.scorebig { text-align: center; font-size: 44px; font-weight: 900; color: #fff; text-shadow: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 0 0 18px var(--magenta); }
.helpgrid { display: grid; grid-template-columns: 40px 1fr; gap: 8px 10px; align-items: center; margin: 8px 0; font-size: 14px; font-weight: 700; }
.helpgrid img { width: 40px; height: 40px; }
