:root {
  --text-scale: 1;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #7EC8E3;
  margin: 0;
  overflow: hidden;
  font-family: 'Patrick Hand', 'Comic Neue', cursive, sans-serif;
  color: #3D3522;
}

#game-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #7EC8E3;
}

#game-canvas {
  display: block;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ── HUD ── */

#hud {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

#score {
  font-size: calc(52px * var(--text-scale));
  font-weight: 700;
  letter-spacing: 2px;
  display: block;
  line-height: 1;
  color: #FFF8E7;
  text-shadow: 3px 3px 0 #3D3522, -1px -1px 0 #3D3522, 1px -1px 0 #3D3522, -1px 1px 0 #3D3522;
  animation: scoreWobble 3s ease-in-out infinite;
}

@keyframes scoreWobble {
  0%, 100% { transform: rotate(-1deg); }
  50% { transform: rotate(1deg); }
}

#hud-label {
  font-size: calc(14px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 4px;
  color: #FFF8E7;
  opacity: 0.8;
  text-shadow: 1px 1px 0 #3D3522;
}

/* ── Combo Counter ── */

#combo-counter {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 15;
  animation: comboFadeOut 2s ease-out forwards;
}

#combo-text {
  font-size: calc(36px * var(--text-scale));
  font-weight: bold;
  color: #FF6B35;
  text-shadow: 3px 3px 0 #3D3522;
  letter-spacing: 2px;
  text-transform: uppercase;
}

@keyframes comboFadeOut {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.3) rotate(-3deg);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(2deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.8) rotate(-1deg);
  }
}

/* ── Help Button (in-game) ── */

#help-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  font-weight: bold;
  border-radius: 50%;
  border: 3px solid #3D3522;
  background: #FFD166;
  color: #3D3522;
  cursor: pointer;
  z-index: 5;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  font-family: 'Patrick Hand', cursive;
  box-shadow: 2px 2px 0 #3D3522;
}

#help-btn:hover {
  background: #FFE49C;
  transform: scale(1.1) rotate(5deg);
}

/* ── Overlay Screens ── */

#start-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255, 248, 231, 0.94);
  z-index: 10;
}

.screen-art {
  font-size: 44px;
  letter-spacing: 4px;
  margin-bottom: 16px;
  color: #2E86AB;
  font-family: 'Patrick Hand', cursive;
  animation: bob 2s ease-in-out infinite;
}

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

#start-screen h1 {
  font-size: clamp(28px, 8vw, 48px);
  font-weight: 700;
  letter-spacing: 3px;
  margin-bottom: 10px;
  color: #2E86AB;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.1);
  animation: titleWobble 4s ease-in-out infinite;
}

@keyframes titleWobble {
  0%, 100% { transform: rotate(-1deg); }
  25% { transform: rotate(0.5deg); }
  50% { transform: rotate(1deg); }
  75% { transform: rotate(-0.5deg); }
}

#start-screen p {
  font-size: 17px;
  color: #5a4e3a;
  opacity: 0.8;
  margin-bottom: 28px;
  max-width: 320px;
  text-align: center;
  line-height: 1.6;
}

/* ── High Score Displays ── */

.highscore-display {
  font-size: 16px;
  color: #5a4e3a;
  margin-bottom: 24px;
  text-align: center;
  letter-spacing: 1px;
}

.highscore-display span {
  color: #FF6B35;
  font-weight: bold;
  font-size: 20px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  padding: 0 16px;
  box-sizing: border-box;
}

button {
  background: #FFD166;
  border: 3px solid #3D3522;
  color: #3D3522;
  padding: 10px 16px;
  font-size: clamp(12px, 3.5vw, 16px);
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.15s;
  font-family: 'Patrick Hand', cursive;
  box-shadow: 3px 3px 0 #3D3522;
  position: relative;
}

button:hover {
  background: #FFE49C;
  transform: translateY(-2px) rotate(1deg);
  box-shadow: 4px 5px 0 #3D3522;
}

button:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 #3D3522;
}

button:focus-visible {
  outline: 3px solid #2E86AB;
  outline-offset: 2px;
}

