:root{
  color-scheme: dark;
  --bg:#0f0c24; --bg2:#171433;
  --panel:#1d1840; --panel2:#241d52;
  --stroke:#312a66;
  --text:#e9e6ff; --muted:#a79fd6;
  --accent:#ffcf5a; --accent2:#5b6ee1;
  --good:#7CFFB2; --bad:#ff5a7a;
  --shadow:0 10px 30px rgba(0,0,0,.45);
}
@media (prefers-color-scheme: light){
  :root{
    color-scheme: light;
    --bg:#e8f1ff; --bg2:#cfe0ff;
    --panel:#ffffff; --panel2:#eaf2ff;
    --stroke:#cdd9f5;
    --text:#1b2350; --muted:#5a6798;
    --accent:#e85d2a; --accent2:#3a86ff;
    --good:#16a34a; --bad:#e0345e;
    --shadow:0 10px 30px rgba(40,60,120,.18);
  }
}
html[data-theme="dark"]{
  color-scheme:dark; --bg:#0f0c24;--bg2:#171433;--panel:#1d1840;--panel2:#241d52;--stroke:#312a66;
  --text:#e9e6ff;--muted:#a79fd6;--accent:#ffcf5a;--accent2:#5b6ee1;--good:#7CFFB2;--bad:#ff5a7a;
  --shadow:0 10px 30px rgba(0,0,0,.45);
}
html[data-theme="light"]{
  color-scheme:light; --bg:#e8f1ff;--bg2:#cfe0ff;--panel:#ffffff;--panel2:#eaf2ff;--stroke:#cdd9f5;
  --text:#1b2350;--muted:#5a6798;--accent:#e85d2a;--accent2:#3a86ff;--good:#16a34a;--bad:#e0345e;
  --shadow:0 10px 30px rgba(40,60,120,.18);
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0;height:100%;}
body{
  background:radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%);
  color:var(--text);
  font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  display:flex; align-items:center; justify-content:center;
  min-height:100dvh; padding:10px;
}
#game{
  width:100%; max-width:560px;
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--stroke);
  border-radius:18px; box-shadow:var(--shadow);
  padding:12px; display:flex; flex-direction:column; gap:10px;
  overflow:hidden; position:relative;
}
#hud{
  display:flex; align-items:center; gap:8px; flex-wrap:wrap;
}
.hud-item{
  display:flex; align-items:center; gap:6px;
  background:var(--panel2); border:1px solid var(--stroke);
  padding:6px 12px; border-radius:999px; font-weight:700; font-size:15px;
  min-width:0;
}
.hud-item .ico{font-size:15px;}
.hud-item span:last-child{font-variant-numeric:tabular-nums;}
.hud-btn{
  margin-left:auto;
  background:var(--panel2); border:1px solid var(--stroke); color:var(--text);
  width:38px; height:38px; border-radius:12px; font-size:17px; cursor:pointer;
  transition:transform .15s, background .2s, border-color .2s;
}
#help{margin-left:0;}
.hud-btn:hover{transform:translateY(-1px); border-color:var(--accent2);}
.hud-btn:active{transform:translateY(0) scale(.95);}

#stage{
  width:100%; aspect-ratio:480/300;
  background:#000; border-radius:14px; overflow:hidden;
  border:1px solid var(--stroke); position:relative;
}
#cv{width:100%; height:100%; display:block; image-rendering:auto;}

#controls{
  display:flex; justify-content:space-between; align-items:center; gap:10px;
}
.pad-left{display:flex; gap:10px;}
.ctrl{
  touch-action:none; user-select:none;
  width:58px; height:58px; border-radius:16px;
  background:linear-gradient(180deg,var(--panel2),var(--panel));
  border:1px solid var(--stroke); color:var(--text);
  font-size:22px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 0 var(--stroke);
  transition:transform .08s, box-shadow .08s, border-color .2s;
}
.ctrl:hover{border-color:var(--accent2);}
.ctrl:active{transform:translateY(3px); box-shadow:0 1px 0 var(--stroke);}
.ctrl.jump{
  width:74px; height:58px; background:linear-gradient(180deg,var(--accent),#e0a83a);
  color:#3a1a08; border-color:transparent; font-weight:800;
  box-shadow:0 4px 0 #b37e1f;
}
.ctrl.jump:active{box-shadow:0 1px 0 #b37e1f;}

#overlay, #note{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  background:rgba(8,6,20,.72); backdrop-filter:blur(4px);
  animation:fade .25s ease;
  z-index:5;
}
#overlay.hidden, #note.hidden{display:none;}
.panel{
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--stroke); border-radius:16px;
  padding:22px 26px; text-align:center; max-width:86%; box-shadow:var(--shadow);
}
.panel h2{margin:0 0 8px; font-size:22px; color:var(--accent);}
.panel p{margin:0 0 16px; color:var(--muted); white-space:pre-line; font-size:15px; line-height:1.4;}
.panel p b{color:var(--text);}
.panel p.tinker{font-size:13px; opacity:.85; margin-bottom:14px;}
.primary{
  background:linear-gradient(180deg,var(--accent2),#3a4cb0);
  color:#fff; border:none; padding:11px 22px; border-radius:12px;
  font-size:15px; font-weight:800; cursor:pointer;
  box-shadow:0 4px 0 #2a3680; transition:transform .08s, box-shadow .08s;
}
.primary:active{transform:translateY(3px); box-shadow:0 1px 0 #2a3680;}
@keyframes fade{from{opacity:0}to{opacity:1}}
@media (max-width:360px){
  .ctrl{width:52px;height:52px;font-size:20px;}
  .ctrl.jump{width:66px;}
  .hud-item{font-size:13px;padding:5px 10px;}
  .panel{padding:18px 18px;}
  .panel h2{font-size:19px;}
}
