/* ========================================
   Тени Элдервуда — Стили
   Тёмная магическая тема
   ======================================== */

/* --- CSS Variables --- */
:root {
  --bg-dark: #080810;
  --bg-surface: #0f0f1a;
  --bg-card: #161625;
  --bg-elevated: #1c1c30;
  --bg-hover: #252540;

  --purple: #7c3aed;
  --purple-light: #a855f7;
  --purple-glow: rgba(124, 58, 237, 0.4);
  --blue: #3b82f6;
  --blue-light: #60a5fa;
  --cyan: #22d3ee;
  --teal: #14b8a6;
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --red: #ef4444;
  --red-dark: #dc2626;
  --green: #22c55e;

  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-bright: #f8fafc;

  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.12);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px var(--purple-glow);

  --font-display: 'Cinzel', serif;
  --font-body: 'Inter', -apple-system, sans-serif;

  --transition: 0.3s ease;
}

/* --- Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-dark);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

/* --- Particles Background --- */
#particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

#particles::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(180, 60, 220, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 120, 40, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 65% 40%, rgba(255, 80, 20, 0.04) 0%, transparent 40%);
  animation: nebula 30s ease-in-out infinite alternate;
}

#particles::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(1.5px 1.5px at 8% 15%, rgba(255, 160, 50, 0.5), transparent),
    radial-gradient(1px 1px at 18% 72%, rgba(168, 85, 247, 0.4), transparent),
    radial-gradient(2px 2px at 28% 35%, rgba(255, 100, 30, 0.35), transparent),
    radial-gradient(1px 1px at 42% 88%, rgba(124, 58, 237, 0.35), transparent),
    radial-gradient(1.5px 1.5px at 55% 22%, rgba(255, 180, 60, 0.4), transparent),
    radial-gradient(1px 1px at 65% 58%, rgba(200, 80, 220, 0.3), transparent),
    radial-gradient(2px 2px at 78% 12%, rgba(255, 120, 40, 0.35), transparent),
    radial-gradient(1px 1px at 85% 75%, rgba(168, 85, 247, 0.4), transparent),
    radial-gradient(1.5px 1.5px at 92% 42%, rgba(255, 200, 80, 0.3), transparent),
    radial-gradient(1px 1px at 35% 50%, rgba(140, 50, 200, 0.25), transparent),
    radial-gradient(1px 1px at 72% 38%, rgba(255, 140, 50, 0.3), transparent),
    radial-gradient(1px 1px at 12% 55%, rgba(180, 70, 240, 0.3), transparent);
  animation: sparkle 6s ease-in-out infinite alternate;
}

@keyframes sparkle {
  0% {
    opacity: 0.3;
    transform: translateY(0);
  }

  50% {
    opacity: 0.7;
    transform: translateY(-4px);
  }

  100% {
    opacity: 0.4;
    transform: translateY(2px);
  }
}

@keyframes nebula {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }

  100% {
    transform: translate(-3%, -2%) rotate(3deg);
  }
}

/* --- App & Screens --- */
#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  overflow: hidden;
}

.screen {
  display: none;
  height: 100vh;
  overflow-y: auto;
}

.screen.active {
  display: flex;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- TITLE SCREEN --- */
#screen-title {
  align-items: center;
  justify-content: center;
}

.title-content {
  text-align: center;
  max-width: 420px;
  padding: 2rem;
}

.logo-wrapper {
  position: relative;
  margin-bottom: 2.5rem;
}

.logo-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 40%, rgba(255, 140, 50, 0.25), transparent 55%),
    radial-gradient(circle at 60% 60%, rgba(140, 40, 220, 0.3), transparent 55%),
    radial-gradient(circle, rgba(255, 80, 20, 0.15), rgba(124, 58, 237, 0.1) 50%, transparent 70%);
  filter: blur(30px);
  animation: portalPulse 4s ease-in-out infinite;
  pointer-events: none;
}