.arcade-btn:focus-visible {
  outline: 3px solid #00ff88;
  outline-offset: 2px;
}

.lb-tab:focus-visible {
  outline: 3px solid #2E86AB;
  outline-offset: -2px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: 2px 2px 0 #3D3522;
}

button:disabled:hover {
  transform: none;
  box-shadow: 2px 2px 0 #3D3522;
}

.arcade-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  text-shadow: none;
}

.arcade-btn:disabled:hover {
  background: #1a1a2e;
  color: #00ff88;
  transform: none;
  box-shadow: none;
}

#start-btn {
  background: #06D6A0;
  font-size: 18px;
  padding: 14px 40px;
  grid-column: 1 / -1;
}

#start-btn:hover {
  background: #33e0b5;
}

#learn-btn {
  background: #118AB2;
  color: #FFF8E7;
}

#learn-btn:hover {
  background: #1a9ec8;
}

#retry-btn {
  background: #06D6A0;
  font-size: 18px;
  padding: 14px 40px;
}

#retry-btn:hover {
  background: #33e0b5;
}

/* ── Instructions Popup ── */

#instructions {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 248, 231, 0.96);
  z-index: 20;
  animation: fadeIn 0.2s ease-out;
}

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

#instructions-inner {
  background: #FFF8E7;
  border: 3px solid #3D3522;
  border-radius: 16px;
  padding: 36px 32px 28px;
  max-width: 420px;
  width: 90%;
  position: relative;
  box-shadow: 5px 5px 0 #C4956A;
}

#instructions-inner h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 24px;
  text-align: center;
  color: #2E86AB;
}

#close-instructions {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 22px;
  border: 2px solid #3D3522;
  color: #3D3522;
  background: #E84855;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 2px 2px 0 #3D3522;
  line-height: 1;
}

#close-instructions:hover {
  background: #f06070;
  transform: rotate(10deg);
}

.step {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #FFD166;
  border: 2px solid #3D3522;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: bold;
  color: #3D3522;
  margin-top: 1px;
  box-shadow: 2px 2px 0 #3D3522;
}

.step-body {
  flex: 1;
}

.step-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 3px;
  color: #3D3522;
}

.step-desc {
  font-size: 14px;
  line-height: 1.5;
  color: #5a4e3a;
  opacity: 0.8;
}

#got-it-btn {
  display: block;
  margin: 24px auto 0;
  padding: 10px 48px;
  background: #06D6A0;
}

/* ── Retro Arcade: Shared ── */

.crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.06) 0px,
    rgba(0, 0, 0, 0.06) 1px,
    transparent 1px,
    transparent 3px
  );
}

.arcade-panel {
  background: #0a0a1a;
  border: 3px solid #333;
  border-radius: 18px;
  padding: 32px 28px 24px;
  max-width: 420px;
  width: 92%;
  position: relative;
  z-index: 3;
  box-shadow:
    0 0 30px rgba(0, 255, 100, 0.15),
    0 0 60px rgba(0, 255, 100, 0.05),
    inset 0 0 80px rgba(0, 0, 0, 0.5),
    0 0 2px 1px rgba(100, 200, 255, 0.3);
  font-family: 'Press Start 2P', monospace;
}

.arcade-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 22px;
  letter-spacing: 3px;
  text-align: center;
  margin-bottom: 24px;
  color: #00ff88;
  text-shadow:
    0 0 10px #00ff88,
    0 0 20px #00ff88,
    0 0 40px #00cc66,
    0 0 80px #009944;
}

@keyframes neonFlicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
    text-shadow:
      0 0 10px #00ff88,
      0 0 20px #00ff88,
      0 0 40px #00cc66,
      0 0 80px #009944;
    opacity: 1;
  }
  20%, 24%, 55% {
    text-shadow: none;
    opacity: 0.8;
  }
}

.neon-flicker {
  animation: neonFlicker 3s infinite;
}

@keyframes crtFlicker {
  0% { opacity: 1; }
  3% { opacity: 0.4; }
  6% { opacity: 1; }
  7% { opacity: 0.7; }
  9% { opacity: 1; }
  100% { opacity: 1; }
}

