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

:root {
  --neon-cyan:    #00d4ff;
  --neon-magenta: #ff00cc;
  --text-primary: #e8f0ff;
  --text-muted:   #5a7090;
  --overlay-bg:   rgba(2, 5, 20, 0.88);
  --btn-primary:  #1a4dcc;
  --btn-hover:    #1540b0;
  --radius:       12px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #000510;
  font-family: "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text-primary);
  user-select: none;
  -webkit-user-select: none;
}

/* ── Shell layout ───────────────────────────────────────────────── */
.shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ── Game area ──────────────────────────────────────────────────── */
.game-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
}

#game-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── Overlay screens ────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.screen[hidden] { display: none; }
.screen--active { display: flex; }

/* Start screen: transparent so the animated night city shows through */
.screen--start {
  background: rgba(2, 5, 20, 0.30);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Game-over screen: opaque for readability while filling in the form */
.screen--gameover {
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.screen__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 36px 28px;
  max-width: 440px;
  width: 100%;
  text-align: center;
}

/* Card treatment for start screen content (glass panel over the city) */
.screen__content--card {
  background: rgba(2, 8, 28, 0.72);
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 20px;
  box-shadow:
    0 0 48px rgba(0, 212, 255, 0.10),
    0 8px 32px rgba(0, 0, 0, 0.55),
    inset 0 0 24px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.screen__bird-preview img {
  filter: drop-shadow(0 0 24px rgba(0, 212, 255, 0.5));
}

.screen__title {
  font-family: "Outfit", sans-serif;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}
.screen__sub  { font-size: clamp(0.95rem, 2vw, 1.1rem); color: var(--text-muted); }
.screen__hint { font-size: 0.8rem; color: rgba(90, 112, 144, 0.8); letter-spacing: 0.06em; }

.screen__score-label { font-size: 0.9rem; color: var(--text-muted); margin-bottom: -8px; }
.screen__score {
  font-family: "Outfit", sans-serif;
  font-size: clamp(2.8rem, 8vw, 4.5rem);
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 18px rgba(0, 212, 255, 0.6);
  line-height: 1;
}

/* ── Submit form ────────────────────────────────────────────────── */
.submit-section { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.submit-section__label { font-size: 0.85rem; color: var(--text-muted); }
.submit-section__row   { display: flex; gap: 8px; }

.nickname-input {
  flex: 1;
  padding: 12px 14px;
  background: rgba(0, 212, 255, 0.05);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.nickname-input::placeholder { color: rgba(90, 112, 144, 0.6); }
.nickname-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}

.submit-error { font-size: 0.82rem; color: #ff5555; }
.submit-error[hidden] { display: none; }

.saved-notice {
  font-size: 0.9rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0,212,255,0.5);
}
.saved-notice[hidden] { display: none; }

/* ── Game-over actions ──────────────────────────────────────────── */
.gameover-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.gameover-hint { margin-top: -4px; }

/* ── Return countdown ───────────────────────────────────────────── */
.return-countdown {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.7;
  margin-top: -4px;
}
.return-countdown[hidden] { display: none; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 28px;
  border-radius: var(--radius);
  font-family: "Outfit", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn--primary {
  background: var(--btn-primary);
  color: #fff;
  box-shadow: 0 0 14px rgba(0, 212, 255, 0.2);
}
.btn--primary:hover {
  background: var(--btn-hover);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.35);
}
.btn--ghost {
  background: transparent;
  border: 1px solid rgba(0, 212, 255, 0.25);
  color: var(--text-muted);
}
.btn--ghost:hover { background: rgba(0, 212, 255, 0.06); color: var(--text-primary); }

.back-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.back-link:hover { color: var(--neon-cyan); }

/* ── HUD score ──────────────────────────────────────────────────── */
.hud-score {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Outfit", sans-serif;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(0,212,255,0.7), 0 2px 6px rgba(0,0,0,0.8);
  z-index: 5;
  pointer-events: none;
}
.hud-score[hidden] { display: none; }

/* ── Leaderboard sidebar ────────────────────────────────────────── */
.lb-panel {
  width: 256px;
  flex-shrink: 0;
  background: #02050f;
  border-left: 1px solid rgba(0, 212, 255, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lb-panel__header {
  padding: 20px 18px 14px;
  border-bottom: 1px solid rgba(0, 212, 255, 0.1);
  flex-shrink: 0;
}
.lb-panel__title {
  font-family: "Outfit", sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}
.lb-panel__game {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Period tabs ────────────────────────────────────────────────── */
.lb-tabs {
  display: flex;
  gap: 4px;
  margin-top: 10px;
}

.lb-tab {
  flex: 1;
  padding: 5px 4px;
  background: transparent;
  border: 1px solid rgba(0, 212, 255, 0.15);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: "Outfit", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.lb-tab:hover {
  background: rgba(0, 212, 255, 0.07);
  color: var(--text-primary);
}
.lb-tab--active {
  background: rgba(0, 212, 255, 0.12);
  border-color: rgba(0, 212, 255, 0.5);
  color: var(--neon-cyan);
}

.sidebar-lb-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,212,255,0.2) transparent;
}

.sidebar-lb-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 0.875rem;
  transition: background 0.1s;
}
.sidebar-lb-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  justify-content: center;
  padding: 24px 18px !important;
  border-bottom: none !important;
}
.sidebar-lb-list li.lb-you {
  background: rgba(0, 212, 255, 0.07);
  border-left: 2px solid var(--neon-cyan);
  padding-left: 16px;
}

.lb-sr {
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  width: 22px;
  text-align: right;
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 0.78rem;
}
.sidebar-lb-list li:nth-child(1) .lb-sr { color: #ffd040; }
.sidebar-lb-list li:nth-child(2) .lb-sr { color: #b0bcd0; }
.sidebar-lb-list li:nth-child(3) .lb-sr { color: #ff8040; }

.lb-sn {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #a0b8d0;
}
.lb-ss {
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  color: var(--neon-cyan);
  flex-shrink: 0;
  font-size: 0.95rem;
}