/* Portal — inner bright ring */
.logo-wrapper::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
      rgba(255, 120, 40, 0.5),
      rgba(255, 60, 20, 0.15),
      rgba(160, 50, 230, 0.5),
      rgba(100, 30, 180, 0.15),
      rgba(255, 160, 60, 0.5),
      rgba(255, 80, 30, 0.15),
      rgba(180, 60, 240, 0.4),
      rgba(255, 120, 40, 0.5));
  mask: radial-gradient(transparent 58%, black 62%, black 72%, transparent 76%);
  -webkit-mask: radial-gradient(transparent 58%, black 62%, black 72%, transparent 76%);
  animation: portalSpin 8s linear infinite;
  pointer-events: none;
  opacity: 0.8;
}

/* Portal — outer dim ring */
.logo-wrapper::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: conic-gradient(from 180deg,
      rgba(140, 40, 200, 0.3),
      rgba(255, 100, 30, 0.12),
      rgba(200, 60, 255, 0.25),
      rgba(255, 140, 50, 0.12),
      rgba(140, 40, 200, 0.3));
  mask: radial-gradient(transparent 64%, black 68%, black 74%, transparent 78%);
  -webkit-mask: radial-gradient(transparent 64%, black 68%, black 74%, transparent 78%);
  animation: portalSpin 12s linear infinite reverse;
  pointer-events: none;
  opacity: 0.5;
}

@keyframes portalSpin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes portalPulse {

  0%,
  100% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    opacity: 0.85;
    transform: translate(-50%, -50%) scale(1.08);
  }
}

.game-title {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--text-bright);
  text-shadow:
    0 0 30px rgba(255, 120, 40, 0.35),
    0 0 60px var(--purple-glow),
    0 2px 8px rgba(0, 0, 0, 0.6);
  line-height: 1.1;
  letter-spacing: 2px;
  position: relative;
}

.game-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-style: italic;
  text-shadow: 0 0 20px rgba(124, 58, 237, 0.3);
}

/* --- Form Elements --- */
.input-group {
  margin-bottom: 1rem;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font-body);
  transition: border-color var(--transition);
  outline: none;
}

input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-glow);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple), #6d28d9);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--purple-light), var(--purple));
  transform: translateY(-1px);
}

.btn-glow {
  box-shadow: var(--shadow-glow);
}

.btn-glow:hover:not(:disabled) {
  box-shadow: 0 0 40px var(--purple-glow);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--purple);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-light);
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

.btn-danger {
  background: var(--red-dark);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: var(--red);
}

.btn-icon-small {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
}

.btn-icon-small:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-ability {
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: #1a1a2e;
  font-weight: 700;
}

/* --- Divider --- */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* --- Join Group --- */
.join-group {
  display: flex;
  gap: 0.5rem;
}

.join-group input {
  flex: 1;
}

/* --- Disclaimer --- */
.disclaimer {
  margin-top: 2rem;
  padding: 0.75rem;
  font-size: 0.65rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  opacity: 0.6;
}

/* --- Title Form Separator --- */
.title-form {
  width: 100%;
  position: relative;
}

.title-form::before {
  content: '⬥ ⬦ ⬥';
  display: block;
  text-align: center;
  color: var(--purple-glow);
  font-size: 0.6rem;
  letter-spacing: 4px;
  margin-bottom: 1.25rem;
  opacity: 0.8;
}

.title-tabs {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-light);
  margin-bottom: 1.25rem;
}

.title-tab {
  flex: 1;
  padding: 0.65rem 1rem;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.title-tab.active {
  background: var(--purple);
  color: white;
}

.title-tab:hover:not(.active) {
  background: var(--bg-hover);
}

.title-tab-content.hidden {
  display: none;
}

/* ================= LOBBY ================= */
.lobby-content {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.lobby-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-bright);
}