.crt-flicker {
  animation: crtFlicker 4s infinite;
}

.arcade-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  background: #1a1a2e;
  color: #00ff88;
  border: 2px solid #00ff88;
  border-radius: 8px;
  padding: 10px 24px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow:
    0 0 8px rgba(0, 255, 136, 0.3),
    inset 0 0 8px rgba(0, 255, 136, 0.1);
  transition: all 0.15s;
  text-shadow: 0 0 6px #00ff88;
}

.arcade-btn:hover {
  background: #00ff88;
  color: #0a0a1a;
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
  transform: translateY(-1px);
  text-shadow: none;
}

.arcade-btn:active {
  transform: translateY(1px);
  box-shadow: 0 0 4px rgba(0, 255, 136, 0.3);
}

.arcade-btn-primary {
  color: #ff2266;
  border-color: #ff2266;
  text-shadow: 0 0 6px #ff2266;
  box-shadow:
    0 0 8px rgba(255, 34, 102, 0.3),
    inset 0 0 8px rgba(255, 34, 102, 0.1);
}

.arcade-btn-primary:hover {
  background: #ff2266;
  color: #0a0a1a;
  box-shadow: 0 0 20px rgba(255, 34, 102, 0.6);
  text-shadow: none;
}

.arcade-btn-small {
  font-size: 0.7em;
  padding: 6px 14px;
}

.arcade-btn-ghost {
  opacity: 0.6;
  border-style: dashed;
}

.arcade-btn-ghost:hover {
  opacity: 1;
}

#remove-ads-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

.arcade-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 16px;
  font-family: 'Press Start 2P', monospace;
  border: 2px solid #ff2266;
  color: #ff2266;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 34, 102, 0.3);
  line-height: 1;
  z-index: 5;
  transition: all 0.15s;
}

.arcade-close:hover {
  background: #ff2266;
  color: #0a0a1a;
  text-shadow: none;
}

@keyframes blinkText {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.insert-coin {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #ffcc00;
  text-align: center;
  margin: 16px 0 12px;
  letter-spacing: 3px;
  animation: blinkText 1s infinite;
  text-shadow: 0 0 8px #ffcc00, 0 0 16px #ff8800;
}

.arcade-loading {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #00ff88;
  text-align: center;
  opacity: 0.6;
  animation: blinkText 1s infinite;
}

/* ── Leaderboard Overlay ── */

#leaderboard-screen {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 248, 231, 0.96);
  z-index: 20;
  animation: fadeIn 0.2s ease-out;
}

#leaderboard-inner {
  background: #FFF8E7;
  border: 3px solid #3D3522;
  border-radius: 16px;
  padding: 36px 32px 28px;
  max-width: 420px;
  width: 90%;
  position: relative;
  box-shadow: 5px 5px 0 #C4956A;
}

#leaderboard-inner h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 24px;
  text-align: center;
  color: #2E86AB;
}

#close-leaderboard {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 22px;
  border: 2px solid #3D3522;
  color: #3D3522;
  background: #E84855;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 2px 2px 0 #3D3522;
  line-height: 1;
}

#close-leaderboard:hover {
  background: #f06070;
  transform: rotate(10deg);
}

.lb-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 3px solid rgba(61, 53, 34, 0.15);
}

.lb-tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: #5a4e3a;
  opacity: 0.5;
  cursor: pointer;
  box-shadow: none;
  margin-bottom: -3px;
  transition: all 0.15s;
  letter-spacing: 1px;
}

.lb-tab:hover {
  opacity: 0.8;
  background: transparent;
  transform: none;
  box-shadow: none;
}

.lb-tab:active {
  transform: none;
  box-shadow: none;
}

.lb-tab-active {
  opacity: 1;
  color: #2E86AB;
  border-bottom-color: #2E86AB;
}

.lb-tab-active:hover {
  opacity: 1;
}

#leaderboard-list {
  max-height: 340px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.lb-loading {
  text-align: center;
  color: #5a4e3a;
  opacity: 0.7;
  font-size: 15px;
}

#leaderboard-back {
  display: block;
  margin: 0 auto;
  padding: 10px 48px;
  background: #06D6A0;
}

