/* ─────────────────────────────────────────────
   Household Game TV — Apple-inspired Design System
   Dual-theme · Spring animations · TV-optimized
   ───────────────────────────────────────────── */

/* ═══════════════ THEME TOKENS ═══════════════ */

:root, [data-theme="dark"] {
  --bg:            #000000;
  --bg-alt:        #111111;
  --bg-nav:        rgba(0,0,0,0.72);
  --surface:       rgba(255,255,255,0.04);
  --surface2:      rgba(255,255,255,0.08);
  --border:        rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --text:          #f5f5f7;
  --text-dim:      #a1a1a6;
  --text-tertiary: #6e6e73;
  --accent:        #6366f1;
  --accent2:       #818cf8;
  --accent-subtle: rgba(99,102,241,0.15);
  --accent-border: rgba(99,102,241,0.25);
  --success:       #30d158;
  --success-subtle:rgba(48,209,88,0.12);
  --warning:       #ffd60a;
  --danger:        #ff453a;
  --danger-subtle: rgba(255,69,58,0.12);
  --card-shadow:   0 0 0 0 transparent;
  --gradient-1:    #6366f1;
  --gradient-2:    #a855f7;
  --radius:        16px;
  --radius-sm:     10px;
  --font:          'SF Pro Display', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --spring:        cubic-bezier(0.16,1,0.3,1);
  --ease:          cubic-bezier(0.25,0.1,0.25,1);
  --transition:    0.35s var(--spring);
}

[data-theme="light"] {
  --bg:            #ffffff;
  --bg-alt:        #f5f5f7;
  --bg-nav:        rgba(255,255,255,0.72);
  --surface:       #ffffff;
  --surface2:      #f5f5f7;
  --border:        rgba(0,0,0,0.06);
  --border-strong: rgba(0,0,0,0.12);
  --text:          #1d1d1f;
  --text-dim:      #6e6e73;
  --text-tertiary: #86868b;
  --accent:        #5856d6;
  --accent2:       #6e6ce3;
  --accent-subtle: rgba(88,86,214,0.08);
  --accent-border: rgba(88,86,214,0.2);
  --success:       #28a745;
  --success-subtle:rgba(40,167,69,0.08);
  --warning:       #bf8600;
  --danger:        #cc2929;
  --danger-subtle: rgba(204,41,41,0.08);
  --card-shadow:   0 2px 12px rgba(0,0,0,0.06);
}

/* ═══════════════ RESET & BASE ═══════════════ */

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

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: clamp(16px, 1.25vw, 28px);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.4s ease, color 0.3s ease;
}

#app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }

/* ═══════════════ PLAY MODE GREEN FELT ═══════════════ */

body.play-mode-bg::before,
body.play-mode-bg::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}
body.play-mode-bg::before {
  background: #1a7a3a;
}
body.play-mode-bg::after {
  background: none;
}
[data-theme="light"] body.play-mode-bg::before,
[data-theme="light"].play-mode-bg::before {
  background: #2d9e52;
}

/* ═══════════════ FOCUS (TV Remote-Friendly) ═══════════════ */

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 6px var(--accent-subtle);
  transition: var(--transition);
  z-index: 10;
  position: relative;
}
button:focus-visible, .card:focus-visible {
  outline-width: 4px;
  box-shadow: 0 0 0 8px var(--accent-subtle), 0 8px 24px rgba(0,0,0,.2);
  transform: scale(1.03);
}

/* ═══════════════ NAVIGATION BAR ═══════════════ */

.page-header {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 32px);
  padding: clamp(12px, 1.2vh, 20px) clamp(24px, 3vw, 48px);
  background: var(--bg-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

.logo {
  font-size: clamp(20px, 1.6vw, 28px);
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
  color: var(--text);
}

.nav-row {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: clamp(13px, 1vw, 18px);
  padding: clamp(6px, 0.5vw, 10px) clamp(14px, 1.2vw, 22px);
  border-radius: 980px;
  cursor: pointer;
  transition: color 0.3s var(--ease), background 0.3s var(--ease);
  font-family: var(--font);
  font-weight: 500;
}
.nav-btn:hover {
  color: var(--text);
  background: var(--surface2);
}
.nav-btn.active {
  color: #fff;
  background: var(--accent);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: clamp(8px, 0.8vw, 14px);
}

/* ── Avatar Background Toggle ── */
.avatar-bg-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 980px;
  min-width: 80px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s var(--ease);
}
.avatar-bg-toggle:hover,
.avatar-bg-toggle:focus,
.avatar-bg-toggle.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Log Toggle Button ── */
.log-toggle-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease);
  color: var(--text-dim);
}
.log-toggle-btn svg {
  width: 18px;
  height: 18px;
}
.log-toggle-btn:hover,
.log-toggle-btn:focus {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Theme Toggle ── */
.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease);
  position: relative;
  overflow: hidden;
  padding: 0;
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
  transition: var(--transition);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
.theme-toggle:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Fullscreen Toggle ── */
.fullscreen-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease);
  padding: 0;
}
.fullscreen-toggle svg {
  width: 16px;
  height: 16px;
  stroke: var(--text);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fullscreen-toggle:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.fullscreen-toggle:hover svg {
  stroke: #fff;
}

/* ── Status Dot ── */
.status-dot {
  font-size: 20px;
  color: var(--text-tertiary);
  transition: var(--transition);
}
.status-dot.online {
  color: var(--success);
  animation: statusPulse 2s ease-in-out infinite;
}
.status-dot.offline { color: var(--danger); }

/* ═══════════════ CONTENT AREAS ═══════════════ */

.home-content, .games-content, .leaderboard-content {
  flex: 1;
  overflow-y: auto;
  padding: clamp(24px, 3vh, 48px) clamp(24px, 3vw, 48px);
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}

/* ═══════════════ SECTION TITLE ═══════════════ */

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(24px, 2vw, 40px);
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: clamp(16px, 1.5vh, 28px);
  color: var(--text);
}
.section-count {
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 980px;
}

/* ═══════════════ CARDS ═══════════════ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(16px, 2vw, 36px);
  box-shadow: var(--card-shadow);
  transition: transform 0.5s var(--spring), box-shadow 0.5s var(--spring), border-color 0.3s var(--ease);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card:hover, .card:focus {
  border-color: var(--accent-border);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(99,102,241,.12);
}

.card-title {
  font-size: clamp(18px, 1.4vw, 26px);
  font-weight: 700;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
  letter-spacing: -0.3px;
}
.card-sub {
  font-size: clamp(14px, 1vw, 18px);
  color: var(--text-dim);
  position: relative;
  z-index: 1;
}
.card > * { position: relative; z-index: 1; }

/* ── Avatar backgrounds on cards ── */
[data-avatar-bg="on"] .has-avatar-bg::before,
[data-avatar-bg="on"] .has-avatar-emoji::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
[data-avatar-bg="on"] .has-avatar-bg::before {
  background-image:
    radial-gradient(circle at 78% 20%, rgba(255,255,255,.22), transparent 44%),
    var(--household-avatar-url);
  background-size: cover, cover;
  background-position: center, center;
  opacity: .15;
  filter: saturate(1.1) contrast(1.08);
}
[data-avatar-bg="on"] .has-avatar-emoji::before {
  content: attr(data-avatar-emoji);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(84px, 8vw, 150px);
  opacity: .10;
  transform: translate(22%, 8%) rotate(-8deg);
}
[data-avatar-bg="off"] .has-avatar-bg::before,
[data-avatar-bg="off"] .has-avatar-emoji::before {
  content: none;
}

/* ── Household avatar ── */
.household-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 12px;
  flex-shrink: 0;
}

/* ── Household ELO badge ── */
.household-elo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.elo-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
}
.elo-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
}

/* ── Member role badge ── */
.member-role {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent2);
  background: var(--accent-subtle);
  padding: 2px 8px;
  border-radius: 8px;
  text-transform: capitalize;
}

.household-badge {
  background: var(--surface2);
  padding: 8px 20px;
  border-radius: 980px;
  font-size: 18px;
  color: var(--accent2);
}

/* ═══════════════ CARD GRID ═══════════════ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(280px, min(100%, 50vw), 360px), 1fr));
  gap: clamp(16px, 1.5vw, 28px);
  padding-top: clamp(16px, 1.5vw, 28px);
  width: 100%;
}

.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(280px, min(100%, 50vw), 380px), 1fr));
  gap: clamp(16px, 1.5vw, 28px);
  padding-top: clamp(16px, 1.5vw, 28px);
  width: 100%;
  animation: fadeIn 0.4s var(--ease) forwards;
}

.sessions-grid + .section-title {
  animation: fadeIn 0.4s var(--ease) forwards;
}

.card-grid > * {
  animation: fadeUp 0.6s var(--spring) both;
}
.card-grid > *:nth-child(1)  { animation-delay: 0ms; }
.card-grid > *:nth-child(2)  { animation-delay: 60ms; }
.card-grid > *:nth-child(3)  { animation-delay: 120ms; }
.card-grid > *:nth-child(4)  { animation-delay: 180ms; }
.card-grid > *:nth-child(5)  { animation-delay: 240ms; }
.card-grid > *:nth-child(6)  { animation-delay: 300ms; }
.card-grid > *:nth-child(7)  { animation-delay: 360ms; }
.card-grid > *:nth-child(8)  { animation-delay: 420ms; }
.card-grid > *:nth-child(9)  { animation-delay: 480ms; }
.card-grid > *:nth-child(10) { animation-delay: 540ms; }

/* Responsive grids for different screen sizes */
@media (max-width: 1080px) {
  .card-grid, .sessions-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
  .sessions-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .card-grid, .sessions-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 600px) {
  .card-grid, .sessions-grid {
    grid-template-columns: 1fr;
  }
  .items-grid, .meals-grid, .recipes-grid {
    grid-template-columns: 1fr;
  }
  .list-add-form {
    flex-direction: column;
  }
}

/* ═══════════════ BUTTONS ═══════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 0.8vw, 14px) clamp(24px, 2vw, 36px);
  border: none;
  border-radius: 980px;
  font-size: clamp(15px, 1.1vw, 20px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s var(--spring);
  font-family: var(--font);
  letter-spacing: -0.1px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: clamp(10px, 1vw, 16px) clamp(24px, 2vw, 36px);
  border-radius: 12px;
  border: none;
  font-size: clamp(14px, 1.1vw, 18px);
}
.btn-primary:hover {
  background: var(--accent2);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99,102,241,0.25);
}
.btn-secondary {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ═══════════════ INPUTS ═══════════════ */

.input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: clamp(15px, 1.1vw, 20px);
  padding: clamp(10px, 0.8vw, 14px) clamp(14px, 1.2vw, 22px);
  font-family: var(--font);
  width: 100%;
  max-width: min(420px, 30vw);
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-subtle);
  outline: none;
}