.room-code-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.room-code-display .label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.room-code-display .code {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--gold);
  letter-spacing: 3px;
  font-weight: 700;
}

.lobby-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* --- Player List (Lobby) --- */
.lobby-players h3,
.lobby-settings h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#player-list {
  list-style: none;
}

#player-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  border: 1px solid var(--border);
  transition: all var(--transition);
}

#player-list li:hover {
  border-color: var(--border-light);
}

.player-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: white;
  flex-shrink: 0;
}

.player-name {
  flex: 1;
  font-weight: 500;
}

.host-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  background: var(--gold);
  color: #1a1a2e;
  border-radius: 99px;
  font-weight: 700;
  text-transform: uppercase;
}

/* --- Settings --- */
.setting-row {
  margin-bottom: 1.25rem;
}

.setting-row>label:first-child {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.setting-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* Toggle Buttons */
.toggle-group {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.toggle-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: none;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-btn.active {
  background: var(--purple);
  color: white;
}

.toggle-btn:hover:not(.active) {
  background: var(--bg-hover);
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  transition: var(--transition);
}

.slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}

.switch input:checked+.slider {
  background: var(--purple);
  border-color: var(--purple);
}

.switch input:checked+.slider::before {
  transform: translateX(20px);
  background: white;
}

/* Range */
.range-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-group input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  outline: none;
}

.range-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--purple);
  cursor: pointer;
  border: 2px solid var(--purple-light);
}

.range-group span {
  min-width: 3rem;
  text-align: center;
  color: var(--gold);
  font-weight: 600;
}

/* --- Lobby Footer --- */
.lobby-footer {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

/* ================= OVERLAY ================= */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 500px;
  width: 90%;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow), var(--shadow-glow);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.overlay-card::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: conic-gradient(from 0deg, var(--purple), var(--blue), var(--purple-light), var(--gold), var(--purple));
  border-radius: var(--radius-lg);
  z-index: -1;
  animation: borderRotate 4s linear infinite;
  opacity: 0.6;
}

@keyframes borderRotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* --- Role Card --- */
.role-card-inner {
  position: relative;
}

.role-icon {
  width: 140px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 20px var(--purple-glow));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

#role-name {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

#role-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.secret-info {
  background: var(--bg-surface);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 1.5rem;
  color: var(--gold-light);
  font-weight: 500;
}

.secret-info.hidden {
  display: none;
}

/* --- Character Select --- */
.character-select-card {
  max-width: 600px;
}

.character-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--purple-light);
  margin: 0.5rem 0 1.5rem;
}

.character-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.char-side {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
}

.char-side:hover {
  border-color: var(--purple);
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.char-side.selected {
  border-color: var(--purple-light);
  box-shadow: 0 0 20px var(--purple-glow);
}

.char-side h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.char-side p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ================= GAME SCREEN ================= */
#screen-game {
  flex-direction: column;
}

.game-layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr 280px;
  height: 100vh;
  gap: 0;
}

/* --- Game Header --- */
.game-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow: hidden;
  min-height: 40px;
}

.header-phase-title {
  flex: 1;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text-bright);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.phase-desc {
  display: none;
}

.phase-badge {
  padding: 0.2rem 0.6rem;
  background: var(--purple);
  color: white;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  animation: phasePulse 2s ease-in-out infinite;
  white-space: nowrap;
  flex-shrink: 0;
}

@keyframes phasePulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 var(--purple-glow);
  }

  50% {
    box-shadow: 0 0 12px 2px var(--purple-glow);
  }
}

.round-badge {
  padding: 0.2rem 0.5rem;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: 99px;
  font-size: 0.7rem;
  border: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
}

