/* ═══════════════════════════════════════════════════════════
   MAFIA — Cinematic Dark Theme
   ═══════════════════════════════════════════════════════════ */

/* ─── Design Tokens ────────────────────────────────────── */
:root {
  --bg-deep: #06060e;
  --bg-primary: #0a0a14;
  --bg-surface: rgba(15, 15, 30, 0.6);
  --bg-surface-solid: #0f0f1e;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(255, 255, 255, 0.12);
  --text-primary: #e8e8ef;
  --text-secondary: #8a8a9e;
  --text-muted: #5a5a70;
  --red: #e94560;
  --red-glow: rgba(233, 69, 96, 0.3);
  --red-dim: rgba(233, 69, 96, 0.15);
  --amber: #d4a03c;
  --amber-glow: rgba(212, 160, 60, 0.3);
  --amber-dim: rgba(212, 160, 60, 0.12);
  --blue: #4a9eff;
  --blue-dim: rgba(74, 158, 255, 0.12);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --glass-blur: blur(16px);
}

/* ─── Phase Themes ─────────────────────────────────────── */
.phase-lobby  { --phase-accent: var(--text-secondary); --phase-bg: var(--bg-primary); }
.phase-night  { --phase-accent: var(--blue); --phase-bg: #050510; }
.phase-day    { --phase-accent: var(--amber); --phase-bg: #0e0c08; }

/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--phase-bg, var(--bg-primary));
  color: var(--text-primary);
  font-family: var(--font);
  transition: background-color 1.2s ease;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: #6db3ff; }

.text-muted { color: var(--text-secondary) !important; }

/* ─── Glass Card ───────────────────────────────────────── */
.glass {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ─── Buttons ──────────────────────────────────────────── */
.btn-cinematic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.25s, background 0.25s;
  width: 100%;
}
.btn-cinematic:active { transform: scale(0.97); }
.btn-cinematic:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-red {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 20px var(--red-glow);
}
.btn-red:hover:not(:disabled) { box-shadow: 0 6px 30px var(--red-glow); }

.btn-red-outline {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-red-outline:hover:not(:disabled) { background: var(--red-dim); }

.btn-amber {
  background: var(--amber);
  color: #111;
  box-shadow: 0 4px 20px var(--amber-glow);
}
.btn-amber:hover:not(:disabled) { box-shadow: 0 6px 30px var(--amber-glow); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-accent);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

.btn-green {
  background: var(--green);
  color: #111;
  box-shadow: 0 4px 20px rgba(52, 211, 153, 0.25);
}
.btn-green:hover:not(:disabled) { box-shadow: 0 6px 30px rgba(52, 211, 153, 0.3); }

.btn-sm {
  padding: 8px 16px;
  font-size: 0.8rem;
  letter-spacing: 1px;
}

/* ─── Inputs ───────────────────────────────────────────── */
.input-dark {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-dark::placeholder { color: var(--text-muted); }
.input-dark:focus {
  border-color: var(--phase-accent, var(--blue));
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.12);
}

/* ═══════════════════════════════════════════════════════════
   LANDING PAGE
   ═══════════════════════════════════════════════════════════ */

.landing-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 20%, #12101e 0%, var(--bg-deep) 70%);
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px 40px;
  text-align: center;
}

.game-title {
  font-size: clamp(3.5rem, 10vw, 6rem);
  font-weight: 900;
  letter-spacing: 12px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 60px var(--red-glow), 0 0 120px rgba(233, 69, 96, 0.15);
  margin: 0 0 8px;
  line-height: 1;
}

.game-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin: 0 0 48px;
}

.action-cards {
  display: flex;
  gap: 24px;
  align-items: center;
  max-width: 700px;
  width: 100%;
}

.action-card {
  flex: 1;
  padding: 32px 28px;
}

.action-card h3 {
  margin: 0 0 20px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.action-card .input-dark { margin-bottom: 12px; }

.divider-or {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* Room Browser */
.room-browser {
  padding: 24px 24px 48px;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
}

.room-browser h2 {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.room-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  text-decoration: none;
  color: var(--text-primary);
}
.room-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-accent);
  color: var(--text-primary);
}