/* ═══════════════ EMPTY STATE ═══════════════ */

.empty-state {
  text-align: center;
  padding: clamp(48px, 6vh, 100px) 0;
  color: var(--text-dim);
}
.empty-icon {
  font-size: clamp(48px, 4.5vw, 80px);
  margin-bottom: clamp(12px, 1.2vw, 24px);
}
.empty-title {
  font-size: clamp(22px, 1.8vw, 36px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-top: 8px;
}
.empty-sub {
  font-size: clamp(15px, 1.1vw, 20px);
  color: var(--text-dim);
  margin-top: 6px;
}

/* ═══════════════ GROCERY / CHORES / MEALS ═══════════════ */

.list-header {
  padding: 0 clamp(24px, 3vw, 48px);
}

.list-add-form {
  display: flex;
  gap: clamp(12px, 1.5vw, 24px);
  margin-top: clamp(16px, 1.5vh, 24px);
}

.list-add-input {
  flex: 1;
  padding: clamp(10px, 1vw, 16px) clamp(14px, 1.5vw, 20px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: clamp(14px, 1.1vw, 18px);
  transition: all 0.3s var(--ease);
  font-family: var(--font);
}
.list-add-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.list-add-input::placeholder {
  color: var(--text-tertiary);
}

.btn-primary {
  padding: clamp(10px, 1vw, 16px) clamp(24px, 2vw, 36px);
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: clamp(14px, 1.1vw, 18px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s var(--spring);
  font-family: var(--font);
  white-space: nowrap;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--accent2);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99,102,241,0.25);
}

/* Items Grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(200px, min(100%, 50vw), 280px), 1fr));
  gap: clamp(14px, 1.5vw, 24px);
  padding: 0 clamp(24px, 3vw, 48px);
  padding-bottom: clamp(24px, 2vh, 40px);
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: clamp(16px, 1.8vw, 28px);
  cursor: pointer;
  transition: all 0.3s var(--spring);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.item-card:hover, .item-card:focus {
  background: var(--surface2);
  border-color: var(--accent-border);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(99,102,241,.12);
}
.item-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.item-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(12px, 1.2vw, 18px);
}

.item-checkbox {
  width: clamp(24px, 3vw, 36px);
  height: clamp(24px, 3vw, 36px);
  border-radius: 8px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(14px, 1.4vw, 18px);
  font-weight: 700;
  color: var(--success);
  transition: all 0.3s var(--ease);
}
.item-checkbox.checked {
  background: var(--success-subtle);
  border-color: var(--success);
}

.item-delete-btn {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: clamp(16px, 1.4vw, 20px);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s var(--ease);
  opacity: 0.6;
}
.item-delete-btn:hover {
  background: var(--danger-subtle);
  opacity: 1;
}

.item-name {
  font-size: clamp(15px, 1.2vw, 21px);
  font-weight: 600;
  color: var(--text);
  margin-bottom: clamp(8px, 0.8vw, 12px);
  word-break: break-word;
}

.item-qty, .item-meta {
  font-size: clamp(13px, 1vw, 16px);
  color: var(--text-dim);
}

.item-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.item-meta span {
  display: inline-block;
}

/* Meal Plan Cards */
.meals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(240px, min(100%, 50vw), 340px), 1fr));
  gap: clamp(16px, 1.5vw, 28px);
  padding: 0 clamp(24px, 3vw, 48px);
  padding-bottom: clamp(24px, 2vh, 40px);
}

.meal-plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: clamp(20px, 2vw, 32px);
  transition: all 0.3s var(--spring);
  animation: fadeUp 0.6s var(--spring) both;
}
.meal-plan-card:hover {
  border-color: var(--accent-border);
  background: var(--surface2);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(99,102,241,.12);
}

.meal-plan-title {
  font-size: clamp(16px, 1.3vw, 22px);
  font-weight: 700;
  color: var(--text);
  margin-bottom: clamp(12px, 1.2vw, 18px);
  letter-spacing: -0.3px;
}

.meal-plan-days {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1vw, 14px);
}

.meal-day-row {
  display: flex;
  gap: clamp(10px, 1.2vw, 16px);
  align-items: flex-start;
}

.meal-day-label {
  font-size: clamp(11px, 0.9vw, 13px);
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  min-width: clamp(40px, 5vw, 60px);
}

.meal-day-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meal-item {
  font-size: clamp(12px, 0.95vw, 16px);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.meal-icon {
  font-size: clamp(14px, 1.2vw, 18px);
}

/* Recipes Grid */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(220px, min(100%, 50vw), 300px), 1fr));
  gap: clamp(14px, 1.5vw, 24px);
  padding: 0 clamp(24px, 3vw, 48px);
  padding-bottom: clamp(24px, 2vh, 40px);
}

.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: clamp(16px, 1.8vw, 24px);
  cursor: pointer;
  transition: all 0.3s var(--spring);
}
.recipe-card:hover {
  background: var(--surface2);
  border-color: var(--accent-border);
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(99,102,241,.12);
}

.recipe-card-title {
  font-size: clamp(15px, 1.2vw, 20px);
  font-weight: 700;
  color: var(--text);
  margin-bottom: clamp(8px, 0.8vw, 12px);
  word-break: break-word;
}

.recipe-card-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: clamp(10px, 1vw, 14px);
}

.recipe-meta-item {
  font-size: clamp(12px, 0.95vw, 15px);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.recipe-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.recipe-tag {
  display: inline-block;
  background: var(--accent-subtle);
  color: var(--accent2);
  font-size: clamp(10px, 0.8vw, 12px);
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

/* ═══════════════ HOME HERO ═══════════════ */

.home-hero {
  display: flex;
  align-items: center;
  gap: clamp(20px, 2.5vw, 40px);
  padding: clamp(28px, 3vw, 52px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  margin-bottom: clamp(20px, 2vh, 36px);
  box-shadow: var(--card-shadow);
  animation: fadeUp 0.7s var(--spring) both;
  position: relative;
  overflow: hidden;
}
.home-hero-avatar {
  font-size: clamp(48px, 5vw, 80px);
  width: clamp(80px, 8vw, 120px);
  height: clamp(80px, 8vw, 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--gradient-2, var(--accent2)));
  border-radius: 24px;
  flex-shrink: 0;
  color: #fff;
}
.home-hero-name {
  font-size: clamp(28px, 3vw, 52px);
  font-weight: 800;
  margin: 0;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1.1;
}
.home-hero-sub {
  font-size: clamp(14px, 1.1vw, 18px);
  color: var(--text-dim);
  margin: 6px 0 0;
}

/* ═══════════════ HOME STATS ═══════════════ */

.home-stats-row {
  display: flex;
  gap: clamp(12px, 1.2vw, 20px);
  margin-bottom: clamp(20px, 2vh, 36px);
  flex-wrap: wrap;
  animation: fadeUp 0.7s var(--spring) 0.1s both;
}
.home-stat {
  flex: 1;
  min-width: 100px;
  text-align: center;
  padding: clamp(18px, 1.8vw, 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  transition: transform 0.4s var(--spring), border-color 0.3s var(--ease);
}
.home-stat:hover {
  transform: translateY(-2px);
  border-color: var(--accent-border);
}
.home-stat-value {
  font-size: clamp(30px, 3vw, 52px);
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  line-height: 1;
}
.home-stat-label {
  font-size: clamp(11px, 0.85vw, 14px);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 8px;
}
.home-stat-win .home-stat-value { color: var(--success); }
.home-stat-loss .home-stat-value { color: var(--danger); }

/* ═══════════════ HOME SECTION GRID ═══════════════ */

.home-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(280px, calc(50vw - 20px), 520px), 1fr));
  gap: clamp(16px, 2vw, 28px);
  margin-bottom: clamp(24px, 2.5vh, 40px);
}

/* ═══════════════ HOME MEMBERS ═══════════════ */

.home-members {
  animation: fadeUp 0.7s var(--spring) 0.2s both;
  padding: clamp(18px, 2vw, 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}
.home-members-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 15vw, 200px), 1fr));
  gap: clamp(12px, 1.5vw, 18px);
  margin-top: 14px;
}
.home-member-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: clamp(12px, 1.2vw, 16px);
  background: linear-gradient(135deg, var(--bg-subtle, rgba(99,102,241,0.06)), var(--bg-subtle-2, rgba(59,130,246,0.06)));
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: clamp(13px, 0.9vw, 16px);
  transition: all 0.3s var(--ease);
  cursor: pointer;
}
.home-member-chip:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99,102,241,0.15);
}
.home-member-name {
  font-weight: 700;
  color: var(--text);
  font-size: clamp(12px, 0.95vw, 14px);
  letter-spacing: -0.3px;
}
.home-member-role {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  background: var(--accent-subtle);
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

/* ═══════════════ GAME CODE JOIN ═══════════════ */

.home-code-join {
  margin-bottom: clamp(20px, 2vh, 36px);
  animation: fadeUp 0.7s var(--spring) 0.25s both;
  padding: clamp(18px, 2vw, 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}
.code-join-row {
  display: flex;
  gap: clamp(8px, 1vw, 12px);
  align-items: center;
  margin-top: 14px;
  max-width: 100%;
}
.code-join-input {
  flex: 1;
  min-width: 140px;
  padding: clamp(10px, 1vw, 14px) clamp(12px, 1.2vw, 18px);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: clamp(13px, 0.95vw, 16px);
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.3s var(--ease);
}
.code-join-input::placeholder {
  color: var(--text-tertiary);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font);
  font-weight: 400;
}
.code-join-input:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.code-join-btn {
  padding: clamp(10px, 1vw, 14px) clamp(16px, 1.8vw, 28px);
  font-size: clamp(13px, 0.9vw, 16px);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--success), #16a34a);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s var(--ease);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}
.code-join-btn:hover {
  background: linear-gradient(135deg, #16a34a, #15803d);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}
.code-join-btn:active {
  transform: translateY(0);
}
.code-join-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.code-join-error {
  margin-top: 8px;
  font-size: clamp(11px, 0.75vw, 14px);
  color: var(--danger);
  min-height: 1.2em;
}

/* ═══════════════ GAMES TOOLBAR ═══════════════ */

.games-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: clamp(16px, 2vh, 28px) 0 clamp(8px, 1vh, 16px);
  flex-shrink: 0;
}

.games-search-wrap {
  position: relative;
  flex: 1 1 300px;
  max-width: 480px;
}
.games-search-wrap .search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  pointer-events: none;
  opacity: 0.5;
}
.games-search {
  width: 100%;
  padding: 12px 18px 12px 50px;
  font-size: clamp(15px, 1.1vw, 18px);
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 980px;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease), background 0.3s var(--ease);
}
.games-search:focus {
  border-color: var(--accent);
  background: var(--surface2);
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-subtle);
}
.games-search::placeholder {
  color: var(--text-dim);
}

