/* ===== シュールビート スタイル ===== */

body {
  margin: 0;
  padding: 0;
  background: var(--sg-bg-dark);
  color: var(--sg-text-light);
  font-family: var(--sg-font-body);
  overflow: hidden;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- 画面管理 --- */
.screen {
  display: none;
  width: 100%;
  max-width: 500px;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* --- トップに戻るリンク --- */
.back-to-top-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 5000;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  backdrop-filter: blur(4px);
  transition: color 0.2s;
}

.back-to-top-link:hover {
  color: #fff;
}

/* ===== タイトル画面 ===== */
.title-content {
  text-align: center;
  padding: 20px;
}

.game-title {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--sg-brand-pink), var(--sg-brand-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  margin-bottom: 8px;
  animation: titlePulse 2s ease-in-out infinite alternate;
}

@keyframes titlePulse {
  from { filter: brightness(1); transform: scale(1); }
  to { filter: brightness(1.2); transform: scale(1.05); }
}

.game-subtitle {
  font-size: 1rem;
  color: var(--sg-text-muted);
  margin-bottom: 20px;
}

.title-emojis {
  font-size: 2.5rem;
  letter-spacing: 8px;
  margin-bottom: 30px;
  animation: emojiFloat 3s ease-in-out infinite;
}

@keyframes emojiFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.neon-btn {
  padding: 14px 48px;
  font-size: 1.2rem;
  font-weight: 700;
  border: 2px solid var(--sg-brand-cyan);
  border-radius: var(--sg-radius-pill);
  background: transparent;
  color: var(--sg-brand-cyan);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: all 0.3s;
  box-shadow: 0 0 15px rgba(0, 255, 247, 0.3), inset 0 0 15px rgba(0, 255, 247, 0.1);
}

.neon-btn:hover,
.neon-btn:active {
  background: rgba(0, 255, 247, 0.15);
  box-shadow: 0 0 30px rgba(0, 255, 247, 0.5), inset 0 0 20px rgba(0, 255, 247, 0.2);
  transform: scale(1.05);
}

.neon-btn-small {
  padding: 10px 28px;
  font-size: 0.9rem;
}

.key-hint {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--sg-text-muted);
  opacity: 0.7;
}

/* ===== ステージ選択画面 ===== */
.stage-select-content {
  text-align: center;
  padding: 20px;
  width: 100%;
}

.stage-select-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--sg-brand-cyan);
  text-shadow: 0 0 10px rgba(0, 255, 247, 0.5);
  margin-bottom: 20px;
}

.stage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto 20px;
}

.stage-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--sg-radius-md);
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 0.3s;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.stage-card:disabled {
  cursor: not-allowed;
}

.stage-card:hover:not(.stage-locked) {
  border-color: var(--sg-brand-cyan);
  background: rgba(0, 255, 247, 0.08);
  transform: translateX(4px);
}

.stage-card.stage-locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.stage-card.stage-cleared {
  border-color: rgba(57, 255, 20, 0.4);
}

.stage-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 900;
  flex-shrink: 0;
  color: #fff;
}

.stage-info {
  flex: 1;
  min-width: 0;
}

.stage-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}

.stage-card-detail {
  font-size: 0.7rem;
  color: var(--sg-text-muted);
}