.room-card-name { font-weight: 600; }
.room-card-code { color: var(--text-muted); margin-left: 10px; font-size: 0.85rem; }
.room-card-count {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--red-dim);
  color: var(--red);
  font-weight: 600;
}

.empty-rooms {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
  font-size: 0.9rem;
}

/* Landing error */
.landing-error {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  background: rgba(233, 69, 96, 0.15);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 0.9rem;
  z-index: 100;
  animation: slideUp 0.3s ease-out;
}

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

/* ═══════════════════════════════════════════════════════════
   GAME PAGE — Layout
   ═══════════════════════════════════════════════════════════ */

.game-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 6, 14, 0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.game-header .back-link {
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color 0.2s;
}
.game-header .back-link:hover { color: var(--text-primary); }

.room-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.room-name-text {
  font-weight: 700;
  font-size: 1rem;
}
.room-code-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  letter-spacing: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Connection badge */
.conn-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.conn-live { background: var(--green-dim); color: var(--green); }
.conn-dead { background: var(--red-dim); color: var(--red); }
.conn-warn { background: var(--amber-dim); color: var(--amber); }

/* ─── Timer ────────────────────────────────────────────── */
.timer-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px 8px;
}

.timer-display {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--phase-accent, var(--text-primary));
  letter-spacing: 2px;
  transition: color 0.3s;
}

.timer-urgent {
  color: var(--red) !important;
  animation: timerPulse 0.6s infinite alternate;
}

@keyframes timerPulse {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(1.08); opacity: 0.7; }
}

.timer-progress {
  width: 100%;
  max-width: 400px;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.timer-progress-fill {
  height: 100%;
  background: var(--phase-accent, var(--text-secondary));
  border-radius: 2px;
  transition: width 1s linear, background-color 0.3s;
}

.timer-progress-fill.urgent {
  background: var(--red) !important;
}

/* ─── Phase Banner ─────────────────────────────────────── */
.phase-banner {
  text-align: center;
  padding: 16px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--phase-accent);
  border-bottom: 1px solid var(--border);
  animation: bannerIn 0.6s ease-out;
}

@keyframes bannerIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Phase Transition Overlay ─────────────────────────── */
.phase-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  pointer-events: none;
}

.phase-overlay-bg {
  position: absolute;
  inset: 0;
  background: #000;
  animation: overlayFade 2s ease-in-out forwards;
}

@keyframes overlayFade {
  0% { opacity: 0; }
  30% { opacity: 0.85; }
  70% { opacity: 0.85; }
  100% { opacity: 0; }
}

.phase-overlay-text {
  position: relative;
  z-index: 1;
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 900;
  letter-spacing: 8px;
  text-transform: uppercase;
  animation: overlayTextIn 2s ease-in-out forwards;
}

@keyframes overlayTextIn {
  0% { opacity: 0; transform: scale(0.8); }
  25% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.1); }
}

.phase-overlay-night .phase-overlay-text { color: var(--blue); text-shadow: 0 0 60px rgba(74, 158, 255, 0.4); }
.phase-overlay-day .phase-overlay-text { color: var(--amber); text-shadow: 0 0 60px var(--amber-glow); }

/* ─── Join Section ─────────────────────────────────────── */
.join-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.join-card {
  max-width: 400px;
  width: 100%;
  padding: 36px 32px;
}

.join-card h3 {
  margin: 0 0 24px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.join-card .input-dark { margin-bottom: 12px; }

.spectate-link {
  display: block;
  text-align: center;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.spectate-link:hover { color: var(--text-secondary); }

/* ─── Game Grid ────────────────────────────────────────── */
.game-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  flex: 1;
  min-height: 0;
}

/* Main Panel (left) */
.main-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
}

/* Side Panel (right) */
.side-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  min-height: 0;
}