.games-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: clamp(13px, 0.95vw, 16px);
  font-family: var(--font);
  font-weight: 500;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 980px;
  cursor: pointer;
  transition: all 0.3s var(--ease);
  white-space: nowrap;
}
.cat-pill:hover {
  border-color: var(--accent-border);
  color: var(--text);
  background: var(--surface2);
}
.cat-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.cat-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 980px;
  background: rgba(255,255,255,.12);
}
.cat-pill.active .cat-count {
  background: rgba(255,255,255,.25);
}

.games-household-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  font-size: clamp(13px, 0.95vw, 16px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 980px;
  color: var(--text-dim);
  margin-left: auto;
}
.badge-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* ═══════════════ GAME CARDS ═══════════════ */

.games-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: clamp(16px, 1.5vw, 28px);
}
.games-grid > * {
  animation: fadeUp 0.6s var(--spring) both;
}
.games-grid > *:nth-child(1)  { animation-delay: 0ms; }
.games-grid > *:nth-child(2)  { animation-delay: 70ms; }
.games-grid > *:nth-child(3)  { animation-delay: 140ms; }
.games-grid > *:nth-child(4)  { animation-delay: 210ms; }
.games-grid > *:nth-child(5)  { animation-delay: 280ms; }
.games-grid > *:nth-child(6)  { animation-delay: 350ms; }

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  transition: transform 0.5s var(--spring), box-shadow 0.5s var(--spring), border-color 0.3s var(--ease);
  overflow: hidden;
}
.game-card:hover, .game-card:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 16px 48px rgba(99,102,241,.1);
  transform: translateY(-6px);
}

.game-card-accent {
  height: 3px;
  width: 100%;
  flex-shrink: 0;
}

.game-card-body {
  padding: clamp(20px, 1.6vw, 32px);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.game-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.game-emoji-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(52px, 4vw, 72px);
  height: clamp(52px, 4vw, 72px);
  border-radius: 18px;
  font-size: clamp(28px, 2.2vw, 40px);
  flex-shrink: 0;
  transition: transform 0.5s var(--spring);
}
.game-card:hover .game-emoji-circle {
  transform: scale(1.12) rotate(-4deg);
}
.game-header-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.game-header-info .card-title {
  font-size: clamp(18px, 1.4vw, 26px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.3px;
}
.game-category-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 3px 10px;
  border-radius: 6px;
  width: fit-content;
}

.game-desc {
  font-size: clamp(14px, 1vw, 18px);
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.6;
}

.game-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.game-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  font-size: clamp(11px, 0.8vw, 14px);
  background: var(--surface2);
  border-radius: 980px;
  color: var(--text-dim);
  font-weight: 600;
  border: 1px solid var(--border);
}
.meta-icon { font-size: 12px; }

.game-card-actions { margin-top: 8px; }
.game-rules-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: clamp(13px, 0.95vw, 16px);
  cursor: pointer;
  padding: 6px 0;
  font-family: var(--font);
  transition: color 0.3s var(--ease);
}
.game-rules-btn:hover {
  color: var(--accent2);
}

.game-card-footer {
  margin-top: auto;
  padding-top: 16px;
}
.btn-game-start {
  width: 100%;
  font-size: clamp(15px, 1.1vw, 20px);
  padding: 14px;
  font-weight: 700;
  letter-spacing: -0.1px;
}

/* ═══════════════ ACTIVE SESSIONS ═══════════════ */

.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr));
  gap: clamp(16px, 1.5vw, 28px);
  padding-top: clamp(16px, 1.5vw, 28px);
}
.sessions-grid > * {
  animation: fadeUp 0.6s var(--spring) both;
}
.sessions-grid > *:nth-child(1) { animation-delay: 0ms; }
.sessions-grid > *:nth-child(2) { animation-delay: 80ms; }
.sessions-grid > *:nth-child(3) { animation-delay: 160ms; }
.sessions-grid > *:nth-child(4) { animation-delay: 240ms; }

.session-card {
  cursor: pointer;
  padding: clamp(28px, 2.5vw, 48px);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.2vw, 20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
  transition: transform 0.5s var(--spring), box-shadow 0.5s var(--spring), border-color 0.3s var(--ease);
  min-height: clamp(200px, 18vw, 320px);
}
.session-card:hover,
.session-card:focus {
  border-color: var(--accent-border);
  box-shadow: 0 16px 48px rgba(99,102,241,.12);
  transform: translateY(-6px);
}

.session-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.session-game-type {
  font-size: clamp(22px, 2vw, 38px);
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.session-id {
  font-size: clamp(12px, 0.9vw, 16px);
  font-family: "SF Mono", "Menlo", monospace;
  color: var(--text-tertiary);
  word-break: break-all;
  line-height: 1.4;
}
.session-players {
  font-size: clamp(20px, 1.8vw, 32px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.session-status {
  display: inline-block;
  padding: clamp(6px, 0.5vw, 10px) clamp(14px, 1.2vw, 24px);
  border-radius: 980px;
  font-size: clamp(14px, 1.1vw, 20px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  width: fit-content;
}
.status-active {
  background: var(--success-subtle);
  color: var(--success);
  border: 1px solid rgba(48,209,88,0.25);
}
.status-waiting {
  background: rgba(255,214,10,0.1);
  color: var(--warning);
  border: 1px solid rgba(255,214,10,0.25);
  animation: statusPulse 2s ease-in-out infinite;
}
.session-time {
  font-size: clamp(13px, 1vw, 18px);
  color: var(--text-dim);
}
.session-action {
  font-size: clamp(14px, 1.1vw, 20px);
  color: var(--accent);
  font-weight: 600;
  margin-top: auto;
}
.session-empty {
  padding: 24px;
}
.session-empty .empty-icon { font-size: 48px; }
.session-empty .empty-sub { font-size: clamp(14px, 1vw, 18px); }

.session-clear-btn {
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid rgba(255,69,58,0.2);
  border-radius: 12px;
  width: clamp(36px, 2.8vw, 48px);
  height: clamp(36px, 2.8vw, 48px);
  font-size: clamp(16px, 1.2vw, 24px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease);
  flex-shrink: 0;
}
.session-clear-btn:hover {
  background: rgba(255,69,58,0.2);
  border-color: var(--danger);
}

.clear-all-btn {
  margin-left: 16px;
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid rgba(255,69,58,0.2);
  border-radius: 980px;
  padding: clamp(6px, 0.5vw, 10px) clamp(14px, 1.2vw, 24px);
  font-size: clamp(13px, 1vw, 18px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s var(--ease);
}
.clear-all-btn:hover {
  background: rgba(255,69,58,0.2);
  border-color: var(--danger);
}

/* ═══════════════ LEADERBOARD ═══════════════ */

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.lb-row {
  display: grid;
  grid-template-columns: clamp(50px, 6vw, 70px) 1fr clamp(60px, 8vw, 90px) clamp(50px, 7vw, 80px) clamp(50px, 7vw, 80px) clamp(50px, 7vw, 80px) clamp(70px, 10vw, 120px);
  align-items: center;
  padding: clamp(12px, 1.5vw, 20px) clamp(16px, 2vw, 32px);
  border-bottom: 1px solid var(--border);
  font-size: clamp(16px, 1.3vw, 22px);
  transition: background 0.3s var(--ease);
  position: relative;
  overflow: hidden;
  animation: slideIn 0.5s var(--spring) both;
}
.lb-row:nth-child(2)  { animation-delay: 50ms; }
.lb-row:nth-child(3)  { animation-delay: 100ms; }
.lb-row:nth-child(4)  { animation-delay: 150ms; }
.lb-row:nth-child(5)  { animation-delay: 200ms; }
.lb-row:nth-child(6)  { animation-delay: 250ms; }
.lb-row:nth-child(7)  { animation-delay: 300ms; }
.lb-row:nth-child(8)  { animation-delay: 350ms; }
.lb-row:nth-child(9)  { animation-delay: 400ms; }
.lb-row:nth-child(10) { animation-delay: 450ms; }

.lb-row:hover {
  background: var(--surface2);
}
.lb-header {
  font-weight: 700;
  color: var(--text-dim);
  font-size: clamp(11px, 0.9vw, 14px);
  text-transform: uppercase;
  letter-spacing: 2px;
  border-bottom: 1px solid var(--border-strong);
  padding: clamp(12px, 1.2vw, 18px) clamp(16px, 2vw, 32px);
}
.lb-top {
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.lb-rank { text-align: center; font-size: clamp(16px, 1.4vw, 22px); font-weight: 600; font-variant-numeric: tabular-nums; }
.lb-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(28px, 3vw, 36px);
  height: clamp(28px, 3vw, 36px);
  border-radius: 50%;
  color: #fff;
  font-size: clamp(13px, 1.2vw, 16px);
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.lb-name {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 14px);
  font-weight: 600;
  position: relative;
  z-index: 1;
  min-width: 0;
}
.lb-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(32px, 4vw, 44px);
  height: clamp(32px, 4vw, 44px);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: clamp(14px, 1.6vw, 20px);
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.lb-team-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
  z-index: 1;
}
.lb-row > .lb-rank,
.lb-row > .lb-gp,
.lb-row > .lb-w,
.lb-row > .lb-d,
.lb-row > .lb-l,
.lb-row > .lb-pts {
  position: relative;
  z-index: 1;
}
.lb-gp { text-align: center; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.lb-w  { text-align: center; font-variant-numeric: tabular-nums; color: var(--success); font-weight: 600; }
.lb-d  { text-align: center; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.lb-l  { text-align: center; font-variant-numeric: tabular-nums; color: var(--danger); font-weight: 600; }
.lb-pts { text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent2); font-size: clamp(18px, 1.6vw, 26px); }

/* Responsive leaderboard for smaller screens */
@media (max-width: 1080px) {
  .lb-row {
    grid-template-columns: 50px 1fr 70px 60px 60px 60px 80px;
    padding: 12px 16px;
    font-size: 16px;
  }
  .lb-header {
    font-size: 11px;
  }
}

@media (max-width: 768px) {
  .lb-row {
    grid-template-columns: 45px 1fr 60px 50px 50px 50px 70px;
    padding: 10px 12px;
    font-size: 14px;
  }
  .lb-header {
    font-size: 10px;
    padding: 10px 12px;
  }
  .lb-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  .lb-name {
    gap: 6px;
  }
}

/* ═══════════════ PLAY / SPECTATOR ═══════════════ */

.play-header .session-info {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-right: auto;
}
.play-header .badge {
  background: var(--accent);
  color: #fff;
  padding: 6px 18px;
  border-radius: 980px;
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
}
.play-header .session-id {
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  font-family: "SF Mono", "Menlo", monospace;
}

.live-connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 980px;
  background: rgba(0,0,0,0.28);
  min-height: 38px;
  border: none;
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

.live-connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 0 0 rgba(255,255,255,0);
}

.live-connection-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
}
[data-theme="light"] .live-connection-label {
  color: #1d1d1f;
}
[data-theme="light"] .live-connection-pill {
  background: rgba(255,255,255,0.35);
}

.live-connection-pill.is-connected {
  border-color: rgba(48,209,88,0.32);
  background: rgba(48,209,88,0.12);
}

.live-connection-pill.is-connected .live-connection-dot {
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(48,209,88,0.14);
}

.live-connection-pill.is-connecting,
.live-connection-pill.is-reconnecting {
  border-color: rgba(255,214,10,0.3);
  background: rgba(255,214,10,0.12);
}

.live-connection-pill.is-connecting .live-connection-dot,
.live-connection-pill.is-reconnecting .live-connection-dot {
  background: var(--warning);
  animation: statusPulse 1.6s ease-in-out infinite;
}

.live-connection-pill.is-disconnected {
  border-color: rgba(255,69,58,0.28);
  background: rgba(255,69,58,0.12);
}

.live-connection-pill.is-disconnected .live-connection-dot {
  background: var(--danger);
}

.play-layout {
  display: flex;
  gap: 32px;
  flex: 1;
  padding-top: 24px;
  overflow: hidden;
}
.play-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.play-right {
  width: clamp(280px, 33vw, 640px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.25vw, 24px);
}

/* ── Scoreboard ── */
.scoreboard-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  flex: 1;
  overflow-y: auto;
}
.scoreboard-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}
.status-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 16px;
  border-radius: 980px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.status-waiting { background: rgba(255,214,10,0.15); color: var(--warning); animation: statusPulse 2s ease-in-out infinite; }
.status-active  { background: var(--success-subtle); color: var(--success); }
.status-complete { background: var(--surface2); color: var(--text-dim); }

.score-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.score-label {
  width: 120px;
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.score-bar-outer {
  flex: 1;
  height: 24px;
  background: var(--surface2);
  border-radius: 12px;
  overflow: hidden;
}
.score-bar-inner {
  height: 100%;
  border-radius: 12px;
  transition: width 0.6s var(--spring);
  min-width: 4px;
}
.score-pts {
  width: 60px;
  text-align: right;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: transform 0.3s ease;
}
.score-pts.pop { animation: scorePop .35s ease; }

.play-actions {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

/* ── Camera Grid ── */
.camera-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  min-height: 300px;
  align-content: start;
}
.camera-placeholder {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 18px;
  padding: 40px;
  text-align: center;
}
.camera-tile {
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: #000;
  aspect-ratio: 4/3;
}
.camera-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.camera-tile .camera-label {
  position: absolute;
  bottom: 6px;
  left: 8px;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: clamp(11px, 0.75vw, 14px);
  padding: 2px 8px;
  border-radius: 8px;
}

/* ── Drawing canvas ── */
.draw-canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#draw-canvas {
  border-radius: var(--radius-sm);
  display: block;
  background: #0a0a0f;
}

/* ── Pictionary Layout ── */
.pictionary-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  padding: 24px 48px;
  gap: 16px;
}
.pictionary-header {
  text-align: center;
}
.pictionary-title {
  font-size: clamp(24px, 3vw, 40px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: 1px;
}
.pictionary-word {
  font-size: clamp(16px, 2vw, 28px);
  color: var(--text-dim);
  margin-top: 4px;
}
.pictionary-canvas-wrap {
  background: #0a0a0f;
  border: 2px solid var(--border-strong);
  border-radius: 16px;
  padding: 8px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1280px;
}
.pictionary-canvas-wrap #draw-canvas {
  width: 100%;
  height: 100%;
  max-width: 1280px;
  max-height: 720px;
}

