/* ==================== RESET & BASE ==================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  /* — Egyptian gilded palette — */
  --bg-primary: #080810;
  --bg-secondary: #0f1018;
  --bg-card: rgba(15, 16, 24, 0.8);
  --bg-card-solid: #0f1018;
  --bg-input: #0a0a14;
  --text: #f0ead6;
  --text-muted: #7a7060;
  --text-dim: #a09880;
  --border: rgba(212,175,55,0.15);
  --border-hover: rgba(212,175,55,0.4);
  --accent: #D4AF37;
  --accent-hover: #E5C249;
  --accent-soft: rgba(212,175,55,0.12);
  --accent-glow: rgba(212,175,55,0.25);
  --purple: #D4AF37;
  --purple-soft: rgba(212,175,55,0.15);
  --red: #ef4444;
  --yellow: #eab308;
  --green: #22c55e;
  --slate: #94a3b8;
  --danger: #dc2626;
  --success: #16a34a;
  --board-light: #dcc8a0;
  --board-dark: #a01818;
  --radius: 10px;
  --radius-lg: 14px;
  --font-display: 'Cinzel', 'Palatino Linotype', Georgia, serif;
  --gold: #D4AF37;
  /* Easing */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  /* Safe areas */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  /* Dynamic board cell size — computed by JS, fallback here */
  --cell-size: 64px;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  letter-spacing: 0.3px;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 30% -5%, rgba(212,175,55,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 105%, rgba(139,0,0,0.04) 0%, transparent 50%);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  padding-top: var(--sat);
  padding-left: var(--sal);
  padding-right: var(--sar);
  padding-bottom: var(--sab);
}

/* — Checkered chess backdrop (subtle) — */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background: repeating-conic-gradient(#8B0000 0% 25%, #111 0% 50%) 0 0 / 60px 60px;
  opacity: 0.055;
  pointer-events: none;
}

/* — Star map / celestial texture overlay — */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 30%, rgba(212,175,55,0.03) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(212,175,55,0.02) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(139,0,0,0.03) 0%, transparent 60%),
    radial-gradient(1px 1px at 15% 25%, rgba(212,175,55,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 35% 65%, rgba(212,175,55,0.1) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 15%, rgba(212,175,55,0.12) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 45%, rgba(212,175,55,0.08) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 85%, rgba(212,175,55,0.1) 0%, transparent 100%);
  opacity: 0.7;
  pointer-events: none;
}

/* ==================== SCREENS ==================== */
.screen { display: none; }
.screen.active {
  display: flex;
  animation: screenIn 0.4s var(--ease-out) both;
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== COMMON ==================== */
.muted { color: var(--text-muted); font-size: 0.9em; }
.highlight { color: var(--accent); font-weight: 600; }
h3 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-dim); margin-bottom: 8px; font-weight: 700;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s var(--ease-out);
  text-decoration: none;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
  min-height: 44px;
  min-width: 44px;
  position: relative;
  overflow: hidden;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #1a1510 0%, #0f0d08 100%);
  color: var(--gold);
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 1px;
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 0 1px rgba(212,175,55,0.3), 0 0 20px rgba(212,175,55,0.15);
}
.btn-secondary {
  background: var(--bg-card-solid);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; min-height: 36px; }
.btn-icon { font-size: 1.3em; font-weight: 300; }
.btn-roll { width: 100%; padding: 14px; font-size: 1.1rem; letter-spacing: 1px; }

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #2a2010 0%, #1a1508 100%);
    border-color: #E5C249;
    box-shadow: inset 0 0 0 1px rgba(229,194,73,0.4), 0 0 30px rgba(212,175,55,0.3);
    transform: translateY(-1px);
  }
  .btn-secondary:hover:not(:disabled) { border-color: var(--border-hover); background: rgba(212,175,55,0.06); }
  .btn-danger:hover:not(:disabled) { background: #b91c1c; }
  .btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(255,255,255,0.04); }
}

/* Active/pressed — Emil: scale(0.97) for tactile feel */
.btn:active:not(:disabled) { transform: scale(0.97); transition-duration: 0.1s; }

/* ==================== INPUTS ==================== */
input[type="text"] {
  background: var(--bg-input); color: var(--text); border: 1px solid var(--border);
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 16px;
  outline: none; width: 100%;
  transition: border-color 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="text"]::placeholder { color: var(--text-muted); }
.input-group { margin-bottom: 16px; }
.input-group label {
  display: block; margin-bottom: 6px; font-weight: 600;
  font-size: 0.8rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1px;
}

