:root{
  --coal:#0A0910;
  --plum:#14101F;
  --olive:#2A3226;
  --blood:#E8243C;
  --glow:#7FD4C1;
  --peach:#F7C9A8;
  --lilac:#C9A7FF;
  --ink:#f5eef8;
  --dim:#a89ab8;
  --r-lg:20px;
  --r-md:14px;
  --r-sm:10px;
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;}

html,body{height:100%;margin:0;padding:0;}

body{
  background:var(--coal);
  color:var(--ink);
  font-family:'Tajawal',system-ui,-apple-system,'Segoe UI',sans-serif;
  overflow:hidden;
  overscroll-behavior:none;
  -webkit-user-select:none;
  user-select:none;
  -webkit-font-smoothing:antialiased;
}

button{font-family:inherit;-webkit-user-select:none;user-select:none;touch-action:manipulation;}

.is-hidden{display:none !important;}

/* ================== ROOT ================== */
.game-root{
  position:relative;
  height:100%;
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  background:radial-gradient(130% 70% at 50% 0%,#1a1226 0%,#0A0910 62%);
}

/* ================== HUD ================== */
.hud{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:8px 12px;
  flex:0 0 auto;
  z-index:5;
}

.score-box{
  display:flex;
  align-items:baseline;
  gap:4px;
  padding:6px 12px;
  border-radius:var(--r-md);
  background:linear-gradient(180deg,rgba(201,167,255,.16),rgba(201,167,255,.06));
  border:1px solid rgba(201,167,255,.28);
  min-width:74px;
  justify-content:center;
  color:var(--ink);
}
.score-value{
  font-size:19px;
  font-weight:900;
  font-variant-numeric:tabular-nums;
  letter-spacing:0;
  line-height:1;
}
.score-label{
  font-size:11px;
  color:var(--lilac);
  font-weight:700;
}

.danger-meter{
  display:flex;
  align-items:center;
  gap:6px;
  padding:9px 11px;
  border-radius:999px;
  background:rgba(232,36,60,.09);
  border:1px solid rgba(232,36,60,.3);
}
.pulse{
  width:11px;height:11px;
  border-radius:50%;
  background:var(--blood);
  box-shadow:0 0 10px rgba(232,36,60,.95),0 0 20px rgba(232,36,60,.45);
  animation:pulseBeat 1.5s ease-in-out infinite;
}
.pulse:nth-child(2){animation-delay:.2s;}
.pulse:nth-child(3){animation-delay:.4s;}
.pulse.is-dead{
  background:#3a2530;
  box-shadow:none;
  animation:none;
  opacity:.65;
}
@keyframes pulseBeat{
  0%,100%{transform:scale(1);opacity:1;}
  50%{transform:scale(.72);opacity:.55;}
}

.hud-group{display:flex;align-items:center;gap:6px;}

.hud-btn{
  width:40px;height:40px;
  display:grid;place-items:center;
  padding:0;border:none;
  border-radius:12px;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.1);
  color:#e7dcf2;
  cursor:pointer;
  transition:transform .12s ease,background .15s ease,color .15s ease;
}
.hud-btn svg{width:19px;height:19px;fill:currentColor;}
.hud-btn:active{transform:scale(.92);background:rgba(255,255,255,.14);}
.hud-btn:focus-visible{outline:2px solid var(--lilac);outline-offset:2px;}
.hud-btn .ic-muted{display:none;}
.hud-btn.is-muted{color:#8d7f9c;background:rgba(232,36,60,.08);border-color:rgba(232,36,60,.25);}
.hud-btn.is-muted .ic-sound{display:none;}
.hud-btn.is-muted .ic-muted{display:block;}

/* ================== STAGE ================== */
.stage{
  position:relative;
  flex:1 1 auto;
  min-height:0;
  overflow:hidden;
  background:#07060c;
}
#gameCanvas{
  display:block;
  width:100%;
  height:100%;
  touch-action:none;
}
.scanlines{
  position:absolute;inset:0;
  pointer-events:none;
  background:repeating-linear-gradient(0deg,rgba(0,0,0,.34) 0 1px,rgba(0,0,0,0) 1px 3px);
  opacity:.45;
  mix-blend-mode:multiply;
}
.vignette{
  position:absolute;inset:0;
  pointer-events:none;
  background:radial-gradient(115% 85% at 50% 45%,rgba(0,0,0,0) 42%,rgba(0,0,0,.62) 100%);
}

/* ================== CONTROLS ================== */
.controls{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 16px 14px;
  background:linear-gradient(180deg,rgba(10,9,16,.2),rgba(10,9,16,.85));
}