.lb-entry {
  display: flex;
  align-items: center;
  padding: 8px 6px;
  font-size: 15px;
  color: #3D3522;
  border-bottom: 1px solid rgba(61, 53, 34, 0.12);
}

.lb-entry.lb-highlight {
  background: rgba(255, 209, 102, 0.25);
  border-radius: 8px;
  font-weight: 700;
}

.lb-rank {
  width: 36px;
  text-align: center;
  flex-shrink: 0;
  font-weight: 700;
}

.lb-rank-1 { color: #d4a017; }
.lb-rank-2 { color: #8a8a8a; }
.lb-rank-3 { color: #b5651d; }

.lb-name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 600;
}

.lb-dots {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  color: rgba(61, 53, 34, 0.2);
  letter-spacing: 2px;
  margin: 0 4px;
}

.lb-score {
  text-align: right;
  flex-shrink: 0;
  color: #FF6B35;
  font-weight: 700;
}

/* ── Game Over Screen ── */

#game-over-screen {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.92);
  z-index: 10;
  padding: 16px;
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.gameover-panel {
  text-align: center;
  max-width: 400px;
  width: 100%;
  padding: 20px 16px;
  box-sizing: border-box;
}

.gameover-title {
  font-family: 'Press Start 2P', monospace;
  font-size: calc(clamp(18px, 5vw, 28px) * var(--text-scale));
  color: #ff2266;
  text-shadow:
    0 0 10px #ff2266,
    0 0 30px #ff0044,
    0 0 60px #cc0033;
  margin-bottom: 20px;
  letter-spacing: 4px;
}

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

.gameover-score-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #aaa;
  letter-spacing: 4px;
  margin-bottom: 6px;
}

.gameover-score-value {
  font-family: 'Press Start 2P', monospace;
  font-size: calc(32px * var(--text-scale));
  color: #00ffcc;
  text-shadow: 0 0 10px #00ffcc, 0 0 30px #00aa88;
}

.new-record {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: #ffd700;
  text-shadow: 0 0 10px #ffd700, 0 0 30px #ffaa00;
  animation: blinkText 0.5s infinite;
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.gameover-stats {
  margin: 16px 0;
  text-align: left;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: calc(9px * var(--text-scale));
}

.stat-label {
  color: #888;
}

.stat-value {
  color: #00ff88;
  text-shadow: 0 0 4px #00ff88;
}

/* Arcade initial picker */
.arcade-name-prompt {
  margin: 16px 0;
}

.arcade-name-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #aaa;
  letter-spacing: 2px;
  margin-bottom: 12px;
  text-align: center;
}

.arcade-initials-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.arcade-initial {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.arcade-initial .init-char {
  font-family: 'Press Start 2P', monospace;
  font-size: 24px;
  color: #00ff88;
  text-shadow: 0 0 8px #00ff88;
  width: 32px;
  text-align: center;
  display: block;
}

.arcade-initial button {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: transparent;
  border: 1px solid rgba(0, 255, 136, 0.3);
  color: #00ff88;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  box-shadow: none;
  transition: all 0.1s;
}

.arcade-initial button:hover {
  background: rgba(0, 255, 136, 0.15);
  border-color: #00ff88;
  transform: none;
  box-shadow: 0 0 6px rgba(0, 255, 136, 0.3);
}

.gameover-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.gameover-buttons .arcade-btn {
  font-size: calc(clamp(8px, 2.5vw, 11px) * var(--text-scale));
  padding: 10px 12px;
  min-width: 0;
  width: 100%;
}

.gameover-buttons .arcade-btn-primary {
  grid-column: 1 / -1;
}

/* Leaderboard button on start screen - match "How to Play" style */
#leaderboard-btn {
  background: #118AB2;
  color: #FFF8E7;
}

#leaderboard-btn:hover {
  background: #1a9ec8;
}

/* Score count-up animation helper */
@keyframes scoreCountPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.score-counting {
  animation: scoreCountPulse 0.1s ease-in-out;
}

/* ── Labs Screen ── */

