/* CHEERS, LOVE! — Tracer time-run. Palette: electric orange / cyan / white on deep dusk blue. */
:root {
  --orange: #ff8c1a;
  --orange-hot: #ffb347;
  --cyan: #39c5ff;
  --cyan-soft: #9fe6ff;
  --dusk: #0d1230;
  --dusk-2: #161d45;
  --white: #f4f7ff;
  --danger: #ff3b5c;
  --font-head: 'Arial Narrow', 'Helvetica Neue', 'Segoe UI', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: var(--dusk); }
body { font-family: var(--font-head); color: var(--white); -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: none; }
#app { position: fixed; inset: 0; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- FX overlays ---------- */
#speedlines { position: absolute; inset: -10%; pointer-events: none; opacity: 0; transition: opacity .18s;
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    transparent 0deg 4deg, rgba(159,230,255,.10) 4deg 5deg, transparent 5deg 13deg);
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 34%, #000 78%);
  mask-image: radial-gradient(ellipse at center, transparent 34%, #000 78%);
  animation: speedspin 0.9s linear infinite; }
@keyframes speedspin { to { transform: rotate(6deg) scale(1.06); } }

#chromatic { position: absolute; inset: 0; pointer-events: none; opacity: 0; mix-blend-mode: screen;
  background:
    linear-gradient(90deg, rgba(255,60,120,.25), transparent 30%, transparent 70%, rgba(57,197,255,.25)),
    radial-gradient(ellipse at center, transparent 45%, rgba(255,140,26,.28) 100%); }
#chromatic.on { animation: chromaflash .28s ease-out; }
@keyframes chromaflash { 0% { opacity: 1; transform: translateX(-6px) skewX(-2deg); } 100% { opacity: 0; transform: none; } }

#glitch { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
#glitch.on { animation: glitchshatter .55s steps(12) forwards;
  background:
    repeating-linear-gradient(0deg, rgba(57,197,255,.16) 0 3px, transparent 3px 11px),
    repeating-linear-gradient(90deg, rgba(255,140,26,.12) 0 2px, transparent 2px 23px),
    linear-gradient(rgba(13,18,48,.15), rgba(13,18,48,.15)); }
@keyframes glitchshatter {
  0% { opacity: 1; transform: translateX(0); clip-path: inset(0 0 62% 0); }
  15% { transform: translateX(-14px); clip-path: inset(30% 0 22% 0); }
  30% { transform: translateX(9px) scaleY(1.04); clip-path: inset(55% 0 5% 0); }
  45% { transform: translateX(-6px); clip-path: inset(8% 0 70% 0); }
  60% { transform: translateX(4px) skewX(3deg); clip-path: inset(40% 0 34% 0); }
  80% { transform: none; clip-path: inset(0); opacity: .6; }
  100% { opacity: 0; } }

#hurt-vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(255,59,92,.55) 100%); }
#heal-vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 48%, rgba(57,197,255,.45) 100%); }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
.hud-label { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--cyan-soft); opacity: .8; font-weight: 700; }
#hud-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 16px; right: 16px; display: flex; gap: 22px; align-items: flex-start; }
#score { font-size: 34px; font-weight: 800; font-style: italic; color: var(--white);
  text-shadow: 0 0 14px rgba(255,140,26,.65); line-height: 1; }
#combo { font-size: 14px; font-weight: 800; font-style: italic; color: var(--orange-hot); margin-top: 2px; }
#objective-block { flex: 1; text-align: center; }
#objective { font-size: 15px; font-weight: 700; font-style: italic; text-transform: uppercase; letter-spacing: .08em; }
#progress-wrap { position: relative; height: 6px; margin-top: 6px; background: rgba(244,247,255,.14); border-radius: 3px; }
#progress-bar { height: 100%; width: 0%; border-radius: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--orange)); box-shadow: 0 0 10px rgba(57,197,255,.7); }
#progress-marker { position: absolute; right: -4px; top: -9px; font-size: 13px; filter: grayscale(1) brightness(2); }
#best-block { text-align: right; }
#best { font-size: 20px; font-weight: 800; font-style: italic; color: var(--cyan-soft); }

