/* ==========================================
   BeatMerge - Style sheet
   Cyberpunk / Neon theme
   ========================================== */

:root {
  --bg-color: #0b0c16;
  --panel-bg: rgba(18, 20, 38, 0.7);
  --panel-border: rgba(0, 242, 254, 0.2);
  --primary-glow: #00f2fe;
  --secondary-glow: #fe007f;
  --text-color: #ffffff;
  --text-muted: #8b92b0;
  
  /* Neon Note Colors (新カラーパレット: 隣接する色のコントラストを向上) */
  --note-1: #d500f9; /* 16分: 鮮やかな紫 */
  --note-2: #2979ff; /* 8分: 深い青 */
  --note-3: #00e676; /* 4分: ネオングリーン */
  --note-4: #ffd600; /* 2分: ゴールドイエロー */
  --note-5: #ff9100; /* 全音: ビビッドオレンジ */
  --note-6: #ff1744; /* 8分休: 蛍光赤ピンク */
  --note-7: #00e5ff; /* 4分休: シアン/水色 */
  --note-8: #ff4081; /* 2分休: サーモンピンク */
  --note-9: #ffffff; /* ト音記号: ホワイトゴールド */

  --font-main: 'Montserrat', sans-serif;
  --font-digital: 'Orbitron', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.35s ease, color 0.35s ease;
}

/* ==========================================
   Background & Glow Effects
   ========================================== */

#bg-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background: radial-gradient(circle at 30% 30%, rgba(197, 78, 255, 0.1), transparent 50%),
              radial-gradient(circle at 80% 70%, rgba(0, 242, 254, 0.15), transparent 50%);
  pointer-events: none;
  transition: background 1s ease;
}

#fever-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  transition: opacity 0.5s ease;
}

body.fever-mode #bg-glow {
  background: radial-gradient(circle at 50% 50%, rgba(254, 0, 127, 0.2), transparent 70%),
              radial-gradient(circle at 20% 80%, rgba(0, 242, 254, 0.2), transparent 50%);
  animation: bgPulse 2s infinite alternate ease-in-out;
}

body.fever-mode #fever-flash {
  opacity: 0.15;
  animation: strobe 0.5s infinite linear;
}

@keyframes bgPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.1); }
}

@keyframes strobe {
  0%, 100% { background-color: rgba(254, 0, 127, 0.3); }
  50% { background-color: rgba(0, 242, 254, 0.3); }
}

/* ==========================================
   Layout Containers
   ========================================== */

.game-container {
  display: grid;
  grid-template-columns: 280px 450px 280px;
  gap: 20px;
  height: auto;
  padding: 0 20px;
  z-index: 1;
  align-items: start;
}

/* Side Panels */
.side-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  scrollbar-width: none; /* Hide scrollbar for clean UI */
  transition: background 0.35s ease, border-color 0.35s ease;
}

.side-panel::-webkit-scrollbar {
  display: none;
}

.left-panel {
  border-right: 1px solid rgba(0, 242, 254, 0.3);
}

.right-panel {
  border-left: 1px solid rgba(0, 242, 254, 0.3);
}

/* Logo */
.logo {
  font-family: var(--font-digital);
  font-weight: 900;
  font-size: 2rem;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 25px;
  text-shadow: 0 0 10px rgba(0, 242, 254, 0.6);
  user-select: none;
}

.highlight {
  color: var(--primary-glow);
  text-shadow: 0 0 15px var(--primary-glow);
}

body.fever-mode .highlight {
  color: var(--secondary-glow);
  text-shadow: 0 0 15px var(--secondary-glow);
}

/* Panel Sections */
.panel-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 15px;
  transition: background 0.35s ease, border-color 0.35s ease;
}

.panel-section h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-section h2 i {
  color: var(--primary-glow);
}

/* Left Panel - Custom Styles */
.instruction-section ul {
  list-style: none;
}

.instruction-section li {
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 10px;
}

.instruction-section li strong {
  color: var(--primary-glow);
}

.desc-detail {
  color: var(--text-muted);
  font-size: 0.75rem !important;
  padding-left: 10px;
  position: relative;
}

.desc-detail::before {
  content: "▪";
  position: absolute;
  left: 0;
  color: var(--primary-glow);
}

/* Controls */
.control-group {
  margin-bottom: 12px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  margin-bottom: 5px;
  color: var(--text-muted);
}

.control-group input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-glow);
  box-shadow: 0 0 8px var(--primary-glow);
  cursor: pointer;
  transition: transform 0.1s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Right Panel - Custom Styles */
