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

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --border: #475569;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #6366f1;
  --primary-light: #818cf8;
  --accent: #ec4899;
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --green: #10b981;
  --green-light: #34d399;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1.5rem;
  background: #0b1220;
  border-bottom: 1px solid var(--border);
}

.back-link {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.back-link:hover { color: var(--text); }

.topbar-tag {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Header ── */
.game-header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
}

.header-inner { max-width: 1100px; margin: 0 auto; }

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
}

.brand-emoji {
  font-size: 2.4rem;
  line-height: 1;
}

.brand-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  background: linear-gradient(135deg, #f8fafc 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── Year control bar ── */
.year-bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0.75rem;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(15, 23, 42, 0.85));
  backdrop-filter: blur(8px);
}

.year-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.year-step {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--gold-light);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
  flex-shrink: 0;
}

.year-step:hover {
  background: var(--surface-2);
  border-color: var(--gold-light);
  transform: scale(1.08);
}

.year-step:active {
  transform: scale(0.95);
}

.year-input {
  background: transparent;
  border: none;
  color: var(--gold-light);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  width: 4ch;
  min-width: 5ch;
  max-width: 7ch;
  font-family: inherit;
  letter-spacing: -0.02em;
  outline: none;
}

.year-input::-webkit-outer-spin-button,
.year-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.year-input { -moz-appearance: textfield; appearance: textfield; }

.year-input:focus { color: #fffbe8; }

.year-era {
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.year-slider {
  width: 100%;
  appearance: none;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

.year-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: var(--gold-light);
  border: 3px solid var(--bg);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 0.1s;
}
.year-slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.1); }
.year-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--gold-light);
  border: 3px solid var(--bg);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.era-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.85rem;
}

.era-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.74rem;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.era-chip:hover {
  color: var(--text);
  border-color: var(--primary-light);
  background: rgba(99, 102, 241, 0.1);
}

/* ── Main ── */
.game-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 3rem;
}

/* ── Status row ── */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.status-count {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.status-count .num {
  color: var(--gold-light);
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.status-count .year {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.status-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sort-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
}

.sort-select:focus { outline: none; border-color: var(--primary-light); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-emoji { font-size: 3rem; margin-bottom: 0.5rem; }

.empty-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* ── People grid ── */
.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.person-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  padding: 1rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  animation: popIn 0.25s ease;
}

.person-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary-light);
  box-shadow: 0 10px 22px rgba(99, 102, 241, 0.18);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.person-avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, var(--surface-2), #2a3a52);
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  line-height: 1;
  overflow: hidden;
  position: relative;
}

.person-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.person-avatar .emoji-fallback {
  font-size: 2.4rem;
  line-height: 1;
}

.person-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-top: 0.15rem;
}

.person-dates {
  font-size: 0.72rem;
  color: var(--gold-light);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.person-age {
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.person-age.born-this-year {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green-light);
  border-color: rgba(16, 185, 129, 0.35);
}

.person-age.died-this-year {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.person-field {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.person-desc {
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: 0.1rem;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .game-header { padding: 1.5rem 1rem; }
  .year-bar { padding: 1rem 1rem 0.5rem; }
  .game-main { padding: 0.5rem 1rem 2rem; }
  .people-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
  .person-avatar { width: 76px; height: 76px; font-size: 2rem; }
}