/* ═══════════════ SPECTATOR LAYOUT ═══════════════ */

.spectator-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
  padding: 0;
  gap: 0;
  position: relative;
}

.spectator-top {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(14px, 1.2vw, 24px);
  padding: clamp(10px, 1.2vh, 20px) clamp(24px, 3vw, 48px) 0;
  width: 100%;
}

.spectator-player {
  display: flex;
  align-items: center;
  flex-direction: row;
  justify-content: flex-start;
  gap: 14px;
  padding: clamp(12px, 1vw, 18px) clamp(20px, 2.5vw, 36px);
  background: rgba(0,0,0,0.2);
  border: none;
  border-radius: 14px;
  min-width: min(100%, clamp(220px, 22vw, 320px));
  max-width: min(100%, 420px);
  transition: all 0.5s var(--spring);
  position: relative;
  overflow: hidden;
}
[data-theme="light"] .spectator-player {
  background: rgba(255,255,255,0.25);
}
.sp-avatar {
  width: clamp(56px, 4.5vw, 82px);
  height: clamp(56px, 4.5vw, 82px);
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(24px, 2vw, 36px);
  font-weight: 800;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}
.sp-avatar.sp-avatar-image {
  background-color: rgba(255,255,255,0.08);
}
.sp-avatar.sp-avatar-emoji {
  font-size: clamp(28px, 2.2vw, 40px);
}
.sp-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.spectator-player.active-turn {
  box-shadow: 0 0 24px rgba(255,214,10,0.4);
  background: rgba(0,0,0,0.35);
  animation: turnGlow 2s ease-in-out infinite;
}
[data-theme="light"] .spectator-player.active-turn {
  background: rgba(255,255,255,0.4);
  box-shadow: 0 0 24px rgba(255,214,10,0.5);
}
.spectator-player.winner {
  box-shadow: 0 0 36px rgba(255,214,10,0.5);
}

.sp-name {
  font-size: clamp(18px, 1.8vw, 32px);
  font-weight: 700;
  color: #fff;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  letter-spacing: -0.3px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme="light"] .sp-name {
  color: #1a1a1a;
  text-shadow: 0 1px 2px rgba(255,255,255,0.4);
}
.sp-cards {
  font-size: clamp(14px, 1.2vw, 22px);
  color: rgba(255,255,255,0.8);
  font-weight: 600;
  position: relative;
  z-index: 1;
}
[data-theme="light"] .sp-cards {
  color: rgba(0,0,0,0.6);
}
.sp-status {
  font-size: clamp(12px, 0.95vw, 16px);
  color: rgba(255,255,255,0.7);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  min-height: 1.3em;
}
[data-theme="light"] .sp-status {
  color: rgba(0,0,0,0.55);
}
.sp-status.is-complete {
  color: #4ade80;
}
[data-theme="light"] .sp-status.is-complete {
  color: #16a34a;
}
.sp-turn-dot {
  font-size: clamp(12px, 1vw, 18px);
  font-weight: 800;
  color: #ffd60a;
  text-transform: uppercase;
  letter-spacing: 2px;
  min-height: 20px;
  position: relative;
  z-index: 1;
}
[data-theme="light"] .sp-turn-dot {
  color: #b45309;
}

.spectator-vs {
  font-size: clamp(18px, 1.8vw, 32px);
  font-weight: 900;
  color: rgba(255,255,255,0.5);
  letter-spacing: 3px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  flex: 0 0 auto;
}
[data-theme="light"] .spectator-vs {
  color: rgba(0,0,0,0.4);
  text-shadow: none;
}

/* ── Pile Area ── */
.spectator-pile-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: clamp(10px, 1vw, 18px);
}

