:root {
  --bg: #000000;
  --bg-subtle: #1c1c1e;
  --border: rgba(255, 255, 255, 0.10);
  --text-1: #f2f2f7;
  --text-2: rgba(235, 235, 245, 0.75);
  --text-3: rgba(235, 235, 245, 0.50);
  --text-4: rgba(235, 235, 245, 0.25);
  --brand: #a78bfa;
  --brand-hover: #c4b5fd;
  --brand-soft: rgba(167, 139, 250, 0.15);
  --glass-bg: rgba(28, 28, 30, 0.72);
  --glass-border: rgba(255, 255, 255, 0.10);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
}

html {
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text-1);
  margin: 0;
  min-height: 100vh;
  line-height: 1.7;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 55% at 15% 0%, rgba(167, 139, 250, 0.30) 0%, transparent 55%),
    radial-gradient(ellipse 55% 45% at 85% 90%, rgba(99, 102, 241, 0.22) 0%, transparent 55%),
    radial-gradient(ellipse 45% 35% at 55% 45%, rgba(124, 58, 237, 0.10) 0%, transparent 60%);
}

body > * { position: relative; z-index: 1; }

.layout-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─── */
header {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-link {
  position: relative;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  transition: color 0.15s;
  padding-bottom: 2px;
  text-decoration: none;
}
.nav-link:hover { color: var(--text-1); }
.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0;
  width: 0; height: 2px;
  background: var(--brand);
  transition: width 0.25s ease;
  border-radius: 2px;
}
.nav-link:hover::after { width: 100%; }

.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.nav-dropdown-btn::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 16px;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28, 28, 30, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.4rem;
  min-width: 140px;
  box-shadow: var(--shadow-card);
}

.nav-dropdown:hover .nav-dropdown-menu {
  display: flex;
  flex-direction: column;
}

.nav-dropdown-menu a {
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-dropdown-menu a:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

@media (max-width: 768px) {
  .nav-dropdown-menu {
    display: none !important;
  }
}

/* ─── Panel ─── */
.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-card);
}

/* ─── Buttons ─── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background-color: var(--brand);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 9999px;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.35);
}
.btn-primary:hover {
  background-color: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.50);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background-color: transparent;
  color: var(--text-1);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 9999px;
  border: 1px solid var(--border);
  transition: all 0.2s;
  cursor: pointer;
}
.btn-secondary:hover {
  border-color: var(--brand);
  background-color: var(--brand-soft);
  color: var(--brand);
}

/* ─── Setup ─── */
.page-title {
  font-family: 'Nunito', 'Inter', sans-serif;
  font-size: 2rem;
  font-weight: 900;
  margin: 0;
  background: linear-gradient(135deg, #f9fafb 0%, #c4b5fd 50%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin: 0;
}

.name-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-1);
  border-radius: 0.75rem;
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}
.name-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

/* ─── Mode toggle ─── */
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}
.mode-btn:hover {
  border-color: var(--brand);
  color: var(--text-1);
  background: var(--brand-soft);
}
.mode-btn.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

/* ─── Color swatches ─── */
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.swatch:hover {
  transform: scale(1.12);
}
.swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.35);
  transform: scale(1.12);
}
.swatch.taken {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Score bar ─── */
.score-bar { border-radius: 16px; }

.score-player {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.score-player--right { flex-direction: row-reverse; }

.score-dot {
  /* width: 12px;
  height: 12px;
  border-radius: 50%; */
  flex-shrink: 0;
  font-weight: 900;
  font-size: 1.25rem;
  line-height: 1;
  transition: color 0.3s;
}

.score-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-num {
  font-family: 'Nunito', sans-serif;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-1);
  line-height: 1;
}

/* ─── Turn indicator ─── */
.turn-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
  height: 2rem;
  transition: opacity 0.2s;
}

.turn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: background-color 0.3s;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  50% { opacity: 0.75; }
}

/* ─── Board ─── */
.board-wrap { border-radius: 20px; }

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  aspect-ratio: 1 / 1;
  width: 100%;
}

.cell {
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  font-size: clamp(2rem, 10vw, 3.5rem);
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  color: var(--text-1);
  transition: background 0.15s, transform 0.12s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.cell:hover:not(:disabled) {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.18);
}

.cell:disabled { cursor: default; }

.cell.marked {
  animation: pop 0.18s ease-out;
}

@keyframes pop {
  0% { transform: scale(0.7); }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.cell.winning {
  animation: winner-pulse 0.7s ease-in-out 2;
  border-color: rgba(255,255,255,0.4) !important;
  background: rgba(255,255,255,0.10) !important;
}

@keyframes winner-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ─── Win overlay ─── */
.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.25s ease;
}
.win-overlay.hidden { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.win-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  padding: 2.5rem 2rem;
  animation: slide-up 0.3s ease;
}

@keyframes slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.win-emoji {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 0.75rem;
  animation: bounce 0.5s ease 0.1s both;
}

@keyframes bounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.win-title {
  font-family: 'Nunito', sans-serif;
  font-size: 2.25rem;
  font-weight: 900;
  margin: 0 0 0.25rem;
  background: linear-gradient(135deg, #f9fafb, #c4b5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.win-sub {
  color: var(--text-3);
  font-size: 0.95rem;
  margin: 0;
}

/* ─── Footer utils ─── */
.font-display { font-family: 'Lora', Georgia, serif; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