#labs-btn {
  background: #9B5DE5;
  color: #FFF8E7;
  font-size: 14px;
}

#labs-btn:hover {
  background: #b07ae8;
}

#labs-screen {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 248, 231, 0.96);
  z-index: 20;
  animation: fadeIn 0.2s ease-out;
}

#labs-inner {
  background: #FFF8E7;
  border: 3px solid #3D3522;
  border-radius: 16px;
  padding: 36px 28px 24px;
  max-width: 420px;
  width: 90%;
  position: relative;
  box-shadow: 5px 5px 0 #9B5DE5;
}

#labs-inner h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 6px;
  text-align: center;
  color: #9B5DE5;
}

.labs-subtitle {
  font-size: 14px;
  color: #5a4e3a;
  opacity: 0.7;
  text-align: center;
  margin-bottom: 20px;
}

#close-labs {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 22px;
  border: 2px solid #3D3522;
  color: #3D3522;
  background: #E84855;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 2px 2px 0 #3D3522;
  line-height: 1;
}

#close-labs:hover {
  background: #f06070;
  transform: rotate(10deg);
}

#labs-toggles {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.labs-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f5edd6;
  border: 2px solid rgba(61, 53, 34, 0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.labs-toggle:hover {
  border-color: #9B5DE5;
  background: #f0e6cc;
}

.labs-toggle-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  pointer-events: none;
}

.labs-toggle-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.labs-toggle-name {
  font-size: 15px;
  font-weight: 700;
  color: #3D3522;
  line-height: 1.2;
}

.labs-toggle-desc {
  font-size: 12px;
  color: #5a4e3a;
  opacity: 0.7;
  line-height: 1.3;
}

.labs-toggle input[type="checkbox"] {
  display: none;
}

.labs-switch {
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  background: #c4b99a;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
  pointer-events: none;
  border: 2px solid rgba(61, 53, 34, 0.2);
}

.labs-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #FFF8E7;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 1px 1px 0 rgba(61, 53, 34, 0.2);
}

.labs-toggle input[type="checkbox"]:checked + .labs-switch {
  background: #9B5DE5;
  border-color: #7a3ec4;
}

.labs-toggle input[type="checkbox"]:checked + .labs-switch::after {
  transform: translateX(20px);
}

.labs-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#labs-active-count {
  font-size: 13px;
  color: #9B5DE5;
  font-weight: 600;
  letter-spacing: 1px;
}

.labs-divider {
  height: 2px;
  background: rgba(61, 53, 34, 0.12);
  margin: 4px 0 14px;
}

.text-scale-section {
  margin-bottom: 16px;
}

.text-scale-label {
  font-size: 15px;
  font-weight: 700;
  color: #3D3522;
  margin-bottom: 8px;
}

.text-scale-buttons {
  display: flex;
  gap: 8px;
}

.text-scale-btn {
  flex: 1;
  padding: 8px 4px;
  font-size: 14px;
  font-weight: 700;
  background: #f5edd6;
  border: 2px solid rgba(61, 53, 34, 0.15);
  border-radius: 8px;
  color: #3D3522;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: none;
  text-align: center;
}

.text-scale-btn:hover {
  border-color: #9B5DE5;
  background: #f0e6cc;
  transform: none;
  box-shadow: none;
}

.text-scale-btn:active {
  transform: none;
  box-shadow: none;
}

.text-scale-btn.text-scale-active {
  background: #9B5DE5;
  border-color: #7a3ec4;
  color: #FFF8E7;
  box-shadow: 0 2px 8px rgba(155, 93, 229, 0.3);
}

.text-scale-btn.text-scale-active:hover {
  background: #b07ae8;
  border-color: #9B5DE5;
}

#labs-back {
  padding: 10px 48px;
  background: #06D6A0;
}

/* ── Coins HUD ── */

#coins-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 5;
}

#coins-icon {
  color: #FFD700;
  font-size: calc(18px * var(--text-scale));
  text-shadow: 1px 1px 0 #3D3522;
}

#coins-value {
  font-size: calc(18px * var(--text-scale));
  font-weight: 700;
  color: #FFD700;
  text-shadow: 1px 1px 0 #3D3522;
}