.ctl{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  width:92px;
  height:66px;
  border-radius:22px;
  border:1px solid transparent;
  cursor:pointer;
  transition:transform .1s ease,box-shadow .15s ease,filter .15s ease;
  -webkit-user-select:none;user-select:none;
  touch-action:none;
}
.ctl svg{width:26px;height:26px;}
.ctl-label{font-size:12px;font-weight:700;letter-spacing:.2px;}

.ctl-jump{
  background:linear-gradient(180deg,#F7C9A8 0%,#e0a67f 100%);
  color:#2c1119;
  box-shadow:0 10px 26px -12px rgba(247,201,168,.95),inset 0 1px 0 rgba(255,255,255,.7);
}
.ctl-slide{
  background:linear-gradient(180deg,rgba(201,167,255,.26),rgba(201,167,255,.1));
  color:#ecdcff;
  border-color:rgba(201,167,255,.4);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.14);
}
.ctl:active{transform:scale(.94);filter:brightness(1.08);}
.ctl:focus-visible{outline:2px solid var(--glow);outline-offset:3px;}

/* ================== SCREENS ================== */
.screen{
  position:absolute;
  inset:0;
  z-index:40;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  background:
    radial-gradient(120% 80% at 50% 0%,rgba(30,18,44,.92) 0%,rgba(8,7,13,.97) 60%),
    linear-gradient(180deg,rgba(6,5,10,.94),rgba(6,5,10,.98));
  animation:screenIn .22s ease-out;
}
@keyframes screenIn{from{opacity:0;}to{opacity:1;}}

.screen-inner{
  min-height:100%;
  max-width:460px;
  margin:0 auto;
  padding:20px 18px 28px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:14px;
  text-align:center;
}
.screen-center{justify-content:center;gap:12px;}
.over-inner{
  justify-content:flex-start;
  padding-top:132px;
  gap:12px;
}

.kicker{
  margin:0;
  font-size:12px;
  font-weight:700;
  letter-spacing:.24em;
  color:var(--glow);
  opacity:.85;
}
.kicker.danger-text{color:#ff7f8f;letter-spacing:.18em;}

.neon-title{
  margin:0;
  font-size:clamp(30px,8.6vw,44px);
  font-weight:900;
  line-height:1.12;
  color:#fff7fa;
  text-shadow:
    0 0 4px rgba(255,255,255,.55),
    0 0 14px rgba(232,36,60,.9),
    0 0 34px rgba(232,36,60,.65),
    0 0 64px rgba(232,36,60,.35);
}

.found-title{
  margin:0;
  font-size:clamp(34px,10vw,52px);
  font-weight:900;
  line-height:1.1;
  color:#fff;
  text-shadow:
    0 0 6px rgba(255,255,255,.4),
    0 0 18px rgba(232,36,60,.95),
    0 0 44px rgba(232,36,60,.6);
}

.panel-title{
  margin:0;
  font-size:26px;
  font-weight:900;
  color:#fff;
  text-shadow:0 0 16px rgba(232,36,60,.7);
}

.lede{
  margin:0;
  font-size:15px;
  line-height:1.65;
  color:var(--dim);
}
.lede.small{font-size:14px;line-height:1.55;}

.best-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:11px 16px;
  border-radius:var(--r-md);
  background:rgba(127,212,193,.07);
  border:1px solid rgba(127,212,193,.22);
  color:#d7f2ea;
  font-size:14px;
}
.best-row strong{
  font-size:20px;
  font-weight:900;
  font-variant-numeric:tabular-nums;
  color:#fff;
}

/* buttons */
.btn{
  min-height:52px;
  width:100%;
  border-radius:16px;
  border:1px solid transparent;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  font-size:17px;
  font-weight:700;
  cursor:pointer;
  transition:transform .12s ease,filter .15s ease,background .15s ease,opacity .15s ease;
  padding:12px 18px;
}
.btn:active{transform:scale(.975);}
.btn:focus-visible{outline:2px solid var(--glow);outline-offset:3px;}
.btn:disabled{opacity:.55;cursor:progress;transform:none;}
.btn-ico{width:20px;height:20px;}

