html, body { margin: 0; height: 100%; overflow: hidden; background: #0e1230; touch-action: none; -webkit-user-select: none; user-select: none; font-family: 'Nunito', system-ui, sans-serif; }
#game, #game canvas { position: fixed; inset: 0; display: block; }
.hud { position: fixed; pointer-events: none; color: #fff; z-index: 5; }

#hearts { top: max(16px, env(safe-area-inset-top)); left: 16px; display: flex; gap: 4px; }
#hearts svg { width: 28px; height: 26px; }
#items { top: max(50px, calc(env(safe-area-inset-top) + 34px)); left: 16px; display: flex; gap: 8px; font-size: 13px; font-weight: 800; }
#items .it { padding: 4px 10px; border-radius: 999px; background: rgba(13,17,48,.78); border: 1px solid rgba(255,255,255,.18); }
#items .it b { color: #f2c14e; }

#clock { top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); text-align: center; }
#clock .t { font: 700 42px/1 'Fredoka', sans-serif; letter-spacing: .06em; text-shadow: 0 0 18px rgba(242,193,78,.35); }
#clock.frozen .t { text-shadow: -3px 0 #6ee7f0, 3px 0 #ff4fa3, 0 0 24px rgba(110,231,240,.55); animation: glitch 2.6s infinite steps(1); }
#clock .s { font: 600 12px 'Fredoka', sans-serif; letter-spacing: .22em; color: #f2c14e; margin-top: 4px; }
#clock.frozen .s { color: #6ee7f0; }
@keyframes glitch { 0%,92%,100% { transform: none; } 93% { transform: translate(2px,-1px) skewX(6deg); } 95% { transform: translate(-3px,1px); } 97% { transform: translate(1px,0) skewX(-4deg); } }

#quest { top: max(14px, env(safe-area-inset-top)); right: 16px; max-width: min(270px, 40vw); padding: 10px 14px; border-radius: 14px; background: rgba(13,17,48,.78); border: 1px solid rgba(242,193,78,.45); }
#quest .k { font: 600 11px 'Fredoka', sans-serif; letter-spacing: .14em; color: #f2c14e; }
#objective { font-size: 14px; font-weight: 700; margin-top: 3px; line-height: 1.35; }

#boss { top: 84px; left: 50%; transform: translateX(-50%); width: min(560px, 80vw); text-align: center; display: none; }
#boss .name { font: 700 22px 'Fredoka', sans-serif; letter-spacing: .08em; color: #6ee7f0; text-shadow: 0 0 14px rgba(110,231,240,.7); }
#boss .bar { margin-top: 6px; height: 12px; border-radius: 99px; background: rgba(255,255,255,.14); overflow: hidden; }
#boss .fill { height: 100%; width: 100%; background: linear-gradient(90deg, #6ee7f0, #f2c14e); transition: width .2s; }
#boss .sub { margin-top: 5px; font: 600 13px 'Fredoka', sans-serif; color: #ffd97a; }

#prompt { left: 50%; bottom: 150px; transform: translateX(-50%); display: none; align-items: center; gap: 10px; padding: 8px 16px 8px 8px; border-radius: 999px; background: rgba(13,17,48,.88); border: 1px solid rgba(242,193,78,.6); font-weight: 800; font-size: 15px; }
#prompt .key { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; border-radius: 8px; background: #f2c14e; color: #1b1b2a; font: 700 15px 'Fredoka', sans-serif; padding: 0 6px; }
#toast { left: 50%; top: 30%; transform: translate(-50%, -10px); padding: 12px 20px; border-radius: 16px; background: rgba(13,17,48,.9); border: 2px solid #f2c14e; font: 600 18px 'Fredoka', sans-serif; opacity: 0; transition: .35s; text-align: center; max-width: 80vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#hint { bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 20px); padding: 10px 16px; border-radius: 999px; background: rgba(13,17,48,.85); font-size: 14px; font-weight: 700; opacity: 0; transition: .4s; white-space: nowrap; }
#hint.show { opacity: 1; transform: translate(-50%, 0); }
#crosshair { left: 50%; top: 46%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; border: 2px solid rgba(255,255,255,.8); display: none; }
#countdown { left: 50%; top: 42%; transform: translate(-50%, -50%); font: 700 120px 'Fredoka', sans-serif; color: #f2c14e; text-shadow: 0 0 40px rgba(242,193,78,.8); opacity: 0; transition: opacity .2s; }

#assists { left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: none; gap: 6px; pointer-events: auto; }
#assists .as { position: relative; width: 78px; padding: 6px 4px 7px; border-radius: 12px; background: rgba(13,17,48,.92); border: 2px solid var(--c); display: flex; flex-direction: column; align-items: center; gap: 2px; overflow: hidden; cursor: pointer; font: inherit; color: #fff; }
#assists .as .w { font: 600 12px 'Fredoka', sans-serif; white-space: nowrap; }
#assists .as .p { font-size: 11px; color: #c9cde0; white-space: nowrap; }
#assists .as .k { position: absolute; top: 3px; right: 4px; font-size: 10px; font-weight: 800; padding: 0 5px; border-radius: 4px; background: rgba(255,255,255,.9); color: #1b1b2a; }
#assists .as .cd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(5,7,22,.75); height: 0; }
#assists .as.locked { opacity: .35; }
#assists .as.ready.final { box-shadow: 0 0 22px rgba(242,193,78,.9); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

#dialogue { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(720px, 92vw); display: none; gap: 14px; align-items: flex-start; padding: 14px 18px; border-radius: 18px; background: rgba(13,17,48,.94); border: 2px solid rgba(242,193,78,.65); color: #fff; z-index: 8; box-sizing: border-box; }
#dialogue.on { display: flex; }
#dialogue .portrait { flex: none; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 700 24px 'Fredoka', sans-serif; color: #1b1b2a; }
#dialogue .body { flex: 1; min-width: 0; }
#dialogue .who { font: 600 15px 'Fredoka', sans-serif; color: #f2c14e; }
#dialogue .text { font-size: 17px; line-height: 1.45; margin-top: 3px; }
#dialogue .next { align-self: flex-end; font: 500 12px 'Fredoka', sans-serif; color: #9aa3c7; white-space: nowrap; }

#joystick { position: fixed; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(13,17,48,.25); opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 6; }
#joystick.on { opacity: 1; }
#knob { position: absolute; left: 30px; top: 30px; width: 50px; height: 50px; border-radius: 50%; background: rgba(242,193,78,.85); }
#touchButtons { position: fixed; right: 14px; bottom: max(110px, calc(env(safe-area-inset-bottom) + 96px)); display: none; grid-template-columns: 70px 70px; gap: 10px; z-index: 7; }
body.touch #touchButtons { display: grid; }
.tb { width: 70px; height: 70px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); background: rgba(13,17,48,.6); color: #fff; font: 700 12px 'Fredoka', sans-serif; }
.tb.fire { background: rgba(242,193,78,.85); color: #1b1b2a; }
.tb.act { background: rgba(110,231,240,.35); }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 9; transition: opacity .25s; }
#flash.red { background: #ff2a4a; }
#fade { position: fixed; inset: 0; background: #05060f; opacity: 0; pointer-events: none; z-index: 10; transition: opacity .6s; }
#fade.on { opacity: 1; }

#intro, #endcard { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: #fff; text-align: center; padding: 24px; transition: opacity .6s; z-index: 11; }
#intro { background: radial-gradient(ellipse at center, rgba(14,18,48,.55), rgba(5,7,22,.95)); }
#intro.hidden, #endcard.hidden { opacity: 0; pointer-events: none; }
#intro h1 { margin: 0; font: 700 clamp(34px, 8vw, 64px)/1 'Fredoka', sans-serif; color: #f2c14e; text-shadow: 0 0 30px rgba(242,193,78,.45); }
#intro p { margin: 0; max-width: 440px; font-size: 16px; line-height: 1.5; color: #d6dbf5; }
#intro p.small { font-size: 13px; color: #9aa3c7; }
#start, #replay { pointer-events: auto; font: 700 20px 'Fredoka', sans-serif; padding: 14px 36px; border-radius: 999px; border: 0; background: #f2c14e; color: #1b1b2a; cursor: pointer; box-shadow: 0 0 30px rgba(242,193,78,.5); }
#endcard { background: radial-gradient(ellipse at center, rgba(14,18,48,.25), rgba(5,7,22,.7)); }
#endcard .inner { max-width: 560px; padding: 28px; border-radius: 24px; background: rgba(13,17,48,.82); border: 2px solid rgba(242,193,78,.7); }
#endcard .kicker { font: 600 14px 'Fredoka', sans-serif; letter-spacing: .2em; color: #6ee7f0; }
#endcard h2 { margin: 8px 0 10px; font: 700 clamp(38px, 8vw, 64px)/1.05 'Fredoka', sans-serif; color: #f2c14e; }
#endcard p { margin: 0 0 14px; font-size: 17px; line-height: 1.5; color: #e4e7f7; }
#endcard .team { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 6px 0 18px; }
#endcard .team span { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.08); }
@media (max-width: 640px) {
  #quest { top: auto; bottom: max(18px, env(safe-area-inset-bottom)); left: 14px; right: auto; max-width: 52vw; }
  #clock .t { font-size: 34px; }
  #assists .as { width: 58px; } #assists .as .p { display: none; }
  #assists { flex-wrap: wrap; width: 96vw; justify-content: center; bottom: auto; top: 140px; }
}

body.has-assists #dialogue { bottom: 112px; }
body.has-assists #prompt { bottom: 200px; }
@media (max-width: 640px) { body.has-assists #dialogue { bottom: 24px; } }
body.has-assists #hint { bottom: 112px; }
body.ended .hud { display: none !important; }
body.ended #touchButtons { display: none; }

#intro .for { font: 600 14px 'Fredoka', sans-serif; letter-spacing: .14em; color: #6ee7f0; text-transform: uppercase; min-height: 1em; }
#intro .btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#intro button.secondary { pointer-events: auto; font: 700 18px 'Fredoka', sans-serif; padding: 14px 28px; border-radius: 999px; border: 2px solid #f2c14e; background: transparent; color: #f2c14e; cursor: pointer; }
#intro .settings { pointer-events: auto; max-width: 420px; width: 90vw; text-align: left; background: rgba(13,17,48,.7); border: 1px solid rgba(255,255,255,.15); border-radius: 14px; padding: 8px 14px; color: #d6dbf5; font-size: 14px; }
#intro .settings summary { cursor: pointer; font: 600 15px 'Fredoka', sans-serif; color: #fff; }
#intro .settings .row { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 10px 0; }
#intro .settings .row input[type=checkbox] { flex: none; width: 18px; height: 18px; accent-color: #f2c14e; }
#intro .settings .row input[type=range] { flex: 1; max-width: 170px; accent-color: #f2c14e; }
#arrow { width: 0; height: 0; border-left: 14px solid transparent; border-right: 14px solid transparent; border-bottom: 26px solid #f2c14e; filter: drop-shadow(0 0 8px rgba(242,193,78,.8)); display: none; margin: -13px 0 0 -14px; }