/* ── Daily Challenge HUD ── */

#daily-challenge-hud {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 10, 26, 0.7);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  pointer-events: none;
  z-index: 5;
  font-size: 12px;
}

#daily-challenge-icon {
  color: #FFD700;
  font-size: 14px;
}

#daily-challenge-text {
  color: #FFF8E7;
  font-family: 'Patrick Hand', cursive;
}

#daily-challenge-status {
  color: #06D6A0;
  font-weight: 700;
}

/* ── Streak Banner ── */

#streak-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 107, 53, 0.12);
  border: 2px solid rgba(255, 107, 53, 0.3);
  border-radius: 12px;
  padding: 8px 16px;
  margin-bottom: 12px;
  font-size: 15px;
  color: #FF6B35;
  font-weight: 700;
}

#streak-fire {
  font-size: 20px;
}

#streak-reward {
  color: #FFD700;
  font-size: 13px;
}

/* ── Daily Banner (start screen) ── */

#daily-banner {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 215, 0, 0.1);
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  padding: 6px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #5a4e3a;
  max-width: 300px;
  text-align: center;
}

#daily-icon {
  color: #FFD700;
  font-size: 16px;
}

/* ── Achievements Button ── */

#achievements-btn {
  background: #FFD166;
  color: #3D3522;
}

#achievements-btn:hover {
  background: #FFE49C;
}

/* ── Achievements Screen ── */

#achievements-screen {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 248, 231, 0.96);
  z-index: 20;
  animation: fadeIn 0.2s ease-out;
}

#achievements-inner {
  background: #FFF8E7;
  border: 3px solid #3D3522;
  border-radius: 16px;
  padding: 36px 28px 24px;
  max-width: 440px;
  width: 92%;
  position: relative;
  box-shadow: 5px 5px 0 #FFD166;
}

#achievements-inner h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-align: center;
  color: #FF6B35;
}

#close-achievements {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 22px;
  border: 2px solid #3D3522;
  color: #3D3522;
  background: #E84855;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 2px 2px 0 #3D3522;
  line-height: 1;
}

#close-achievements:hover {
  background: #f06070;
  transform: rotate(10deg);
}

#achievements-stats {
  text-align: center;
  font-size: 14px;
  color: #5a4e3a;
  margin-bottom: 16px;
}

#ach-count {
  font-weight: 700;
  color: #FF6B35;
}

#ach-coins {
  color: #FFD700;
  font-weight: 700;
  margin-left: 12px;
}

#achievements-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.ach-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f5edd6;
  border: 2px solid rgba(61, 53, 34, 0.1);
}

.ach-entry.ach-locked {
  opacity: 0.45;
}

.ach-entry.ach-unlocked {
  border-color: rgba(255, 215, 0, 0.4);
  background: rgba(255, 215, 0, 0.08);
}

.ach-star {
  font-size: 20px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.ach-info {
  flex: 1;
}

.ach-name {
  font-size: 14px;
  font-weight: 700;
  color: #3D3522;
}

.ach-desc {
  font-size: 12px;
  color: #5a4e3a;
  opacity: 0.7;
}

#achievements-back {
  display: block;
  margin: 0 auto;
  padding: 10px 48px;
  background: #06D6A0;
}

/* ── Game Over Coins ── */

.gameover-coins {
  text-align: center;
  margin: 8px 0;
}

.coins-earned-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #aaa;
  letter-spacing: 2px;
  display: block;
  margin-bottom: 4px;
}

.coins-earned-value {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  color: #FFD700;
  text-shadow: 0 0 8px #FFD700;
}

/* ── Game Over Achievements ── */

.gameover-achievements {
  margin: 8px 0;
  text-align: center;
}

.gameover-ach {
  display: inline-block;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 8px;
  padding: 4px 10px;
  margin: 2px 4px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #FFD700;
  text-shadow: 0 0 4px #FFD700;
}

/* ── Revenge Button ── */

.arcade-btn-revenge {
  color: #FFD700;
  border-color: #FFD700;
  text-shadow: 0 0 6px #FFD700;
  box-shadow:
    0 0 8px rgba(255, 215, 0, 0.3),
    inset 0 0 8px rgba(255, 215, 0, 0.1);
}