.stage-status {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ステージごとのテーマ色（公開順に対応） */
/* 1: 脱出 / 2: かにかに / 3: 経営分析 / 4: ドライバー / 5: うんコーン / 6: かいだん / 7: 進化論 / 8: リバーシ */
.stage-card[data-stage="0"] .stage-number { background: linear-gradient(135deg, #f8bbd0, #e91e63, #ad1457); }
.stage-card[data-stage="1"] .stage-number { background: linear-gradient(135deg, #ffb6c1, #ff69b4, #c2185b); }
.stage-card[data-stage="2"] .stage-number { background: linear-gradient(135deg, #ffe082, #ffb300, #ff8f00); }
.stage-card[data-stage="3"] .stage-number { background: linear-gradient(135deg, #ffe0b2, #ff9800, #e65100); }
.stage-card[data-stage="4"] .stage-number { background: linear-gradient(135deg, #d7ccc8, #8d6e63, #4e342e); }
.stage-card[data-stage="5"] .stage-number { background: linear-gradient(135deg, #b0bec5, #607d8b, #37474f); }
.stage-card[data-stage="6"] .stage-number { background: linear-gradient(135deg, #fff9c4, #fff176, #f9a825); color: #5a4500; }
.stage-card[data-stage="7"] .stage-number {
  background: linear-gradient(135deg, #ce93d8, #9c27b0, #6a1b9a);
  background-size: 200% 200%;
  animation: rainbowBg 2s linear infinite;
  box-shadow: 0 0 18px rgba(156, 39, 176, 0.7);
}

@keyframes rainbowBg {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ===== ゲーム画面 ===== */
#game-screen.active {
  justify-content: flex-start;
  padding: 0;
}

/* --- 背景パルス --- */
#game-screen {
  transition: background-color 0.1s;
}

#game-screen.bg-pulse {
  animation: bgPulse 0.15s ease-out;
}

@keyframes bgPulse {
  0% { background-color: rgba(255, 255, 255, 0.08); }
  100% { background-color: transparent; }
}

/* --- 画面揺れ --- */
.screen-shake {
  animation: screenShake 0.3s ease-out;
}

@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

/* --- HUD --- */
.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10;
  flex-shrink: 0;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-stage-name {
  flex: 1;
  text-align: center;
}

.hud-stage-text {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sg-brand-pink);
  text-shadow: 0 0 8px rgba(255, 110, 199, 0.5);
  letter-spacing: 1px;
}

.hud-label {
  font-size: 0.65rem;
  color: var(--sg-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--sg-brand-cyan);
  text-shadow: 0 0 10px rgba(0, 255, 247, 0.5);
}

/* --- プレイエリア --- */
#play-area {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at top, rgba(255, 255, 255, 0.04), transparent 60%), #0a0010;
  transition: background 0.6s ease;
}

.lane {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 25%;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-sizing: border-box;
  z-index: 2;
}

.lane[data-lane="3"] { border-right: none; }

.lane[data-lane="0"] { left: 0; }
.lane[data-lane="1"] { left: 25%; }
.lane[data-lane="2"] { left: 50%; }
.lane[data-lane="3"] { left: 75%; }

/* --- レーン光波エフェクト --- */
.lane-flash {
  position: absolute;
  bottom: 0;
  width: 25%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  animation: laneFlashUp 0.5s ease-out forwards;
}

.lane-flash[data-lane="0"] { left: 0; }
.lane-flash[data-lane="1"] { left: 25%; }
.lane-flash[data-lane="2"] { left: 50%; }
.lane-flash[data-lane="3"] { left: 75%; }

.lane-flash {
  background: linear-gradient(to top, var(--stage-flash, rgba(0, 255, 247, 0.6)) 0%, transparent 40%);
  mix-blend-mode: screen;
}

@keyframes laneFlashUp {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- パーティクルキャンバス --- */
#particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* --- 判定ライン --- */
#judge-line {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--sg-brand-pink), var(--sg-brand-cyan), var(--sg-brand-pink));
  box-shadow: 0 0 12px rgba(255, 110, 199, 0.6), 0 0 24px rgba(0, 255, 247, 0.4);
  z-index: 5;
  animation: judgeGlow 1.5s ease-in-out infinite alternate;
}

@keyframes judgeGlow {
  from { box-shadow: 0 0 8px rgba(255, 110, 199, 0.4), 0 0 16px rgba(0, 255, 247, 0.3); }
  to { box-shadow: 0 0 20px rgba(255, 110, 199, 0.8), 0 0 40px rgba(0, 255, 247, 0.6); }
}

/* --- ノーツ --- */
.note {
  position: absolute;
  width: 25%;
  text-align: center;
  font-size: 2rem;
  line-height: 1;
  pointer-events: none;
  z-index: 3;
  transition: none;
  will-change: top;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.4));
}

/* --- コンボ炎エフェクト --- */
.note.note-fire {
  filter: drop-shadow(0 0 8px rgba(255, 100, 0, 0.8)) drop-shadow(0 0 16px rgba(255, 60, 0, 0.5));
}

.note.note-rainbow {
  filter: drop-shadow(0 0 8px rgba(255, 0, 255, 0.6)) drop-shadow(0 0 16px rgba(0, 255, 255, 0.6));
  animation: noteRainbow 0.4s linear infinite;
}

@keyframes noteRainbow {
  0% { filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.7)) drop-shadow(0 0 18px rgba(255, 200, 0, 0.5)); }
  33% { filter: drop-shadow(0 0 10px rgba(0, 255, 0, 0.7)) drop-shadow(0 0 18px rgba(0, 200, 255, 0.5)); }
  66% { filter: drop-shadow(0 0 10px rgba(0, 100, 255, 0.7)) drop-shadow(0 0 18px rgba(255, 0, 255, 0.5)); }
  100% { filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.7)) drop-shadow(0 0 18px rgba(255, 200, 0, 0.5)); }
}

/* --- 判定エフェクト --- */
#judge-effect {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}

.judge-text {
  position: absolute;
  font-size: 1.4rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: judgePopUp 0.6s ease-out forwards;
  pointer-events: none;
}

.judge-text.perfect {
  color: transparent;
  background: linear-gradient(90deg, #ff6ec7, #00fff7, #39ff14, #ffff00, #ff6ec7);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: judgePopUp 0.6s ease-out forwards, rainbowShift 0.5s linear infinite;
  text-shadow: none;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
}

.judge-text.great {
  color: var(--sg-brand-yellow);
  text-shadow: 0 0 12px rgba(255, 255, 0, 0.6);
}

.judge-text.miss {
  color: #ff4444;
  text-shadow: 0 0 12px rgba(255, 68, 68, 0.6);
}

@keyframes judgePopUp {
  0% { opacity: 1; transform: translateY(0) scale(1.3); }
  60% { opacity: 1; transform: translateY(-20px) scale(1); }
  100% { opacity: 0; transform: translateY(-40px) scale(0.8); }
}

@keyframes rainbowShift {
  from { background-position: 0% 50%; }
  to { background-position: 200% 50%; }
}

/* --- タップゾーン --- */
#tap-zones {
  display: flex;
  width: 100%;
  flex-shrink: 0;
}

.tap-btn {
  flex: 1;
  height: 64px;
  border: none;
  border-top: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.3);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.tap-btn:nth-child(odd) {
  background: rgba(255, 255, 255, 0.05);
}

.tap-btn:active,
.tap-btn.pressed {
  background: rgba(0, 255, 247, 0.2);
  border-top-color: var(--sg-brand-cyan);
}

/* --- プログレスバー --- */
#progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--sg-brand-pink), var(--sg-brand-cyan));
  transition: width 0.1s linear;
}

/* ===== ステージクリア画面 ===== */
#clear-screen.active {
  justify-content: flex-start;
  padding-top: 30px;
}

.clear-content {
  text-align: center;
  padding: 16px;
  width: 100%;
}

.clear-title {
  font-size: 1.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ffd700, #39ff14, #00fff7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  animation: clearTitleGlow 1s ease-in-out infinite alternate;
}

@keyframes clearTitleGlow {
  from { filter: brightness(1); transform: scale(1); }
  to { filter: brightness(1.3); transform: scale(1.03); }
}

.clear-stage-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--sg-text-muted);
  margin-bottom: 12px;
}

.clear-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

/* --- フルコンボバナー --- */
.fullcombo-banner {
  font-size: 1.4rem;
  font-weight: 900;
  padding: 8px 20px;
  margin: 8px 0;
  border-radius: var(--sg-radius-pill);
  background: linear-gradient(90deg, #ff6ec7, #ffd700, #39ff14, #00fff7, #ff6ec7);
  background-size: 300% 100%;
  color: #fff;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  animation: fullcomboShine 1.5s linear infinite, fullcomboPulse 0.6s ease-in-out infinite alternate;
}

@keyframes fullcomboShine {
  from { background-position: 0% 50%; }
  to { background-position: 300% 50%; }
}

@keyframes fullcomboPulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.fail-hint {
  font-size: 0.85rem;
  color: var(--sg-brand-yellow);
  margin: 12px 0;
  padding: 8px;
  background: rgba(255, 255, 0, 0.08);
  border-radius: var(--sg-radius-sm);
}

/* ===== リザルト画面 ===== */
#result-screen.active {
  justify-content: flex-start;
  padding-top: 30px;
}

.result-content {
  text-align: center;
  padding: 16px;
  width: 100%;
}

.result-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: #ff4444;
  text-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
  margin-bottom: 8px;
}

.result-score {
  margin-bottom: 12px;
}

.result-label {
  display: block;
  font-size: 0.8rem;
  color: var(--sg-text-muted);
  margin-bottom: 4px;
}

.result-value {
  font-size: 2.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--sg-brand-pink), var(--sg-brand-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-details {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.result-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--sg-radius-md);
  min-width: 70px;
}

.detail-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.result-detail.perfect .detail-label {
  background: linear-gradient(90deg, #ff6ec7, #00fff7, #39ff14);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-detail.great .detail-label {
  color: var(--sg-brand-yellow);
}

.result-detail.miss .detail-label {
  color: #ff4444;
}

.result-detail.combo-max .detail-label {
  color: var(--sg-brand-cyan);
}

.detail-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
}

.rank-display {
  font-size: 3rem;
  font-weight: 900;
  margin: 8px 0 12px;
  text-shadow: 0 0 20px currentColor;
}

.rank-display.rank-s { color: #ffd700; }
.rank-display.rank-a { color: var(--sg-brand-cyan); }
.rank-display.rank-b { color: var(--sg-brand-green); }
.rank-display.rank-c { color: var(--sg-brand-yellow); }
.rank-display.rank-d { color: #ff4444; }

/* ===== ノーツ消滅エフェクト ===== */
.note-hit {
  animation: noteHit 0.3s ease-out forwards;
}

@keyframes noteHit {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
  100% { transform: scale(2); opacity: 0; }
}

/* 共通ボタン（音量・シェア）がタップボタンと重ならないよう上にオフセット */
body:has(#game-screen.active) .sg-sound-toggle,
body:has(#game-screen.active) .sg-share-btn {
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

/* ===== レスポンシブ ===== */
@media (max-height: 600px) {
  .game-title { font-size: 1.8rem; }
  .title-emojis { font-size: 2rem; margin-bottom: 20px; }
  .neon-btn { padding: 10px 36px; font-size: 1rem; }
  .tap-btn { height: 50px; }
  .note { font-size: 1.6rem; }
  .stage-card { padding: 8px 12px; }
  .stage-number { width: 32px; height: 32px; font-size: 0.9rem; }
}

@media (max-height: 500px) {
  .game-title { font-size: 1.5rem; }
  .title-emojis { font-size: 1.5rem; letter-spacing: 4px; margin-bottom: 12px; }
  .game-subtitle { font-size: 0.8rem; margin-bottom: 10px; }
  .tap-btn { height: 44px; }
}

@media (min-width: 700px) {
  .screen {
    max-width: 620px;
  }

  #title-screen.active {
    justify-content: flex-start;
    padding-top: clamp(92px, 11vh, 128px);
  }

  #stage-select-screen.active,
  #clear-screen.active,
  #result-screen.active {
    justify-content: flex-start;
    padding-top: 42px;
  }

  .title-content,
  .stage-select-content,
  .clear-content,
  .result-content {
    width: min(100%, 620px);
  }

  .game-title {
    font-size: 3rem;
  }

  .game-subtitle {
    font-size: 1.08rem;
  }

  .title-emojis {
    font-size: 2.7rem;
    margin-bottom: 34px;
  }

  .stage-select-title {
    font-size: 1.9rem;
  }

  .stage-list {
    max-width: 520px;
  }

  .stage-card {
    padding: 14px 18px;
  }

  .game-hud {
    padding: 10px 20px;
  }

  .hud-value {
    font-size: 1.55rem;
  }

  .tap-btn {
    font-size: 1.12rem;
  }
}

@media (min-width: 501px) {
  .tap-btn {
    font-size: 1.1rem;
  }
  .key-hint {
    display: block;
  }
}

@media (max-width: 500px) {
  .key-hint {
    font-size: 0.65rem;
  }
}

/* ===== ステージ背景装飾（ふんわり浮かぶ絵文字） ===== */
#stage-bg-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.bg-emoji {
  position: absolute;
  opacity: 0.18;
  filter: blur(0.3px) drop-shadow(0 0 6px rgba(255, 255, 255, 0.2));
  animation: bgEmojiFloat 8s ease-in-out infinite;
  user-select: none;
}

@keyframes bgEmojiFloat {
  0%, 100% { transform: translateY(0) rotate(-4deg); opacity: 0.12; }
  50% { transform: translateY(-14px) rotate(4deg); opacity: 0.25; }
}

/* ===== ステージ開始バナー ===== */
#stage-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  pointer-events: none;
  text-align: center;
  z-index: 60;
  opacity: 0;
}

#stage-banner.show {
  animation: bannerShow 2s ease-out forwards;
}

