/* ═══════════════════════════════════════════════════════
   CARDS AGAINST HUMANITY — Classic CAH
   Design: Black/White + Gold, Russo One / Chakra Petch
═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Russo+One&family=Chakra+Petch:wght@300;400;500;600;700&display=swap');

/* ── Dark theme (default) ── */
:root {
  --bg:         #0A0A0A;
  --bg-modal:   rgba(10,10,10,0.96);
  --surface:    #141414;
  --surface2:   #1E1E1E;
  --border:     #2A2A2A;
  --border-lt:  #3A3A3A;

  --gold:       #CA8A04;
  --gold-lt:    #EAB308;
  --gold-dim:   rgba(202,138,4,0.12);
  --gold-glow:  0 4px 20px rgba(202,138,4,0.25);

  --accent:     #CA8A04;
  --accent-lt:  #EAB308;
  --accent-dim: rgba(202,138,4,0.12);

  --white-card: #FAFAFA;
  --black-card: #111111;

  --text:       #FAFAFA;
  --text-dim:   #666;
  --text-mid:   #888;

  --green:      #22C55E;
  --red:        #EF4444;

  --radius:     12px;
  --radius-lg:  20px;
  --shadow:     0 8px 32px rgba(0,0,0,0.55);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.75);
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg:         #E8E8E8;
  --bg-modal:   rgba(232,232,232,0.97);
  --surface:    #F2F2F2;
  --surface2:   #E2E2E2;
  --border:     #CCCCCC;
  --border-lt:  #BBBBBB;

  --gold:       #A16207;
  --gold-lt:    #CA8A04;
  --gold-dim:   rgba(161,98,7,0.12);
  --gold-glow:  0 4px 16px rgba(161,98,7,0.2);

  --accent:     #A16207;
  --accent-lt:  #CA8A04;
  --accent-dim: rgba(161,98,7,0.12);

  --white-card: #FAFAFA;
  --black-card: #111111;

  --text:       #1A1A1A;
  --text-dim:   #888;
  --text-mid:   #555;

  --shadow:     0 8px 32px rgba(0,0,0,0.1);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.15);
}

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

html, body {
  height: 100%;
  font-family: 'Chakra Petch', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

h1, h2, h3, .menu-title h1 {
  font-family: 'Russo One', sans-serif;
}

/* ── Background: radial glows ── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 20% 30%, rgba(202,138,4,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 70%, rgba(202,138,4,0.04) 0%, transparent 55%),
    var(--bg);
  animation: bgPulse 14s ease-in-out infinite alternate;
}
[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 80% 60% at 20% 30%, rgba(161,98,7,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 70%, rgba(161,98,7,0.04) 0%, transparent 55%),
    var(--bg);
}

@keyframes bgPulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.75; }
  100% { opacity: 1; }
}


#bg-canvas {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
}
[data-theme="light"] #bg-canvas { opacity: 0.3; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-lt); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ══════════════════════════════
   SCREENS
══════════════════════════════ */
.screen { display: none; width: 100vw; height: 100vh; overflow: hidden; position: relative; z-index: 1; }
.screen.active { display: flex; }

/* ══════════════════════════════
   TOP-LEFT USER MENU
══════════════════════════════ */
#top-left-menu {
  position: fixed; top: 14px; left: 14px; z-index: 500;
  display: flex; flex-direction: column; gap: 0;
}
#top-left-trigger {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; padding: 8px 14px 8px 10px;
  background: var(--bg-modal);
  border: 1px solid var(--border-lt);
  border-radius: 40px;
  backdrop-filter: blur(12px);
  transition: all 0.25s;
  user-select: none;
}
#top-left-trigger:hover {
  border-color: var(--gold);
}
.tl-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gold);
  color: #000;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 0.85rem; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(202,138,4,0.3);
}
.tl-name {
  font-size: 0.85rem; font-weight: 600; max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: 0.3px;
}
.tl-flag { font-size: 1.1rem; line-height: 1; }
.tl-chevron {
  font-size: 0.65rem; color: var(--text-mid);
  transition: transform 0.25s; margin-left: 2px;
}
#top-left-menu.open .tl-chevron { transform: rotate(180deg); }