.arcade-btn-revenge:hover {
  background: #FFD700;
  color: #0a0a1a;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
  text-shadow: none;
}

/* ── Share Button ── */

#share-btn {
  color: #00aaff;
  border-color: #00aaff;
  text-shadow: 0 0 6px #00aaff;
  box-shadow:
    0 0 8px rgba(0, 170, 255, 0.3),
    inset 0 0 8px rgba(0, 170, 255, 0.1);
}

#share-btn:hover {
  background: #00aaff;
  color: #0a0a1a;
  text-shadow: none;
}

/* ── Custom Scrollbars ── */

#leaderboard-list::-webkit-scrollbar,
#achievements-list::-webkit-scrollbar {
  width: 6px;
}

#leaderboard-list::-webkit-scrollbar-track,
#achievements-list::-webkit-scrollbar-track {
  background: rgba(61, 53, 34, 0.06);
  border-radius: 3px;
}

#leaderboard-list::-webkit-scrollbar-thumb,
#achievements-list::-webkit-scrollbar-thumb {
  background: rgba(61, 53, 34, 0.2);
  border-radius: 3px;
}

#leaderboard-list::-webkit-scrollbar-thumb:hover,
#achievements-list::-webkit-scrollbar-thumb:hover {
  background: rgba(61, 53, 34, 0.35);
}

#leaderboard-list,
#achievements-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(61, 53, 34, 0.2) rgba(61, 53, 34, 0.06);
}

/* ── Responsive: Small screens ── */

@media (max-width: 400px) {
  #hud {
    top: 10px;
  }

  #score {
    font-size: calc(40px * var(--text-scale));
  }

  #hud-label {
    font-size: calc(11px * var(--text-scale));
    letter-spacing: 3px;
  }

  #coins-hud {
    top: 10px;
    left: 10px;
  }

  #coins-icon,
  #coins-value {
    font-size: calc(14px * var(--text-scale));
  }

  .btn-row {
    max-width: 280px;
    gap: 8px;
    padding: 0 12px;
  }

  #start-btn {
    font-size: 16px;
    padding: 12px 28px;
  }

  #start-screen h1 {
    margin-bottom: 8px;
  }

  #start-screen p {
    font-size: 15px;
    margin-bottom: 20px;
    max-width: 280px;
  }

  .gameover-panel {
    padding: 16px 12px;
  }

  .gameover-title {
    font-size: calc(clamp(16px, 5vw, 22px) * var(--text-scale));
    margin-bottom: 14px;
  }

  .gameover-buttons {
    max-width: 100%;
  }

  #leaderboard-inner,
  #labs-inner,
  #achievements-inner {
    padding: 28px 18px 20px;
  }

  #daily-challenge-hud {
    bottom: 8px;
    font-size: 11px;
    padding: 5px 10px;
  }
}

/* ── Responsive: Landscape short screens ── */

@media (max-height: 500px) {
  #hud {
    top: 6px;
  }

  #score {
    font-size: calc(36px * var(--text-scale));
  }

  #coins-hud {
    top: 8px;
  }

  .screen-art {
    font-size: 30px;
    margin-bottom: 8px;
  }

  #start-screen p {
    margin-bottom: 14px;
  }

  .highscore-display {
    margin-bottom: 14px;
  }

  #combo-counter {
    top: 40%;
  }

  .gameover-panel {
    padding: 14px 12px;
  }

  .gameover-title {
    margin-bottom: 10px;
  }

  .gameover-stats {
    margin: 8px 0;
  }

  .arcade-name-prompt {
    margin: 8px 0;
  }
}

/* ── Responsive: Wide screens ── */

@media (min-width: 768px) {
  .btn-row {
    max-width: 360px;
    gap: 12px;
  }

  #leaderboard-inner,
  #labs-inner,
  #achievements-inner {
    max-width: 480px;
  }

  .gameover-panel {
    max-width: 440px;
  }

  .gameover-buttons {
    max-width: 400px;
  }
}

.hidden {
  display: none !important;
}