.score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.score-box:last-child {
  margin-bottom: 0;
}

.score-box .label {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.score-box .value {
  font-family: var(--font-digital);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-color);
  letter-spacing: 1px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Fever Gauge */
.fever-gauge-title {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

#fever-status-text {
  color: var(--text-muted);
  transition: color 0.3s;
}

.gauge-container {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

#fever-gauge-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-glow), var(--secondary-glow));
  transition: width 0.15s ease-out;
  border-radius: 6px;
}

#fever-gauge-glow {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.5);
  opacity: 0;
  mix-blend-mode: overlay;
  pointer-events: none;
}

body.fever-mode #fever-status-text {
  color: var(--secondary-glow);
  text-shadow: 0 0 8px var(--secondary-glow);
  animation: pulseText 1s infinite alternate;
}

body.fever-mode #fever-gauge-bar {
  animation: feverBarFlash 0.5s infinite alternate linear;
}

@keyframes pulseText {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

@keyframes feverBarFlash {
  0% { background: var(--secondary-glow); }
  100% { background: #ff7ebb; }
}

/* Next Note Preview */
.next-preview-box {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 130px;
}

#next-canvas {
  filter: drop-shadow(0 0 12px rgba(0, 242, 254, 0.5));
  transition: filter 0.3s ease;
}

body.fever-mode #next-canvas {
  filter: drop-shadow(0 0 15px rgba(254, 0, 127, 0.7));
}

/* Evolution Chain */
.evolution-chain {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  align-items: center;
  justify-items: center;
  font-family: var(--font-digital);
  margin-top: 5px;
}

.evo-item {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-color);
  user-select: none;
  cursor: help;
  transition: all 0.2s ease;
}

.evo-arrow {
  color: var(--text-muted);
  font-size: 0.6rem;
  user-select: none;
}

/* Set evolution border glow based on music note colors */
.evo-item[data-index="1"] { border-color: var(--note-1); text-shadow: 0 0 6px var(--note-1); color: var(--note-1); }
.evo-item[data-index="2"] { border-color: var(--note-2); text-shadow: 0 0 6px var(--note-2); color: var(--note-2); }
.evo-item[data-index="3"] { border-color: var(--note-3); text-shadow: 0 0 6px var(--note-3); color: var(--note-3); }
.evo-item[data-index="4"] { border-color: var(--note-4); text-shadow: 0 0 6px var(--note-4); color: var(--note-4); }
.evo-item[data-index="5"] { border-color: var(--note-5); text-shadow: 0 0 6px var(--note-5); color: var(--note-5); }
.evo-item[data-index="6"] { border-color: var(--note-6); text-shadow: 0 0 6px var(--note-6); color: var(--note-6); }
.evo-item[data-index="7"] { border-color: var(--note-7); text-shadow: 0 0 6px var(--note-7); color: var(--note-7); }
.evo-item[data-index="8"] { border-color: var(--note-8); text-shadow: 0 0 6px var(--note-8); color: var(--note-8); }
.evo-item[data-index="9"] { border-color: var(--note-9); text-shadow: 0 0 6px var(--note-9); color: var(--note-9); font-weight: bold; }

.evo-item:hover {
  transform: scale(1.15);
  box-shadow: 0 0 10px currentColor;
}

/* ==========================================
   Central Game Area & Beat Guide
   ========================================== */

.main-game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 450px;
}

.beat-guide-container {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0 20px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.beat-pulse-half {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary-glow));
  opacity: 0.3;
  transition: opacity 0.1s ease;
}

#beat-pulse-right {
  background: linear-gradient(90deg, var(--primary-glow), transparent);
}

#beat-indicator-wrap {
  width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

#beat-indicator {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--primary-glow);
  box-shadow: 0 0 8px var(--primary-glow);
  transition: transform 0.05s ease-out, background-color 0.05s ease-out;
}

#beat-label {
  font-family: var(--font-digital);
  font-size: 0.6rem;
  margin-top: 4px;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* Beat Flash Keyframes & Helper Classes */
.beat-flash #beat-indicator {
  transform: scale(1.3);
  background-color: var(--primary-glow);
  box-shadow: 0 0 20px var(--primary-glow);
}

.beat-flash .beat-pulse-half {
  opacity: 1;
  height: 3px;
}

body.fever-mode #beat-indicator {
  border-color: var(--secondary-glow);
  box-shadow: 0 0 8px var(--secondary-glow);
}