@keyframes bannerShow {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6) rotate(-6deg); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(2deg); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9) rotate(0deg); }
}

#stage-banner .banner-num {
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 4px;
}

#stage-banner .banner-name {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1.1;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.3));
}

#stage-banner .banner-detail {
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 4px;
  letter-spacing: 1px;
}

/* ===== ステージ別演出 ===== */
/* 4) リバーシ: 盤目模様オーバーレイ */
#play-area.theme-reversi::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(206, 147, 216, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(206, 147, 216, 0.06) 1px, transparent 1px);
  background-size: 25% 12.5%;
  pointer-events: none;
  z-index: 1;
}

/* 5) かいだん: 揺らめくホラーノイズ */
#play-area.theme-kaidan::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 20%, rgba(150, 100, 255, 0.08), transparent 40%),
    radial-gradient(circle at 70% 80%, rgba(96, 125, 139, 0.1), transparent 50%);
  pointer-events: none;
  z-index: 1;
  animation: horrorFlicker 4s ease-in-out infinite;
}

@keyframes horrorFlicker {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
  52% { opacity: 0.3; }
  54% { opacity: 0.9; }
}

/* 8) ドライブ: 疾走スピードライン */
#play-area.theme-drive::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0,
    transparent 30px,
    rgba(255, 152, 0, 0.08) 30px,
    rgba(255, 152, 0, 0.08) 32px
  );
  pointer-events: none;
  z-index: 1;
  animation: speedLines 0.6s linear infinite;
}