.role-mini {
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

/* --- Game Main --- */
.game-main {
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

/* --- Action Required Edge Pulse --- */
.game-layout.action-required::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  animation: edgePulse 2.5s ease-in-out infinite;
}

@keyframes edgePulse {

  0%,
  100% {
    box-shadow:
      inset 0 0 15px 2px rgba(124, 58, 237, 0.0),
      inset 0 0 30px 4px rgba(255, 140, 50, 0.0);
  }

  50% {
    box-shadow:
      inset 0 0 20px 3px rgba(124, 58, 237, 0.18),
      inset 0 0 40px 6px rgba(255, 140, 50, 0.08);
  }
}

/* --- Table Area --- */
.table-area {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.category-column {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  transition: border-color var(--transition);
}

.category-column[data-cat="circumstance"] {
  border-top: 3px solid var(--purple);
}

.category-column[data-cat="location"] {
  border-top: 3px solid var(--blue);
}

.category-column[data-cat="artifact"] {
  border-top: 3px solid var(--gold);
}

.category-column.voting-active {
  border-color: var(--purple-light);
  box-shadow: 0 0 20px var(--purple-glow);
  background: rgba(124, 58, 237, 0.06);
  animation: votingPulse 1.5s ease-in-out infinite;
}

@keyframes votingPulse {

  0%,
  100% {
    box-shadow: 0 0 15px var(--purple-glow);
  }

  50% {
    box-shadow: 0 0 30px rgba(124, 58, 237, 0.6);
  }
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.cat-icon {
  font-size: 1.1rem;
}

.cat-name {
  color: var(--text);
}

.category-cards {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* --- Cards --- */
.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: default;
  transition: all var(--transition);
  display: flex;
  align-items: stretch;
  gap: 0;
  user-select: none;
  min-height: 50px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.card.card-clickable {
  cursor: pointer;
  transition: all 0.2s ease;
}

.card.card-clickable:hover {
  border-color: var(--purple);
  background: var(--bg-hover);
  transform: translateX(3px);
}

.card.card-clickable:active {
  transform: scale(0.98);
}

.card.selected {
  border-color: var(--purple-light);
  background: rgba(124, 58, 237, 0.15);
  box-shadow: 0 0 15px var(--purple-glow);
}

.card.correct {
  border-color: var(--green);
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
}

.card.wrong {
  border-color: var(--red);
  opacity: 0.6;
}

.card.voted {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.card.true-clue-marker {
  border-color: var(--gold);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: inset 0 0 8px rgba(245, 158, 11, 0.15), 0 0 12px rgba(245, 158, 11, 0.2);
  animation: trueClueGlow 2s ease-in-out infinite;
}

@keyframes trueClueGlow {

  0%,
  100% {
    box-shadow: inset 0 0 8px rgba(245, 158, 11, 0.15), 0 0 8px rgba(245, 158, 11, 0.15);
  }

  50% {
    box-shadow: inset 0 0 12px rgba(245, 158, 11, 0.25), 0 0 16px rgba(245, 158, 11, 0.3);
  }
}

.card.true-clue-marker .card-name::after {
  content: ' \1F511';
  font-size: 0.75rem;
}

.card-swatch {
  width: 50px;
  height: auto;
  min-height: 50px;
  border-radius: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-name-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
}

.card-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.card-check {
  font-size: 1rem;
  color: var(--green);
  display: none;
}

.card.selected .card-check {
  display: inline;
}

/* Large card (for hand) */
.card-large {
  flex-direction: column;
  padding: 0;
  width: 140px;
  height: 190px;
  min-width: 110px;
  text-align: center;
  flex-shrink: 0;
  align-items: stretch;
}

.card-large .card-swatch {
  width: 100%;
  height: auto;
  flex: 1;
  border-radius: 0;
  margin-bottom: 0;
  background-position: center center !important;
}

.card-large .card-name-wrapper {
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 48px;
}

.card-large .card-name {
  font-size: 0.8rem;
  line-height: 1.2;
}

.card-large:hover {
  transform: translateY(-6px);
}

/* --- Clues Area --- */
.clues-area {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  position: relative;
}

.clues-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--purple-light), var(--blue-light), var(--purple-light), transparent);
  opacity: 0.6;
}

.area-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.disappeared-badge {
  padding: 0.15rem 0.5rem;
  background: var(--bg-elevated);
  border-radius: 99px;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.clues-cards {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.clue-card {
  background: var(--bg-card);
  border: 1px solid var(--purple);
  border-radius: var(--radius-sm);
  padding: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  box-shadow: 0 0 10px var(--purple-glow);
  animation: clueAppear 0.5s ease;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  min-height: 36px;
}

.clue-card:hover {
  transform: scale(1.05);
  border-color: var(--purple-light);
}

@keyframes clueAppear {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.clue-card .card-swatch {
  width: 36px;
  height: auto;
  border-radius: 0;
}

.clue-card .card-name-wrapper {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.6rem;
}

.clue-card .card-name {
  font-size: 0.8rem;
}

.clue-round-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  background: var(--bg-surface);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

/* --- Spirit Workspace --- */
.spirit-workspace {
  background: var(--bg-surface);
  border: 2px solid var(--purple);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 0 20px var(--purple-glow);
  position: relative;
  overflow: hidden;
}

.spirit-workspace::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, rgba(124, 58, 237, 0.06), transparent 70%);
  pointer-events: none;
  animation: spiritPulse 3s ease-in-out infinite;
}

@keyframes spiritPulse {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

.spirit-workspace.hidden {
  display: none;
}

.mailbox-cards {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.spirit-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* --- Hand Area --- */
.hand-area {
  grid-column: 1 / 2;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  max-height: 50vh;
}

.hand-header {
  display: none;
}

.hand-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hand-toggle {
  font-size: 0.8rem;
  color: var(--text-dim);
  transition: transform var(--transition);
}

.hand-card-count {
  font-size: 0.65rem;
  color: var(--purple-light);
  background: var(--bg-elevated);
  padding: 0.1rem 0.45rem;
  border-radius: 99px;
  font-weight: 600;
  display: none;
}

.hand-body {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.hand-cards {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  flex: 1;
  padding: 0.25rem;
  flex-wrap: wrap;
  justify-content: center;
}

.hand-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* --- Side Panel --- */
.side-panel {
  grid-row: 2 / 4;
  grid-column: 2;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.panel-tab {
  flex: 1;
  padding: 0.6rem;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
}

.panel-tab.active {
  color: var(--purple-light);
  border-bottom-color: var(--purple);
}

.panel-tab:hover:not(.active) {
  color: var(--text-muted);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.panel-content.hidden {
  display: none;
}

/* --- Chat --- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.chat-msg {
  font-size: 0.8rem;
  padding: 0.3rem 0;
  word-break: break-word;
}

.chat-msg .msg-author {
  font-weight: 600;
  color: var(--purple-light);
}

.chat-msg .msg-text {
  color: var(--text);
}

.chat-msg.system {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.75rem;
}

.chat-input-area {
  display: flex;
  gap: 0.3rem;
  padding: 0.5rem;
  border-top: 1px solid var(--border);
}

.chat-input-area input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
}

.chat-input-area.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --- Game Players --- */
.game-players {
  list-style: none;
  padding: 0.5rem;
}

.game-players li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
}

.game-players li:hover {
  background: var(--bg-hover);
}

.game-players li.player-clickable {
  cursor: pointer;
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  min-height: 44px;
}

.game-players li.player-clickable:hover {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.08);
}

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.player-dot.disconnected {
  background: var(--red);
}

.player-dot.ready {
  background: var(--gold);
  animation: blink 1s infinite;
}

@keyframes blink {
  50% {
    opacity: 0.4;
  }
}

.player-role-tag {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

/* --- Info Panel --- */
.info-text {
  padding: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.info-text h4 {
  color: var(--text);
  font-size: 0.85rem;
  margin: 0.75rem 0 0.25rem;
}

.info-text .secret-highlight {
  color: var(--gold);
  font-weight: 600;
}

/* --- Action Area --- */
.action-area {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  min-height: 44px;
}

.action-area:empty {
  display: none;
}

/* ================= VOTING SCREEN ================= */
#screen-voting {
  align-items: center;
  justify-content: center;
}

.voting-content {
  max-width: 700px;
  width: 90%;
  text-align: center;
}

#voting-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--text-bright);
  margin-bottom: 0.5rem;
}

#voting-description {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.voting-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.voting-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.voting-card:hover {
  border-color: var(--purple);
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}

.voting-card:active {
  transform: translateY(0) scale(0.98);
}

.voting-card.selected {
  border-color: var(--purple-light);
  background: rgba(124, 58, 237, 0.15);
  box-shadow: 0 0 20px var(--purple-glow);
}

.voting-card .vc-swatch {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.voting-card .vc-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.voting-players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.voting-players-grid.hidden {
  display: none;
}

.vote-player-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.vote-player-card:hover {
  border-color: var(--red);
  transform: translateY(-2px);
}

.vote-player-card.selected {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.1);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.vote-player-card .vp-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  margin: 0 auto 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
}

.vote-player-card .vp-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.vote-status {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* ================= RESULTS SCREEN ================= */
#screen-results {
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
}

.results-content {
  max-width: 800px;
  width: 90%;
  text-align: center;
  padding: 2rem;
  margin: auto 0;
}

.result-banner {
  margin-bottom: 2rem;
  padding: 2rem;
  border-radius: var(--radius-lg);
}

.result-banner.light-wins {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(59, 130, 246, 0.1));
  border: 1px solid var(--green);
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.2);
  animation: winGlow 2s ease-in-out infinite;
}

@keyframes winGlow {

  0%,
  100% {
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
  }

  50% {
    box-shadow: 0 0 40px rgba(34, 197, 94, 0.4);
  }
}

.result-banner.dark-wins {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(124, 58, 237, 0.1));
  border: 1px solid var(--red);
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.2);
  animation: darkWinGlow 2s ease-in-out infinite;
}

@keyframes darkWinGlow {

  0%,
  100% {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
  }

  50% {
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.4);
  }
}