#tl-dropdown {
  background: var(--bg-modal);
  border: 1px solid var(--border-lt);
  border-radius: 14px;
  margin-top: 8px; padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  max-height: 0; opacity: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.25s;
  padding-top: 0; padding-bottom: 0; overflow: hidden;
}
#top-left-menu.open #tl-dropdown {
  max-height: 280px; opacity: 1;
  padding-top: 10px; padding-bottom: 10px;
}
.tl-section-label {
  font-size: 0.62rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1.5px; padding: 0 4px 4px;
}
.tl-lang-btns { display: flex; gap: 6px; }
.tl-theme-btn {
  width: 100%; padding: 7px 10px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--surface2);
  color: var(--text-mid); cursor: pointer; font-size: 0.85rem;
  text-align: left; transition: all 0.18s; font-weight: 600;
  font-family: 'Chakra Petch', sans-serif;
  display: flex; align-items: center; gap: 8px;
}
.tl-theme-btn:hover { border-color: var(--border-lt); color: var(--text); }
.tl-lang-btn {
  flex: 1; padding: 7px 4px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--surface2);
  color: var(--text-mid); cursor: pointer; font-size: 0.85rem;
  text-align: center; transition: all 0.18s; font-weight: 600;
  font-family: 'Chakra Petch', sans-serif;
}
.tl-lang-btn.active  { border-color: var(--accent); color: var(--accent-lt); background: var(--accent-dim); }
.tl-lang-btn:hover:not(.active) { border-color: var(--border-lt); color: var(--text); }

/* ══════════════════════════════
   MENU SCREEN
══════════════════════════════ */
#screen-menu {
  flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
}

.menu-bg-cards {
  position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}

.menu-box {
  position: relative; z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border-lt);
  border-radius: var(--radius-lg);
  padding: 52px 44px;
  width: 440px; max-width: 95vw;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.04);
  display: flex; flex-direction: column; gap: 28px;
  animation: slideUp 0.45s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(40px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.menu-title { text-align: center; }
.menu-title h1 {
  font-size: 2.2rem; font-weight: 400;
  line-height: 1.1; letter-spacing: 2px;
  text-transform: uppercase;
}
.menu-title h1 span { color: var(--gold); }
.menu-tagline {
  color: var(--text-mid); font-size: 0.8rem; margin-top: 8px;
  text-align: center; letter-spacing: 0.5px;
}

/* Inputs */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label {
  font-size: 0.72rem; font-weight: 600; color: var(--text-mid);
  text-transform: uppercase; letter-spacing: 1px;
}
.field input {
  background: var(--surface2); border: 1.5px solid var(--border-lt);
  color: var(--text); border-radius: 10px; padding: 13px 16px;
  font-size: 0.95rem; font-family: 'Chakra Petch', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.field input::placeholder { color: var(--text-dim); }

/* Buttons */
.btn {
  padding: 13px 22px; border-radius: 10px; font-weight: 600;
  font-size: 0.95rem; font-family: 'Chakra Petch', sans-serif;
  cursor: pointer; border: none; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  letter-spacing: 0.3px;
}
.btn-primary {
  background: var(--gold);
  color: #000;
  box-shadow: 0 4px 16px rgba(202,138,4,0.2);
}
.btn-primary:hover {
  background: var(--gold-lt);
  box-shadow: 0 4px 20px rgba(202,138,4,0.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface2); color: var(--text);
  border: 1.5px solid var(--border-lt);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-lt); }

.btn-ghost {
  background: transparent; color: var(--text-mid);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-lt); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }

.btn-green {
  background: linear-gradient(135deg, #16A34A, #22C55E);
  color: #fff;
  box-shadow: 0 4px 16px rgba(34,197,94,0.3);
}
.btn-green:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 3px; font-weight: 700; }

.divider { border: none; border-top: 1px solid var(--border); }

/* Lang toggle (standalone, kept for compatibility) */
.lang-toggle { display: flex; gap: 8px; }
.lang-btn {
  flex: 1; padding: 10px; border-radius: 8px; font-weight: 600;
  font-size: 0.9rem; border: 1.5px solid var(--border);
  background: var(--surface2); color: var(--text-mid);
  cursor: pointer; transition: all 0.2s; font-family: 'Chakra Petch', sans-serif;
}
.lang-btn.active  { border-color: var(--accent); color: var(--accent-lt); background: var(--accent-dim); }
.lang-btn:hover:not(.active) { border-color: var(--border-lt); color: var(--text); }

/* ══════════════════════════════
   LOBBY SCREEN
══════════════════════════════ */
#screen-lobby {
  flex-direction: column; align-items: center;
  gap: 20px; overflow-y: auto;
}
.lobby-content {
  width: 100%; max-width: 880px; padding: 28px 24px;
  display: flex; flex-direction: column; gap: 20px;
  position: relative; z-index: 1; margin: 0 auto;
}
.lobby-bg-cards {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}

