:root {
  --bg: #070a16;
  --fg: #e6edff;
  --dim: #6f80ae;
  --accent: #6bd3ff;
  --gold: #ffd447;
  --pink: #ff6bd6;
  --font: "DotGothic16", "MS Gothic", "Hiragino Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% -10%, #1c2a5e 0%, transparent 55%),
    radial-gradient(circle at 50% 110%, #2a1050 0%, transparent 50%),
    var(--bg);
  padding: 10px;
}

#frame {
  width: min(100%, 560px);
  height: 100svh;
  max-height: 1040px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- HUD ---------- */
#hud {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 14px;
  border: 2px solid #24325e;
  border-radius: 10px;
  background: linear-gradient(180deg, #101838, #0a0f24);
  letter-spacing: 0.06em;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: clamp(15px, 4.2vw, 21px);
  line-height: 1.1;
}

.hud-label { font-size: 10px; color: var(--dim); letter-spacing: 0.2em; }

#score { color: var(--accent); }
#best  { color: var(--gold); }
#combo { color: var(--pink); }

/* ---------- ステージ ---------- */
#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border: 2px solid #24325e;
  border-radius: 10px;
  overflow: hidden;
  background: #060912;
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: none;
}

/* ---------- オーバーレイ ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 20, 0.9);
  backdrop-filter: blur(2px);
  padding: 14px;
  overflow-y: auto;
  z-index: 5;
}

.overlay.hidden { display: none; }

.panel {
  width: min(100%, 460px);
  text-align: center;
  border: 2px solid #2f4080;
  border-radius: 12px;
  background: linear-gradient(180deg, #101a3e, #090d20);
  padding: clamp(16px, 4vw, 26px);
  box-shadow: 0 0 30px rgba(107, 211, 255, 0.14);
}

.panel.small { max-width: 350px; }

.panel h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 8vw, 46px);
  line-height: 1.02;
  color: var(--accent);
  text-shadow: 0 0 16px rgba(107, 211, 255, 0.45);
  letter-spacing: 0.05em;
}

.panel h1 span {
  display: block;
  color: var(--pink);
  text-shadow: 0 0 16px rgba(255, 107, 214, 0.45);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: clamp(22px, 6vw, 30px);
  color: var(--pink);
  letter-spacing: 0.1em;
}

.tagline {
  margin: 0 0 14px;
  color: var(--dim);
  font-size: clamp(12px, 3.2vw, 14px);
  line-height: 1.7;
}
.tagline b { color: var(--accent); }

.rules {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  text-align: left;
  font-size: clamp(11px, 3vw, 13px);
  line-height: 1.9;
  color: #9db0dd;
}
.rules li { padding-left: 15px; position: relative; }
.rules li::before { content: "▸"; position: absolute; left: 0; color: var(--accent); }
.rules b { color: var(--fg); }

.score-line { margin: 6px 0; font-size: 13px; color: var(--dim); letter-spacing: 0.1em; }
.score-line b { color: var(--accent); font-size: 26px; }
.score-line.sub b { color: var(--gold); font-size: 18px; }

.record {
  color: var(--gold);
  margin: 10px 0 0;
  font-size: 14px;
  animation: blink 0.7s steps(2) infinite;
}
.record.hidden { display: none; }
@keyframes blink { 50% { opacity: 0.25; } }

.btn {
  margin-top: 18px;
  font-family: var(--font);
  font-size: clamp(15px, 4vw, 19px);
  letter-spacing: 0.24em;
  padding: 12px 34px;
  color: #04121a;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 0 #2b8fbe, 0 0 24px rgba(107, 211, 255, 0.35);
  touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #2b8fbe; }

/* ---------- フッター ---------- */
#foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 30px;
}

.mini {
  font-family: var(--font);
  font-size: 12px;
  color: var(--dim);
  background: #0e1530;
  border: 1px solid #2a3a6e;
  border-radius: 7px;
  padding: 6px 14px;
  touch-action: manipulation;
}
.mini:active { color: var(--fg); background: #18224a; }

/* ヒントはタッチ端末だけの話なので、マウス環境では出さない */
.hint { display: none; font-size: 10px; color: #4a5880; letter-spacing: 0.05em; }

@media (hover: none) and (pointer: coarse) and (min-width: 421px) {
  .hint { display: inline; }
}