/* ==================== SESSION BANNER ==================== */
.session-banner {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px; padding: 10px 14px; margin-bottom: 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(212,175,55,0.25);
  border-radius: var(--radius); font-size: 0.88rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.session-info { color: var(--text-dim); }
.session-info strong { color: var(--accent); }
.session-actions { display: flex; gap: 6px; }

/* ==================== MODE TABS ==================== */
.mode-tabs {
  display: flex; gap: 3px; border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  padding: 3px; margin-bottom: 2px;
}
.mode-tab {
  flex: 1; padding: 8px 6px; background: transparent; border: none;
  color: var(--text-muted); font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  touch-action: manipulation; min-height: 36px;
  border-radius: var(--radius);
}
.mode-tab.active {
  background: linear-gradient(135deg, #D4AF37 0%, #b8962e 100%);
  color: #080810;
  box-shadow: 0 2px 10px rgba(212,175,55,0.35);
  font-weight: 700;
  font-family: var(--font-display);
}
@media (hover: hover) and (pointer: fine) {
  .mode-tab:not(.active):hover { background: rgba(212,175,55,0.08); color: var(--text); }
}

/* ==================== R&G TOGGLE ==================== */
.rg-toggle { margin: 10px 0; }
.toggle-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.85rem; color: var(--text-dim); cursor: pointer;
  user-select: none;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-track {
  width: 42px; height: 24px; background: rgba(212,175,55,0.12); border-radius: 12px;
  border: 1px solid rgba(212,175,55,0.2);
  position: relative; flex-shrink: 0; transition: background 0.25s var(--ease-out);
}
.toggle-track::after {
  content: '\1FAB2'; position: absolute; top: 2px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-primary);
  font-size: 14px; line-height: 18px; text-align: center;
  transition: transform 0.25s var(--ease-spring);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.toggle-label input:checked + .toggle-track { background: var(--gold); border-color: var(--gold); }
.toggle-label input:checked + .toggle-track::after { transform: translateX(18px); }

/* ==================== TEAM BADGES ==================== */
.team-badge {
  font-size: 0.6rem; font-weight: 800; padding: 2px 6px;
  border-radius: 6px; letter-spacing: 0.5px; flex-shrink: 0;
}
.team-A { background: rgba(212,175,55,0.2); color: #D4AF37; border: 1px solid rgba(212,175,55,0.3); }
.team-B { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.25); }

/* ==================== LOBBY ==================== */
#lobby-screen {
  justify-content: center; align-items: flex-start;
  padding: 36px 28px 56px;
  min-height: 100vh; min-height: 100dvh;
}
.lobby-container { max-width: 980px; width: 100%; margin: 0 auto; }

.lobby-topbar { margin-bottom: 28px; }

/* Hero split layout */
.lobby-hero {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 48px;
  align-items: start;
  margin-bottom: 20px;
}

.hero-panel {
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.hero-tagline {
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--text-dim);
  max-width: 400px;
}
.hero-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.hero-features li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  transition: transform 0.2s var(--ease-out);
}
.hero-features li strong { color: var(--text); display: block; margin-bottom: 1px; }
.hf-icon { font-size: 1.25rem; width: 30px; text-align: center; flex-shrink: 0; margin-top: 1px; }
.hero-mode-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-pill {
  padding: 5px 14px;
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 20px;
  font-size: 0.75rem;
  color: rgba(212,175,55,0.75);
  background: rgba(212,175,55,0.05);
  letter-spacing: 0.3px;
  transition: all 0.2s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .hero-pill:hover { border-color: rgba(212,175,55,0.4); background: rgba(212,175,55,0.1); }
}

.lobby-hero-right { display: flex; flex-direction: column; gap: 10px; }
.lobby-hero-right .lobby-card { margin-bottom: 0; }

.lobby-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.lobby-bottom .lobby-card { margin-bottom: 0; }

.logo { text-align: center; margin-bottom: 20px; }
.logo h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 3rem);
  letter-spacing: 8px;
  background: linear-gradient(160deg, #fff8e0 0%, #D4AF37 40%, #D4AF37 70%, #9a7d1e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}
.logo .subtitle {
  color: var(--text-dim);
  margin-top: 6px;
  font-size: 0.72rem;
  letter-spacing: 4px;
  text-transform: uppercase;
}
.logo::after {
  content: '';
  display: block;
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: 14px auto 0;
  opacity: 0.5;
}

.lobby-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 4vw, 24px);
  margin-bottom: 12px;
  box-shadow:
    0 4px 24px rgba(0,0,0,0.4),
    0 1px 0 rgba(255,255,255,0.03) inset;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .lobby-card:hover {
    border-color: rgba(255,255,255,0.08);
  }
}
.lobby-actions { display: flex; flex-direction: column; gap: 12px; }
.divider { text-align: center; color: var(--gold); position: relative; margin: 8px 0; }
.divider span { background: var(--bg-card-solid); padding: 0 14px; position: relative; z-index: 1; font-size: 1.2rem; letter-spacing: 1px; }
.divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: 0.4; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; text-align: center; letter-spacing: 3px; font-weight: 600; text-transform: uppercase; }

.games-list { max-height: 180px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.game-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px; border-radius: var(--radius); margin-bottom: 4px;
  background: rgba(255,255,255,0.02); border: 1px solid transparent;
  transition: all 0.2s var(--ease-out);
  cursor: pointer; touch-action: manipulation;
  min-height: 44px;
}
@media (hover: hover) and (pointer: fine) {
  .game-item:hover { border-color: var(--border-hover); background: var(--accent-soft); }
}
.game-item:active { border-color: var(--accent); transform: scale(0.98); }
.game-item .code { font-weight: 700; letter-spacing: 1px; color: var(--accent); }
.game-item .info { font-size: 0.85em; color: var(--text-dim); }