@keyframes speedLines {
  from { background-position: 0 0; }
  to { background-position: 0 32px; }
}

/* 7) かにかに: ピンクパニック */
#play-area.theme-kanikani::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 105, 180, 0.12), transparent 30%),
    radial-gradient(circle at 80% 70%, rgba(194, 24, 91, 0.12), transparent 30%);
  pointer-events: none;
  z-index: 1;
  animation: panicPulse 0.4s ease-in-out infinite alternate;
}

@keyframes panicPulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* 6) うんこ: あたたかい茶色グロー */
#play-area.theme-unko::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 100%, rgba(141, 110, 99, 0.18), transparent 60%);
  pointer-events: none;
  z-index: 1;
}

/* 3) アナリシス: 数字グリッド */
#play-area.theme-analysis::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 179, 0, 0.06) 1px, transparent 1px);
  background-size: 100% 14.28%;
  pointer-events: none;
  z-index: 1;
}

/* 2) シュール進化論: ピクセル */
#play-area.theme-evo::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 241, 118, 0.05) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255, 241, 118, 0.05) 2px, transparent 2px);
  background-size: 16px 16px;
  pointer-events: none;
  z-index: 1;
}

/* 1) 脱出: ピンクハートグロー */
#play-area.theme-escape::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(248, 187, 208, 0.18), transparent 70%);
  pointer-events: none;
  z-index: 1;
}

