:root {
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --bg-tertiary: #21262D;
  --text-primary: #F0F6FC;
  --text-secondary: #8B949E;
  --text-muted: #484F58;
  --accent: #3B82F6;
  --border: #30363D;
  --btn-bg: #21262D;
  --btn-active: #30363D;
  --overlay-bg: rgba(0, 0, 0, 0.85);
  --board-bg: #0A0E14;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F6F8FA;
    --bg-tertiary: #E9ECF0;
    --text-primary: #1B1E28;
    --text-secondary: #57606A;
    --text-muted: #8C959F;
    --accent: #3182F6;
    --border: #D0D7DE;
    --btn-bg: #E9ECF0;
    --btn-active: #D0D7DE;
    --overlay-bg: rgba(255, 255, 255, 0.9);
    --board-bg: #F0F2F5;
  }
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  overflow: hidden;
  touch-action: none;
}

#app {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100dvh;
  background: var(--bg-primary);
}

#game-wrapper {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  background: var(--board-bg);
  overflow: hidden;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

/* ── HUD ─────────────────────────────────────────────── */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px;
  pointer-events: none;
  z-index: 10;
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-block.center {
  align-items: center;
  flex: 1;
}

.hud-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hud-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.hud-value.accent {
  color: var(--accent);
}

.lives-display {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.life-icon {
  font-size: 16px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.life-icon.lost {
  opacity: 0.2;
  transform: scale(0.8);
}

.timer-ring {
  position: relative;
  width: 48px;
  height: 48px;
}

.timer-svg {
  width: 48px;
  height: 48px;
  transform: rotate(-90deg);
}

.timer-track {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 3;
}

.timer-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.5s ease;
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
}

.combo-display {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  z-index: 15;
  text-shadow: 0 0 20px rgba(59, 130, 246, 0.6);
  transition: opacity 0.3s ease;
}

/* ── OVERLAYS ─────────────────────────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--overlay-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  gap: 0;
  transition: opacity 0.3s ease;
}

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

.game-title {
  font-size: 72px;
  font-weight: 900;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #F97316 0%, #EF4444 35%, #3B82F6 70%, #A855F7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
  line-height: 1;
}

.game-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 32px;
}

.fruit-banner {
  font-size: 32px;
  margin-bottom: 36px;
  letter-spacing: 4px;
  animation: float 3s ease-in-out infinite;
}

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

.highscore-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 28px;
  text-align: center;
  margin-bottom: 36px;
}

.highscore-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.highscore-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 16px 48px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 24px rgba(59, 130, 246, 0.35);
  margin-bottom: 16px;
  min-width: 200px;
}

.btn-primary:active {
  transform: scale(0.96);
  opacity: 0.9;
}

.btn-secondary {
  background: var(--btn-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 32px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  min-width: 160px;
}

.btn-secondary:active {
  transform: scale(0.96);
  background: var(--btn-active);
}

.result-score-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 28px;
}

.result-score-value {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.result-new-record {
  font-size: 13px;
  font-weight: 700;
  color: #F59E0B;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 32px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.result-new-record.show {
  opacity: 1;
}

.result-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 36px;
}

.stat-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  text-align: center;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.game-over-title {
  font-size: 42px;
  font-weight: 900;
  color: #EF4444;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.game-over-reason {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* ── SCORE POPUP ───────────────────────────────────────── */
.score-popup {
  position: absolute;
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  pointer-events: none;
  z-index: 20;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  animation: scoreFloat 0.9s ease-out forwards;
}

@keyframes scoreFloat {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  60%  { opacity: 1; transform: translateY(-40px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-70px) scale(0.9); }
}

/* ── PAUSE BUTTON ─────────────────────────────────────── */
#pause-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s ease;
}

#pause-btn:active {
  background: var(--btn-active);
}

.pause-title {
  font-size: 36px;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.pause-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 36px;
}

/* ── BOMB FLASH ───────────────────────────────────────── */
#bomb-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(239,68,68,0.6) 0%, rgba(239,68,68,0) 70%);
  pointer-events: none;
  opacity: 0;
  z-index: 50;
  transition: opacity 0.05s ease;
}

#bomb-flash.active {
  opacity: 1;
}
