:root {
  --bg: #04030c;
  --panel: #0b0820;
  --line: #2a1f55;
  --text: #d9dcff;
  --dim: #7d78b0;
  --cyan: #22f3ff;
  --magenta: #ff3df2;
  --yellow: #ffe54a;
  --lime: #8dff5a;
  --red: #ff4d6a;
  --font: 'Orbitron', 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
body {
  display: flex; align-items: center; justify-content: center; padding: 12px;
  background: radial-gradient(ellipse at 50% 30%, #140b33 0%, var(--bg) 70%);
}

.wrap { display: flex; gap: 16px; align-items: stretch; max-width: 100%; }

/* Playfield keeps a 3:4 ratio and fills the height available */
.stage {
  position: relative;
  height: min(calc(100vh - 24px), calc((100vw - 24px - 236px) * 4 / 3));
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  box-shadow: 0 0 40px rgba(120, 60, 255, 0.25), inset 0 0 0 1px rgba(34, 243, 255, 0.08);
}
#field { display: block; width: 100%; height: 100%; }

/* ---------- side panel ---------- */
.panel {
  width: 220px; padding: 18px 16px;
  background: linear-gradient(180deg, var(--panel), #070514);
  border: 1px solid var(--line);
  font-size: 11px; letter-spacing: 0.06em;
  display: flex; flex-direction: column; gap: 10px;
}
.panel .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel label { color: var(--dim); font-size: 10px; }
.panel .num { color: #fff; font-weight: 700; }
.panel .big { font-size: 15px; color: var(--cyan); text-shadow: 0 0 10px rgba(34, 243, 255, 0.6); }
.panel hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.icons { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; min-height: 12px; }
.ico { width: 11px; height: 11px; display: inline-block; transform: rotate(45deg); }
.ico.life { border: 2px solid var(--magenta); box-shadow: 0 0 6px var(--magenta); }
.ico.bomb { border: 2px solid var(--lime); box-shadow: 0 0 6px var(--lime); border-radius: 50%; }
.none { color: var(--dim); font-size: 9px; }
.bar { height: 6px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); }
.fill { height: 100%; width: 0; transition: width 0.15s; }
.fill.power { background: linear-gradient(90deg, #ff4d6a, #ff9a3c); box-shadow: 0 0 8px rgba(255, 120, 60, 0.6); }
.fill.graze { background: linear-gradient(90deg, #22f3ff, #ffffff); box-shadow: 0 0 8px rgba(34, 243, 255, 0.6); }
.hint { margin: -4px 0 0; color: var(--dim); font-size: 9px; line-height: 1.5; letter-spacing: 0.02em; }
.back { margin-top: auto; color: var(--dim); text-decoration: none; font-size: 10px; }
.back:hover { color: var(--text); }

/* ---------- overlays ---------- */
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  text-align: center; padding: 6%;
  background: rgba(4, 3, 12, 0.72);
}
.hidden { display: none !important; }
.logo {
  margin: 0; font-size: clamp(42px, 9vh, 76px); font-weight: 900; letter-spacing: 0.18em;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--yellow));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(255, 61, 242, 0.45));
}
.tagline { margin: -8px 0 6px; color: var(--dim); letter-spacing: 0.4em; font-size: 11px; text-transform: uppercase; }
.diffs { display: flex; gap: 8px; }
.diff {
  font-family: var(--font); font-size: 11px; letter-spacing: 0.1em; color: var(--dim);
  background: transparent; border: 1px solid var(--line); padding: 8px 14px; cursor: pointer;
}
.diff.sel { color: #fff; border-color: var(--cyan); box-shadow: 0 0 12px rgba(34, 243, 255, 0.45), inset 0 0 10px rgba(34, 243, 255, 0.15); }
.hi { margin: 0; font-size: 11px; color: var(--dim); }
.hi span { color: var(--yellow); }
.cta {
  font-family: var(--font); background: none; border: 0; cursor: pointer;
  color: #fff; font-size: 13px; letter-spacing: 0.2em; margin: 6px 0;
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }
.controls { font-size: 10px; color: var(--dim); line-height: 2; letter-spacing: 0.04em; }
.controls b, .menu b { color: var(--cyan); font-weight: 700; }
h2 { margin: 0; font-size: 30px; letter-spacing: 0.15em; text-shadow: 0 0 16px currentColor; }
h2.red { color: var(--red); }
h2.gold { color: var(--yellow); }
.menu { font-size: 12px; line-height: 2.2; }
.stats { width: min(320px, 90%); font-size: 11px; display: flex; flex-direction: column; gap: 8px; }
.stats div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.stats span { color: var(--dim); }
.stats em { color: var(--yellow); font-style: normal; font-size: 9px; margin-left: 6px; }
.note { margin: 0; color: var(--dim); font-size: 10px; }

@media (max-width: 760px) {
  .wrap { flex-direction: column; align-items: center; }
  .stage { height: auto; width: min(100%, calc((100vh - 140px) * 3 / 4)); }
  .panel { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .panel hr, .hint { display: none; }
}

/* ---------- stage select / links ---------- */
.stages { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--dim); }
.stages .lbl { margin-right: 4px; letter-spacing: 0.15em; }
.stagebtn {
  font-family: var(--font); width: 30px; height: 26px; font-size: 11px; color: var(--dim); cursor: pointer;
  background: transparent; border: 1px solid var(--line);
}
.stagebtn.sel { color: #fff; border-color: var(--magenta); box-shadow: 0 0 10px rgba(255, 61, 242, 0.45); }
.stagebtn.locked { opacity: 0.25; cursor: not-allowed; }
.link {
  font-family: var(--font); background: none; border: 0; cursor: pointer;
  color: var(--dim); font-size: 10px; letter-spacing: 0.15em; padding: 4px 8px;
}
.link:hover { color: var(--cyan); }
.btns { display: flex; flex-direction: column; align-items: center; gap: 2px; }

/* ---------- score submission ---------- */
.submit { width: min(320px, 92%); font-size: 10px; color: var(--yellow); }
.submit p { margin: 0 0 8px; }
.srow { display: flex; gap: 6px; }
.srow input {
  flex: 1; min-width: 0; font-family: var(--font); font-size: 12px; color: #fff;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); padding: 7px 9px; outline: none;
}
.srow input:focus { border-color: var(--cyan); box-shadow: 0 0 8px rgba(34, 243, 255, 0.4); }
.srow button {
  font-family: var(--font); font-size: 10px; letter-spacing: 0.1em; cursor: pointer;
  color: #04030c; background: var(--cyan); border: 0; padding: 0 12px;
}
.srow button:disabled { opacity: 0.5; }
.status { color: var(--dim); font-size: 10px; min-height: 12px; margin: 6px 0 0; }

/* ---------- leaderboard ---------- */
.board { background: rgba(4, 3, 12, 0.94); justify-content: flex-start; padding-top: 8%; z-index: 5; }
.btabs { display: flex; gap: 6px; }
.btab {
  font-family: var(--font); font-size: 10px; letter-spacing: 0.1em; color: var(--dim);
  background: transparent; border: 1px solid var(--line); padding: 6px 12px; cursor: pointer;
}
.btab.sel { color: #fff; border-color: var(--cyan); }
.blist { width: min(380px, 94%); flex: 1; overflow-y: auto; font-size: 11px; }
.brow { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); align-items: center; }
.brow .rank { color: var(--dim); }
.brow .name { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.brow .st { color: var(--dim); font-size: 9px; }
.brow .sc { color: var(--cyan); }
.brow.you { background: rgba(255, 61, 242, 0.1); }
.brow.you .name { color: var(--magenta); }

/* ---------- touch ---------- */
.touch-only, .tbtn { display: none !important; }
body.touch .touch-only { display: block !important; }
body.touch .kbd-only { display: none !important; }
body.touch .tbtn {
  display: flex !important; align-items: center; justify-content: center;
  position: absolute; z-index: 3; font-family: var(--font); font-size: 11px; letter-spacing: 0.1em;
  color: #fff; background: rgba(10, 6, 30, 0.45); border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%; width: 64px; height: 64px; user-select: none; -webkit-user-select: none; touch-action: none;
}
body.touch .tbomb { right: 10px; bottom: 12px; border-color: var(--lime); color: var(--lime); }
body.touch .tfocus { left: 10px; bottom: 12px; border-color: var(--magenta); color: var(--magenta); }
body.touch .tpause { right: 8px; top: 30px; width: 34px; height: 34px; font-size: 10px; border-radius: 8px; }
body.touch #field { touch-action: none; }
body.touch:not(.playing) .tbtn { display: none !important; }