/* 9) THE MACHINE: 青白い機械グリッド */
#play-area.theme-machine::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(3, 169, 244, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(3, 169, 244, 0.06) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 0%, rgba(3, 169, 244, 0.18), transparent 60%);
  background-size: 24px 24px, 24px 24px, 100% 100%;
  pointer-events: none;
  z-index: 1;
}

/* ===== ステージリストの高さ調整（9ステージ対応） ===== */
.stage-list {
  max-height: calc(100dvh - 200px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 247, 0.4) transparent;
}

.stage-list::-webkit-scrollbar {
  width: 4px;
}

.stage-list::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 247, 0.4);
  border-radius: 2px;
}

@media (max-height: 700px) {
  .stage-card { padding: 8px 12px; }
  .stage-number { width: 32px; height: 32px; font-size: 0.95rem; }
  .stage-card-name { font-size: 0.85rem; }
  .stage-card-detail { font-size: 0.65rem; }
  .stage-list { gap: 6px; }
}

@media (max-height: 600px) {
  .stage-select-title { font-size: 1.3rem; margin-bottom: 12px; }
  .stage-card { padding: 6px 10px; gap: 8px; }
  .stage-number { width: 28px; height: 28px; font-size: 0.8rem; }
  .stage-card-name { font-size: 0.78rem; }
  .stage-card-detail { font-size: 0.6rem; }
  .mode-btn { padding: 4px 6px !important; font-size: 0.62rem !important; min-width: 46px !important; }
}