#hud-bottom { position: absolute; left: 16px; right: 16px; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 18px; }
#health-block { width: min(240px, 34vw); }
.bar { height: 14px; background: rgba(244,247,255,.12); border-radius: 7px; overflow: hidden; margin-top: 4px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.5); }
.bar.slim { height: 9px; }
#health-bar { height: 100%; width: 100%; border-radius: 7px;
  background: linear-gradient(90deg, #ff8c1a, #ffb347); box-shadow: 0 0 12px rgba(255,140,26,.8);
  transition: width .15s ease-out; }
#health-bar.low { background: linear-gradient(90deg, #ff3b5c, #ff8c1a); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { filter: brightness(1.5); } }

#abilities { display: flex; gap: 14px; margin-left: auto; }
.ability { width: 92px; text-align: center; }
.ab-key { font-size: 10px; font-weight: 800; color: var(--dusk); background: var(--cyan-soft); border-radius: 3px;
  display: inline-block; padding: 1px 6px; margin-top: 4px; letter-spacing: .06em; }
.ab-name { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; margin-top: 3px; opacity: .85; }
.pips { display: flex; gap: 5px; justify-content: center; height: 12px; align-items: center; }
.pips i { width: 16px; height: 10px; border-radius: 3px; background: rgba(244,247,255,.15); transform: skewX(-14deg);
  transition: background .12s, box-shadow .12s; }
.pips i.full { background: var(--cyan); box-shadow: 0 0 9px rgba(57,197,255,.9); }
.ability.ready .ab-key { background: var(--orange); box-shadow: 0 0 12px rgba(255,140,26,.9); animation: pulse .6s infinite alternate; }
#recall-bar, #bomb-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--cyan-soft)); border-radius: 5px; }
#bomb-bar { background: linear-gradient(90deg, var(--orange), #ff5e3a); }

#crosshair { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; transform: translate(-50%,-50%); }
#crosshair span { position: absolute; background: var(--white); box-shadow: 0 0 6px rgba(57,197,255,.9); }
#crosshair span:nth-child(1) { left: 16px; top: 0; width: 2px; height: 9px; }
#crosshair span:nth-child(2) { left: 16px; bottom: 0; width: 2px; height: 9px; }
#crosshair span:nth-child(3) { top: 16px; left: 0; height: 2px; width: 9px; }
#crosshair span:nth-child(4) { top: 16px; right: 0; height: 2px; width: 9px; }
#crosshair i { position: absolute; left: 15px; top: 15px; width: 4px; height: 4px; border-radius: 50%; background: var(--cyan); }
#crosshair.hit { animation: hitpop .16s ease-out; }
@keyframes hitpop { 50% { transform: translate(-50%,-50%) scale(1.45) rotate(45deg); } }

#quip { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%) skewX(-8deg);
  font-size: clamp(17px, 3vw, 26px); font-weight: 800; font-style: italic; color: var(--orange-hot);
  text-shadow: 0 2px 0 rgba(13,18,48,.9), 0 0 18px rgba(255,140,26,.5); white-space: nowrap;
  animation: quipin .25s ease-out; }
@keyframes quipin { from { transform: translateX(-50%) skewX(-8deg) translateY(14px); opacity: 0; } }

#popups { position: absolute; inset: 0; overflow: hidden; }
.popup { position: absolute; font-weight: 800; font-style: italic; font-size: 19px; color: var(--cyan-soft);
  text-shadow: 0 0 10px rgba(57,197,255,.8), 0 2px 0 rgba(13,18,48,.8); white-space: nowrap;
  animation: popfloat 1.05s ease-out forwards; }