/* ==================== WAITING ROOM ==================== */
#waiting-screen {
  justify-content: center; align-items: center;
  min-height: 100vh; min-height: 100dvh;
  padding: 20px 16px;
}
.waiting-container { text-align: center; max-width: 500px; width: 100%; }
.waiting-container h2 {
  margin-bottom: 20px; font-size: clamp(1.3rem, 5vw, 1.8rem);
  font-family: var(--font-display); letter-spacing: 2px;
}
.room-code-display {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.room-code-display .label { color: var(--text-dim); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; }
.room-code-display .code {
  font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; letter-spacing: 5px;
  color: var(--accent); background: var(--bg-card-solid); padding: 8px 18px;
  border-radius: var(--radius); border: 1px solid var(--border-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}
.waiting-players {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 20px;
}
.waiting-slot {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 10px; text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.3s var(--ease-out);
}
.waiting-slot:not(.filled) {
  animation: waitingPulse 2.5s ease-in-out infinite;
}
@keyframes waitingPulse {
  0%, 100% { border-color: var(--border); }
  50% { border-color: rgba(212,175,55,0.2); }
}
.waiting-slot.filled { border-color: var(--success); box-shadow: 0 0 12px rgba(22,163,74,0.15); }
.waiting-slot .color-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; margin-bottom: 4px; }
.waiting-slot .player-name { font-weight: 600; font-size: 0.9rem; word-break: break-word; }
.waiting-slot .empty-label { color: var(--text-muted); font-size: 0.9rem; }
.waiting-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

/* ==================== GAME LAYOUT ==================== */
#game-screen {
  min-height: 100vh; min-height: 100dvh;
  padding: 8px;
  padding-bottom: calc(8px + var(--sab));
}
.game-layout {
  display: flex; gap: 12px; justify-content: center;
  align-items: flex-start; width: 100%; max-width: 1400px; margin: 0 auto;
}
.game-sidebar { width: 260px; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.board-area { flex-shrink: 0; }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ==================== TURN INDICATOR ==================== */
.turn-indicator {
  font-size: 1.15rem; font-weight: 700; text-align: center;
  padding: 4px 0; transition: all 0.3s var(--ease-out);
}
.turn-red    { color: var(--red); text-shadow: 0 0 20px rgba(239,68,68,0.3); }
.turn-yellow { color: var(--yellow); text-shadow: 0 0 20px rgba(234,179,8,0.3); }
.turn-green  { color: var(--green); text-shadow: 0 0 20px rgba(34,197,94,0.3); }
.aow-mode .turn-green { text-shadow: 0 0 20px rgba(59,130,246,0.3); }
.turn-black  { color: var(--slate); text-shadow: 0 0 20px rgba(148,163,184,0.2); }

/* ==================== PLAYERS LIST ==================== */
.player-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  font-size: 0.9rem; border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: all 0.25s var(--ease-out);
}
.player-row:last-child { border-bottom: none; }
.player-row .dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  transition: box-shadow 0.3s var(--ease-out);
}
.player-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .pieces { color: var(--text-dim); font-size: 0.8em; font-variant-numeric: tabular-nums; }
.player-row.eliminated { opacity: 0.25; text-decoration: line-through; }
.player-row.current {
  font-weight: 700;
}
.player-row.current .dot {
  box-shadow: 0 0 8px currentColor;
}
.player-row .you-badge {
  font-size: 0.6rem; background: var(--accent); color: white;
  padding: 2px 7px; border-radius: 8px; font-weight: 700;
  letter-spacing: 0.5px;
}
.player-row .disconnected { color: var(--danger); font-size: 0.75em; }

