:root {
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --bg-tertiary: #21262D;
  --text-primary: #F0F6FC;
  --text-secondary: #8B949E;
  --text-muted: #484F58;
  --accent: #3B82F6;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --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;
    --accent-glow: rgba(49, 130, 246, 0.2);
    --border: #D0D7DE;
    --btn-bg: #E9ECF0;
    --btn-active: #D0D7DE;
    --overlay-bg: rgba(255, 255, 255, 0.9);
    --board-bg: #F0F2F5;
  }
}

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

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

body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
}

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

/* Score bar */
#score-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
  pointer-events: none;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

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

.score-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

#score-value {
  color: var(--accent);
  text-shadow: 0 0 16px var(--accent-glow);
}

#best-value {
  font-size: 20px;
  color: #F59E0B;
  text-shadow: 0 0 12px rgba(245,158,11,0.4);
}

/* Canvas */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  background: var(--board-bg);
}

/* Overlay base */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 24px;
  gap: 20px;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

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

/* Game title */
.game-title {
  font-size: clamp(52px, 15vw, 80px);
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6, #EC4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  line-height: 1;
  filter: drop-shadow(0 4px 24px rgba(139,92,246,0.4));
}

.game-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
  max-width: 280px;
}

/* Bird mascot on start screen */
.bird-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FCD34D, #F59E0B);
  box-shadow: 0 0 32px rgba(245,158,11,0.5), inset -4px -4px 8px rgba(0,0,0,0.2);
  position: relative;
  animation: float 2s ease-in-out infinite;
}

.bird-preview::before {
  content: '';
  position: absolute;
  top: 20px;
  right: -8px;
  width: 22px;
  height: 14px;
  background: #FB923C;
  border-radius: 0 8px 8px 0;
  box-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.bird-preview::after {
  content: '';
  position: absolute;
  top: 18px;
  left: 16px;
  width: 12px;
  height: 12px;
  background: #1C1917;
  border-radius: 50%;
  box-shadow: 0 0 0 3px #FFF, 2px -1px 0 3px #1C1917;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(-3deg); }
  50% { transform: translateY(-10px) rotate(3deg); }
}

/* Start/tap hint */
.tap-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: pulse-hint 1.5s ease-in-out infinite;
}

@keyframes pulse-hint {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50% { opacity: 0.6; transform: translateY(4px); }
}

.tap-hint-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.tap-hint-icon {
  font-size: 28px;
}

/* Controls info */
.controls-info {
  display: flex;
  gap: 16px;
}

.control-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.key-icon {
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  box-shadow: 0 2px 0 var(--border);
}

/* Game over overlay */
#gameover-overlay .game-title {
  font-size: clamp(36px, 10vw, 56px);
}

.result-card {
  width: 100%;
  max-width: 320px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.result-score {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
}

.result-best {
  font-size: 22px;
  font-weight: 800;
  color: #F59E0B;
}

.result-divider {
  height: 1px;
  background: var(--border);
}

.new-record-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(139,92,246,0.2));
  border: 1px solid rgba(139,92,246,0.4);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #A78BFA;
  letter-spacing: 0.04em;
  animation: record-glow 2s ease-in-out infinite;
}

@keyframes record-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(139,92,246,0.3); }
  50% { box-shadow: 0 0 20px rgba(139,92,246,0.6); }
}

/* Buttons */
.btn-group {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.btn {
  flex: 1;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  background: #2563EB;
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-secondary {
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--btn-active);
}

/* Difficulty indicator */
.difficulty-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
  pointer-events: none;
}

.diff-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.diff-track {
  flex: 1;
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.diff-fill {
  height: 100%;
  background: linear-gradient(90deg, #3B82F6, #8B5CF6, #EC4899);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Pause button */
#pause-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 15;
  width: 36px;
  height: 36px;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.15s;
}

#pause-btn:hover { background: var(--btn-active); }
#pause-btn.visible { display: flex; }

/* Pause overlay */
#pause-overlay .game-title {
  font-size: clamp(36px, 10vw, 52px);
}

.pause-desc {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}
