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

:root {
  --bg-dark: #2c1810;
  --bg-medium: #5a3a28;
  --bg-light: #8b6914;
  --wood-color: #c4a265;
  --wood-light: #d4b87a;
  --wood-dark: #8b6914;
  --text-light: #f5e6c8;
  --text-dark: #2c1810;
  --accent: #ffd700;
  --grid-line: rgba(0, 0, 0, 0.25);
  --cell-bg: rgba(255, 255, 255, 0.06);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-dark);
  color: var(--text-light);
  touch-action: manipulation;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 8px;
  gap: 8px;
}

/* ---- HUD ---- */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 10px;
  background: linear-gradient(135deg, var(--bg-medium), var(--bg-dark));
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 52px;
}

#hud-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-label {
  font-size: 10px;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ball-preview {
  display: flex;
  gap: 4px;
}

.ball-preview .mini-ball {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

#hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#score-display {
  font-size: 24px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  letter-spacing: 2px;
}

#combo-display {
  font-size: 14px;
  font-weight: bold;
  color: #ff6b35;
  text-shadow: 0 0 8px rgba(255, 107, 53, 0.5);
  animation: combo-pulse 0.5s ease-in-out;
}

@keyframes combo-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

#hud-right {
  display: flex;
  gap: 6px;
}

.hud-btn {
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-light);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.hud-btn:active {
  background: rgba(255, 255, 255, 0.25);
}

/* ---- Canvas ---- */
#game-canvas {
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  /* Size is set by JS */
}

/* ---- Powerup Panel ---- */
#powerup-panel {
  display: flex;
  gap: 6px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.powerup-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.powerup-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.2);
}

/* ---- Overlay / Game Over ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.overlay-content {
  background: linear-gradient(135deg, var(--bg-medium), var(--bg-dark));
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.overlay-content h2 {
  font-size: 24px;
  margin-bottom: 12px;
  color: var(--accent);
}

.overlay-content p {
  font-size: 18px;
  margin-bottom: 20px;
}

.action-btn {
  display: block;
  width: 100%;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.action-btn {
  background: linear-gradient(135deg, #ffd700, #f0a500);
  color: var(--text-dark);
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-light);
}

.action-btn:active {
  transform: scale(0.97);
}

/* ---- Utilities ---- */
.hidden {
  display: none !important;
}

/* Ball colors for preview */
.ball-red { background: radial-gradient(circle at 35% 35%, #ff6b6b, #cc0000); }
.ball-blue { background: radial-gradient(circle at 35% 35%, #6bb5ff, #0044cc); }
.ball-green { background: radial-gradient(circle at 35% 35%, #6bff6b, #00aa00); }
.ball-yellow { background: radial-gradient(circle at 35% 35%, #ffff6b, #ccaa00); }
.ball-turquoise { background: radial-gradient(circle at 35% 35%, #6bffff, #00aaaa); }
.ball-joker { background: radial-gradient(circle at 35% 35%, #ffffff, #cccccc); }