.lobby-header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.lobby-header h2 { font-size: 1.5rem; letter-spacing: 2px; text-transform: uppercase; }
.room-code-display {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border-lt);
  border-radius: 12px; padding: 10px 18px;
}
.room-code-display .code {
  font-size: 1.6rem; font-weight: 700; letter-spacing: 6px;
  color: var(--gold);
  font-family: 'Russo One', sans-serif;
}

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

.lobby-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.lobby-card h3 {
  font-size: 0.68rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 2px; margin-bottom: 16px;
  font-family: 'Chakra Petch', sans-serif;
}

.player-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  animation: fadeIn 0.3s ease;
  transition: border-color 0.2s;
}
.player-item:hover { border-color: var(--border-lt); }

.kick-btn {
  margin-left: auto; flex-shrink: 0;
  background: transparent; border: 1px solid var(--border-lt);
  color: var(--text-dim); border-radius: 6px;
  width: 26px; height: 26px; cursor: pointer;
  font-size: 0.7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s; line-height: 1;
}
.kick-btn:hover { background: var(--red); color: #fff; border-color: var(--red); }

@keyframes fadeIn { from { opacity:0; transform:translateX(-10px); } to { opacity:1; transform:none; } }

.player-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold);
  color: #000;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 0.9rem; flex-shrink: 0;
}
.player-name { font-weight: 600; flex: 1; font-size: 0.9rem; }
.player-badge {
  font-size: 0.68rem; font-weight: 700; padding: 2px 9px;
  border-radius: 20px; background: var(--gold-dim); color: var(--gold);
  border: 1px solid var(--gold); letter-spacing: 0.5px;
}

/* Settings */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 0.88rem; font-weight: 500; }
.setting-desc { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* Help Icon / Tooltip */
.help-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border-lt);
  color: var(--text-dim); font-size: 0.72rem; font-weight: 700;
  cursor: help; position: relative; transition: all 0.2s;
}
.help-icon:hover {
  background: var(--accent-dim); color: var(--accent-lt); border-color: var(--accent);
}
.help-tooltip {
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--bg-modal); border: 1px solid var(--border-lt);
  padding: 8px 12px; border-radius: 8px; font-size: 0.75rem;
  color: var(--text); width: max-content; max-width: 220px;
  text-align: center; opacity: 0; pointer-events: none;
  transition: all 0.2s; z-index: 100; box-shadow: var(--shadow);
  backdrop-filter: blur(8px); white-space: normal; font-weight: 400;
  letter-spacing: 0; line-height: 1.4;
}
.help-icon:hover .help-tooltip {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* Toggle */
.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { display: none; }
.toggle-track {
  position: absolute; inset: 0; border-radius: 12px;
  background: var(--border-lt); cursor: pointer; transition: background 0.2s;
}
.toggle input:checked + .toggle-track {
  background: var(--gold);
}
.toggle-track::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform 0.2s; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.toggle input:checked + .toggle-track::after { transform: translateX(20px); }

/* Number input */
.num-input { display: flex; align-items: center; gap: 8px; }
.num-input button {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border-lt);
  background: var(--surface2); color: var(--text);
  font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; font-family: inherit;
}
.num-input button:hover { border-color: var(--accent); color: var(--accent-lt); }
.num-input span { font-weight: 700; min-width: 24px; text-align: center; font-family: 'Russo One', sans-serif; }

/* Card actions */
.lobby-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lobby-footer {
  display: flex; gap: 10px; align-items: center;
  justify-content: space-between; flex-wrap: wrap;
}
.status-msg { color: var(--text-mid); font-size: 0.88rem; }

/* Czar radio group */
.czar-radio-group { display: flex; gap: 8px; align-items: center; }
.czar-radio-label {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-lt);
  font-size: 0.85rem; transition: all 0.18s; user-select: none;
  background: var(--surface2);
}
.czar-radio-label input[type="radio"] { display: none; }
.czar-radio-custom {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-lt); background: transparent;
  flex-shrink: 0; transition: all 0.18s; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.czar-radio-custom::after {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: #fff; opacity: 0; transform: scale(0); transition: all 0.18s;
}
.czar-radio-label input:checked ~ .czar-radio-custom {
  border-color: var(--gold); background: var(--gold);
  box-shadow: 0 0 6px rgba(202,138,4,0.4);
}
.czar-radio-label input:checked ~ .czar-radio-custom::after {
  opacity: 1; transform: scale(1);
}
.czar-radio-label:has(input:checked) {
  border-color: var(--gold); background: var(--gold-dim);
}