/* ==================== DICE ==================== */
.dice-area { text-align: center; }
.dice-display { display: flex; justify-content: center; gap: 12px; margin: 10px 0; }
.die {
  width: 64px; height: 64px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; transition: all 0.3s var(--ease-out); cursor: default;
}
.die-icon { font-size: 1.4rem; line-height: 1; }
.die-label { font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.75; }
.die.active {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent); box-shadow: 0 0 16px var(--accent-glow);
}
.die.used { opacity: 0.18; }
.die.die-king.active   { border-color: #E5C249; background: rgba(229,194,73,0.1); color: #E5C249; box-shadow: 0 0 12px rgba(229,194,73,0.2); }
.die.die-elephant.active { border-color: #38bdf8; background: rgba(56,189,248,0.1); color: #38bdf8; box-shadow: 0 0 12px rgba(56,189,248,0.15); }
.die.die-horse.active  { border-color: #fb923c; background: rgba(251,146,60,0.1); color: #fb923c; box-shadow: 0 0 12px rgba(251,146,60,0.15); }
.die.die-boat.active   { border-color: #34d399; background: rgba(52,211,153,0.1); color: #34d399; box-shadow: 0 0 12px rgba(52,211,153,0.15); }

@keyframes diceRoll {
  0% { transform: rotateX(0deg) scale(1); }
  30% { transform: rotateX(180deg) scale(1.08); }
  60% { transform: rotateX(360deg) scale(0.96); }
  100% { transform: rotateX(360deg) scale(1); }
}
.die.rolling { animation: diceRoll 0.5s var(--ease-out); }

/* ==================== BOARD ==================== */
.board {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  border: 4px solid rgba(212, 175, 55, 0.65);
  border-radius: 6px;
  padding: 0;
  background: rgba(212, 175, 55, 0.08);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.85),
    0 0 0 4px rgba(212, 175, 55, 0.35),
    0 14px 56px rgba(0, 0, 0, 0.8),
    0 0 80px rgba(212, 175, 55, 0.12);
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.cell {
  width: var(--cell-size); height: var(--cell-size);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell-size) * 0.46);
  cursor: pointer; position: relative;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
  transition: box-shadow 0.15s var(--ease-out), filter 0.15s var(--ease-out);
}
.cell.light { background: var(--board-light); }
.cell.dark  { background: var(--board-dark); }
.cell.selected { box-shadow: inset 0 0 0 3px #D4AF37; z-index: 2; }
.cell.move-target::after {
  content: ''; position: absolute; width: 28%; height: 28%;
  background: rgba(34, 197, 94, 0.6); border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.3);
}
.cell.capture-target {
  box-shadow: inset 0 0 0 3px var(--red);
  z-index: 1;
}
.cell.capture-target::after {
  content: ''; position: absolute; inset: 3px;
  border-radius: 50%;
  border: 2px solid rgba(239, 68, 68, 0.3);
  pointer-events: none;
}
.cell.last-move { background: rgba(201, 162, 39, 0.18) !important; }

@media (hover: hover) and (pointer: fine) {
  .cell:hover { filter: brightness(1.06); }
}
.cell:active { filter: brightness(0.92); transition-duration: 0.05s; }

/* ==================== PIECE RENDERING ==================== */
.piece-wrap {
  display: flex; flex-direction: column; align-items: center;
  line-height: 1; gap: 0; position: relative;
  transition: transform 0.15s var(--ease-out);
}
.piece-icon { font-size: calc(var(--cell-size) * 0.46); line-height: 1; }
.piece-name {
  font-size: max(6px, calc(var(--cell-size) * 0.14));
  font-weight: 800; letter-spacing: 0.3px; line-height: 1.1;
  text-transform: uppercase; opacity: 0.85;
}

.piece-wrap.piece-red    { color: #ef4444; filter: drop-shadow(0 1px 3px rgba(239,68,68,0.35)); }
.piece-wrap.piece-yellow { color: #eab308; filter: drop-shadow(0 1px 3px rgba(234,179,8,0.35)); }
.piece-wrap.piece-green  { color: #22c55e; filter: drop-shadow(0 1px 3px rgba(34,197,94,0.35)); }
.aow-mode .piece-wrap.piece-green { color: #3b82f6; filter: drop-shadow(0 1px 3px rgba(59,130,246,0.35)); }
.piece-wrap.piece-black  { color: #c0c8d8; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5)); }

/* ==================== THRONE SQUARE ==================== */
.throne-double {
  background: radial-gradient(circle, rgba(212,175,55,0.2) 0%, transparent 75%) !important;
  outline: 1px solid rgba(212,175,55,0.3);
  outline-offset: -1px;
}
.throne-partner {
  display: block;
  font-size: max(5px, calc(var(--cell-size) * 0.13));
  opacity: 0.7;
  line-height: 1;
  margin-top: 1px;
  letter-spacing: 0.2px;
}

/* ==================== BOARD COORDINATES ==================== */
.coord-label {
  position: absolute; font-size: max(7px, calc(var(--cell-size) * 0.16));
  font-weight: 700; opacity: 0.3; line-height: 1; pointer-events: none;
  color: #333;
}
.cell.dark .coord-label { color: #e8d5b0; }
.rank-label { top: 2px; left: 2px; }
.file-label { bottom: 2px; right: 3px; }

@keyframes piecePlace {
  from { transform: scale(1.15); opacity: 0.6; }
  to { transform: scale(1); opacity: 1; }
}
.cell .piece-anim { animation: piecePlace 0.2s var(--ease-spring); }

/* ==================== TABS ==================== */
.tabs-panel { display: flex; flex-direction: column; height: 400px; }
.tabs { display: flex; gap: 0; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; padding: 8px; background: none; border: none; color: var(--text-muted);
  font-size: 0.82rem; font-weight: 600; cursor: pointer; text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 2px solid transparent;
  transition: all 0.25s var(--ease-out);
  touch-action: manipulation; min-height: 44px;
}
.tab:active { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.tab-content.active { display: flex; }

/* ==================== MOVE HISTORY ==================== */
.move-history {
  flex: 1; overflow-y: auto; font-size: 0.8rem; line-height: 1.8;
  font-family: 'JetBrains Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.move-history::-webkit-scrollbar { width: 3px; }
.move-history::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.move-entry {
  padding: 3px 6px; border-bottom: 1px solid rgba(255,255,255,0.02);
  transition: background 0.15s;
}
.move-entry:hover { background: rgba(255,255,255,0.02); }
.move-entry .turn-num { color: var(--text-muted); margin-right: 6px; }
.move-entry .capture { color: var(--red); font-weight: 600; }
.move-entry .promotion { color: var(--accent); font-weight: 600; }
.move-entry.king-capture { background: rgba(239, 68, 68, 0.08); border-left: 2px solid var(--red); }

/* ==================== CHAT ==================== */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 4px; font-size: 0.85rem;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.chat-msg { padding: 4px 0; }
.chat-msg .chat-name { font-weight: 700; margin-right: 4px; }
.chat-msg .chat-name.red { color: var(--red); }
.chat-msg .chat-name.yellow { color: var(--yellow); }
.chat-msg .chat-name.green { color: var(--green); }
.chat-msg .chat-name.black { color: var(--slate); }
.chat-msg .chat-text { color: var(--text); word-break: break-word; }
.chat-msg .chat-time { color: var(--text-muted); font-size: 0.75em; margin-left: 6px; }
.chat-input-row { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; padding: 8px 10px; }

/* ==================== PIECE LEGEND ==================== */
.piece-legend { font-size: 0.78rem; }
.legend-row { padding: 3px 0; color: var(--text-dim); display: flex; align-items: flex-start; gap: 6px; }
.legend-row b { color: var(--text); }
.leg-sym { font-size: 1.2em; flex-shrink: 0; width: 20px; text-align: center; }

/* ==================== REPLAY ==================== */
.replay-controls {
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
#replay-counter { font-size: 0.85rem; color: var(--text-dim); min-width: 60px; text-align: center; font-variant-numeric: tabular-nums; }

/* ==================== OVERLAY ==================== */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center; justify-content: center;
  padding: 20px;
}
.overlay.show {
  display: flex;
  animation: overlayIn 0.3s var(--ease-out) both;
}
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.overlay-content {
  text-align: center;
  background: var(--bg-card-solid);
  padding: clamp(24px, 5vw, 40px) clamp(20px, 5vw, 60px);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow:
    0 24px 80px rgba(0,0,0,0.6),
    0 0 0 1px rgba(255,255,255,0.04) inset;
  max-width: 90vw;
  animation: contentIn 0.35s var(--ease-spring) both;
  animation-delay: 0.05s;
}
@keyframes contentIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.overlay-content h2 { font-size: clamp(1.5rem, 6vw, 2.2rem); margin-bottom: 12px; font-family: var(--font-display); letter-spacing: 2px; }
.overlay-content p { color: var(--text-dim); margin-bottom: 20px; }
.overlay-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ==================== RESPONSIVE — TABLETS ==================== */
@media (max-width: 1100px) {
  .game-layout { flex-direction: column; align-items: center; }
  .game-sidebar { width: 100%; max-width: 520px; }
  .sidebar-left { order: 1; flex-direction: row; flex-wrap: wrap; }
  .sidebar-left .panel { flex: 1; min-width: 160px; }
  .board-area { order: 2; }
  .sidebar-right { order: 3; }
  .tabs-panel { height: 280px; }
}

/* ==================== RESPONSIVE — LOBBY HERO COLLAPSE ==================== */
@media (max-width: 860px) {
  .lobby-hero { grid-template-columns: 1fr; gap: 0; }
  .hero-panel { display: none; }
  .lobby-hero-right { max-width: 520px; margin: 0 auto; width: 100%; }
  .lobby-bottom { max-width: 520px; margin: 0 auto; width: 100%; }
}
@media (max-width: 600px) {
  .lobby-bottom { grid-template-columns: 1fr; }
}

/* ==================== RESPONSIVE — PHONES ==================== */
@media (max-width: 600px) {
  html { font-size: 13px; }
  #lobby-screen { padding: 16px 12px 32px; }
  .lobby-container { max-width: 100%; }
  .lobby-card { padding: 14px 12px; }

  .game-layout { gap: 8px; }
  .sidebar-left { flex-direction: column; }
  .sidebar-left .panel { min-width: 0; }
  .game-sidebar { max-width: 100%; }
  .tabs-panel { height: 220px; }

  .die { width: 50px; height: 50px; font-size: 0.65rem; }
  .dice-display { gap: 8px; }

  .waiting-players { gap: 8px; }
  .waiting-slot { padding: 10px 8px; }
}

/* ==================== RESPONSIVE — VERY SMALL ==================== */
@media (max-width: 380px) {
  html { font-size: 12px; }
  .lobby-card { padding: 12px 10px; }
  .panel { padding: 10px 8px; }
  .die { width: 44px; height: 44px; }
}

/* ==================== LANDSCAPE PHONE ==================== */
@media (max-height: 500px) and (orientation: landscape) {
  #game-screen { padding: 4px; }
  .game-layout { flex-direction: row; flex-wrap: nowrap; align-items: flex-start; gap: 8px; }
  .game-sidebar { width: 200px; }
  .sidebar-left { order: 1; flex-direction: column; }
  .board-area { order: 2; }
  .sidebar-right { order: 3; }
  .tabs-panel { height: 200px; }
  .panel { padding: 8px; }
}

/* ==================== CONNECTION STATUS BAR ==================== */
.connection-bar {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 6px 12px;
  padding-top: calc(6px + var(--sat));
  background: var(--danger);
  color: white; text-align: center;
  font-size: 0.8rem; font-weight: 600;
  z-index: 2000;
  transform: translateY(-100%);
  transition: transform 0.3s var(--ease-out);
}
.connection-bar.show { transform: translateY(0); }

/* ==================== AUTH SIGN-IN SCREEN ==================== */
.auth-fullscreen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(212,175,55,0.06) 0%, transparent 60%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 18px;
  padding: 40px 32px;
  max-width: 420px; width: 100%;
  text-align: center;
  box-shadow:
    0 24px 80px rgba(0,0,0,0.6),
    0 0 0 1px rgba(255,255,255,0.03) inset;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}
.auth-logo h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: 5px;
  background: linear-gradient(160deg, #fff8e0 0%, #D4AF37 45%, #9a7d1e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  margin-bottom: 4px;
}
.auth-logo p  { color: var(--text-muted); font-size: 0.8rem; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 28px; }
.auth-body h2 { font-size: 1.4rem; margin-bottom: 8px; }
.auth-sub     { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }

.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 20px;
  background: #fff; color: #1f1f1f;
  border: none; border-radius: 10px;
  font-size: 1rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}
.btn-google:hover  { background: #f5f5f5; box-shadow: 0 2px 12px rgba(0,0,0,0.2); }
.btn-google:active { transform: scale(0.97); }

.auth-features    { margin-top: 24px; text-align: left; }
.auth-feature-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; font-size: 0.9rem; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.auth-feature-row:last-child { border-bottom: none; }
.auth-feature-row strong     { color: var(--text); }
.auth-feature-icon           { font-size: 1rem; flex-shrink: 0; padding-top: 1px; }
.premium-row .auth-feature-icon { color: #D4AF37; }

/* ==================== USER BAR ==================== */
.user-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.user-name    { font-size: 0.9rem; color: var(--text-dim); }
.user-actions { display: flex; gap: 6px; }

/* ==================== PAYMENT WALL ==================== */
.payment-content {
  max-width: 680px; width: 100%;
  padding: 36px 32px;
  position: relative;
}
.payment-content h2 { font-family: var(--font-display); font-size: 1.6rem; letter-spacing: 2px; margin-bottom: 6px; }
.payment-sub        { color: var(--text-muted); margin-bottom: 28px; }

.payment-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 560px) { .payment-options { grid-template-columns: 1fr; } }

.payment-option {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px 20px; text-align: center;
  position: relative; display: flex; flex-direction: column; gap: 16px;
  transition: border-color 0.25s var(--ease-out);
}
.payment-option:first-child { border-color: var(--accent); box-shadow: 0 0 20px var(--accent-glow); }
.payment-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #D4AF37, #D4AF37);
  color: white;
  font-size: 0.72rem; font-weight: 700; padding: 3px 14px;
  border-radius: 20px; white-space: nowrap;
}
.payment-option h3   { font-size: 1.1rem; }
.payment-price       { font-size: 2rem; font-weight: 700; color: var(--accent); }
.payment-price span  { font-size: 0.9rem; color: var(--text-muted); font-weight: 400; }
.payment-features    { list-style: none; text-align: left; margin: 0; padding: 0; flex: 1; }
.payment-features li { padding: 5px 0; color: var(--text-muted); font-size: 0.9rem; }
.payment-features li::before { content: '✓ '; color: var(--accent); }

.btn-close-overlay {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; color: var(--text-muted);
  font-size: 1.2rem; cursor: pointer; line-height: 1;
  transition: color 0.15s, transform 0.15s var(--ease-out);
}
.btn-close-overlay:hover { color: var(--text); transform: scale(1.1); }
.btn-close-overlay:active { transform: scale(0.95); }

/* ==================== HISTORY & INFO OVERLAY ==================== */
.history-content {
  max-width: 660px; width: 100%; padding: 28px 28px 32px;
  position: relative; max-height: 88vh; overflow-y: auto;
  text-align: left;
}
.history-tabs {
  display: flex; gap: 6px; margin-bottom: 24px; flex-wrap: wrap;
}
.history-tab {
  padding: 7px 16px; border-radius: 20px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 0.85rem; font-weight: 600;
  transition: all 0.2s var(--ease-out);
}
.history-tab.active {
  background: var(--accent); color: white; border-color: var(--accent);
  font-weight: 700;
}
.history-tab:hover:not(.active) { border-color: var(--border-hover); color: var(--text); }
.history-pane { display: none; }
.history-pane.active { display: block; animation: fadeInContent 0.3s var(--ease-out) both; }
@keyframes fadeInContent {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.history-pane h2 { font-size: 1.3rem; margin-bottom: 14px; }
.history-pane h3 { font-size: 1rem; margin: 16px 0 8px; color: var(--text-dim); }
.history-pane p { line-height: 1.7; color: var(--text); font-size: 0.92rem; margin-bottom: 12px; }
.history-placeholder {
  color: var(--text-muted); font-style: italic; font-size: 0.88rem;
  padding: 14px 16px; background: var(--accent-soft);
  border-left: 3px solid var(--accent); border-radius: 4px;
  margin-bottom: 20px;
}
.history-rules-preview {
  background: var(--bg-secondary); border-radius: var(--radius);
  padding: 16px 18px; margin-top: 8px;
  border: 1px solid var(--border);
}
.social-links-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.social-link {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; background: var(--bg-secondary);
  border-radius: var(--radius); text-decoration: none;
  color: var(--text); font-weight: 600; font-size: 0.92rem;
  border: 1px solid var(--border);
  transition: all 0.2s var(--ease-out);
}
.social-link:hover { border-color: var(--border-hover); background: var(--accent-soft); transform: translateY(-1px); }
.social-link.placeholder-link { opacity: 0.4; cursor: default; }
.social-link.placeholder-link:hover { transform: none; border-color: var(--border); background: var(--bg-secondary); }
.social-icon { font-size: 1.1rem; width: 24px; text-align: center; }

/* ==================== LEADERBOARD ==================== */
.leaderboard-content {
  max-width: 560px; width: 100%; padding: 32px 28px;
  position: relative;
}
.leaderboard-content h2 { margin-bottom: 20px; font-family: var(--font-display); letter-spacing: 3px; }
.leaderboard-table {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
}
.leaderboard-table th {
  text-align: left; padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted); font-weight: 600;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px;
}
.leaderboard-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.leaderboard-table tr:last-child td { border-bottom: none; }
.lb-rank   { width: 40px; color: var(--text-muted); font-weight: 700; font-size: 1.1em; }
.lb-name   { display: flex; align-items: center; gap: 10px; }
.lb-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.lb-played { color: var(--text-dim); }
.lb-wins   { font-weight: 700; color: var(--accent); }
.lb-rate   { color: var(--text-muted); }
.lb-points { font-weight: 700; color: #a78bfa; }

/* ==================== MARKETPLACE ==================== */
.marketplace-content {
  max-width: 720px; width: 100%; padding: 32px 28px;
  position: relative; max-height: 85vh; overflow-y: auto;
}
.marketplace-content h2 { margin-bottom: 4px; font-family: var(--font-display); letter-spacing: 3px; }
.marketplace-sub { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 18px; }
.marketplace-filters {
  display: flex; align-items: center; gap: 6px; margin-bottom: 18px; flex-wrap: wrap;
}
.mp-filter {
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim); font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s var(--ease-out);
}
.mp-filter.active { background: var(--purple-soft); border-color: var(--accent); color: var(--accent); }
.mp-filter:not(.active):hover { border-color: rgba(212,175,55,0.3); }
.mp-sort-select {
  margin-left: auto; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--text-primary); font-size: 0.8rem;
  cursor: pointer;
}
.marketplace-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.mp-card {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--bg-secondary); cursor: pointer;
  transition: transform 0.2s var(--ease-out), border-color 0.2s;
}
.mp-card:hover { transform: translateY(-2px); border-color: rgba(212,175,55,0.4); }
.mp-preview {
  height: 120px; position: relative; display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 8px;
}
.mp-type-badge {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,0.6); color: #fff;
}
.mp-info { padding: 12px; }
.mp-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.mp-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mp-creator { font-size: 0.75rem; color: var(--text-muted); }
.mp-rating { font-size: 0.8rem; color: #eab308; letter-spacing: 1px; }
.mp-bottom { display: flex; justify-content: space-between; align-items: center; }
.mp-price {
  font-size: 0.8rem; font-weight: 700; padding: 2px 8px; border-radius: 6px;
}
.mp-price.free { background: rgba(34,197,94,0.15); color: #22c55e; }
.mp-price.paid { background: rgba(167,139,250,0.15); color: #a78bfa; }
.mp-downloads { font-size: 0.7rem; color: var(--text-dim); }

@media (max-width: 600px) {
  .marketplace-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .mp-preview { height: 90px; }
  .marketplace-content { padding: 20px 16px; }
}

/* ==================== PROFILE ==================== */
.profile-content {
  max-width: 580px; width: 100%; padding: 28px 28px 32px;
  position: relative; max-height: 88vh; overflow-y: auto;
  text-align: left;
}
.profile-tabs {
  display: flex; gap: 6px; margin-bottom: 24px; flex-wrap: wrap;
}
.profile-tab {
  padding: 7px 16px; border-radius: 20px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 0.85rem; font-weight: 600;
  transition: all 0.2s var(--ease-out);
}
.profile-tab.active {
  background: var(--accent); color: white; border-color: var(--accent);
  font-weight: 700;
}
.profile-tab:hover:not(.active) { border-color: var(--border-hover); color: var(--text); }
.profile-pane { display: none; }
.profile-pane.active { display: block; animation: fadeInContent 0.3s var(--ease-out) both; }

.profile-header {
  display: flex; align-items: center; gap: 18px; margin-bottom: 24px;
  padding-bottom: 20px; border-bottom: 1px solid var(--border);
}
.profile-avatar-wrap { flex-shrink: 0; }
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--accent); background: var(--bg-secondary);
}
.profile-name-wrap h2 { font-size: 1.4rem; margin-bottom: 4px; }
.profile-points { font-size: 0.9rem; color: #a78bfa; font-weight: 700; }

.profile-form { display: flex; flex-direction: column; gap: 14px; }
.profile-field { display: flex; flex-direction: column; gap: 4px; }
.profile-field label {
  font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.profile-field input,
.profile-field textarea {
  padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 0.9rem; font-family: inherit;
  transition: border-color 0.2s;
}
.profile-field input:focus,
.profile-field textarea:focus { outline: none; border-color: var(--accent); }
.profile-field textarea { resize: vertical; min-height: 60px; }
.profile-select {
  padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 0.9rem; cursor: pointer; width: 100%;
}

.profile-stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.profile-stat-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.profile-stat-value {
  font-size: 1.8rem; font-weight: 700; color: var(--accent); line-height: 1;
}
.profile-stat-label {
  font-size: 0.75rem; color: var(--text-muted); margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.5px;
}

@media (max-width: 600px) {
  .profile-content { padding: 20px 16px; }
  .profile-header { flex-direction: column; text-align: center; }
  .profile-stats-grid { gap: 8px; }
}

/* ==================== PREMIUM TAB INDICATOR ==================== */
.mode-tab.premium-tab::after { content: ''; }
.mode-tab.premium-tab { position: relative; }

/* ==================== TOAST ==================== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card-solid); border: 1px solid var(--border);
  color: var(--text); padding: 12px 24px; border-radius: var(--radius);
  font-size: 0.9rem; z-index: 10000;
  animation: toastIn 0.35s var(--ease-spring);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast-success { border-color: var(--accent); color: var(--accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ==================== FOCUS STATES (ACCESSIBILITY) ==================== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:focus-visible { outline-offset: 3px; }

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

/* ==================== HEADINGS ==================== */
.leaderboard-content h2 { font-family: var(--font-display); letter-spacing: 3px; }
.history-content > .overlay-header h2 { font-family: var(--font-display); letter-spacing: 3px; }
.history-pane h2 { font-family: var(--font-display); letter-spacing: 2px; }

/* ==================== BOARD THEMES ==================== */
.board.theme-bw .cell.light { background: #ebebeb; }
.board.theme-bw .cell.dark  { background: #454545; }
.board.theme-bw .cell.dark .coord-label { color: #ccc; }
.board.theme-bw .cell.last-move { background: rgba(212,175,55,0.2) !important; }

.board.theme-green .cell.light { background: #e4ecd8; }
.board.theme-green .cell.dark  { background: #6e9060; }
.board.theme-green .cell.dark .coord-label { color: #c4d8b8; }
.board.theme-green .cell.last-move { background: rgba(212,175,55,0.2) !important; }

/* Enochian elemental sub-boards. Each of the 4 elements shows the board "tinged"
   with its primary color, and the 4 quadrants are shaded by the sub-element.
   Quadrant assignment: Yellow/Air=NW, Blue/Water=NE, Red/Fire=SE, Black/Earth=SW */

/* Air (Yellow dominant) */
.board.theme-air .cell.light { background: #faf0b8; }
.board.theme-air .cell.dark.quad-nw { background: #d4b830; }
.board.theme-air .cell.dark.quad-ne { background: #96b4cc; }
.board.theme-air .cell.dark.quad-se { background: #d47040; }
.board.theme-air .cell.dark.quad-sw { background: #645838; }
.board.theme-air .cell.dark .coord-label { color: #f5e59a; }
.board.theme-air .cell.last-move { background: rgba(212,175,55,0.28) !important; }

/* Water (Blue dominant) */
.board.theme-water .cell.light { background: #d4e8f5; }
.board.theme-water .cell.dark.quad-nw { background: #a0b070; }
.board.theme-water .cell.dark.quad-ne { background: #3870a0; }
.board.theme-water .cell.dark.quad-se { background: #884860; }
.board.theme-water .cell.dark.quad-sw { background: #2a3858; }
.board.theme-water .cell.dark .coord-label { color: #bcd6ea; }
.board.theme-water .cell.last-move { background: rgba(212,175,55,0.28) !important; }

/* Earth (Black/Olive dominant) */
.board.theme-earth .cell.light { background: #c4b898; }
.board.theme-earth .cell.dark.quad-nw { background: #9a8438; }
.board.theme-earth .cell.dark.quad-ne { background: #3e5470; }
.board.theme-earth .cell.dark.quad-se { background: #784030; }
.board.theme-earth .cell.dark.quad-sw { background: #2e2e2e; }
.board.theme-earth .cell.dark .coord-label { color: #d4c4a0; }
.board.theme-earth .cell.last-move { background: rgba(212,175,55,0.28) !important; }

/* Fire (Red dominant) */
.board.theme-fire .cell.light { background: #f0c8a0; }
.board.theme-fire .cell.dark.quad-nw { background: #d89038; }
.board.theme-fire .cell.dark.quad-ne { background: #845070; }
.board.theme-fire .cell.dark.quad-se { background: #b83030; }
.board.theme-fire .cell.dark.quad-sw { background: #503028; }
.board.theme-fire .cell.dark .coord-label { color: #ffd7b8; }
.board.theme-fire .cell.last-move { background: rgba(212,175,55,0.28) !important; }

/* ==================== CUSTOMIZATION ==================== */
.customize-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.customize-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.customize-label { font-size: 0.78rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; min-width: 42px; }
.customize-options { display: flex; gap: 4px; }
.customize-opt {
  padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim); font-size: 0.78rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s var(--ease-out);
  touch-action: manipulation;
}
.customize-opt.active {
  background: var(--purple-soft); border-color: var(--accent); color: var(--accent);
}
.customize-opt:not(.active):hover { border-color: rgba(212,175,55,0.3); }

/* ==================== TRIAL COUNTER ==================== */
.trial-counter {
  font-size: 0.72rem; color: var(--text-muted); text-align: center;
  margin-top: 8px; letter-spacing: 0.3px;
}
.trial-counter strong { color: var(--accent); }

/* ==================== FORTUNE DISPLAY ==================== */
.fortune-display { margin: 12px 0; }
.fortune-card {
  background: linear-gradient(135deg, rgba(167,139,250,0.1), rgba(212,175,55,0.08));
  border: 1px solid rgba(167,139,250,0.3);
  border-radius: 12px; padding: 16px; text-align: center;
}
.fortune-header {
  font-family: var(--font-display); font-size: 0.75rem; letter-spacing: 2px;
  text-transform: uppercase; color: #a78bfa; margin-bottom: 10px;
}
.fortune-figure { margin-bottom: 10px; }
.fortune-dots {
  font-size: 1.4rem; line-height: 1.6; letter-spacing: 4px;
  color: #D4AF37; margin-bottom: 6px;
}
.fortune-name {
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 700;
  color: var(--text-primary); letter-spacing: 1px;
}
.fortune-attrs {
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px;
}
.fortune-attr b { color: var(--text-dim); }
.fortune-code {
  font-size: 0.72rem; color: var(--text-dim); letter-spacing: 0.5px; margin-top: 6px;
}

/* ==================== FROZEN PIECES (Enochian Chess) ==================== */
.piece-wrap.frozen {
  opacity: 0.25;
  filter: grayscale(90%) brightness(0.8);
  pointer-events: none;
}
.player-row.frozen .name {
  font-style: italic;
  opacity: 0.5;
}
.frozen-badge {
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(71,85,105,0.4);
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

/* ==================== PLAYER SCORE ==================== */
.player-score {
  font-size: 0.75em;
  color: #D4AF37;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==================== PAWN PROMOTION DIALOG ==================== */
.promotion-content {
  text-align: center;
  max-width: 400px;
}
.promotion-content h2 {
  font-family: var(--font-display);
  color: var(--accent);
  margin-bottom: 8px;
}
.promotion-content p {
  color: var(--text-dim);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.promotion-options {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.promotion-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 20px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  color: var(--text-primary);
}
.promotion-btn:hover, .promotion-btn:active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 16px var(--accent-glow);
  transform: scale(1.05);
}
.promo-icon {
  font-size: 2.4rem;
  line-height: 1;
}
.promo-name {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ==================== POINTS FLOAT ANIMATION ==================== */
.points-float {
  position: fixed;
  color: #ffffff;
  font-size: 1.4rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 4000;
  text-shadow: 0 0 8px rgba(212,175,55,0.6), 0 2px 4px rgba(0,0,0,0.5);
  opacity: 0;
  transition: none;
}
.points-float.animate {
  opacity: 1;
  animation: pointsFloatUp 1.4s ease-out forwards;
}
@keyframes pointsFloatUp {
  0% { opacity: 1; transform: translateY(0); }
  60% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-60px); }
}

/* ==================== REWATCH CONTROLS ==================== */
.rewatch-controls {
  padding: 12px;
  text-align: center;
}
.rewatch-controls .replay-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ==================== BOT THINKING INDICATOR ==================== */
.turn-indicator.bot-thinking {
  background: linear-gradient(135deg, rgba(212,175,55,0.15), rgba(167,139,250,0.1));
  border: 1px solid rgba(212,175,55,0.4);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  animation: botGlow 1.4s ease-in-out infinite;
  box-shadow: 0 0 16px rgba(212,175,55,0.25);
}
@keyframes botGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(212,175,55,0.2); }
  50% { box-shadow: 0 0 22px rgba(212,175,55,0.45); }
}

/* ==================== PAWN TYPE BADGE (Enochian) ==================== */
.pawn-type-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  font-size: 0.65rem;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.4);
}
.piece-wrap { position: relative; }