/* ===== モードボタン（表 / 裏）旧スタイル — 互換のため残置 ===== */
.stage-modes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.mode-btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  padding: 5px 10px;
  min-width: 60px;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 1px;
  border-radius: var(--sg-radius-pill);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.mode-btn:hover:not(:disabled) {
  transform: scale(1.08);
}

.mode-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mode-btn--normal {
  border-color: rgba(0, 255, 247, 0.5);
  color: #a3f9ff;
}

.mode-btn--normal:hover:not(:disabled) {
  background: rgba(0, 255, 247, 0.18);
  box-shadow: 0 0 12px rgba(0, 255, 247, 0.4);
}

.mode-btn--hard {
  border-color: rgba(255, 80, 40, 0.6);
  color: #ffcc88;
  background: linear-gradient(135deg, rgba(255, 60, 0, 0.15), rgba(255, 180, 0, 0.15));
}

.mode-btn--hard:not(:disabled) {
  animation: hardBtnPulse 2s ease-in-out infinite;
}

.mode-btn--hard:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(255, 60, 0, 0.3), rgba(255, 180, 0, 0.3));
  box-shadow: 0 0 16px rgba(255, 100, 0, 0.6);
  color: #ffee99;
}

@keyframes hardBtnPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 100, 0, 0.2); }
  50% { box-shadow: 0 0 16px rgba(255, 100, 0, 0.55); }
}

.stage-card.stage-hard-cleared {
  border-color: rgba(255, 150, 0, 0.5);
  box-shadow: 0 0 12px rgba(255, 100, 0, 0.18);
}

/* ===== 裏モード時のゲーム画面演出 ===== */
#game-screen.hard-mode #play-area::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(255, 40, 20, 0.18) 100%);
  animation: hardVignette 1.2s ease-in-out infinite alternate;
  mix-blend-mode: screen;
}

@keyframes hardVignette {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

#game-screen.hard-mode .note {
  filter: drop-shadow(0 0 8px rgba(255, 80, 0, 0.7)) drop-shadow(0 0 16px rgba(255, 200, 0, 0.4));
}

#game-screen.hard-mode #judge-line {
  height: 5px;
  animation: hardJudgeGlow 0.8s ease-in-out infinite alternate;
}