body.fever-mode .beat-flash #beat-indicator {
  background-color: var(--secondary-glow);
  box-shadow: 0 0 25px var(--secondary-glow);
}

body.fever-mode .beat-flash .beat-pulse-half {
  background: linear-gradient(90deg, transparent, var(--secondary-glow));
}

body.fever-mode #beat-pulse-right.beat-pulse-half {
  background: linear-gradient(90deg, var(--secondary-glow), transparent);
}

/* Drop Preview Line */
#drop-preview-line {
  position: absolute;
  left: 0;
  width: 2px;
  height: 100%;
  top: 0;
  border-left: 1px dashed rgba(255, 255, 255, 0.2);
  pointer-events: none;
  display: none;
  z-index: 10;
}

/* Judge Rating Display */
#judge-rating-display {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  font-family: var(--font-digital);
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 2px;
  pointer-events: none;
  z-index: 20;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#judge-rating-display.show {
  animation: judgePop 0.5s ease-out forwards;
}

@keyframes judgePop {
  0% { transform: translate(-50%, -40%) scale(0.6); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -55%) scale(0.95); opacity: 0; }
}

.judge-perfect { color: #ffe600; text-shadow: 0 0 15px rgba(255, 230, 0, 0.8), 0 0 2px black !important; }
.judge-great { color: #00f2fe; text-shadow: 0 0 12px rgba(0, 242, 254, 0.8), 0 0 2px black !important; }
.judge-good { color: #00ff87; text-shadow: 0 0 8px rgba(0, 255, 135, 0.6), 0 0 2px black !important; }
.judge-miss { color: #ff3c00; text-shadow: 0 0 8px rgba(255, 60, 0, 0.6), 0 0 2px black !important; }

/* Canvas Container */
#canvas-container {
  width: 100%;
  max-width: 450px;
  aspect-ratio: 3 / 4;
  height: auto;
  flex-shrink: 0;
  position: relative;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
  cursor: crosshair;
  transition: border-color 0.3s ease, background 0.35s ease, box-shadow 0.35s ease;
}

#canvas-container canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

body.fever-mode #canvas-container {
  border-color: rgba(254, 0, 127, 0.5);
  box-shadow: inset 0 0 40px rgba(254, 0, 127, 0.2);
}

/* ==========================================
   Overlay UI (Start, GameOver)
   ========================================== */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 12, 22, 0.85);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

.overlay-content {
  text-align: center;
  background: rgba(18, 20, 38, 0.9);
  border: 1px solid rgba(0, 242, 254, 0.3);
  border-radius: 24px;
  padding: 40px 50px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 242, 254, 0.1);
  transform: scale(0.9);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay.active .overlay-content {
  transform: scale(1);
}

.logo-large {
  font-family: var(--font-digital);
  font-weight: 900;
  font-size: 3.5rem;
  letter-spacing: 4px;
  margin-bottom: 15px;
  text-shadow: 0 0 20px rgba(0, 242, 254, 0.7);
  user-select: none;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 30px;
}

.loading-bar-container {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-bottom: 30px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  background: var(--primary-glow);
  box-shadow: 0 0 8px var(--primary-glow);
  width: 0;
  transition: width 0.3s;
}

.btn-primary {
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #0b0c16;
  background: linear-gradient(90deg, #00f2fe, #4facfe);
  border: none;
  border-radius: 30px;
  padding: 14px 40px;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 25px rgba(0, 242, 254, 0.7);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(-1px);
}

.audio-notice {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 15px;
}

/* GameOver Overlay */
#gameover-overlay .overlay-content {
  border-color: rgba(254, 0, 127, 0.3);
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(254, 0, 127, 0.1);
}

.gameover-title {
  font-family: var(--font-digital);
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--secondary-glow);
  text-shadow: 0 0 20px rgba(254, 0, 127, 0.6);
  margin-bottom: 25px;
}

.stats-summary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 30px;
}

.ranking-panel {
  margin: 0 0 24px;
  text-align: left;
}

.ranking-label,
.ranking-title {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.ranking-submit-row {
  display: flex;
  gap: 8px;
}

.ranking-input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-color);
  padding: 10px 12px;
  font: 700 0.9rem var(--font-main);
}

.btn-ranking-submit {
  border: 0;
  border-radius: 8px;
  background: var(--secondary-glow);
  color: #fff;
  cursor: pointer;
  font: 800 0.78rem var(--font-main);
  letter-spacing: 1px;
  padding: 0 12px;
}

.btn-ranking-submit:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ranking-status {
  min-height: 1.2em;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin: 8px 0 12px;
}

