/* Piano Tiles 2 - Modern Glassmorphism Styling */

:root {
  --bg-dark: #0a0c16;
  --bg-gradient: radial-gradient(circle at 50% 20%, #171d33 0%, #080a12 100%);
  --neon-cyan: #00e5ff;
  --neon-pink: #ff3366;
  --gold: #ffd700;
  --mint: #38ef7d;
  --glass-bg: rgba(22, 28, 48, 0.72);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-dark);
  background-image: var(--bg-gradient);
  font-family: var(--font-family);
  color: #ffffff;
  touch-action: none;
}

#app-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Stage Area (Aspect Ratio Clamped) */
#game-stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  background: #000;
  box-shadow: 0 0 50px rgba(0, 229, 255, 0.15);
  overflow: hidden;
  /* CSS containment: tells browser this subtree is independent for layout/paint */
  contain: layout style paint;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  /* GPU layer promotion without will-change: contents backing-store overhead */
  transform: translateZ(0);
}

/* Top HUD */
.hud {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate3d(-50%, 0, 0);
  width: 100%;
  max-width: 480px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
  background: linear-gradient(180deg, rgba(10, 12, 22, 0.85) 0%, rgba(10, 12, 22, 0) 100%);
  pointer-events: auto;
  transition: opacity 0.3s ease;
  contain: layout style;
}

.hud.hidden {
  opacity: 0;
  pointer-events: none;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-info {
  display: flex;
  flex-direction: column;
}

.hud-title {
  font-size: 15px;
  font-weight: 700;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.mode-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: fit-content;
  margin-top: 2px;
}

.mode-badge.classic {
  background: rgba(0, 229, 255, 0.2);
  color: var(--neon-cyan);
  border: 1px solid rgba(0, 229, 255, 0.4);
}

.mode-badge.baby {
  background: rgba(255, 126, 179, 0.25);
  color: #ff9ebb;
  border: 1px solid rgba(255, 126, 179, 0.5);
}

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

.hud-score-box {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hud-score {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.hud-combo {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(255, 215, 0, 0.18);
  padding: 1px 6px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.hud-combo.hidden {
  display: none;
}

.hud-progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 140px;
  margin-top: 4px;
}

.hud-stars {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.25);
  margin-bottom: 2px;
}

.star-icon.earned {
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold);
  transform: scale(1.15);
}

.progress-bar-bg {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--mint));
  border-radius: 4px;
  transform-origin: left center;
  transform: scaleX(0);
  /* GPU-composited scaleX avoids layout thrashing on iOS Safari */
  transition: transform 0.2s ease;
  will-change: transform;
}

.icon-btn {
  background: rgba(18, 24, 42, 0.78);
  border: 1px solid var(--glass-border);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  /* backdrop-filter removed: blurring live canvas behind HUD causes severe iOS Safari jank */
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* Modals & Overlays */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 6, 12, 0.88);
  /* backdrop-filter removed: causes severe jank on iPhone 8/12 Safari */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  opacity: 1;
  transition: opacity 0.25s ease;
  padding: 16px;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.glass-modal {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 24px;
  width: 100%;
  max-width: 440px;
  color: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Catalog Modal */
.catalog-modal {
  max-height: 92vh;
  padding: 12px 14px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-text {
  min-width: 0;
}

.logo-tile {
  font-size: 22px;
  background: linear-gradient(135deg, #00e5ff 0%, #0d47a1 100%);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 12px rgba(0, 229, 255, 0.3);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.brand-text .tagline {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.theme-toggle-pill {
  padding: 4px 10px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle-pill .theme-icon {
  font-size: 13px;
  line-height: 1;
}

.theme-toggle-pill.light {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.95);
  color: #0f172a;
  box-shadow: 0 2px 10px rgba(255, 215, 0, 0.28);
}

.theme-toggle-pill.dark {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.42);
  color: #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.theme-toggle-pill:hover {
  transform: scale(1.04);
}

.theme-toggle-pill:active {
  transform: scale(0.96);
}

.total-stars-pill {
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.35);
  padding: 4px 10px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-size: 13px;
  color: var(--gold);
}

/* Mode Switch Tabs */
.mode-switch-wrapper {
  margin-bottom: 6px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px;
  border-radius: 14px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  padding: 7px 10px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mode-btn .icon {
  font-size: 17px;
  line-height: 1;
}

.mode-btn-text {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.mode-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.75);
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  margin-left: auto;
  transition: all 0.2s;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.mode-info-icon:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

.mode-info-popover {
  margin-top: 6px;
  background: rgba(15, 20, 38, 0.96);
  border: 1px solid rgba(0, 229, 255, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: fadeInDown 0.2s ease;
}

.mode-info-popover.hidden {
  display: none;
}

.mode-info-text {
  flex: 1;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.9);
}

.mode-info-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
}

.mode-info-close:hover {
  color: #fff;
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.25) 0%, rgba(20, 50, 90, 0.4) 100%);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#mode-tab-baby.active {
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.3) 0%, rgba(90, 20, 60, 0.4) 100%);
  border-color: rgba(255, 126, 179, 0.5);
}