@keyframes hardJudgeGlow {
  from { box-shadow: 0 0 12px rgba(255, 60, 0, 0.6), 0 0 24px rgba(255, 180, 0, 0.4); }
  to { box-shadow: 0 0 24px rgba(255, 100, 0, 1), 0 0 48px rgba(255, 200, 0, 0.8); }
}

#game-screen.hard-mode .hud-stage-text {
  color: #ff8844;
  text-shadow: 0 0 10px rgba(255, 100, 0, 0.9), 0 0 20px rgba(255, 60, 0, 0.5);
  animation: hardHudBlink 1s ease-in-out infinite alternate;
}

@keyframes hardHudBlink {
  from { filter: brightness(0.95); }
  to { filter: brightness(1.35); }
}

/* 裏モードのステージバナー */
#game-screen.hard-mode #stage-banner .banner-num::before {
  content: '★ ';
  color: #ff6600;
  text-shadow: 0 0 12px rgba(255, 100, 0, 0.8);
}

#game-screen.hard-mode #stage-banner .banner-num::after {
  content: ' ★';
  color: #ff6600;
  text-shadow: 0 0 12px rgba(255, 100, 0, 0.8);
}

#game-screen.hard-mode #stage-banner .banner-num {
  color: #ff8844;
  letter-spacing: 6px;
}

/* ===== カウントダウン（READY→3→2→1→GO） ===== */
#countdown-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: none;
  text-align: center;
  z-index: 70;
  font-family: var(--sg-font-title, sans-serif);
  font-weight: 900;
  font-size: 7rem;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 20px rgba(0, 255, 247, 0.8),
    0 0 40px rgba(255, 110, 199, 0.6),
    0 6px 16px rgba(0, 0, 0, 0.8);
  opacity: 0;
}

#countdown-overlay.tick {
  animation: countdownTick 0.7s ease-out forwards;
}

#countdown-overlay.go {
  animation: countdownGo 0.6s ease-out forwards;
  font-size: 5.5rem;
  background: linear-gradient(90deg, #ff6ec7, #ffd700, #00fff7);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

@keyframes countdownTick {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
  25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  85%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
}

@keyframes countdownGo {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.4); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
}

@media (max-height: 600px) {
  #countdown-overlay { font-size: 5rem; }
  #countdown-overlay.go { font-size: 4rem; }
}

/* ===== 共通オーバーレイ（イントロ・全クリア） ===== */
.sb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  box-sizing: border-box;
  animation: sbOverlayFadeIn 0.4s ease-out;
}

.sb-overlay.hidden {
  display: none;
}

@keyframes sbOverlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sb-overlay-inner {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.97), rgba(250, 245, 240, 0.97));
  border-radius: 18px;
  padding: 18px 18px 16px;
  max-width: 92%;
  max-height: 92%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 0 40px rgba(0, 255, 247, 0.4), 0 12px 32px rgba(0, 0, 0, 0.6);
  animation: sbOverlayPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes sbOverlayPop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.sb-overlay-img {
  max-width: 100%;
  max-height: 60dvh;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  display: block;
}

.sb-overlay .neon-btn {
  margin-top: 4px;
}

/* 全クリア専用の追加演出 */
.sb-overlay-celebrate {
  background: linear-gradient(135deg, rgba(255, 248, 220, 0.97), rgba(255, 235, 200, 0.97));
  border: 3px solid #ffd700;
  box-shadow:
    0 0 60px rgba(255, 215, 0, 0.6),
    0 0 30px rgba(255, 105, 199, 0.4),
    0 12px 32px rgba(0, 0, 0, 0.6);
}