.ranking-submitted {
  min-height: 1.2em;
  color: var(--primary-glow);
  font-family: var(--font-digital);
  font-size: 0.78rem;
  margin: 0 0 12px;
}

.ranking-list {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ranking-item,
.ranking-empty {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.8rem;
}

.ranking-rank,
.ranking-score {
  font-family: var(--font-digital);
  color: var(--primary-glow);
}

.ranking-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 1rem;
}

.stat-row:last-child {
  margin-bottom: 0;
}

.stat-row span:first-child {
  color: var(--text-muted);
}

.stat-row span:last-child {
  font-family: var(--font-digital);
  font-weight: 700;
}

#gameover-overlay .btn-primary {
  background: linear-gradient(90deg, #fe007f, #ff7ebb);
  box-shadow: 0 0 15px rgba(254, 0, 127, 0.4);
}

#gameover-overlay .btn-primary:hover {
  box-shadow: 0 5px 25px rgba(254, 0, 127, 0.7);
}

.beatmerge-version {
  margin: 14px 0 0;
  color: var(--text-muted);
  font: 700 0.68rem var(--font-main);
  letter-spacing: 0;
  opacity: 0.72;
  user-select: text;
}

/* ==========================================
   Responsive Adaptation
   ========================================== */

@media (max-width: 1100px) {
  .game-container {
    grid-template-columns: 220px 450px 220px;
    gap: 12px;
    padding: 0 10px;
  }
  .logo { font-size: 1.7rem; }
  .logo-large { font-size: 2.8rem; }
}

@media (max-width: 950px) {
  .game-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    width: 100%;
    height: auto;
    overflow-y: auto;
    padding: 20px 10px;
    justify-items: center;
  }
  body {
    overflow-y: auto;
    overflow-x: hidden;
  }
  .side-panel {
    height: auto;
    width: 100%;
    max-width: 450px;
  }
  .main-game-area {
    width: min(450px, calc(100vw - 20px));
    max-width: 450px;
    min-width: 0;
  }
  #canvas-container {
    width: min(450px, calc(100vw - 20px));
  }
}

/* ==========================================
   Countdown Overlay Styles
   ========================================== */

.countdown-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 12, 22, 0.82);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 30;
  pointer-events: none;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border-radius: 16px;
  transition: all 0.3s ease;
}

.countdown-container.active {
  display: flex;
}

#countdown-text {
  font-family: var(--font-digital);
  font-size: 5rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 0 25px var(--primary-glow);
  transform: scale(0.9);
  animation: countdownPop 0.5s ease-out infinite alternate;
  user-select: none;
}

.countdown-container.fever-start #countdown-text {
  text-shadow: 0 0 35px var(--secondary-glow);
  color: #ffffff;
}

.countdown-container.fever-end #countdown-text {
  text-shadow: 0 0 25px #ff1744;
  color: #ff1744;
}

#countdown-sub {
  font-family: var(--font-main);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text-color);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
  margin-top: 15px;
  text-transform: uppercase;
  user-select: none;
}

@keyframes countdownPop {
  0% { transform: scale(0.9); }
  100% { transform: scale(1.15); }
}

/* ==========================================
   Theme Toggle Button
   文字色・枠線は CSS 変数（--primary-glow / --panel-border）に追従。
   背景・発光はネオンの淡いリテラルティント（ライト時は下の
   html.bm-light 個別ルールで深いシアンへ寄せる）。
   ========================================== */

.theme-toggle-group .btn-theme {
  width: 100%;
  margin-top: 2px;
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--primary-glow);
  background: rgba(0, 242, 254, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease, color 0.35s ease;
}

.theme-toggle-group .btn-theme:hover {
  background: rgba(0, 242, 254, 0.14);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.25);
  transform: translateY(-1px);
}

.theme-toggle-group .btn-theme i {
  color: var(--primary-glow);
}

/* 画面隅の常時表示トグル（スタート画面〜GameOver の全状態で押せる） */
.btn-theme-fixed {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 200; /* overlay(100) / countdown(30) より前面 */
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  color: var(--primary-glow);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.35s ease,
    border-color 0.35s ease, color 0.35s ease;
}

.btn-theme-fixed:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 22px rgba(0, 242, 254, 0.35);
}

.btn-theme-fixed i {
  color: var(--primary-glow);
}