/* ─── Spectator Banner ─────────────────────────────────── */
.spectator-banner {
  text-align: center;
  padding: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

/* ─── Role Card ────────────────────────────────────────── */
.role-card {
  padding: 24px;
  text-align: center;
  border-color: var(--phase-accent, var(--border));
  animation: cardFlip 0.6s ease-out;
}

@keyframes cardFlip {
  0% { transform: perspective(800px) rotateY(90deg); opacity: 0; }
  100% { transform: perspective(800px) rotateY(0); opacity: 1; }
}

.role-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.role-name {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.role-mafia .role-name { color: var(--red); }
.role-doctor .role-name { color: var(--green); }
.role-detective .role-name { color: var(--blue); }
.role-villager .role-name { color: var(--text-primary); }

.role-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ─── Teammates ────────────────────────────────────────── */
.teammates-card {
  padding: 16px 20px;
  border-color: rgba(233, 69, 96, 0.3);
  background: var(--red-dim);
  font-size: 0.9rem;
}
.teammates-card strong { color: var(--red); }

/* ─── Investigation Result ─────────────────────────────── */
.investigation-card {
  padding: 16px 20px;
  border-color: rgba(74, 158, 255, 0.3);
  background: var(--blue-dim);
  font-size: 0.9rem;
}
.investigation-card strong { color: var(--blue); }

/* ─── Phase Results ────────────────────────────────────── */
.phase-results-card {
  padding: 20px 24px;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.6;
  animation: resultIn 0.4s ease-out;
}

@keyframes resultIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.phase-results-card strong { color: var(--red); }

/* ─── Last Game Result ─────────────────────────────────── */
.last-game-card {
  padding: 14px 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-color: rgba(74, 158, 255, 0.2);
}

/* ─── Action Panel (Night / Day) ───────────────────────── */
.action-panel {
  padding: 24px;
}

.action-panel h3 {
  margin: 0 0 16px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.target-btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border-accent);
  background: transparent;
  color: var(--text-primary);
}
.target-btn:hover:not(:disabled) {
  border-color: var(--phase-accent);
  background: rgba(255, 255, 255, 0.04);
}
.target-btn:active:not(:disabled) { transform: scale(0.96); }
.target-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Night-specific target buttons */
.phase-night .target-btn:hover:not(:disabled) {
  border-color: var(--red);
  box-shadow: 0 0 12px var(--red-glow);
}

.target-btn-skip {
  border-style: dashed;
  color: var(--text-muted);
}

.action-done {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  letter-spacing: 1px;
}

/* ─── Host Controls ────────────────────────────────────── */
.host-panel {
  padding: 24px;
}

.host-panel .setting-group {
  margin-bottom: 14px;
}

.host-panel label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.host-panel .input-dark {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.checkbox-group input[type="checkbox"] {
  accent-color: var(--red);
  width: 16px;
  height: 16px;
}

.checkbox-group label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 0;
  text-transform: none;
}

/* ─── Game End ─────────────────────────────────────────── */
.game-end-panel {
  padding: 32px 24px;
  text-align: center;
}

.winner-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin: 0 0 24px;
  animation: winnerIn 0.6s ease-out;
}

@keyframes winnerIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.winner-mafia { color: var(--red); text-shadow: 0 0 40px var(--red-glow); }
.winner-civilian { color: var(--green); text-shadow: 0 0 40px rgba(52, 211, 153, 0.3); }
.winner-draw { color: var(--amber); text-shadow: 0 0 40px var(--amber-glow); }

.roles-reveal {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 360px;
  margin: 0 auto;
}

.role-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  animation: roleRowIn 0.4s ease-out backwards;
}

.role-row-name { font-weight: 500; }

.role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
}
.role-badge-mafia { background: var(--red-dim); color: var(--red); }
.role-badge-villager { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); }
.role-badge-doctor { background: var(--green-dim); color: var(--green); }
.role-badge-detective { background: var(--blue-dim); color: var(--blue); }

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

/* ─── Players Section ──────────────────────────────────── */
.players-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.players-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.players-header h4 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.player-count-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: background 0.15s;
}
.player-item:hover { background: var(--bg-hover); }

.player-name { font-weight: 500; }
.player-you { color: var(--text-muted); font-size: 0.8rem; }

.player-badges {
  display: flex;
  gap: 6px;
}