.sb-clear-title {
  font-family: var(--sg-font-title, sans-serif);
  font-size: 1.4rem;
  margin: 0;
  text-align: center;
  background: linear-gradient(90deg, #ff6ec7, #ffd700, #00fff7, #ff6ec7);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sbClearTitleShine 3s linear infinite;
}

@keyframes sbClearTitleShine {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

@media (max-height: 600px) {
  .sb-overlay-img { max-height: 48dvh; }
  .sb-clear-title { font-size: 1.15rem; }
  .sb-overlay-inner { padding: 12px 14px 12px; gap: 8px; }
}

/* ===== モード（表/裏）選択オーバーレイ ===== */
.sb-mode-select-inner {
  background: linear-gradient(135deg, rgba(15, 4, 28, 0.96), rgba(40, 10, 60, 0.96));
  border: 2px solid rgba(0, 255, 247, 0.5);
  box-shadow:
    0 0 40px rgba(0, 255, 247, 0.4),
    0 0 30px rgba(255, 110, 199, 0.3),
    0 12px 32px rgba(0, 0, 0, 0.7);
  color: #fff;
  width: min(92%, 420px);
  padding: 18px 18px 16px;
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mode-select-stage-name {
  font-size: 1.05rem;
  font-weight: 900;
  text-align: center;
  background: linear-gradient(90deg, var(--sg-brand-pink), var(--sg-brand-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.mode-select-chara {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1 1 auto;
  min-height: 100px;
  max-height: 30dvh;
  background: radial-gradient(ellipse at center, rgba(0, 255, 247, 0.1), transparent 70%);
  border-radius: 12px;
}

.mode-select-chara-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 20px rgba(0, 255, 247, 0.45));
  animation: modeSelectFloat 2.4s ease-in-out infinite;
}

.mode-select-chara-emoji {
  font-size: 7rem;
  filter: drop-shadow(0 4px 16px rgba(255, 110, 199, 0.5));
  animation: modeSelectFloat 2.4s ease-in-out infinite;
}

@keyframes modeSelectFloat {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-8px) rotate(1deg); }
}

.mode-select-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
  flex-shrink: 0;
}

.mode-select-btn {
  flex: 1;
  max-width: 160px;
  padding: 14px 20px;
  font-size: 1.3rem;
  letter-spacing: 4px;
}

.mode-select-btn--normal {
  border-color: var(--sg-brand-cyan);
  color: var(--sg-brand-cyan);
}

.mode-select-btn--hard {
  border-color: #ff8844;
  color: #ffcc88;
  box-shadow: 0 0 15px rgba(255, 100, 0, 0.4), inset 0 0 15px rgba(255, 100, 0, 0.15);
  animation: modeHardPulse 2s ease-in-out infinite;
}

.mode-select-btn--hard:hover:not(:disabled),
.mode-select-btn--hard:active:not(:disabled) {
  background: rgba(255, 120, 40, 0.2);
  box-shadow: 0 0 30px rgba(255, 100, 0, 0.6), inset 0 0 20px rgba(255, 100, 0, 0.25);
}

@keyframes modeHardPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 100, 0, 0.4), inset 0 0 15px rgba(255, 100, 0, 0.15); }
  50% { box-shadow: 0 0 24px rgba(255, 100, 0, 0.7), inset 0 0 22px rgba(255, 100, 0, 0.3); }
}

.mode-select-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  animation: none;
}

.mode-select-close-btn {
  margin-top: 4px;
  opacity: 0.8;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

/* ステージカードを <button> 化したのでリセット */
button.stage-card {
  width: 100%;
  font-family: inherit;
  text-align: left;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button.stage-card:disabled {
  cursor: not-allowed;
}

.stage-status {
  font-size: 1rem;
  flex-shrink: 0;
  letter-spacing: 1px;
  min-width: 28px;
  text-align: right;
  color: rgba(255, 255, 255, 0.7);
}

@media (max-height: 600px) {
  .sb-mode-select-inner { padding: 12px 14px 12px; gap: 8px; }
  .mode-select-chara { max-height: 22dvh; min-height: 80px; }
  .mode-select-chara-emoji { font-size: 5rem; }
  .mode-select-btn { font-size: 1.05rem; padding: 10px 14px; letter-spacing: 2px; }
  .mode-select-stage-name { font-size: 0.92rem; }
}