/* ==========================================
   Light Theme — 「明るいサイバー」
   html.bm-light を <html> に付与して有効化。
   サイバー/ネオンのアクセントは維持し、地の色だけ明るくする。
   追加は全て html.bm-light 配下に閉じ、ダーク（クラス無し）は不変。
   ========================================== */

html.bm-light {
  --bg-color: #e9eef7;                       /* 明るい青みグレー */
  --panel-bg: rgba(255, 255, 255, 0.72);
  --panel-border: rgba(0, 152, 190, 0.38);   /* ライト背景でも見えるシアン枠 */
  --primary-glow: #0098be;                   /* やや濃いシアン（可読性とネオン感の両立） */
  --secondary-glow: #e6007a;                 /* やや濃いマゼンタ */
  --text-color: #182039;                     /* 暗紺 */
  --text-muted: #586089;
}

/* 背景グロー: ライト用の淡いパステルへ */
html.bm-light #bg-glow {
  background: radial-gradient(circle at 30% 30%, rgba(0, 152, 190, 0.10), transparent 50%),
              radial-gradient(circle at 80% 70%, rgba(230, 0, 122, 0.07), transparent 50%);
}

html.bm-light body.fever-mode #bg-glow {
  background: radial-gradient(circle at 50% 50%, rgba(230, 0, 122, 0.16), transparent 70%),
              radial-gradient(circle at 20% 80%, rgba(0, 152, 190, 0.16), transparent 50%);
}

/* 白オーバーレイ → 暗オーバーレイへ反転 */
html.bm-light .panel-section {
  background: rgba(20, 28, 56, 0.04);
  border-color: rgba(20, 28, 56, 0.10);
}

html.bm-light .panel-section h2 {
  border-bottom-color: rgba(20, 28, 56, 0.12);
}

html.bm-light .control-group input[type="range"] {
  background: rgba(20, 28, 56, 0.14);
}

html.bm-light .beat-guide-container {
  background: rgba(20, 28, 56, 0.04);
}

html.bm-light .gauge-container {
  background: rgba(20, 28, 56, 0.06);
  border-color: rgba(20, 28, 56, 0.12);
}

/* スコア値の白グロー → 淡いシアングローへ */
html.bm-light .score-box .value {
  text-shadow: 0 0 10px rgba(0, 152, 190, 0.25);
}

/* 進化チップ: 暗いまま維持し、ネオン色を映えさせる（チップ据え置きの設計と一致） */
html.bm-light .evo-item {
  background: rgba(12, 16, 34, 0.62);
  border-color: rgba(20, 28, 56, 0.18);
}

/* 落下プレビューライン */
html.bm-light #drop-preview-line {
  border-left-color: rgba(20, 28, 56, 0.30);
}

/* 盤面: 明るい半透明に。暗いチップが高コントラストで読める */
html.bm-light #canvas-container {
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 30px rgba(20, 28, 56, 0.12);
}

html.bm-light body.fever-mode #canvas-container {
  border-color: rgba(230, 0, 122, 0.55);
  box-shadow: inset 0 0 40px rgba(230, 0, 122, 0.18);
}

/* オーバーレイ（スタート/ゲームオーバー） */
html.bm-light .overlay {
  background: rgba(225, 232, 244, 0.82);
}

html.bm-light .overlay-content {
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 10px 50px rgba(40, 60, 110, 0.18), 0 0 30px rgba(0, 152, 190, 0.12);
}

html.bm-light .loading-bar-container {
  background: rgba(20, 28, 56, 0.10);
}

html.bm-light .stats-summary {
  background: rgba(20, 28, 56, 0.04);
  border-color: rgba(20, 28, 56, 0.08);
}

/* カウントダウン: スクリム（暗幕）を明るく、白文字を暗色化（ライト背景で可読に） */
html.bm-light .countdown-container {
  background: rgba(231, 238, 247, 0.86);
}

html.bm-light #countdown-text {
  color: #182039;
  text-shadow: 0 0 25px var(--primary-glow);
}

html.bm-light .countdown-container.fever-start #countdown-text {
  color: #182039;
  text-shadow: 0 0 30px var(--secondary-glow);
}
/* fever-end（赤文字）はライト背景でも可読のため据え置き */

/* トグルボタンの背景/発光もライトの深いシアンへ寄せる（基底はネオンのリテラル） */
html.bm-light .theme-toggle-group .btn-theme {
  background: rgba(0, 152, 190, 0.07);
}

html.bm-light .theme-toggle-group .btn-theme:hover {
  background: rgba(0, 152, 190, 0.16);
  box-shadow: 0 0 10px rgba(0, 152, 190, 0.28);
}