/* ══════════════════════════════
   GAME SCREEN
══════════════════════════════ */
#screen-game { flex-direction: row; }

/* Sidebar */
.sidebar {
  width: 210px; min-width: 210px;
  background: var(--bg-modal);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; padding: 16px 0;
  backdrop-filter: blur(8px);
}
@media (max-width: 640px) { .sidebar { display: none; } }

.sidebar-title {
  font-size: 0.62rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 2px;
  padding: 0 16px 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.score-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; transition: all 0.2s;
  border-radius: 8px; margin: 3px 8px;
  border: 1px solid transparent;
}
.score-item.czar {
  background: rgba(202,138,4,0.12);
  border-color: rgba(202,138,4,0.35);
}
.score-item.me { border-left: 3px solid var(--accent); }
.score-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
  background: var(--surface2); color: var(--text);
}
.score-item.czar .score-avatar {
  background: var(--gold); color: #000; box-shadow: var(--gold-glow);
}
.score-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.score-name {
  font-size: 0.83rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; font-weight: 600;
}
.czar-badge {
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.5px;
  color: #000; background: var(--gold);
  padding: 2px 7px 2px 5px; border-radius: 999px;
  text-transform: uppercase; box-shadow: var(--gold-glow);
  width: fit-content; line-height: 1.4;
}
.czar-crown {
  display: inline-flex; align-items: center; justify-content: center;
  font-style: normal; line-height: 1; vertical-align: middle; font-size: 0.85rem;
}
.score-pts { font-weight: 700; font-size: 1.1rem; color: var(--gold); flex-shrink: 0; font-family: 'Russo One', sans-serif; }
.submitted-dot {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.62rem; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  background: rgba(34,197,94,0.15); color: var(--green);
  border: 1px solid var(--green); flex-shrink: 0;
}
.waiting-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim); flex-shrink: 0;
  animation: waitPulse 1.3s ease-in-out infinite;
}
@keyframes waitPulse {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50%       { opacity: 1;    transform: scale(1.1); }
}