.popup.style { color: var(--orange-hot); font-size: 22px; text-shadow: 0 0 12px rgba(255,140,26,.9), 0 2px 0 rgba(13,18,48,.8); }
@keyframes popfloat { 0% { opacity: 0; transform: translateY(10px) scale(.7); } 12% { opacity: 1; transform: translateY(0) scale(1.08); }
  25% { transform: scale(1); } 100% { opacity: 0; transform: translateY(-46px); } }

#recall-warning { position: absolute; left: 50%; top: 34%; transform: translateX(-50%);
  font-size: clamp(20px, 4vw, 34px); font-weight: 800; font-style: italic; color: var(--danger);
  text-shadow: 0 0 20px rgba(255,59,92,.8); animation: pulse .3s infinite alternate; white-space: nowrap; }
#recall-warning b { color: var(--white); }
#reload-hint { position: absolute; left: 50%; top: 58%; transform: translateX(-50%);
  font-size: 13px; letter-spacing: .3em; color: var(--cyan-soft); animation: pulse .3s infinite alternate; }
#boss-banner { position: absolute; left: 50%; top: 13%; transform: translateX(-50%); text-align: center;
  font-size: clamp(18px, 3vw, 28px); font-weight: 800; font-style: italic; letter-spacing: .18em; color: #ff5e3a;
  text-shadow: 0 0 18px rgba(255,94,58,.8); }
.bossbar { width: min(380px, 60vw); margin: 8px auto 0; }
#boss-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #ff3b5c, #ff5e3a); box-shadow: 0 0 12px rgba(255,59,92,.8); }

/* ---------- Touch ---------- */
#touch-ui { position: absolute; inset: 0; pointer-events: none; }
#stick-zone { position: absolute; left: 0; bottom: 0; width: 46%; height: 62%; pointer-events: auto; }
#stick-base { position: absolute; left: 60px; bottom: 90px; width: 110px; height: 110px; border-radius: 50%;
  border: 2px solid rgba(159,230,255,.4); background: rgba(13,18,48,.4); }
#stick-nub { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; border-radius: 50%;
  transform: translate(-50%,-50%); background: rgba(57,197,255,.55); box-shadow: 0 0 14px rgba(57,197,255,.7); }
#touch-buttons { position: absolute; right: 12px; bottom: 84px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; pointer-events: auto; }
.tbtn { width: 72px; height: 56px; border-radius: 12px; border: 2px solid rgba(159,230,255,.5);
  background: rgba(13,18,48,.55); color: var(--white); font-family: var(--font-head); font-weight: 800; font-style: italic;
  font-size: 13px; letter-spacing: .08em; }
.tbtn:active { background: rgba(255,140,26,.5); border-color: var(--orange); }
#tb-fire { grid-column: span 2; width: 100%; background: rgba(255,140,26,.35); border-color: rgba(255,179,71,.7); }

/* ---------- Screens ---------- */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  background: radial-gradient(ellipse at 50% 120%, rgba(255,140,26,.16), transparent 55%),
    linear-gradient(rgba(10,13,34,.82), rgba(10,13,34,.88));
  backdrop-filter: blur(3px); z-index: 20; overflow-y: auto; }
.title-inner { max-width: 640px; padding: 28px 22px; }
.eyebrow { font-size: 13px; letter-spacing: .4em; text-transform: uppercase; color: var(--cyan); font-weight: 700; }
h1 { font-size: clamp(56px, 11vw, 108px); line-height: .92; font-weight: 800; font-style: italic; letter-spacing: -.01em;
  color: var(--white); text-shadow: 4px 4px 0 var(--orange), 0 0 34px rgba(255,140,26,.45); margin: 10px 0 2px; }