.badge-host {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--amber-dim);
  color: var(--amber);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge-dead {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--red-dim);
  color: var(--red);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.player-dead {
  opacity: 0.4;
}

/* ─── Chat Section ─────────────────────────────────────── */
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.chat-header h4 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.chat-tabs {
  display: flex;
  gap: 4px;
}

.chat-tab {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}
.chat-tab:hover { border-color: var(--border-accent); color: var(--text-secondary); }
.chat-tab.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-accent);
  color: var(--text-primary);
}
.chat-tab-mafia.active {
  background: var(--red-dim);
  border-color: rgba(233, 69, 96, 0.3);
  color: var(--red);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 200px;
  max-height: calc(100vh - 350px);
}

.chat-msg {
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  animation: chatIn 0.2s ease-out;
}

@keyframes chatIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg-user {
  background: rgba(255, 255, 255, 0.03);
}

.chat-msg-system {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8rem;
  padding: 4px 10px;
}

.chat-msg-mafia {
  border-left: 2px solid var(--red);
  background: var(--red-dim);
}

.chat-sender {
  font-weight: 600;
  margin-right: 6px;
}
.chat-sender-public { color: var(--blue); }
.chat-sender-mafia { color: var(--red); }

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.chat-input-area input {
  flex: 1;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  outline: none;
}
.chat-input-area input:focus { border-color: var(--border-accent); }

.chat-input-area button {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.chat-input-area button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ─── Share Footer ─────────────────────────────────────── */
.share-footer {
  text-align: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.share-footer code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* ─── Toast ────────────────────────────────────────────── */
.toast-msg {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 300;
  animation: slideUp 0.3s ease-out;
}
.toast-danger {
  background: rgba(233, 69, 96, 0.15);
  border: 1px solid var(--red);
  color: var(--red);
}

/* ─── Language Toggle ──────────────────────────────────── */
.lang-toggle {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 999;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-accent);
  background: var(--bg-surface-solid);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: var(--glass-blur);
}
.lang-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

[dir="rtl"] .lang-toggle { left: auto; right: 20px; }

/* ─── RTL Support ──────────────────────────────────────── */
[dir="rtl"] {
  font-family: 'Segoe UI', 'Arabic UI Display', 'Tahoma', system-ui, sans-serif;
}

[dir="rtl"] .game-grid {
  grid-template-columns: 340px 1fr;
}

[dir="rtl"] .side-panel {
  border-left: none;
  border-right: 1px solid var(--border);
  order: -1;
}

[dir="rtl"] .chat-msg-mafia {
  border-left: none;
  border-right: 2px solid var(--red);
}

[dir="rtl"] .room-card-code {
  margin-left: 0;
  margin-right: 10px;
}

[dir="rtl"] .chat-sender {
  margin-right: 0;
  margin-left: 6px;
}

[dir="rtl"] .game-title {
  letter-spacing: 4px;
}

@media (max-width: 768px) {
  [dir="rtl"] .game-grid {
    grid-template-columns: 1fr;
  }
  [dir="rtl"] .side-panel {
    border-right: none;
    border-top: 1px solid var(--border);
    order: 0;
  }
}

/* ─── Utility ──────────────────────────────────────────── */
.d-none { display: none !important; }
.d-flex { display: flex !important; }

/* ─── Mobile Responsive ────────────────────────────────── */
@media (max-width: 768px) {
  .action-cards {
    flex-direction: column;
  }
  .divider-or {
    padding: 4px 0;
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .chat-messages {
    max-height: 250px;
    min-height: 150px;
  }

  .main-panel {
    padding: 16px;
  }

  .timer-display {
    font-size: 1.5rem;
  }

  .game-header {
    padding: 10px 16px;
  }

  .players-section {
    max-height: 200px;
    overflow-y: auto;
  }

  .target-grid {
    grid-template-columns: 1fr 1fr;
  }

  .winner-title {
    font-size: 1.4rem;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 40px 16px 32px;
  }

  .action-card {
    padding: 24px 20px;
  }

  .game-title {
    letter-spacing: 6px;
  }

  .target-grid {
    grid-template-columns: 1fr;
  }
}