.phase-lays {
  width: 100%;
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.spectator-live-status {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 2px 0 4px;
}

.phase-lay-panel {
  background: rgba(0,0,0,0.2);
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
}
[data-theme="light"] .phase-lay-panel {
  background: rgba(255,255,255,0.2);
}

.phase-lay-title {
  font-size: clamp(13px, 1vw, 18px);
  font-weight: 800;
  color: #86efac;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
[data-theme="light"] .phase-lay-title {
  color: #15803d;
}

.phase-lay-groups {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.phase-lay-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Phase 10 mini cards ── */
.phase-mini-card {
  width: 34px;
  height: 48px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  clip-path: none;
}

.phase-mini-card[data-color="red"] { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.phase-mini-card[data-color="blue"] { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.phase-mini-card[data-color="green"] { background: linear-gradient(135deg, #22c55e, #15803d); }
.phase-mini-card[data-color="yellow"] { background: linear-gradient(135deg, #f2cc00, #d4a600); }
.phase-mini-card[data-color="wild"] { background: linear-gradient(135deg, #a855f7, #6366f1); }

.spectator-message {
  font-size: clamp(16px, 1.4vw, 26px);
  font-weight: 700;
  color: #fff;
  text-align: center;
  padding: clamp(10px, 1vw, 16px) clamp(20px, 2vw, 32px);
  background: rgba(0,0,0,0.3);
  border: none;
  border-radius: 980px;
  max-width: 92%;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  align-self: center;
}
[data-theme="light"] .spectator-message {
  background: rgba(255,255,255,0.3);
  color: #1a1a1a;
  text-shadow: none;
}

.spectator-pile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  min-height: 0;
  border-radius: 0;
  background: transparent;
}

.pile-empty {
  font-size: clamp(16px, 1.3vw, 24px);
  color: rgba(255,255,255,0.5);
  padding: 40px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
[data-theme="light"] .pile-empty {
  color: rgba(0,0,0,0.4);
  text-shadow: none;
}

.pile-play {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0.25;
  transform: scale(0.85);
  inset: 0;
  justify-content: center;
  transition: all 0.4s var(--spring);
}
.pile-play.pile-latest {
  opacity: 1;
  transform: scale(1);
  position: relative;
  inset: auto;
}

.pile-player-label {
  font-size: clamp(14px, 1.1vw, 20px);
  color: rgba(255,255,255,0.75);
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
[data-theme="light"] .pile-player-label {
  color: rgba(0,0,0,0.6);
  text-shadow: none;
}

.pile-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(8px, 0.8vw, 14px);
  max-width: min(100%, 760px);
}

/* ── TV Playing Cards (base) ── */
.tv-card {
  width: clamp(78px, 5.8vw, 124px);
  height: clamp(108px, 8.3vw, 176px);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s var(--spring);
  clip-path: none;
}

/* ── President (standard playing cards) ── */
.tv-card-president {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.08);
}
.pile-latest .tv-card-president {
  box-shadow: 0 6px 24px rgba(0,0,0,0.22), 0 2px 6px rgba(0,0,0,0.1);
  transform: scale(1.05);
}
.tv-card-president .tv-card-center .tv-card-suit {
  font-size: clamp(36px, 3.5vw, 64px);
  line-height: 1;
}

/* ── Joker card ── */
.tv-card-joker {
  background: linear-gradient(135deg, #7b2ff7, #e0245e, #f77f00) !important;
  border: 1px solid rgba(255,255,255,0.3) !important;
}
.tv-card-joker .tv-joker-letter {
  color: #fff;
  font-weight: 900;
}
.tv-card-joker .tv-card-joker-icon {
  font-size: clamp(32px, 3vw, 56px);
  line-height: 1;
}
.tv-card-joker .tv-card-joker-label {
  font-size: clamp(8px, 0.7vw, 12px);
  font-weight: 900;
  color: #fff;
  letter-spacing: 2px;
  margin-top: 2px;
}
.tv-card-joker .tv-card-corner-tl,
.tv-card-joker .tv-card-corner-br {
  color: #fff;
}

/* ── UNO cards ── */
.tv-card-uno {
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  color: #fff;
}
.tv-card-uno-red { background: linear-gradient(135deg, #e6261f, #b71c1c); }
.tv-card-uno-blue { background: linear-gradient(135deg, #1a4fe0, #0d2d80); }
.tv-card-uno-green { background: linear-gradient(135deg, #00b333, #007a26); }
.tv-card-uno-yellow { background: linear-gradient(135deg, #f2cc00, #d9a600); }
.tv-card-uno-wild { background: linear-gradient(135deg, #7b1fa2, #4527a0); }

.tv-card-uno-oval {
  position: absolute;
  width: 85%;
  height: 55%;
  background: rgba(255,255,255,0.22);
  border-radius: 50%;
  transform: rotate(-30deg);
}
.tv-card-uno .tv-card-rank {
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}
.tv-card-uno .tv-card-corner-rank {
  color: #fff;
  font-weight: 800;
  position: relative;
  z-index: 1;
}
.tv-card-uno-wild-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  z-index: 1;
}
.tv-card-uno-wild-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.tv-card-uno-wild-dots .dot-red { background: #e6261f; }
.tv-card-uno-wild-dots .dot-blue { background: #1a4fe0; }
.tv-card-uno-wild-dots .dot-green { background: #00b333; }
.tv-card-uno-wild-dots .dot-yellow { background: #f2cc00; }

.pile-latest .tv-card-uno {
  box-shadow: 0 8px 28px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.15);
  transform: scale(1.05);
}

/* ── Whot! cards ── */
.tv-card-whot {
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 4px 14px rgba(0,0,0,0.22);
  color: #fff;
}
.tv-card-whot-yellow { background: linear-gradient(135deg, #f2cc00, #d9a600); }
.tv-card-whot-red { background: linear-gradient(135deg, #e6261f, #b71c1c); }
.tv-card-whot-blue { background: linear-gradient(135deg, #1a4fe0, #0d2d80); }
.tv-card-whot-green { background: linear-gradient(135deg, #00b333, #007a26); }
.tv-card-whot-purple { background: linear-gradient(135deg, #8c28c8, #5b1680); }
.tv-card-whot-wild,
.tv-card-whot- { background: linear-gradient(135deg, #e67300, #cc5200); }

.tv-card-whot .tv-card-center .tv-card-suit {
  font-size: clamp(32px, 3vw, 56px);
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.tv-card-whot .tv-card-corner-rank {
  color: #fff;
  font-weight: 800;
}
.pile-latest .tv-card-whot {
  box-shadow: 0 8px 28px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.15);
  transform: scale(1.05);
}

/* ── Phase 10 cards ── */
.tv-card-p10 {
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  color: #fff;
}
.tv-card-p10-red { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.tv-card-p10-blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.tv-card-p10-green { background: linear-gradient(135deg, #22c55e, #15803d); }
.tv-card-p10-yellow { background: linear-gradient(135deg, #f2cc00, #d4a600); }
.tv-card-p10-wild { background: linear-gradient(135deg, #a855f7, #6366f1, #7c3aed); }

.tv-card-p10-texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tv-card-p10-wild .tv-card-p10-texture {
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.08), transparent 50%);
}
.tv-card-p10:not(.tv-card-p10-wild) .tv-card-p10-texture {
  background: radial-gradient(circle at 65% 35%, rgba(255,255,255,0.08), transparent 45%);
}

.tv-card-p10 .tv-card-rank {
  font-weight: 900;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.tv-card-p10-icon {
  font-size: clamp(14px, 1.2vw, 22px);
  position: relative;
  z-index: 1;
  opacity: 0.9;
}
.tv-card-p10-wild .tv-card-p10-icon {
  color: #fbbf24;
}
.tv-card-p10-color-letter {
  font-size: clamp(9px, 0.7vw, 13px);
  font-weight: 800;
  opacity: 0.65;
  position: relative;
  z-index: 1;
}

.pile-latest .tv-card-p10 {
  box-shadow: 0 8px 28px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.15);
  transform: scale(1.05);
}

/* ── Shared card typography ── */
/* ── Shared card typography ── */
.tv-card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 0;
}
.tv-card-corner-tl { top: 6px; left: 8px; }
.tv-card-corner-br { bottom: 6px; right: 8px; transform: rotate(180deg); }
.tv-card-corner-rank { font-size: clamp(12px, 1vw, 18px); font-weight: 800; }
.tv-card-corner-suit { font-size: clamp(10px, 0.8vw, 14px); }
.tv-card-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tv-card-rank {
  font-size: clamp(32px, 3vw, 56px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1px;
}
.tv-card-suit {
  font-size: clamp(36px, 3.5vw, 64px);
  line-height: 1;
}
.tv-card-red .tv-card-rank,
.tv-card-red .tv-card-suit,
.tv-card-red .tv-card-corner-rank,
.tv-card-red .tv-card-corner-suit {
  color: #dc2626;
}
.tv-card-black .tv-card-rank,
.tv-card-black .tv-card-suit,
.tv-card-black .tv-card-corner-rank,
.tv-card-black .tv-card-corner-suit {
  color: #1a1a2e;
}

/* ── Phase 10 mini cards ── */

/* ── Game Log Sidebar ── */
.spectator-log {
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, 80vw);
  height: 100vh;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(255,255,255,0.1);
  border-radius: 0;
  padding: 60px 16px 16px;
  overflow-y: auto;
  font-size: clamp(13px, 1vw, 16px);
  z-index: 9000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.spectator-log.log-open {
  transform: translateX(0);
}
[data-theme="light"] .spectator-log {
  background: rgba(255,255,255,0.9);
  border-left-color: rgba(0,0,0,0.1);
}

.log-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
[data-theme="light"] .log-close-btn {
  background: rgba(0,0,0,0.08);
  color: #1a1a1a;
}

.log-sidebar-title {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
}
[data-theme="light"] .log-sidebar-title {
  color: #1a1a1a;
}

.log-entry {
  padding: 6px 0;
  color: rgba(255,255,255,0.65);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.log-entry:first-child {
  color: #fff;
  font-weight: 600;
}
[data-theme="light"] .log-entry {
  color: rgba(0,0,0,0.6);
  border-bottom-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .log-entry:first-child {
  color: #1a1a1a;
}
.log-time {
  color: #ffd60a;
  font-weight: 500;
  margin-right: 8px;
  font-size: 0.85em;
}
[data-theme="light"] .log-time {
  color: #b8860b;
}

@media (max-width: 1366px) {
  .spectator-top {
    gap: 12px;
  }
  .spectator-player {
    min-width: min(100%, 300px);
    padding: 14px 18px;
  }
}

@media (max-width: 980px) {
  .spectator-top {
    flex-direction: column;
  }
  .spectator-vs {
    order: 2;
  }
  .spectator-player {
    width: min(100%, 540px);
  }
  .pile-cards {
    max-width: 100%;
  }
  .phase-lays {
    grid-template-columns: 1fr;
  }
  .tv-card {
    width: clamp(66px, 12vw, 110px);
    height: clamp(96px, 16vw, 150px);
  }
  .tv-card-rank {
    font-size: clamp(26px, 5vw, 44px);
  }
  .tv-card-suit,
  .tv-card-president .tv-card-center .tv-card-suit {
    font-size: clamp(28px, 5.5vw, 48px);
  }
}

/* ═══════════════ TOAST ═══════════════ */

.toast {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: var(--text);
  padding: 14px 32px;
  border-radius: 980px;
  font-size: 18px;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  opacity: 0;
  transition: all 0.5s var(--spring);
  z-index: 9999;
  pointer-events: none;
  border: 1px solid var(--border);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--accent); }

/* ═══════════════ SPINNER ═══════════════ */

.spinner {
  display: flex;
  justify-content: center;
  padding: 60px;
}
.spinner-ring {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ═══════════════ ANIMATIONS ═══════════════ */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .65; }
}
@keyframes turnGlow {
  0%, 100% { box-shadow: 0 0 24px rgba(255,214,10,.2); }
  50%      { box-shadow: 0 0 42px rgba(255,214,10,.35); }
}
@keyframes scorePop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Also keep old animation names for backwards compat */
@keyframes cardFadeUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,.15); }
  50%      { box-shadow: 0 0 20px 4px rgba(99,102,241,.2); }
}
@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .7; }
}

/* ═══════════════ SCROLLBAR ═══════════════ */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ═══════════════ CREATE BAR / MEMBER LIST ═══════════════ */

.create-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 8px;
}
.member-list {
  list-style: none;
  padding: 0;
  margin-top: 12px;
}
.member-list li {
  font-size: 17px;
  color: var(--text-dim);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.member-list li:last-child { border: none; }

.add-member-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.add-member-bar .input {
  max-width: none;
  flex: 1;
  font-size: clamp(14px, 1vw, 18px);
  padding: 8px 12px;
}
.add-member-bar .btn-add-member {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.add-member-bar .btn-add-member:hover {
  background: var(--accent2);
}
.member-list .member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.member-list .btn-remove-member {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0.6;
  transition: all 0.3s var(--ease);
}
.member-list .btn-remove-member:hover {
  opacity: 1;
  background: var(--danger-subtle);
}

/* ═══════════════ RESPONSIVE ═══════════════ */

/* Allow scrolling on non-TV screens (laptops, tablets) */
@media (max-width: 1920px) {
  html, body {
    overflow-y: auto;
    overflow-x: hidden;
    height: auto;
    min-height: 100vh;
  }
  #app {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .home-content, .games-content, .leaderboard-content {
    overflow: visible;
  }
  .card-grid {
    max-height: none;
  }
}

/* Large laptops (1280px–1440px) */
@media (max-width: 1440px) {
  .home-hero {
    padding: clamp(20px, 2.5vw, 36px);
  }
  .sessions-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  }
  .session-card {
    min-height: auto;
    padding: clamp(20px, 2vw, 32px);
  }
  .home-stat {
    min-width: 90px;
    padding: clamp(14px, 1.5vw, 24px);
  }
  .rules-body {
    padding: 28px 40px;
    gap: 28px;
  }
}

/* Small laptops and large tablets (768px–1024px) */
@media (max-width: 1024px) {
  .page-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
  }
  .nav-row {
    margin-left: 0;
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 4px;
  }
  .header-actions {
    margin-left: auto;
  }
  .home-hero {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
  .home-hero-avatar {
    margin: 0 auto;
  }
  .home-stats-row {
    gap: 8px;
  }
  .home-stat {
    min-width: 80px;
    padding: 14px 10px;
  }
  .home-stat-value {
    font-size: clamp(22px, 2.5vw, 36px);
  }
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    max-height: none;
  }
  .sessions-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  }
  .session-card {
    min-height: auto;
    padding: 20px;
  }
  .games-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .games-search-wrap {
    max-width: 100%;
    flex: auto;
  }
  .games-household-badge {
    margin-left: 0;
  }
  .play-layout { flex-direction: column; }
  .play-right { width: 100%; flex-direction: row; }
  .camera-grid { min-height: 180px; }
  .rules-body { grid-template-columns: 1fr; }
  .rules-hero {
    padding: 28px 24px;
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
}

/* Tablets and phones (< 768px) */
@media (max-width: 768px) {
  .page-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  .logo {
    font-size: 18px;
  }
  .nav-row {
    margin-left: 0;
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 4px;
  }
  .nav-btn {
    font-size: 13px;
    padding: 6px 12px;
  }
  .header-actions {
    margin-left: auto;
    gap: 6px;
  }
  .avatar-bg-toggle {
    min-width: 60px;
    height: 32px;
    font-size: 11px;
    padding: 0 10px;
  }
  .theme-toggle,
  .fullscreen-toggle {
    width: 32px;
    height: 32px;
  }
  .home-content, .games-content, .leaderboard-content {
    padding: 16px;
  }
  .home-hero {
    padding: 20px;
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  .home-hero-avatar {
    width: 64px;
    height: 64px;
    font-size: 32px;
    border-radius: 16px;
  }
  .home-hero-name {
    font-size: 24px;
  }
  .home-stats-row {
    gap: 6px;
    flex-wrap: wrap;
  }
  .home-stat {
    min-width: 70px;
    padding: 16px 12px;
  }
  .home-section-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .home-members-list {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  .code-join-row {
    flex-direction: column;
  }
  .code-join-input {
    width: 100%;
  }
  .home-stat-value {
    font-size: 22px;
  }
  .home-stat-label {
    font-size: 9px;
    letter-spacing: 1px;
  }
  .card-grid {
    grid-template-columns: 1fr;
    max-height: none;
  }
  .sessions-grid {
    grid-template-columns: 1fr;
  }
  .session-card {
    min-height: auto;
    padding: 18px;
  }
  .section-title {
    font-size: 20px;
  }
  .games-grid {
    grid-template-columns: 1fr;
  }
  .branding-footer {
    font-size: 10px;
    padding: 8px 12px;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .home-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .home-stat:nth-child(4),
  .home-stat:nth-child(5) {
    grid-column: span 1;
  }
  .session-game-type {
    font-size: 18px;
  }
  .session-players {
    font-size: 16px;
  }
  .ob-login-section {
    width: min(360px, 95vw);
  }
  .ob-social-buttons {
    flex-direction: column;
  }
}

/* ═══════════════ BRANDING FOOTER ═══════════════ */

.branding-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  padding: 10px 16px;
  font-size: clamp(11px, 0.85vw, 15px);
  color: var(--text-tertiary);
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  letter-spacing: 0.3px;
  z-index: 50;
  pointer-events: none;
}
.header-branding-sep { opacity: 0.4; }

/* ── Logout button ── */
.logout-btn {
  background: var(--danger-subtle) !important;
  color: var(--danger) !important;
  border: 1px solid rgba(255,69,58,0.2) !important;
  font-size: clamp(12px, 0.9vw, 15px) !important;
}
.logout-btn:hover {
  background: rgba(255,69,58,0.2) !important;
}

/* ── Play mode header overrides ── */
.play-header .logo,
.play-header .session-info,
.play-header .session-id {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.play-header .nav-btn {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
}
.play-header .nav-btn:hover {
  background: rgba(0,0,0,0.55);
}

/* ═══════════════ ONBOARDING & LOGIN ═══════════════ */

.ob-page {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(99,102,241,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(168,85,247,0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 0%, rgba(255,255,255,0.03) 0%, transparent 60%),
    var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .ob-page {
    justify-content: flex-start;
    padding: 60px 0 32px;
  }
}

/* ── Floating emojis ── */
.ob-floaters {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.ob-floater {
  position: absolute;
  opacity: 0.06;
  animation: obFloat 5s ease-in-out infinite alternate;
}
@keyframes obFloat {
  from { transform: translateY(8px); }
  to   { transform: translateY(-8px); }
}

/* ── Page dots ── */
.ob-dots {
  position: fixed;
  top: clamp(16px, 3vh, 32px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 102;
}
@media (max-width: 768px) {
  .ob-dots { top: 16px; }
}
.ob-dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.2);
  transition: all 0.4s var(--spring);
}
.ob-dot--active {
  width: 32px;
  background: var(--accent);
}

/* ── Feature step ── */
.ob-feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  z-index: 1;
  animation: obFadeUp 0.6s var(--spring);
  padding: 0 24px;
  margin-top: -6vh;
}
@keyframes obFadeUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ob-icon-ring {
  position: relative;
  width: clamp(120px, 18vw, 220px);
  height: clamp(120px, 18vw, 220px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: clamp(20px, 3vh, 40px);
}
.ob-icon-ring-outer {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent-subtle);
  animation: obRingPulse 3s ease-in-out infinite;
}
.ob-icon-ring-inner {
  position: absolute;
  inset: 15%;
  border-radius: 50%;
  background: var(--accent-subtle);
  opacity: 0.6;
}
@keyframes obRingPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.06); opacity: 0.6; }
}
.ob-icon-emoji {
  font-size: clamp(48px, 7vw, 88px);
  position: relative;
  z-index: 1;
}
.ob-feature-title {
  font-size: clamp(28px, 4vw, 56px);
  font-weight: 800;
  color: var(--text);
  margin: 0 0 14px;
  letter-spacing: -1px;
  line-height: 1.1;
}
.ob-feature-desc {
  font-size: clamp(15px, 1.6vw, 22px);
  color: var(--text-dim);
  max-width: 560px;
  line-height: 1.55;
  margin: 0 0 clamp(32px, 6vh, 60px);
}

/* ── Responsive hide for large screens ── */
@media (min-width: 1025px) {
}

/* ── Onboarding actions ── */
.ob-actions {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 2;
  margin-bottom: clamp(16px, 2vh, 28px);
}
@media (max-width: 1024px) {
  .ob-actions {
    margin-bottom: clamp(16px, 2vh, 28px);
    gap: 8px;
  }
}
@media (max-width: 768px) {
  .ob-actions {
    margin-bottom: clamp(16px, 2vh, 28px);
    gap: 8px;
  }
}
.ob-btn-continue {
  padding: 16px 0;
  width: clamp(260px, 30vw, 400px);
  font-size: clamp(17px, 1.4vw, 22px);
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 980px;
  cursor: pointer;
  transition: all 0.3s var(--spring);
  letter-spacing: -0.1px;
}
@media (max-width: 768px) {
  .ob-btn-continue { width: min(300px, 80vw); }
}
.ob-btn-continue:hover,
.ob-btn-continue:focus-visible {
  background: var(--accent2);
  transform: scale(1.03);
}
.ob-btn-skip {
  padding: 10px 24px;
  font-size: clamp(14px, 1.1vw, 17px);
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.3s var(--ease);
}
.ob-btn-skip:hover {
  color: var(--text);
}

/* ── Login step ── */
.ob-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  z-index: 1;
  animation: obFadeUp 0.6s var(--spring);
  margin-bottom: clamp(16px, 2vh, 36px);
  flex-shrink: 0;
}
.ob-logo-ring {
  width: clamp(80px, 14vw, 150px);
  height: clamp(80px, 14vw, 150px);
  border-radius: 50%;
  background: var(--accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: clamp(12px, 2vh, 28px);
}
.ob-logo-img {
  width: 70%;
  height: 70%;
  border-radius: 22%;
  object-fit: cover;
}
.ob-choice-title {
  font-size: clamp(26px, 3.5vw, 52px);
  font-weight: 800;
  color: var(--text);
  margin: 0 0 8px;
  line-height: 1.15;
  letter-spacing: -1px;
}
.ob-choice-desc {
  font-size: clamp(15px, 1.4vw, 22px);
  color: var(--text-dim);
  margin: 0;
}

/* ── Login card ── */
.ob-login-section {
  z-index: 1;
  width: min(420px, 90vw);
  animation: obFadeUp 0.6s var(--spring) 0.15s both;
  flex-shrink: 0;
  margin-top: clamp(20px, 3vh, 40px);
  margin-bottom: clamp(40px, 6vh, 80px);
}
.ob-login-card {
  padding: clamp(24px, 3vw, 40px);
}
@media (max-width: 768px) {
  .ob-login-section {
    margin-top: clamp(24px, 4vh, 50px);
    margin-bottom: clamp(24px, 4vh, 50px);
    width: min(100%, 90vw);
  }
}

.ob-btn-login {
  width: 100%;
  padding: 14px;
  font-size: clamp(16px, 1.3vw, 20px);
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 980px;
  cursor: pointer;
  transition: all 0.3s var(--spring);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: -0.1px;
}
.ob-btn-login:hover,
.ob-btn-login:focus-visible {
  background: var(--accent2);
  transform: scale(1.02);
}

/* ── Social sign-in ── */
.ob-social-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: clamp(18px, 2.5vh, 28px) 0 clamp(14px, 2vh, 20px);
}
.ob-social-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.ob-social-text {
  font-size: clamp(11px, 0.9vw, 14px);
  color: var(--text-dim);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ob-social-buttons {
  display: flex;
  gap: 20px;
  flex-direction: column;
}
.ob-social-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  font-size: clamp(13px, 1.05vw, 16px);
  font-weight: 600;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.3s var(--ease);
}
.ob-social-apple {
  background: #fff;
  color: #000;
}
.ob-social-apple:hover {
  background: #e8e8e8;
  transform: scale(1.02);
}
.ob-social-google {
  background: #fff;
  color: #444;
}
.ob-social-google:hover {
  background: #e8e8e8;
  transform: scale(1.02);
}

/* ── Cast message ── */
.ob-cast-msg {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: clamp(12px, 1vw, 15px);
  line-height: 1.55;
  text-align: center;
}
.ob-cast-msg .ob-cast-icon {
  font-size: 22px;
  display: block;
  margin-bottom: 4px;
}
.ob-cast-msg strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Back button ── */
.ob-btn-back {
  position: relative;
  font-size: clamp(14px, 1.1vw, 17px);
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  z-index: 2;
  transition: color 0.3s var(--ease);
}
@media (max-width: 768px) {
  .ob-btn-back {
    position: relative;
    bottom: auto;
    flex-shrink: 0;
  }
}
.ob-btn-back:hover {
  color: var(--text);
}

/* ── Login form fields ── */
.login-field {
  text-align: left;
  margin-bottom: clamp(14px, 2vh, 24px);
}
.login-field label {
  display: block;
  font-size: clamp(13px, 1vw, 16px);
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.login-field input {
  width: 100%;
  padding: 12px 16px;
  font-size: clamp(15px, 1.2vw, 18px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
  box-sizing: border-box;
  font-family: var(--font);
}
.login-field input::placeholder {
  color: var(--text-tertiary);
}
.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-subtle);
}
.login-error {
  background: var(--danger-subtle);
  border: 1px solid rgba(255,69,58,0.2);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 14px;
  text-align: center;
}
.login-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Onboarding branding ── */
.ob-branding {
  position: relative;
  text-align: center;
  color: var(--text-tertiary);
  font-size: clamp(10px, 0.8vw, 13px);
  line-height: 1.7;
  z-index: 2;
  margin-top: clamp(32px, 5vh, 60px);
  padding: 0;
}
@media (max-width: 768px) {
  .ob-branding {
    position: relative;
    bottom: auto;
    margin-top: 24px;
    padding: 16px 20px;
    background: var(--surface);
    border-radius: 14px;
    flex-shrink: 0;
    font-size: 11px;
    width: min(420px, 90vw);
  }
}
.ob-branding p { margin: 0; }
.ob-branding-products { color: var(--text-tertiary); }
.ob-branding-products strong { color: var(--text-dim); font-weight: 600; }
.ob-branding-url { color: var(--text-tertiary); font-size: clamp(9px, 0.7vw, 11px); opacity: 0.7; }
.ob-back-site {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: clamp(11px, 1vw, 14px);
  font-weight: 600;
  transition: opacity 0.2s;
}
.ob-back-site:hover { opacity: 0.7; text-decoration: underline; }

/* ═══════════════ RULES OVERLAY ═══════════════ */

.rules-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}
.rules-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.rules-overlay-content {
  position: relative;
  z-index: 1;
  background: var(--bg);
  width: 100%;
  height: 100%;
  overflow-y: auto;
  animation: rulesFadeIn 0.4s var(--spring);
  display: flex;
  flex-direction: column;
}
@keyframes rulesFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.rules-hero {
  position: relative;
  padding: clamp(36px, 4vh, 72px) clamp(40px, 5vw, 100px);
  display: flex;
  align-items: center;
  gap: clamp(24px, 3vw, 48px);
  flex-shrink: 0;
}
.rules-hero-bg {
  position: absolute;
  inset: 0;
  opacity: 0.1;
}
.rules-emoji {
  font-size: clamp(56px, 6vw, 100px);
  width: clamp(80px, 8vw, 140px);
  height: clamp(80px, 8vw, 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 28px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.rules-hero-text { position: relative; z-index: 1; }
.rules-title {
  font-size: clamp(36px, 4.5vw, 68px);
  font-weight: 800;
  margin: 0;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1.05;
}
.rules-category {
  display: inline-block;
  font-size: clamp(11px, 1vw, 16px);
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 5px 16px;
  border-radius: 8px;
  margin-top: 12px;
}
.rules-close-btn {
  position: absolute;
  top: clamp(16px, 2vh, 32px);
  right: clamp(16px, 2vw, 40px);
  width: clamp(40px, 3.5vw, 56px);
  height: clamp(40px, 3.5vw, 56px);
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: clamp(22px, 2.2vw, 36px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease);
  z-index: 2;
}
.rules-close-btn:hover {
  background: var(--danger-subtle);
  border-color: rgba(255,69,58,0.25);
  color: var(--danger);
  transform: scale(1.08);
}

.rules-body {
  flex: 1;
  padding: clamp(28px, 3vw, 64px) clamp(40px, 5vw, 100px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(28px, 3vw, 64px);
  align-content: start;
}
.rules-left {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 2vh, 36px);
}
.rules-right {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.rules-description {
  font-size: clamp(18px, 1.5vw, 28px);
  color: var(--text-dim);
  line-height: 1.7;
  margin: 0;
}
.rules-meta {
  display: flex;
  gap: clamp(10px, 1vw, 20px);
  flex-wrap: wrap;
}
.rules-meta-item {
  display: flex;
  align-items: center;
  gap: clamp(8px, 0.6vw, 14px);
  padding: clamp(10px, 1vh, 18px) clamp(16px, 1.5vw, 28px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: clamp(16px, 1.3vw, 24px);
  font-weight: 700;
  color: var(--text);
}
.rules-meta-item span { font-size: clamp(18px, 1.5vw, 28px); }
.rules-section-title {
  font-size: clamp(24px, 2.2vw, 44px);
  font-weight: 800;
  margin: 0 0 clamp(16px, 2vh, 32px);
  color: var(--text);
  letter-spacing: -0.5px;
}
.rules-list {
  padding-left: 0;
  margin: 0;
  list-style: none;
  counter-reset: rule-counter;
}
.rules-list li {
  counter-increment: rule-counter;
  font-size: clamp(16px, 1.3vw, 24px);
  line-height: 1.7;
  margin-bottom: clamp(12px, 1.2vh, 22px);
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: clamp(12px, 1vw, 20px);
  font-weight: 500;
}
.rules-list li::before {
  content: counter(rule-counter);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(28px, 2.2vw, 40px);
  height: clamp(28px, 2.2vw, 40px);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: clamp(13px, 1vw, 18px);
  font-weight: 800;
  margin-top: 2px;
}

@media (max-width: 900px) {
  .rules-body { grid-template-columns: 1fr; }
}

/* ═══════════════ SMOOTH SCROLL ═══════════════ */

.home-content, .games-content, .leaderboard-content,
.card-grid, .scoreboard-wrap, .spectator-log {
  scroll-behavior: smooth;
}

/* ═══════════════ REDUCED MOTION ═══════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════ WIN OVERLAY ═══════════════ */

.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: background 0.5s ease, backdrop-filter 0.5s ease, -webkit-backdrop-filter 0.5s ease;
}
.win-overlay-visible {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.win-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -40px;
  font-size: 28px;
  animation: confettiFall 3s ease-in forwards;
  opacity: 0;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  8% { opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

.win-panel {
  position: relative;
  z-index: 1;
  width: min(90vw, 480px);
  background: rgba(15, 23, 42, 0.95);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: scale(0.8);
  opacity: 0;
  animation: winPanelIn 0.5s ease-out 0.2s forwards;
}

@keyframes winPanelIn {
  to { transform: scale(1); opacity: 1; }
}

.win-panel-header {
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  padding: 28px 24px 20px;
  text-align: center;
}

.win-trophy {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 8px;
  animation: trophyBounce 1s ease-in-out 0.6s;
}

@keyframes trophyBounce {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.25); }
  60% { transform: scale(0.95); }
}

.win-title {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 800;
  color: #fff;
}
.win-subtitle {
  font-size: clamp(14px, 1.8vw, 20px);
  color: rgba(255,255,255,0.8);
  margin-top: 4px;
}

.win-scores {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.win-score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
}
.win-score-row.win-score-winner {
  background: rgba(234, 179, 8, 0.1);
  border-color: rgba(234, 179, 8, 0.3);
}

.win-medal {
  font-size: 24px;
  min-width: 32px;
  text-align: center;
}
.win-score-name {
  font-size: clamp(14px, 1.5vw, 20px);
  font-weight: 700;
  color: #fff;
  flex: 1;
}
.win-score-value {
  font-size: clamp(12px, 1.2vw, 16px);
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  font-variant-numeric: tabular-nums;
}
.win-score-winner .win-score-value {
  color: #4ade80;
}

.win-home-btn {
  display: block;
  width: calc(100% - 48px);
  margin: 0 24px 24px;
  padding: 14px;
  font-size: clamp(14px, 1.5vw, 18px);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.win-home-btn:hover {
  opacity: 0.85;
}

/* ═══════════════ LARGE TV SCREENS (75"+) ═══════════════ */
/* Optimized for UHD and 4K displays (2560px width and above) */

@media (min-width: 2560px) {
  /* ── Base scales for ultra-large screens ── */
  html, body {
    font-size: 32px;
  }
  
  .page-header {
    padding: 28px 60px;
    gap: 40px;
  }
  
  .logo {
    font-size: 36px;
  }
  
  .nav-btn {
    font-size: 24px;
    padding: 12px 28px;
  }
  
  /* ── Content areas ── */
  .home-content, .games-content, .leaderboard-content {
    padding: 60px 80px;
  }
  
  /* ── Hero section ── */
  .home-hero {
    gap: 60px;
    padding: 48px 64px;
    border-radius: 32px;
    margin-bottom: 48px;
  }
  
  .home-hero-avatar {
    width: 160px;
    height: 160px;
    font-size: 80px;
    border-radius: 32px;
  }
  
  .home-hero-name {
    font-size: 64px;
    margin-bottom: 16px;
  }
  
  .home-hero-sub {
    font-size: 28px;
  }
  
  /* ── Stats row ── */
  .home-stats-row {
    gap: 32px;
    margin-bottom: 48px;
  }
  
  .home-stat {
    padding: 40px 32px;
    border-radius: 24px;
    min-width: 140px;
  }
  
  .home-stat-value {
    font-size: 72px;
    margin-bottom: 12px;
  }
  
  .home-stat-label {
    font-size: 20px;
  }
  
  /* ── Card grids - more columns on ultra-wide displays ── */
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
    gap: 36px;
    padding-top: 36px;
  }
  
  /* ── Games grid ── */
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
    gap: 36px;
  }
  
  /* ── Sections ── */
  .section-title {
    font-size: 52px;
    gap: 20px;
    margin-bottom: 40px;
  }
  
  .section-count {
    font-size: 18px;
    padding: 6px 20px;
  }
  
  /* ── Cards ── */
  .card {
    padding: 48px;
    border-radius: 24px;
  }
  
  .card-title {
    font-size: 36px;
    margin-bottom: 8px;
  }
  
  .card-sub {
    font-size: 24px;
  }
  
  /* ── Household avatar on cards ── */
  .household-avatar {
    width: 72px;
    height: 72px;
    font-size: 32px;
    margin-bottom: 16px;
  }
  
  .household-badge {
    font-size: 28px;
    padding: 12px 32px;
  }
  
  /* ── Buttons ── */
  .btn {
    padding: 16px 48px;
    font-size: 28px;
    border-radius: 12px;
  }
  
  /* ── Inputs ── */
  .input {
    font-size: 24px;
    padding: 16px 28px;
    max-width: min(600px, 40vw);
    border-radius: 16px;
  }
  
  /* ── Game cards ── */
  .game-card {
    border-radius: 28px;
  }
  
  .game-card-body {
    padding: 40px;
  }
  
  .game-card-header {
    gap: 20px;
    margin-bottom: 24px;
  }
  
  .game-emoji-circle {
    width: 100px;
    height: 100px;
    font-size: 56px;
    border-radius: 24px;
  }
  
  .game-header-info .card-title {
    font-size: 32px;
  }
  
  .game-desc {
    font-size: 24px;
    margin-bottom: 24px;
  }
  
  .game-meta-chip {
    padding: 8px 20px;
    font-size: 18px;
    margin-bottom: 8px;
  }
  
  .game-category-badge {
    font-size: 14px;
    padding: 6px 16px;
  }
  
  .btn-game-start {
    font-size: 24px;
    padding: 20px;
  }
  
  /* ── Sessions grid ── */
  .sessions-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr));
    gap: 36px;
    padding-top: 36px;
  }
  
  .session-card {
    padding: 48px;
    border-radius: 24px;
    min-height: auto;
    gap: 20px;
  }
  
  .session-game-type {
    font-size: 52px;
  }
  
  .session-id {
    font-size: 20px;
    line-height: 1.6;
  }
  
  .session-players {
    font-size: 44px;
  }
  
  .session-status {
    padding: 12px 28px;
    font-size: 24px;
  }
  
  .session-time {
    font-size: 24px;
  }
  
  .session-action {
    font-size: 28px;
  }
  
  /* ── Leaderboard ── */
  .lb-row {
    padding: 24px 40px;
    font-size: 28px;
    grid-template-columns: 80px 1.5fr 100px 80px 80px 80px 120px;
  }
  
  .lb-header {
    font-size: 18px;
    padding: 20px 40px;
  }
  
  .lb-rank {
    font-size: 28px;
  }
  
  .lb-medal {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }
  
  .lb-avatar {
    width: 52px;
    height: 52px;
    font-size: 24px;
  }
  
  .lb-pts {
    font-size: 32px;
  }
  
  /* ── Play layout ── */
  .play-layout {
    gap: 40px;
    padding-top: 32px;
  }
  
  .play-right {
    width: clamp(320px, 38vw, 800px);
    gap: 20px;
  }
  
  .scoreboard-wrap {
    padding: 40px;
    border-radius: 24px;
  }
  
  .scoreboard-title {
    font-size: 36px;
    margin-bottom: 28px;
  }
  
  .score-label {
    font-size: 28px;
    width: 160px;
  }
  
  .score-bar-outer {
    height: 36px;
    border-radius: 18px;
  }
  
  .score-pts {
    font-size: 32px;
    width: 80px;
  }
  
  /* ── Camera grid ── */
  .camera-grid {
    padding: 16px;
    min-height: 420px;
    border-radius: 24px;
  }
  
  .camera-tile .camera-label {
    font-size: 18px;
    padding: 6px 12px;
  }
  
  /* ── Drawing canvas ── */
  .draw-canvas-wrap {
    padding: 16px;
    border-radius: 24px;
  }
  
  #draw-canvas {
    border-radius: 20px;
  }
  
  /* ── Pictionary ── */
  .pictionary-layout {
    padding: 48px 64px;
    gap: 24px;
  }
  
  .pictionary-title {
    font-size: 56px;
  }
  
  .pictionary-word {
    font-size: 40px;
  }
  
  .pictionary-canvas-wrap {
    border: 4px solid var(--border-strong);
    border-radius: 24px;
    padding: 12px;
    max-width: 1600px;
  }
  
  /* ── Spectator layout ── */
  .spectator-top {
    gap: 32px;
    padding: 24px 60px 0;
  }
  
  .spectator-player {
    gap: 20px;
    padding: 20px 40px;
    border-radius: 20px;
    min-width: min(100%, 360px);
  }
  
  .sp-avatar {
    width: 120px;
    height: 120px;
    font-size: 56px;
    border-radius: 50%;
  }
  
  .sp-name {
    font-size: 44px;
  }
  
  .sp-cards {
    font-size: 32px;
  }
  
  .sp-status {
    font-size: 20px;
  }
  
  .sp-turn-dot {
    font-size: 24px;
  }
  
  .spectator-vs {
    font-size: 48px;
  }
  
  .spectator-pile-area {
    padding: 24px;
  }
  
  .spectator-message {
    font-size: 36px;
    padding: 16px 40px;
  }
  
  .phase-lay-title {
    font-size: 24px;
    margin-bottom: 16px;
  }
  
  .phase-mini-card {
    width: 48px;
    height: 68px;
    border-radius: 8px;
    font-size: 20px;
  }
  
  /* ── TV Playing cards ── */
  .tv-card {
    width: clamp(100px, 7.5vw, 160px);
    height: clamp(144px, 10vw, 224px);
    border-radius: 14px;
    gap: 6px;
  }
  
  .tv-card-corner-rank {
    font-size: 24px;
  }
  
  .tv-card-corner-suit {
    font-size: 20px;
  }
  
  .tv-card-rank {
    font-size: 64px;
  }
  
  .tv-card-suit {
    font-size: 80px;
  }
  
  .tv-card-uno-oval {
    border-radius: 50%;
  }
  
  /* ── Pile cards ── */
  .pile-cards {
    gap: 18px;
    max-width: min(100%, 960px);
  }
  
  .pile-player-label {
    font-size: 28px;
  }
  
  .pile-empty {
    font-size: 32px;
  }
  
  /* ── Empty states ── */
  .empty-state {
    padding: 100px 0;
  }
  
  .empty-icon {
    font-size: 120px;
    margin-bottom: 32px;
  }
  
  .empty-title {
    font-size: 52px;
    margin-top: 16px;
  }
  
  .empty-sub {
    font-size: 28px;
    margin-top: 12px;
  }
  
  /* ── Members section ── */
  .home-members {
    margin-bottom: 48px;
  }
  
  .home-members-list {
    gap: 16px;
    margin-top: 24px;
  }
  
  .home-member-chip {
    gap: 12px;
    padding: 12px 28px;
    font-size: 20px;
  }
  
  .home-member-role {
    font-size: 14px;
    padding: 4px 12px;
  }
  
  /* ── Game code join ── */
  .home-code-join {
    margin-bottom: 48px;
  }
  
  .code-join-row {
    gap: 16px;
    margin-top: 24px;
    max-width: 680px;
  }
  
  .code-join-input {
    padding: 16px 28px;
    font-size: 24px;
    letter-spacing: 2px;
  }
  
  .code-join-btn {
    padding: 16px 40px;
    font-size: 20px;
  }
  
  .code-join-error {
    margin-top: 12px;
    font-size: 18px;
  }
  
  /* ── Games toolbar ── */
  .games-toolbar {
    gap: 24px;
    padding: 32px 0 24px;
  }
  
  .games-search-wrap {
    flex: 1 1 400px;
    max-width: 620px;
  }
  
  .games-search-wrap .search-icon {
    font-size: 24px;
    left: 24px;
  }
  
  .games-search {
    padding: 16px 28px 16px 68px;
    font-size: 24px;
    border-radius: 12px;
  }
  
  .games-filter-row {
    gap: 12px;
  }
  
  .cat-pill {
    padding: 12px 24px;
    font-size: 20px;
  }
  
  .games-household-badge {
    padding: 12px 28px;
    font-size: 20px;
    gap: 12px;
  }
  
  .badge-dot {
    width: 12px;
    height: 12px;
  }
  
  /* ── Toast notifications ── */
  .toast {
    bottom: 64px;
    padding: 20px 48px;
    border-radius: 12px;
    font-size: 24px;
  }
  
  /* ── Spectator log sidebar ── */
  .spectator-log {
    width: min(420px, 90vw);
    padding: 80px 24px 24px;
  }
  
  .log-close-btn {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
  
  .log-sidebar-title {
    font-size: 20px;
    margin-bottom: 16px;
  }
  
  .log-entry {
    padding: 8px 0;
    font-size: 18px;
  }
  
  .log-time {
    font-size: 16px;
  }
  
  /* ── Status indicators ── */
  .status-dot {
    font-size: 28px;
  }
  
  /* ── Member lists ── */
  .member-list li {
    font-size: 24px;
    padding: 12px 0;
  }
  
  .add-member-bar {
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
  }
  
  .add-member-bar .input {
    font-size: 20px;
    padding: 12px 16px;
    max-width: 100%;
  }
  
  .add-member-bar .btn-add-member {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }
  
  .member-list .btn-remove-member {
    font-size: 18px;
    padding: 4px 10px;
  }
  
  /* ── Win screen ── */
  .win-head-emoji {
    font-size: 120px;
  }
  
  .win-title {
    font-size: 64px;
  }
  
  .win-score-list {
    gap: 16px;
  }
  
  .win-score-medal {
    gap: 16px;
  }
  
  .win-medal {
    font-size: 36px;
    min-width: 48px;
  }
  
  .win-score-name {
    font-size: 28px;
  }
  
  .win-score-value {
    font-size: 22px;
  }
  
  .win-home-btn {
    font-size: 28px;
    padding: 20px;
    margin: 36px 32px 32px;
    border-radius: 16px;
    width: calc(100% - 64px);
  }
  
  /* ── Avatar backgrounds ── */
  [data-avatar-bg="on"] .has-avatar-emoji::before {
    font-size: clamp(120px, 12vw, 200px);
  }
}

/* ═══════════════ ULTRAWIDE 4K (3840px+) ═══════════════ */
/* 55"-65" TVs and cinematic displays */

@media (min-width: 3840px) {
  html, body {
    font-size: 48px;
  }
  
  .page-header {
    padding: 40px 80px;
  }
  
  .logo {
    font-size: 52px;
  }
  
  .home-content, .games-content, .leaderboard-content {
    padding: 80px 120px;
  }
  
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr));
    gap: 48px;
  }
  
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr));
  }
  
  .home-hero {
    gap: 80px;
    padding: 64px 80px;
  }
  
  .home-hero-avatar {
    width: 220px;
    height: 220px;
    font-size: 120px;
  }
  
  .home-hero-name {
    font-size: 80px;
  }
  
  .home-stats-row {
    gap: 40px;
  }
  
  .home-stat-value {
    font-size: 96px;
  }
  
  .sessions-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 620px), 1fr));
  }
}