/* Speed Control Stepper-Slider: Ultra-compact Panel */
.speed-control-panel {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 5px 8px;
  margin-bottom: 6px;
  transition: all 0.3s ease;
}

.speed-control-panel:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}

.speed-control-panel.baby {
  border-color: rgba(255, 126, 179, 0.25);
}

.speed-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  padding: 0 2px;
}

.speed-level-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-title {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
}

.speed-badge {
  background: rgba(0, 229, 255, 0.15);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: #00f2fe;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.2);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.speed-control-panel.baby .speed-badge,
.pause-speed-control.baby .speed-badge {
  background: rgba(255, 126, 179, 0.2);
  border-color: rgba(255, 126, 179, 0.5);
  color: #ff7eb3;
  box-shadow: 0 0 8px rgba(255, 126, 179, 0.2);
}

.miss-toggle-header {
  display: flex;
  align-items: center;
  gap: 4px;
}

.miss-toggle-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
}

.miss-info-icon {
  margin-left: 0;
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  font-size: 10px;
}

.speed-stepper-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.speed-step-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.2s, border-color 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.speed-step-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
}

.speed-step-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.25);
}

.speed-slider-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.speed-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
}

.speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00f2fe, #4facfe);
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.6);
  transition: transform 0.1s;
}

.speed-slider::-webkit-slider-thumb:active {
  transform: scale(1.15);
}

.speed-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00f2fe, #4facfe);
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.6);
  transition: transform 0.1s;
}

.speed-control-panel.baby .speed-slider::-webkit-slider-thumb,
.pause-speed-control.baby .speed-slider::-webkit-slider-thumb {
  background: linear-gradient(135deg, #ff7eb3, #ff758c);
  box-shadow: 0 0 10px rgba(255, 126, 179, 0.6);
}

.speed-control-panel.baby .speed-slider::-moz-range-thumb,
.pause-speed-control.baby .speed-slider::-moz-range-thumb {
  background: linear-gradient(135deg, #ff7eb3, #ff758c);
  box-shadow: 0 0 10px rgba(255, 126, 179, 0.6);
}

.speed-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  padding: 0 4px;
  font-weight: 600;
}

/* Pause dialog speed control */
.pause-speed-control {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 8px 10px;
  margin: 10px 0 14px 0;
  text-align: left;
}

/* Miss Toggle Group & Fixed-Size Switch (Always Shown) */
.miss-toggle-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}

.miss-toggle-label {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

.fixed-toggle-switch {
  width: 66px;
  height: 28px;
  min-width: 66px;
  max-width: 66px;
  min-height: 28px;
  max-height: 28px;
  border-radius: 14px;
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 0;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.4);
  transition: all 0.25s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  box-sizing: border-box;
}

.fixed-toggle-switch .switch-knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  z-index: 2;
  line-height: 1;
}

.fixed-toggle-switch .switch-state-text {
  position: absolute;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  z-index: 1;
  line-height: 1;
}

/* Safe State: TẮT */
.fixed-toggle-switch.safe {
  background: rgba(0, 229, 255, 0.12);
  border-color: rgba(0, 229, 255, 0.45);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.15);
}

.fixed-toggle-switch.safe .switch-knob {
  transform: translateX(0);
  background: #e0faff;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

.fixed-toggle-switch.safe .switch-state-text {
  right: 7px;
  left: auto;
  color: #00f2fe;
}

/* Danger State: BẬT */
.fixed-toggle-switch.danger {
  background: rgba(255, 71, 87, 0.18);
  border-color: rgba(255, 71, 87, 0.65);
  box-shadow: 0 0 10px rgba(255, 71, 87, 0.25);
}

.fixed-toggle-switch.danger .switch-knob {
  transform: translateX(38px);
  background: #fff0f2;
  box-shadow: 0 0 8px rgba(255, 71, 87, 0.5);
}

.fixed-toggle-switch.danger .switch-state-text {
  left: 7px;
  right: auto;
  color: #ff4757;
}

.fixed-toggle-switch:hover {
  filter: brightness(1.15);
}

.fixed-toggle-switch:active .switch-knob {
  transform: scale(0.9);
}
.fixed-toggle-switch.danger:active .switch-knob {
  transform: translateX(38px) scale(0.9);
}

/* Category Filter Pills */
.category-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.cat-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cat-pill.active {
  background: #ffffff;
  color: #0a0c16;
  border-color: #ffffff;
}

/* Song Catalog Grid */
.songs-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 58vh;
  padding-right: 4px;
}

