: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;
  }
}

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

html, body {
  height: 100%;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.game-wrapper {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  overflow: hidden;
}

/* ---------- Header Bar ---------- */
.header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  z-index: 10;
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.score-current {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.score-best {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Canvas Area ---------- */
.canvas-area {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 56px;
  padding-bottom: 64px;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--board-bg);
  touch-action: none;
}

/* ---------- Controls Bar ---------- */
.controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  z-index: 10;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--btn-bg);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active,
.ctrl-btn.active {
  background: var(--btn-active);
  border-color: var(--accent);
  color: var(--text-primary);
}

.ctrl-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  flex: 1;
  max-width: 180px;
}

.ctrl-btn.primary:active {
  opacity: 0.85;
}

.ctrl-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

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

.overlay.hidden {
  display: none;
}

.overlay-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 16px;
}

.overlay-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.overlay-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  text-align: center;
  line-height: 1.5;
}

.overlay-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 28px;
}

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

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

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

.overlay-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 32px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  min-width: 160px;
}

.overlay-btn:active {
  opacity: 0.85;
  transform: scale(0.97);
}

.overlay-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
  text-align: center;
}

/* ---------- Night mode indicator ---------- */
.night-badge {
  position: absolute;
  top: 60px;
  right: 12px;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.5s;
  z-index: 5;
  pointer-events: none;
}

.night-badge.visible {
  opacity: 1;
}

/* ---------- Responsive touch buttons ---------- */
.touch-jump-zone {
  position: absolute;
  bottom: 64px;
  left: 0;
  right: 0;
  height: calc(100% - 120px);
  z-index: 8;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Duck button ---------- */
.ctrl-btn.duck {
  flex-shrink: 0;
}

/* Scrollbar hide */
::-webkit-scrollbar { display: none; }