#result-title {
  font-family: var(--font-display);
  font-size: 2rem;
}

#result-subtitle {
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.result-section {
  margin-bottom: 1.5rem;
  text-align: left;
}

.result-section h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.result-cards {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.result-roles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.result-role-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.result-role-item .rr-name {
  font-weight: 500;
  flex: 1;
}

.result-role-item .rr-role {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}

.results-footer {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

/* ================= TOAST ================= */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 360px;
  backdrop-filter: blur(8px);
}

.toast.error {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

.toast.success {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.1);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ================= SCROLLBAR ================= */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ================= CARD ZOOM MODAL ================= */
.card-zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: pointer;
  animation: fadeIn 0.2s ease;
}

.card-zoom-overlay.hidden {
  display: none;
}

.card-zoom-content {
  background: var(--bg-card);
  border: 2px solid var(--purple);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  box-shadow: 0 0 60px var(--purple-glow);
  animation: zoomIn 0.3s ease;
  max-width: 280px;
  width: 80%;
  -webkit-user-select: none;
  user-select: none;
}

body.no-select {
  -webkit-user-select: none;
  user-select: none;
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.7);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.card-zoom-swatch {
  width: 160px;
  height: 160px;
  border-radius: var(--radius);
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
}

.card-zoom-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--text-bright);
  line-height: 1.3;
}