/* Main game area */
.game-main {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

/* Status bar */
.game-status-bar {
  background: var(--bg-modal);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  flex-wrap: wrap; text-align: center;
  backdrop-filter: blur(8px);
}
.status-round { font-weight: 600; font-size: 0.82rem; color: var(--text-dim); letter-spacing: 0.5px; }
.status-czar  { font-size: 0.82rem; color: var(--text-mid); }

/* Phase banner */
.phase-top-banner {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, var(--bg-modal) 60%, transparent 100%);
  padding: 14px 20px 10px;
  text-align: center; width: 100%;
}
.phase-top-banner .phase-label {
  font-size: 1.2rem; font-family: 'Russo One', sans-serif;
  color: var(--gold); letter-spacing: 2px; text-transform: uppercase;
  animation: phaseIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes phaseIn {
  from { opacity:0; transform: translateY(-10px) scale(0.94); }
  to   { opacity:1; transform: none; }
}

/* Play zone */
.game-play-zone {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 24px; padding: 20px; overflow-y: auto;
}

/* ── CARDS ── */
.card {
  width: 160px; height: 220px; border-radius: 12px;
  display: flex; flex-direction: column; padding: 14px;
  position: relative; cursor: default; user-select: none;
  transition: transform 0.2s, box-shadow 0.2s;
}
.card-white {
  background: var(--white-card); color: #111;
  border: 2px solid #ddd; box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.card-black {
  background: var(--black-card); color: var(--white-card);
  border: 2px solid #222; box-shadow: 0 6px 20px rgba(0,0,0,0.7);
}
.card-logo {
  position: absolute; bottom: 10px; right: 12px;
  font-size: 0.62rem; font-weight: 900; opacity: 0.25; letter-spacing: 0;
  font-family: 'Russo One', sans-serif;
}
.card-black .card-logo { color: #fff; }
.card-white .card-logo { color: #000; }
.card-text { font-weight: 700; font-size: 0.88rem; line-height: 1.4; flex: 1; }
.card-pick-badge {
  position: absolute; bottom: 10px; left: 12px;
  background: var(--white-card); color: #000;
  font-weight: 900; font-size: 0.58rem; padding: 2px 7px;
  border-radius: 20px; letter-spacing: 0.5px; z-index: 1;
}
.card-black .card-pick-badge {
  background: rgba(255,255,255,0.12); color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
}

/* Selectable cards */
.card-selectable { cursor: pointer; transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.22s; }
.card-selectable:hover {
  transform: translateY(-10px) scale(1.03);
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
}
.card-selectable.selected {
  transform: translateY(-18px) scale(1.04);
  box-shadow: 0 0 0 3px var(--gold), 0 0 20px rgba(202,138,4,0.35), 0 18px 40px rgba(0,0,0,0.5);
}
.card-selectable.selected-2 {
  transform: translateY(-18px) scale(1.04);
  box-shadow: 0 0 0 3px var(--gold-lt), 0 0 20px rgba(234,179,8,0.35), 0 18px 40px rgba(0,0,0,0.5);
}
.card-selectable.card-pop {
  animation: cardPop 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes cardPop {
  0%   { transform: translateY(-18px) scale(1.04); }
  50%  { transform: translateY(-22px) scale(1.08); }
  100% { transform: translateY(-18px) scale(1.04); }
}

/* Card flip */
.card-flip-wrapper { perspective: 1000px; width: 160px; height: 220px; flex-shrink: 0; }
.card-flip-inner {
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.4,0,0.2,1);
  position: relative;
}
.card-flip-inner.flipped { transform: rotateY(180deg); }
.card-flip-front, .card-flip-back {
  position: absolute; width: 100%; height: 100%;
  backface-visibility: hidden; border-radius: 12px;
}
.card-flip-back { transform: rotateY(180deg); }
.card-back-face {
  width: 100%; height: 100%;
  background: var(--black-card);
  border: 2px solid #222; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.82rem; color: var(--text-dim);
  letter-spacing: 1.5px; font-family: 'Chakra Petch', sans-serif;
}

@keyframes dealCard {
  from { opacity: 0; transform: translateY(60px) scale(0.85); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.card-deal { animation: dealCard 0.4s cubic-bezier(0.34,1.56,0.64,1) both; }

@keyframes cardShuffle {
  0%   { transform: rotateY(0deg) scale(1); }
  25%  { transform: rotateY(90deg) scale(0.9); }
  50%  { transform: rotateY(180deg) scale(0.85); }
  75%  { transform: rotateY(270deg) scale(0.9); }
  100% { transform: rotateY(360deg) scale(1); }
}
.card-shuffle { animation: cardShuffle 0.55s cubic-bezier(0.4,0,0.2,1); }

@keyframes winnerPulse {
  0%   { box-shadow: 0 0 0 3px var(--gold); }
  50%  { box-shadow: 0 0 0 10px rgba(202,138,4,0.25), 0 0 30px rgba(202,138,4,0.5); }
  100% { box-shadow: 0 0 0 3px var(--gold); }
}
.card-winner { animation: winnerPulse 1s ease infinite; }

/* Black card area — sticky so it stays visible while scrolling plays */
.black-card-zone {
  display: flex; align-items: center; gap: 20px;
  flex-wrap: wrap; justify-content: center;
  position: sticky; top: 0; z-index: 4;
  background: var(--bg);
  padding: 12px 0 8px;
  width: 100%;
}

/* Submitted plays */
.plays-area {
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: center; max-width: 920px;
}
.play-entry { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.play-cards  { display: flex; gap: 8px; }
.play-author { font-size: 0.73rem; color: var(--text-mid); font-weight: 600; letter-spacing: 0.3px; }

.play-entry.pickable { cursor: pointer; }
.play-entry.pickable:hover .card { transform: translateY(-10px); box-shadow: 0 4px 20px rgba(202,138,4,0.3); }
.play-entry.pickable:hover .play-author { color: var(--gold); }
.play-entry.eliminated { opacity: 0.25; pointer-events: none; }

/* Hand zone */
.hand-zone {
  background: var(--bg-modal);
  border-top: 1px solid var(--border);
  padding: 16px 20px; overflow-x: auto; flex-shrink: 0;
  backdrop-filter: blur(8px);
}
.hand-title {
  font-size: 0.62rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 2px; margin-bottom: 12px;
}
.hand-cards {
  display: flex; gap: 12px; overflow-x: auto;
  padding-top: 26px; padding-bottom: 8px;
}
.hand-cards::-webkit-scrollbar { height: 4px; }
.hand-cards::-webkit-scrollbar-thumb { background: var(--border-lt); border-radius: 2px; }

/* Action bar */
.action-bar {
  background: var(--bg-modal);
  border-top: 1px solid var(--border);
  padding: 14px 20px; display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; justify-content: center;
  backdrop-filter: blur(8px);
}

/* Phase banners */
.phase-banner { text-align: center; padding: 8px 0; }
.phase-banner h3 { font-size: 1.1rem; font-family: 'Russo One', sans-serif; letter-spacing: 1px; }
.phase-banner p  { font-size: 0.85rem; color: var(--text-mid); margin-top: 4px; }

/* Round result */
.round-result {
  position: absolute; inset: 0; background: rgba(0,0,0,0.88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; z-index: 10; animation: fadeIn 0.3s;
  padding: 20px; backdrop-filter: blur(4px);
}
.round-result h2 {
  font-size: 1.8rem; font-family: 'Russo One', sans-serif;
  color: var(--gold); letter-spacing: 2px; text-transform: uppercase;
}
.round-result .winner-name { font-size: 1.2rem; font-weight: 600; }
.result-cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ══════════════════════════════
   POPUP / OVERLAY
══════════════════════════════ */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s;
}
.overlay.hidden { display: none; }

.popup {
  background: var(--surface);
  border: 1px solid var(--border-lt);
  border-radius: var(--radius-lg); padding: 34px;
  width: 460px; max-width: 95vw; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: popIn 0.28s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
}
@keyframes popIn {
  from { opacity:0; transform:scale(0.88); }
  to   { opacity:1; transform:scale(1); }
}
.popup h3 {
  font-size: 1.15rem; font-family: 'Russo One', sans-serif;
  margin-bottom: 20px; letter-spacing: 1px; color: var(--text);
}

.radio-group { display: flex; gap: 10px; margin-bottom: 16px; }
.radio-option {
  flex: 1; padding: 12px; border-radius: 10px;
  border: 1.5px solid var(--border-lt);
  background: var(--surface2); cursor: pointer; text-align: center;
  font-weight: 600; font-size: 0.88rem; transition: all 0.2s; color: var(--text-mid);
}
.radio-option.active {
  border-color: var(--gold); color: var(--gold); background: var(--gold-dim);
}

.popup-actions { display: flex; gap: 10px; margin-top: 20px; }
.popup-actions .btn { flex: 1; }

/* Toast */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--gold);
  color: var(--gold);
  padding: 11px 22px; border-radius: 22px; font-weight: 600; font-size: 0.9rem;
  z-index: 999; box-shadow: var(--shadow);
  letter-spacing: 0.3px;
  animation: toastIn 0.3s, toastOut 0.3s 2.2s forwards;
}
@keyframes toastIn  { from { opacity:0; transform: translateX(-50%) translateY(20px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { to   { opacity:0; transform: translateX(-50%) translateY(20px); } }

/* ══════════════════════════════
   CONNECTING SCREEN
══════════════════════════════ */
.connecting-screen {
  position: fixed; inset: 0; background: var(--bg-modal);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; z-index: 200; backdrop-filter: blur(8px);
}
.spinner {
  width: 42px; height: 42px;
  border: 3px solid var(--border-lt);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════
   FLOATING BG CARDS
══════════════════════════════ */
.bg-card {
  position: absolute; border-radius: 10px;
  opacity: 0.06; pointer-events: none;
  animation: floatCard linear infinite;
}
.bg-card-white { background: #fff; }
.bg-card-black { background: #fff; border: 1px solid #333; }

[data-theme="light"] .bg-card { opacity: 0.18; }
[data-theme="light"] .bg-card-white { background: #1a1a1a; border: 1px solid #555; }
[data-theme="light"] .bg-card-black { background: #2a2a2a; border: 1px solid #444; }
@keyframes floatCard {
  from { transform: translateY(110vh) rotate(var(--rot)); }
  to   { transform: translateY(-20vh) rotate(var(--rot)); }
}

/* ══════════════════════════════
   GAME OVER SCREEN
══════════════════════════════ */
.game-over-screen {
  position: fixed; inset: 0; background: var(--bg-modal);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px; z-index: 300; padding: 20px; backdrop-filter: blur(8px);
}
.game-over-screen h1 {
  font-size: 3rem; font-family: 'Russo One', sans-serif;
  color: var(--gold); text-align: center; letter-spacing: 3px;
}
.game-over-screen .winner-name { font-size: 1.5rem; font-weight: 600; text-align: center; }
.final-scores {
  display: flex; flex-direction: column; gap: 10px; width: 320px; max-width: 95vw;
}
.final-score-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border-lt);
  border-radius: 10px; padding: 12px 18px;
}
.final-score-row.winner {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(202,138,4,0.3);
  background: rgba(202,138,4,0.08);
}
.go-actions { display: flex; gap: 12px; }

/* ══════════════════════════════
   CZAR BLACK CARD CHOICE
══════════════════════════════ */
.czar-black-choice {
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: center; padding: 4px 0;
}
.czar-black-option {
  cursor: pointer; flex: 1 1 180px; max-width: 220px;
  border-radius: 14px; border: 2px solid transparent;
  position: relative; overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), border-color 0.25s, box-shadow 0.25s;
}
.czar-black-option:hover {
  transform: translateY(-10px) scale(1.04);
  border-color: var(--gold);
  box-shadow: 0 12px 32px rgba(202,138,4,0.35);
}
.czar-black-option.chosen {
  border-color: var(--gold-lt);
  box-shadow: 0 0 28px rgba(234,179,8,0.4);
  transform: translateY(-12px) scale(1.06);
}
.czar-black-option .card-text,
.czar-black-option .card-logo,
.czar-black-option .card-pick-badge { transition: opacity 0.25s, filter 0.25s; }
.czar-black-option:hover .card-text,
.czar-black-option:hover .card-logo,
.czar-black-option:hover .card-pick-badge { opacity: 0.12; filter: blur(2px); }
.czar-black-option::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
  border-radius: inherit; opacity: 0;
  transition: opacity 0.25s; z-index: 2; pointer-events: none;
}
.czar-black-option:hover::before { opacity: 1; }
.czar-black-option::after {
  content: attr(data-select-label);
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%) scale(0.8);
  color: var(--gold-lt);
  font-family: 'Russo One', sans-serif;
  font-size: 0.95rem; letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(202,138,4,0.8);
  opacity: 0; transition: opacity 0.25s, transform 0.25s;
  z-index: 3; pointer-events: none; white-space: nowrap;
}
.czar-black-option:hover::after {
  opacity: 1; transform: translate(-50%,-50%) scale(1);
}

/* ══════════════════════════════
   UTILITIES
══════════════════════════════ */
.hidden { display: none !important; }
.gold        { color: var(--gold); }
.muted       { color: var(--text-mid); }
.bold        { font-weight: 700; }
.text-center { text-align: center; }

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

/* ══════════════════════════════════════════════════════
   RESPONSIVE — TABLET & MOBILE
══════════════════════════════════════════════════════ */

/* ── Touch devices: replace hover with :active ── */
@media (hover: none) {
  .card-selectable:hover { transform: none; box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
  .card-selectable:active {
    transform: translateY(-8px) scale(1.03);
    box-shadow: 0 12px 32px rgba(0,0,0,0.55);
  }
  .card-selectable.selected:hover,
  .card-selectable.selected:active {
    transform: translateY(-18px) scale(1.04);
    box-shadow: 0 0 0 3px var(--gold), 0 0 20px rgba(202,138,4,0.35), 0 18px 40px rgba(0,0,0,0.5);
  }
  .play-entry.pickable:hover .card { transform: none; box-shadow: none; }
  .play-entry.pickable:active .card {
    transform: translateY(-8px);
    box-shadow: 0 4px 20px rgba(202,138,4,0.4);
  }
  .play-entry.pickable:hover .play-author { color: var(--text-mid); }
  .play-entry.pickable:active .play-author { color: var(--gold); }
  .czar-black-option:hover { transform: none; border-color: transparent; box-shadow: none; }
  .czar-black-option:hover::before { opacity: 0; }
  .czar-black-option:hover::after { opacity: 0; }
  .czar-black-option:hover .card-text,
  .czar-black-option:hover .card-logo,
  .czar-black-option:hover .card-pick-badge { opacity: 1; filter: none; }
  .czar-black-option:active {
    transform: translateY(-6px) scale(1.02);
    border-color: var(--gold);
    box-shadow: 0 8px 24px rgba(202,138,4,0.3);
  }
  .btn:hover { transform: none; }
  .btn-primary:hover { background: var(--gold); box-shadow: 0 4px 16px rgba(202,138,4,0.2); }
  .btn:active:not(:disabled) { transform: scale(0.96); opacity: 0.85; }
}

/* ── Mobile score strip (shown when sidebar hides at ≤640px) ── */
.mobile-scores { display: none; }

@media (max-width: 640px) {
  .mobile-scores {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding: 7px 12px;
    background: var(--bg-modal);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-scores::-webkit-scrollbar { display: none; }
}

.mobile-score-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 9px 4px 5px;
  font-size: 0.73rem; font-weight: 600;
  white-space: nowrap; flex-shrink: 0;
  transition: border-color 0.2s;
}
.mobile-score-chip.czar { border-color: var(--gold); background: var(--gold-dim); }
.mobile-score-chip.me  { border-color: var(--accent); }
.chip-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface2); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 900; flex-shrink: 0;
}
.mobile-score-chip.czar .chip-avatar { background: var(--gold); color: #000; }
.chip-name { color: var(--text); }
.chip-pts {
  font-weight: 700; color: var(--gold);
  font-family: 'Russo One', sans-serif; font-size: 0.8rem;
}
.chip-dot {
  font-size: 0.6rem; border-radius: 999px; padding: 1px 4px; flex-shrink: 0;
}
.chip-dot-ok   { color: var(--green); background: rgba(34,197,94,0.12); border: 1px solid var(--green); }
.chip-dot-wait {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim); animation: waitPulse 1.3s ease-in-out infinite;
}

/* ── Tablet: sidebar still shows, cards shrink slightly ── */
@media (min-width: 641px) and (max-width: 900px) {
  .sidebar { width: 170px; min-width: 170px; }
  .card { width: 140px; height: 196px; }
  .card-flip-wrapper { width: 140px; height: 196px; }
}

/* ── Phone landscape / small tablet: smaller cards ── */
@media (max-width: 640px) {
  #screen-game { flex-direction: column; }

  .game-play-zone { padding: 12px 10px; gap: 14px; }
  .game-status-bar { padding: 8px 12px; gap: 8px; }
  .status-round, .status-czar, .status-phase { font-size: 0.75rem; }

  .hand-zone { padding: 10px 10px 8px; }
  .hand-title { font-size: 0.58rem; margin-bottom: 8px; }
  .hand-cards { gap: 8px; padding-top: 18px; }

  .action-bar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .action-bar .btn { flex: 1 1 auto; min-width: 120px; }

  .plays-area { gap: 10px; }
  .black-card-zone { gap: 12px; padding: 8px 0 4px; }
  .phase-top-banner { padding: 10px 12px 8px; }
  .phase-top-banner .phase-label { font-size: 0.95rem; }

  .round-result h2 { font-size: 1.4rem; }
  .round-result .winner-name { font-size: 1rem; }
  .result-cards { gap: 8px; }
}

/* ── Phone portrait: smallest cards ── */
@media (max-width: 480px) {
  .card { width: 118px; height: 165px; }
  .card-text { font-size: 0.76rem; }
  .card-flip-wrapper { width: 118px; height: 165px; }
  .card-logo { font-size: 0.55rem; }

  .czar-black-option { flex: 1 1 130px; max-width: 160px; }

  /* Menu */
  .menu-box { padding: 32px 20px; gap: 22px; }
  .menu-title h1 { font-size: 1.65rem; letter-spacing: 1px; }

  /* Lobby */
  .lobby-content { padding: 14px 12px; gap: 14px; }
  .lobby-header { gap: 8px; }
  .lobby-header h2 { font-size: 1.2rem; }
  .room-code-display { padding: 8px 12px; }
  .room-code-display .code { font-size: 1.2rem; letter-spacing: 4px; }
  .lobby-card { padding: 14px; }
  .setting-row { flex-wrap: wrap; gap: 6px; padding: 8px 0; }
  .czar-radio-group { flex-wrap: wrap; }
  .lobby-actions { flex-direction: column; }
  .lobby-actions .btn { width: 100%; }
  #btn-start { width: 100%; }

  /* Top-left menu: compact */
  .tl-name { max-width: 70px; }
  #top-left-trigger { padding: 7px 10px 7px 8px; }

  /* Popup */
  .popup { padding: 24px 18px; }

  /* Game over */
  .game-over-screen h1 { font-size: 2.2rem; }
  .go-actions { flex-direction: column; width: 100%; }
  .go-actions .btn { width: 100%; }
}

/* ── Ensure inputs/buttons are big enough for touch ── */
@media (max-width: 767px) {
  .field input, .btn { min-height: 44px; }
  .toggle { width: 48px; height: 26px; }
  .toggle-track::after { width: 20px; height: 20px; }
  .toggle input:checked + .toggle-track::after { transform: translateX(22px); }
  .num-input button { width: 36px; height: 36px; }
}