.btn-primary{
  background:linear-gradient(180deg,#F7C9A8 0%,#e6a67e 100%);
  color:#2b1017;
  box-shadow:0 14px 30px -14px rgba(247,201,168,.95),inset 0 1px 0 rgba(255,255,255,.7);
  font-size:18px;
}
.btn-soft{
  background:rgba(201,167,255,.16);
  color:#eadcff;
  border-color:rgba(201,167,255,.36);
}
.btn-ghost{
  background:transparent;
  color:#c7b8d8;
  border-color:rgba(201,167,255,.24);
}
.btn-sm{min-height:44px;font-size:15px;border-radius:13px;}

/* hints */
.hint-row{
  display:flex;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
  gap:8px;
}
.hint{
  display:inline-flex;
  align-items:center;
  gap:5px;
  padding:7px 12px;
  border-radius:999px;
  font-size:13px;
  font-weight:700;
  color:#d8cbe6;
  background:rgba(255,255,255,.055);
  border:1px solid rgba(255,255,255,.1);
}
.hint svg{width:15px;height:15px;color:var(--glow);}
.hint-text{color:#9c8fae;background:transparent;border-color:transparent;font-weight:500;}

/* music card */
.music-card{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:14px;
  border-radius:var(--r-lg);
  background:rgba(127,212,193,.055);
  border:1px solid rgba(127,212,193,.2);
  text-align:start;
}
.music-head{display:flex;align-items:flex-start;gap:10px;}
.music-dot{
  flex:0 0 auto;
  width:10px;height:10px;margin-top:5px;
  border-radius:50%;
  background:var(--glow);
  box-shadow:0 0 12px rgba(127,212,193,.9);
  animation:pulseBeat 2.4s ease-in-out infinite;
}
.music-copy strong{display:block;font-size:15px;color:#e6f7f2;}
.music-copy p{margin:3px 0 0;font-size:13px;line-height:1.55;color:#93a9a3;}
.music-audio{width:100%;height:40px;border-radius:10px;filter:invert(.92) hue-rotate(180deg) saturate(.7);}
.music-dl{
  font-size:13px;
  font-weight:700;
  color:var(--glow);
  text-decoration:none;
  text-align:center;
  padding:6px;
  border-radius:10px;
  background:rgba(127,212,193,.1);
}
.music-dl:active{background:rgba(127,212,193,.2);}

/* leaderboard */
.board-card{
  padding:14px;
  border-radius:var(--r-lg);
  background:rgba(201,167,255,.06);
  border:1px solid rgba(201,167,255,.2);
  text-align:start;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.board-head{display:flex;align-items:baseline;justify-content:space-between;gap:8px;}
.board-head strong{font-size:14px;color:#e8dbff;}
.board-note{font-size:10.5px;color:#8d7fa0;}
.board-list{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:6px;}
.board-list li{
  display:flex;
  align-items:center;
  gap:10px;
  font-size:13px;
  color:#cfc0e2;
  padding:6px 10px;
  border-radius:10px;
  background:rgba(255,255,255,.04);
}
.board-list li.is-you{background:rgba(247,201,168,.16);color:#ffeedd;}
.board-list .rank{width:16px;font-weight:900;color:var(--lilac);}
.board-list .handle{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.board-list .pts{font-weight:900;font-variant-numeric:tabular-nums;color:#fff;}

/* game over stats */
.stat-row{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;}
.stat{
  display:flex;
  flex-direction:column;
  gap:3px;
  padding:12px 6px;
  border-radius:var(--r-md);
  background:rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.09);
}
.stat span{font-size:11.5px;color:#a294b4;}
.stat strong{font-size:20px;font-weight:900;color:#fff;font-variant-numeric:tabular-nums;}

.save-note{
  margin:0;
  min-height:16px;
  font-size:12.5px;
  color:#8c7fa0;
}

/* ================== RESPONSIVE ================== */
@media (max-height:560px){
  .over-inner{padding-top:120px;}
  .screen-inner{padding-top:12px;padding-bottom:16px;gap:10px;}
  .neon-title{font-size:clamp(26px,7.4vw,34px);}
  .found-title{font-size:clamp(28px,8vw,40px);}
  .lede{font-size:13.5px;}
  .ctl{width:80px;height:60px;border-radius:18px;}
  .hint-row{display:none;}
}

@media (max-width:360px){
  .score-box{min-width:64px;padding:5px 9px;}
  .score-value{font-size:17px;}
  .danger-meter{padding:8px 9px;gap:5px;}
  .pulse{width:9px;height:9px;}
  .hud{padding:6px 8px;gap:6px;}
  .ctl{width:84px;height:62px;}
}

@media (prefers-reduced-motion:reduce){
  .pulse,.music-dot{animation:none;}
  .screen{animation:none;}
  .btn,.ctl,.hud-btn{transition:none;}
}