/* ================= MOBILE BOTTOM NAV ================= */
.mobile-bottom-nav {
  display: none;
}

.mobile-panel {
  display: none;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 768px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    overflow: hidden;
  }

  .game-main {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 110px;
  }

  .action-area {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--bg-dark);
    border-top: 1px solid var(--border);
    padding: 0.4rem;
    margin: 0 -0.5rem;
    flex-wrap: wrap;
  }

  .action-area.hidden {
    display: none !important;
  }

  /* --- Mobile Clues Area --- */
  .clues-area {
    padding: 0.5rem;
  }

  .clues-cards {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.35rem;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
  }

  .clues-cards::-webkit-scrollbar {
    display: none;
  }

  .clue-card {
    flex-shrink: 0;
    min-width: 100px;
    max-width: 140px;
  }

  .clue-card .card-swatch {
    width: 28px;
    min-height: 28px;
  }

  .clue-card .card-name-wrapper {
    padding: 0.25rem 0.4rem;
  }

  .clue-card .card-name {
    font-size: 0.7rem;
  }

  .area-title {
    font-size: 0.75rem;
    margin-bottom: 0.4rem;
  }

  .spirit-workspace {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
  }

  .spirit-workspace .mailbox-cards {
    gap: 0.3rem;
    max-height: 200px;
    overflow-y: auto;
  }

  .spirit-workspace .mailbox-cards .card {
    padding: 0;
    min-height: 36px;
    font-size: 0.8rem;
  }

  .spirit-workspace .mailbox-cards .card .card-swatch {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }

  .spirit-workspace .mailbox-cards .card .card-name {
    font-size: 0.7rem;
  }

  .spirit-actions {
    margin-top: 0.4rem;
  }

  .side-panel {
    display: none;
  }

  .hand-area {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 56px;
    z-index: 80;
    grid-column: 1;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    max-height: 45vh;
    padding: 0;
    transition: transform 0.3s ease;
    transform: translateY(0);
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .hand-area.hand-minimized {
    transform: translateY(calc(100% - 40px));
    overflow: hidden;
  }



  .table-area {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .category-column {
    padding: 0.4rem;
  }

  .category-header {
    margin-bottom: 0.4rem;
    font-size: 0.75rem;
  }

  .card {
    min-height: 42px;
  }

  .card .card-swatch {
    width: 42px;
  }

  .card .card-name {
    font-size: 0.78rem;
  }

  .lobby-body {
    grid-template-columns: 1fr;
  }

  .game-title {
    font-size: 2.5rem;
  }

  .title-content {
    padding: 1.5rem;
    max-width: 100%;
  }

  .game-header {
    padding: 0.35rem 0.5rem;
    gap: 0.35rem;
  }

  .phase-badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
  }

  .round-badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.35rem;
  }

  .header-phase-title {
    font-size: 0.75rem;
  }

  .role-mini {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
  }

  .hand-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    gap: 0.5rem;
    flex-shrink: 0;
    position: relative;
  }

  .hand-header::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--text-dim);
    border-radius: 2px;
    opacity: 0.5;
  }

  .hand-label {
    font-size: 0.7rem;
    writing-mode: horizontal-tb;
    text-align: center;
    margin-top: 4px;
  }

  .hand-toggle {
    margin-top: 4px;
    font-size: 0.7rem;
    transition: transform 0.3s ease;
  }

  .hand-minimized .hand-toggle {
    transform: rotate(180deg);
  }

  .hand-card-count {
    display: inline-block;
  }

  .hand-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0 0.5rem 0.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    flex: 1 1 auto;
  }

  .hand-cards {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    gap: 0.5rem;
    padding: 0.25rem 0.25rem 0.5rem;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    flex-shrink: 0;
    touch-action: pan-x;
  }

  .hand-cards::-webkit-scrollbar {
    display: none;
  }

  .hand-cards .card-large {
    width: 90px;
    min-width: 90px;
    flex-shrink: 0;
    scroll-snap-align: start;
  }

  .hand-cards .card-large .card-swatch {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }

  .hand-cards .card-large .card-name {
    font-size: 0.65rem;
  }

  .hand-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    flex-wrap: nowrap;
    flex-direction: row;
    flex-shrink: 0;
    padding-bottom: 0.25rem;
  }

  .hand-actions .btn {
    flex: 1;
    min-width: 0;
    white-space: normal;
    font-size: 0.7rem;
    padding: 0.4rem 0.4rem;
    text-align: center;
    line-height: 1.2;
  }

  .game-main {
    padding: 0.5rem;
    gap: 0.75rem;
  }

  .category-column {
    padding: 0.5rem;
  }

  .overlay-card {
    padding: 1.5rem;
    width: 95%;
  }

  .character-sides {
    grid-template-columns: 1fr;
  }

  .voting-cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .toast {
    max-width: 100%;
  }

  .results-content {
    padding: 1rem;
  }

  .result-roles {
    grid-template-columns: 1fr;
  }

  .card-zoom-content {
    max-width: 240px;
  }

  .card-zoom-swatch {
    width: 120px;
    height: 120px;
    font-size: 2.5rem;
  }

  .card-zoom-name {
    font-size: 1.1rem;
  }

  /* --- Mobile Bottom Nav --- */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0;
    height: 56px;
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.3rem 0;
    transition: color 0.2s, background 0.2s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-btn span {
    font-size: 0.6rem;
    font-family: var(--font-body);
    font-weight: 500;
    letter-spacing: 0.3px;
  }

  .mobile-nav-btn.active {
    color: var(--purple-light);
  }

  .mobile-nav-btn.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--purple);
    border-radius: 0 0 2px 2px;
  }

  .mobile-nav-btn.has-badge::before {
    content: '';
    position: absolute;
    top: 6px;
    right: calc(50% - 14px);
    width: 6px;
    height: 6px;
    background: var(--red);
    border-radius: 50%;
  }

  /* --- Mobile Panels --- */
  .mobile-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 56px;
    background: var(--bg-dark);
    z-index: 90;
    flex-direction: column;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: translateY(0);
    opacity: 1;
  }

  .mobile-panel:not(.hidden) {
    display: flex;
  }

  .mobile-panel.hidden {
    display: flex !important;
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
  }

  .mobile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
  }

  .mobile-panel-header h3 {
    font-size: 0.95rem;
    color: var(--text-bright);
    margin: 0;
  }

  .mobile-panel-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-panel-close:hover {
    background: var(--bg-elevated);
    color: var(--text);
  }

  .mobile-panel-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  .mobile-panel-body .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
  }

  .mobile-panel-body .chat-input-area {
    border-top: 1px solid var(--border);
    padding: 0.5rem;
  }

  .mobile-panel-body .game-players {
    padding: 0.5rem;
  }

  .mobile-panel-body .info-text {
    padding: 0.75rem;
  }

  /* Toast above bottom nav */
  .toast-container {
    top: auto;
    bottom: 64px;
    right: 0.5rem;
    left: 0.5rem;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 2rem;
  }

  .game-subtitle {
    font-size: 0.8rem;
  }

  .title-content {
    padding: 1rem;
  }

  .btn-large {
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
  }

  .hand-cards .card-large {
    width: 80px;
    min-width: 80px;
  }

  .hand-cards .card-large .card-swatch {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  .hand-cards .card-large .card-name {
    font-size: 0.6rem;
  }

  .card .card-name {
    font-size: 0.8rem;
  }

  .game-header {
    padding: 0.3rem 0.4rem;
    gap: 0.25rem;
  }

  .lobby-content {
    padding: 1rem;
  }

  .lobby-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }

  .lobby-footer {
    flex-direction: column;
  }

  .lobby-footer .btn {
    width: 100%;
  }

  .action-area {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .hand-actions {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.3rem;
  }

  .hand-actions .btn {
    flex: 1;
    min-width: 0;
    white-space: normal;
    font-size: 0.7rem;
    padding: 0.35rem 0.3rem;
    text-align: center;
    line-height: 1.2;
  }

  .spirit-workspace {
    padding: 0.75rem;
  }

  .voting-card .vc-swatch {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
}