.subtitle { font-size: clamp(15px, 2.6vw, 22px); font-weight: 800; font-style: italic; letter-spacing: .5em; color: var(--cyan-soft); margin-bottom: 16px; }
h2 { font-size: clamp(40px, 8vw, 72px); font-weight: 800; font-style: italic; color: var(--white);
  text-shadow: 4px 4px 0 var(--danger), 0 0 30px rgba(255,59,92,.5); margin: 8px 0; }
h2.win-h { text-shadow: 4px 4px 0 var(--orange), 0 0 30px rgba(255,140,26,.6); }
.brief { font-size: 16px; line-height: 1.5; color: rgba(244,247,255,.88); margin: 12px auto 18px; max-width: 520px; }
.brief b { color: var(--orange-hot); }
.controls-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 0 auto 20px; max-width: 560px; }
.controls-grid div { background: rgba(244,247,255,.06); border: 1px solid rgba(159,230,255,.18); border-radius: 8px; padding: 8px 6px; }
.controls-grid b { display: block; font-size: 13px; color: var(--cyan); letter-spacing: .05em; }
.controls-grid span { font-size: 12px; color: rgba(244,247,255,.7); }
.big-btn { pointer-events: auto; cursor: pointer; font-family: var(--font-head); font-size: 24px; font-weight: 800; font-style: italic;
  letter-spacing: .1em; color: var(--dusk); background: linear-gradient(180deg, var(--orange-hot), var(--orange));
  border: none; border-radius: 10px; padding: 14px 44px; box-shadow: 0 0 26px rgba(255,140,26,.55), 0 4px 0 #b35c00;
  transform: skewX(-8deg); transition: transform .1s, box-shadow .1s; }
.big-btn:hover { transform: skewX(-8deg) translateY(-2px) scale(1.04); box-shadow: 0 0 40px rgba(255,140,26,.8), 0 6px 0 #b35c00; }
.big-btn:active { transform: skewX(-8deg) translateY(2px); box-shadow: 0 0 18px rgba(255,140,26,.5), 0 1px 0 #b35c00; }
.ghost-btn { pointer-events: auto; cursor: pointer; display: block; margin: 14px auto 0; background: none; border: 1px solid rgba(159,230,255,.4);
  color: var(--cyan-soft); font-family: var(--font-head); font-weight: 700; font-style: italic; font-size: 15px;
  padding: 8px 22px; border-radius: 8px; letter-spacing: .1em; }
.title-quip { margin-top: 16px; font-style: italic; color: rgba(159,230,255,.75); font-size: 15px; }
#over-stats, #win-stats { margin: 14px auto 20px; font-size: 17px; line-height: 1.8; color: rgba(244,247,255,.9); }
#over-stats b, #win-stats b { color: var(--orange-hot); font-style: italic; }

#mute-btn { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 10px; z-index: 30; width: 38px; height: 38px;
  border-radius: 50%; border: 1px solid rgba(159,230,255,.35); background: rgba(13,18,48,.6); color: var(--cyan-soft);
  font-size: 17px; cursor: pointer; }
#mute-btn.muted { color: rgba(244,247,255,.3); text-decoration: line-through; }
#fps-warn { position: absolute; bottom: 4px; left: 8px; font-size: 10px; color: rgba(244,247,255,.4); }

@media (max-width: 700px) {
  #hud-top { gap: 10px; }
  #score { font-size: 26px; }
  .ability { width: 74px; }
  #hud-bottom { bottom: max(150px, env(safe-area-inset-bottom)); }
  .controls-grid { grid-template-columns: repeat(2, 1fr); }
  h1 { text-shadow: 3px 3px 0 var(--orange); }
}

/* touch devices: keyboard hint chips are noise, and the HUD must clear the touch controls */
body.touch .ab-key { display: none; }
body.touch #hud-bottom { bottom: max(300px, env(safe-area-inset-bottom)); left: 10px; right: 10px; }
body.touch #abilities { gap: 8px; }
body.touch .ability { width: 66px; }
body.touch #best-block { margin-right: 40px; }
