:root {
  --bg: #05070f;
  --panel: rgba(6, 10, 22, 0.92);
  --ink: #e8f1ff;
  --sub: #9fb2d6;
  --cyan: #46e6ff;
  --amber: #ffb238;
  --line: rgba(70, 230, 255, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at 50% 30%, #0d1530 0%, var(--bg) 70%);
  background-color: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

.wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: max(6px, env(safe-area-inset-top)) 16px max(6px, env(safe-area-inset-bottom));
}

/* 台は 400x760（論理座標）。HUD 60px と下の余白を引いた高さに合わせる */
.stage, .hud { width: var(--w); }
.wrap { --h: min(calc(100dvh - 100px), calc((100vw - 32px) * 760 / 400), 1100px); --w: calc(var(--h) * 400 / 760); }
@media (pointer: coarse) {
  .wrap { --h: min(calc(100dvh - 76px), calc((100vw - 16px) * 760 / 400), 1100px); padding-left: 8px; padding-right: 8px; }
}

.hud {
  height: 58px;
  padding: 4px 10px;
  background: linear-gradient(180deg, #0a0f1f, #04060d);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: inset 0 0 14px rgba(70, 230, 255, 0.15);
  font-family: "Orbitron", system-ui, sans-serif;
  overflow: hidden;
}
.hud-row { display: flex; justify-content: space-between; align-items: center; }
.hud-score {
  font-size: 26px;
  font-weight: 800;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255, 178, 56, 0.7);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.hud-side { text-align: right; font-size: 11px; line-height: 1.3; color: var(--cyan); }
.hud-rank { font-family: system-ui, sans-serif; font-weight: bold; }
.hud-msg {
  font-size: 12px;
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(70, 230, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "Orbitron", system-ui, sans-serif;
}
.hud-msg.jp { font-family: system-ui, sans-serif; font-weight: bold; }
.hud-msg.flash { color: #fff; text-shadow: 0 0 10px #fff, 0 0 18px var(--amber); }

.stage {
  position: relative;
  height: var(--h);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 10px;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
}
.overlay[hidden] { display: none; }

.panel {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 0 24px rgba(70, 230, 255, 0.2), inset 0 0 20px rgba(70, 230, 255, 0.08);
  padding: 18px 14px;
  text-align: center;
  line-height: 1.5;
}
.panel[hidden] { display: none; }

h1 {
  margin: 0 0 2px;
  font-family: "Orbitron", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1.1;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 10px var(--cyan), 0 0 22px rgba(70, 230, 255, 0.6);
}
h2 { margin: 0 0 12px; font-family: "Orbitron", system-ui, sans-serif; font-size: clamp(20px, 5.5vw, 28px); color: var(--cyan); }

.lead { margin: 0 0 10px; font-size: 14px; color: var(--sub); letter-spacing: 0.2em; }
.rules { list-style: none; padding: 0; margin: 0 0 10px; text-align: left; font-size: 13px; }
.rules li { display: flex; gap: 8px; align-items: flex-start; margin: 5px 0; }
.dot { flex: none; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; }
.dot.c1 { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.dot.c2 { background: #c46bff; box-shadow: 0 0 6px #c46bff; }
.dot.c3 { background: #ff4d6d; box-shadow: 0 0 6px #ff4d6d; }
.dot.c4 { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.keys { margin: 6px 0; font-size: 12px; color: var(--sub); }
.hi { margin: 10px 0 0; font-size: 13px; color: var(--sub); }
.result { margin: 4px 0; font-size: 22px; font-family: "Orbitron", system-ui, sans-serif; color: var(--amber); }
.result.small { font-size: 13px; color: var(--sub); font-family: inherit; }

.speed { display: flex; gap: 6px; align-items: stretch; margin: 10px 0 0; }
.speed-label { flex: none; align-self: center; font-size: 12px; color: var(--sub); }
.speed-btn {
  flex: 1;
  padding: 6px 2px;
  font: inherit;
  font-size: 13px;
  line-height: 1.25;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(159, 178, 214, 0.4);
  border-radius: 6px;
  cursor: pointer;
}
.speed-btn[aria-pressed="true"] { color: #021018; background: var(--amber); border-color: var(--amber); box-shadow: 0 0 10px rgba(255, 178, 56, 0.5); }

.btn {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 12px;
  font: inherit;
  font-size: 18px;
  font-weight: bold;
  color: #021018;
  background: linear-gradient(180deg, #7ff0ff, #1fb8d8);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(70, 230, 255, 0.45);
}
.btn:active { transform: translateY(1px); }
.btn.sub { background: linear-gradient(180deg, #c9d4ea, #8e9bb8); box-shadow: none; font-size: 15px; }

.corner {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 6px;
}
.mini {
  width: 32px;
  height: 32px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.mini.off { opacity: 0.45; text-decoration: line-through; }

.touch-only { display: none; }
@media (pointer: coarse) {
  .touch-only { display: block; }
  .pc-only { display: none; }
  .back { display: none; }
}

.back { margin: 0; font-size: 13px; }
.back a { color: #7f8db0; }