.songs-grid::-webkit-scrollbar {
  width: 5px;
}

.songs-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.song-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 9px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
}

.song-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(0, 229, 255, 0.35);
  transform: translateY(-2px);
}

.song-details h3 {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 2px;
}

.song-artist {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 6px;
}

.song-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
}

.song-stars {
  color: rgba(255, 255, 255, 0.3);
  font-size: 13px;
  letter-spacing: 2px;
}

.song-stars .earned {
  color: var(--gold);
}

.song-high-score {
  color: var(--mint);
  font-weight: 600;
}

.play-action-btn {
  background: linear-gradient(135deg, var(--neon-cyan), #0072ff);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  box-shadow: 0 4px 14px rgba(0, 229, 255, 0.4);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.play-action-btn:hover {
  transform: scale(1.1);
}

.keyboard-guide {
  margin-top: 14px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
}

.ios-sound-tip {
  margin-top: 6px;
  font-size: 11px;
  color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 215, 0, 0.2);
}

kbd {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-family: monospace;
}

/* Small Modal (Pause) */
.small-modal {
  padding: 28px 24px;
  text-align: center;
}

.small-modal h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 20px;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.primary-btn {
  background: linear-gradient(135deg, var(--neon-cyan), #0072ff);
  border: none;
  color: #fff;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.35);
  transition: all 0.2s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 229, 255, 0.5);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: #fff;
  padding: 13px 20px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.text-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  padding: 8px;
  font-size: 14px;
  cursor: pointer;
}

/* Result Modal */
.result-modal {
  padding: 26px 22px;
  text-align: center;
}

.result-icon {
  font-size: 48px;
  margin-bottom: 8px;
  animation: bounce 1.2s ease 3; /* Limited to 3 bounces instead of infinite */
}

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

.result-modal h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.result-modal p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 16px;
}

.result-stars {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 32px;
  color: rgba(255, 255, 255, 0.2);
  margin-bottom: 18px;
}

.res-star.earned {
  color: var(--gold);
  text-shadow: 0 0 16px var(--gold);
  animation: popIn 0.4s ease-out;
}

@keyframes popIn {
  0% { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.3); }
  100% { transform: scale(1.0); opacity: 1; }
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-card {
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 6px;
  border-radius: 12px;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 2px;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.new-record-banner {
  background: linear-gradient(90deg, #ff416c, #ff4b2b);
  padding: 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(255, 65, 108, 0.4);
}

.new-record-banner.hidden {
  display: none;
}

/* Start Prompt for First Note */
.start-prompt {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 229, 255, 0.2);
  border: 1px solid var(--neon-cyan);
  color: #fff;
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
  animation: pulsePrompt 1.2s infinite;
  z-index: 15;
}

.start-prompt.hidden {
  display: none;
}

@keyframes pulsePrompt {
  0%, 100% { opacity: 0.8; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.06); }
}

/* Light In-Game Background Theme Overrides */
#app-container.game-bg-light #game-stage {
  background: #f4f7fc;
  box-shadow: 0 0 40px rgba(15, 23, 42, 0.35);
}

#app-container.game-bg-light .hud {
  background: linear-gradient(180deg, rgba(244, 247, 252, 0.92) 0%, rgba(244, 247, 252, 0) 100%);
  color: #0f172a;
}

#app-container.game-bg-light .hud-title {
  color: #0f172a;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.85);
}

#app-container.game-bg-light .hud-score {
  color: #0f172a;
  text-shadow: 0 1px 6px rgba(255, 255, 255, 0.9);
}

#app-container.game-bg-light .hud-combo {
  color: #b45309;
  background: rgba(245, 158, 11, 0.2);
}

#app-container.game-bg-light .hud-stars {
  color: rgba(15, 23, 42, 0.22);
}

#app-container.game-bg-light .star-icon.earned {
  color: #eab308;
  text-shadow: 0 0 6px rgba(234, 179, 8, 0.45);
}

#app-container.game-bg-light .progress-bar-bg {
  background: rgba(15, 23, 42, 0.14);
}

#app-container.game-bg-light .icon-btn {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(15, 23, 42, 0.15);
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

#app-container.game-bg-light .icon-btn:hover {
  background: rgba(255, 255, 255, 1);
}

#app-container.game-bg-light .mode-badge.classic {
  background: rgba(2, 132, 199, 0.14);
  color: #0369a1;
  border-color: rgba(2, 132, 199, 0.35);
}

#app-container.game-bg-light .mode-badge.baby {
  background: rgba(236, 72, 153, 0.14);
  color: #be185d;
  border-color: rgba(236, 72, 153, 0.35);
}

#app-container.game-bg-light .start-prompt {
  background: rgba(15, 23, 42, 0.85);
  border-color: #0284c7;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.25);
}
