/* CSS Variables - Midnight Woods Theme */
:root {
  /* Core Colors */
  --bg-dark: #090a0f;
  --bg-darker: #050508;
  --glass-bg: rgba(15, 20, 30, 0.85);
  --glass-border: rgba(100, 116, 139, 0.2);
  --glass-highlight: rgba(255, 255, 255, 0.05);
  
  /* Accents */
  --primary: #94a3b8;      /* Lunar Silver */
  --primary-glow: rgba(148, 163, 184, 0.5);
  --danger: #991b1b;       /* Blood Red */
  --danger-glow: rgba(153, 27, 27, 0.6);
  --success: #059669;      /* Deep Forest Green */
  --warning: #b45309;      /* Autumn Amber */
  --text-main: #e2e8f0;
  --text-muted: #64748b;
  
  /* Values */
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 0 20px rgba(0, 0, 0, 0.5);
  /* Removed the old --village-bg SVG */
  
  --role-color: var(--primary); /* Dynamically overridden in JS */
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
  background-color: var(--bg-dark);
  background-image: url('background.svg');
  background-position: center bottom;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  min-height: 100vh;
  padding: 2rem 1rem 2rem 1rem;
  overflow-x: hidden;
  position: relative;
  line-height: 1.6;
}

h1, h2, h3, h4, .role-title, .badge-text {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

.ambient-glow {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 100vw; height: 100vh;
  background: transparent;
  pointer-events: none;
  z-index: -1;
  transition: background 0.8s ease;
}

/* Glassmorphism Containers */
.container {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  z-index: 10;
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.glass-panel-inner {
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.box-panel {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

/* Header */
.app-header {
  text-align: center;
  padding: 3rem 2rem 2rem;
  background: rgba(5, 5, 8, 0.9);
  border-bottom: 1px solid var(--glass-border);
  position: relative;
}

.header-icon {
  margin-bottom: 1rem;
  animation: glow-pulse 4s ease-in-out infinite;
}

.header-logo {
  width: 80px;
  height: 80px;
  filter: invert(1) drop-shadow(0 0 15px rgba(148, 163, 184, 0.5));
}

@keyframes glow-pulse {
  0% { filter: drop-shadow(0 0 10px rgba(148, 163, 184, 0.3)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 20px rgba(148, 163, 184, 0.7)); transform: scale(1.05); }
  100% { filter: drop-shadow(0 0 10px rgba(148, 163, 184, 0.3)); transform: scale(1); }
}

.app-header h1 {
  font-size: 3.5rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.2rem;
}

.app-header h2 {
  font-size: 1.2rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

.app-header p {
  color: var(--text-muted);
}

/* Forms & Inputs */
.setup-form {
  padding: 2rem;
}

.settings-section {
  margin-bottom: 2.5rem;
}

.settings-section h3 {
  font-size: 1.4rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
}

.settings-section h3 i {
  color: var(--primary);
}

.section-desc {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* Custom modern inputs */
.custom-input label {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1.2rem;
  color: var(--text-muted);
  font-size: 1.2rem;
  z-index: 2;
  transition: color 0.3s ease;
}

.custom-input input {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1rem 1.1rem 3.5rem;
  font-size: 1.1rem;
  font-weight: 500;
  color: #fff;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.custom-input input::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

.custom-input input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(59, 130, 246, 0.25);
  background: rgba(15, 23, 42, 0.9);
}

.custom-input input:focus + .input-icon,
.custom-input input:focus ~ .input-icon {
  color: var(--primary);
}

.custom-input .unit {
  position: absolute;
  right: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

/* Hide spin buttons for numbers globally */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Danger inputs specifically for wolves */
.danger-input .input-icon { color: var(--danger); }
.danger-input input:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-glow);
}

/* Role Grid */
.basic-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.role-inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.role-input-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.15);
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.role-input-group:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(148, 163, 184, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.role-input-group label {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  font-size: 1.05rem;
}

.role-icon {
  font-size: 1.2rem;
  width: 26px;
  text-align: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Theme specifics for roles */
.theme-village .role-icon { color: var(--primary); }
.theme-wolf .role-icon { color: var(--danger); }
.theme-neutral .role-icon { color: var(--warning); }

.role-input-group input {
  width: 65px;
  background: rgba(2, 6, 23, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #fff;
  padding: 0.6rem;
  border-radius: 8px;
  text-align: center;
  font-size: 1.1rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.role-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  background: #0f172a;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.theme-wolf input:focus {
  border-color: var(--danger);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 0 3px rgba(239, 68, 68, 0.25);
}

.theme-neutral input:focus {
  border-color: var(--warning);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 0 3px rgba(245, 158, 11, 0.25);
}

/* Custom Select Dropdowns */
.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select {
  width: 100%;
  appearance: none;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #fff;
  padding: 0.9rem 2.5rem 0.9rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.custom-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(59, 130, 246, 0.25);
  background: rgba(15, 23, 42, 0.9);
}

.custom-select-wrapper::after {
  content: '\f0d7';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  right: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1.1rem;
}

.custom-select option {
  background: var(--bg-dark);
  color: #fff;
}

/* Custom Textarea */
.custom-textarea {
  width: 100%;
  min-height: 120px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  color: #fff;
  font-family: 'Inter', sans-serif;
  resize: vertical;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.custom-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Custom Player Names Inputs */
#playerNamesList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.player-name-input {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.player-name-input:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(148, 163, 184, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.player-name-input .player-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  margin-right: 0.8rem;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.player-name-input input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 500;
  padding: 0.5rem 0;
  outline: none;
}

.player-name-input input::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

/* Toggle Switch */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  width: fit-content;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(30, 41, 59, 1);
  transition: .4s;
  border: 1px solid var(--glass-border);
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  transition: .4s;
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
  transform: translateX(22px);
  background-color: #fff;
}

.toggle-label {
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle-label i {
  color: var(--primary);
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(2, 6, 23, 0.5);
  border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

/* Villager Counter */
.villager-counter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding: 1rem 1.2rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-main);
}

.villager-counter i {
  color: var(--primary);
  font-size: 1.3rem;
}

.villager-counter strong {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  color: #fff;
}

.villager-counter.warning strong {
  color: var(--warning);
}

.villager-counter.error strong {
  color: var(--danger);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--primary);
  color: #0f172a;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-secondary {
  background: rgba(71, 85, 105, 0.8);
  color: white;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--text-muted);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #fff;
}

.text-danger { color: #fca5a5 !important; border-color: #fca5a5 !important; }
.text-danger:hover { background: rgba(220, 38, 38, 0.1) !important; }

.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(0);
}

.btn-glow.btn-primary:hover {
  box-shadow: 0 10px 20px -10px var(--primary);
}

/* Action Bars */
.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--glass-border);
}

.secondary-actions {
  display: flex;
  gap: 1rem;
}

/* Timer Section */
.timer-controls {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.timer-input {
  display: flex;
  gap: 1rem;
}

.timer-input .input-wrapper {
  width: 120px;
}

.timer-input input {
  padding-left: 1rem;
  text-align: center;
}

.timer-display {
  font-family: 'Outfit', sans-serif;
  font-size: 5rem;
  font-weight: 800;
  text-align: center;
  padding: 2rem 0;
  color: var(--primary);
  text-shadow: 0 0 30px var(--primary-glow);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.timer-display.timer-warning {
  color: var(--danger);
  text-shadow: 0 0 30px var(--danger-glow);
  animation: pulse-danger 1s infinite alternate;
}

@keyframes pulse-danger {
  from { opacity: 0.8; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1.02); }
}

/* Game Results Links Area */
.qr-instructions {
  color: var(--text-muted);
  margin-bottom: 2rem;
  text-align: center;
  font-size: 1.1rem;
}

/* ---- Distribution Summary Cards ---- */
.game-info {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--glass-border);
}

.game-info h3 {
  margin-bottom: 1.25rem;
}

.game-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.6);
  transition: var(--transition-fast);
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}

.summary-card.wolf {
  border-color: rgba(220, 38, 38, 0.4);
  background: rgba(153, 27, 27, 0.15);
}

.summary-card.village {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(30, 41, 59, 0.5);
}

.summary-card.neutral {
  border-color: rgba(180, 83, 9, 0.4);
  background: rgba(180, 83, 9, 0.1);
}

.summary-icon {
  font-size: 1.4rem;
}

.summary-count {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: #fff;
  min-width: 1.2rem;
  text-align: center;
}

.summary-role {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* ---- Reveal Secret Assignments Transition ---- */
.role-assignments {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.4s ease, max-height 0.4s ease;
}

.role-assignments.revealed {
  opacity: 1;
  max-height: 2000px;
}

.role-assignments-controls {
  margin-top: 1.5rem;
  text-align: center;
}

.role-assignments-note {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.player-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.player-link-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.player-link-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--role-color, var(--primary));
  opacity: 0.8;
}

.player-link-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px -10px rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.1);
}

.player-link-card h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: #fff;
}

.qr-code-container {
  display: flex;
  justify-content: center;
  border-radius: var(--radius-sm);
  width: 200px;
  height: 200px;
  margin: 1.5rem auto;
  overflow: hidden;
  background: white; /* QR codes need a white background behind the black pixels to scan reliably */
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.qr-code-container canvas {
  width: 100% !important;
  height: 100% !important;
}

@keyframes qrPopIn {
  0% { opacity: 0; transform: scale(0.6) translateY(-20px); }
  60% { transform: scale(1.05) translateY(5px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.qr-expand-anim {
  animation: qrPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.link-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* Master Board / Game Tracking */
.tracking-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .tracking-grid {
    grid-template-columns: 1fr;
  }
}

.player-status-list {
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.player-status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(2, 6, 23, 0.5);
  border: 1px solid var(--glass-border);
  padding: 1rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.player-status-item:hover {
  background: rgba(30, 41, 59, 0.8);
}

.player-status-item.alive {
  border-left: 4px solid var(--success);
}

.player-status-item.dead {
  border-left: 4px solid var(--text-muted);
  opacity: 0.6;
  filter: grayscale(1);
}

.player-status-item.dead .player-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: #fff;
}

.player-name {
  font-weight: 600;
  font-size: 1.1rem;
}

.player-role {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-controls {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.status-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  outline: none;
}

.status-btn a {
  text-decoration: none;
}

.status-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Active states for toggle pills */
.player-status-item.alive .status-btn.alive {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.player-status-item.dead .status-btn.dead {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.status-btn.lover-btn {
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.4rem 0.6rem;
}

.status-btn.lover-btn.active {
  background: rgba(236, 72, 153, 0.2);
  color: #ec4899; /* Pink Cupid Color */
  text-shadow: 0 0 10px rgba(236, 72, 153, 0.5);
}

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stat-box {
  background: rgba(2, 6, 23, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 1rem;
  transition: var(--transition-fast);
}

.stat-box:hover {
  background: rgba(30, 41, 59, 0.4);
  border-color: rgba(255, 255, 255, 0.1);
}

.stat-box i {
  grid-column: 1;
  grid-row: 1 / 3;
  font-size: 2.2rem;
  margin-bottom: 0;
}

.stat-box.alive i { color: var(--success); }
.stat-box.dead i { color: var(--text-muted); }

.stat-value {
  grid-column: 2;
  grid-row: 1;
  font-size: 2.5rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  line-height: 1;
  text-align: right;
  margin-bottom: 0.2rem;
}

.stat-box.alive .stat-value { color: var(--success); }
.stat-box.dead .stat-value { color: var(--text-muted); }

.stat-label {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  text-align: right;
}

/* Night Actions */
.night-actions {
  margin-top: 1.5rem;
}

.night-actions h3 {
  margin-bottom: 1rem;
}

.action-auto-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  min-width: 120px;
  transition: var(--transition-fast);
}

.action-auto-icon {
  font-size: 1.2rem;
}

.action-auto-text {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

.action-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.action-form .custom-select-wrapper {
  flex: 1;
  min-width: 140px;
}

.action-form .btn {
  align-self: stretch;
}

@media (max-width: 768px) {
  .action-form {
    flex-direction: column;
  }
  .action-form .custom-select-wrapper {
    min-width: 100%;
  }
}

.actions-list {
  max-height: 300px;
  overflow-y: auto;
  background: rgba(2, 6, 23, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.actions-list:empty::after {
  content: "No night actions recorded yet.";
  display: block;
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
}

.action-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
}

.action-item:last-child {
  border-bottom: none;
}

.action-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.action-text {
  font-size: 0.95rem;
  font-weight: 500;
}

.action-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}



/* Phase Tracking */
.phase-tracking {
  margin-top: 1.5rem;
}

.phase-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(2, 6, 23, 0.5);
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
}

.phase-badge {
  font-size: 1.5rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary-glow);
}

.phase-buttons {
  display: flex;
  gap: 1rem;
}

/* Role Assignments List (Secret) */
.role-assignments-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.role-assignment-item {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--glass-border);
  padding: 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
  border-left: 4px solid var(--role-color, var(--primary));
}

.role-assignment-icon {
  font-size: 1.5rem;
}

.role-assignment-info {
  display: flex;flex-direction: column;
}

.role-assignment-player {
  font-weight: 600;
  font-size: 1.05rem;
}

.role-assignment-role {
  font-size: 0.85rem;
  color: var(--text-muted);
}



/* -------------------------------------------
   PLAYER VIEW - 3D CARD ANIMATIONS
---------------------------------------------*/
.player-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.player-container {
  width: 100%;
  max-width: 450px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* 3D Scene setup */
.scene {
  width: 100%;
  height: 520px;
  perspective: 1000px;
}

.card {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
  cursor: pointer;
}

.card.is-flipped {
  transform: rotateY(180deg);
}

.card__face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.card__face--front {
  transform: rotateY(180deg); /* This is the actual role card */
  /* dynamic color glow applied in JS */
  box-shadow: inset 0 0 40px rgba(0,0,0,0.5), 0 20px 40px rgba(0,0,0,0.6);
}

.card__face--back {
  /* This is the back of the card visible initially */
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(2, 6, 23, 0.95) 100%);
  align-items: center;
  justify-content: center;
  text-align: center;
  /* Premium card back pattern */
  background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,0.02) 10px, rgba(255,255,255,0.02) 20px);
}

.card-back-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.moon-logo {
  font-size: 5rem;
  color: var(--text-muted);
  filter: drop-shadow(0 0 15px rgba(255,255,255,0.1));
}

.card-back-content h2 {
  font-size: 2.5rem;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.card-back-content p {
  color: var(--text-muted);
  font-size: 1rem;
}

.tap-hint {
  margin-top: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.9rem;
}

.pulse-anim {
  font-size: 2rem;
  animation: pulse-op 1.5s infinite;
}

@keyframes pulse-op {
  0% { transform: scale(0.95); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.5; }
}

/* Card Front Content */
.role-display {
  padding: 2.5rem 2rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 100%);
}

.corner-pin {
  position: absolute;
  width: 8px; height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}
.top-left { top: 1rem; left: 1rem; }
.top-right { top: 1rem; right: 1rem; }
.bottom-left { bottom: 1rem; left: 1rem; }
.bottom-right { bottom: 1rem; right: 1rem; }

.player-name-badge {
  background: rgba(0,0,0,0.3);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255,255,255,0.05);
}

.role-icon-wrapper {
  font-size: 5rem;
  margin-bottom: 1rem;
  color: var(--role-color, #fff);
  filter: drop-shadow(0 0 20px rgba(255,255,255,0.2));
  transform: translateZ(30px); /* 3D effect internally */
}

.role-title {
  font-size: 2.8rem;
  color: var(--role-color, #fff);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  margin-bottom: 1rem;
  line-height: 1.1;
}

.role-divider {
  width: 50px;
  height: 3px;
  background: var(--role-color, #fff);
  margin-bottom: 1.5rem;
  border-radius: 2px;
}

.role-description {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #fff;
}

.role-detailed-description {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.werewolf-team {
  margin-top: auto;
  width: 100%;
  border-color: rgba(220, 38, 38, 0.2);
  background: rgba(127, 29, 29, 0.1);
}

.werewolf-team h3 {
  color: var(--danger);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.teammates-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.teammates-list span {
  font-size: 0.9rem;
  color: #fca5a5;
  font-weight: 500;
}

.player-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.player-controls .btn {
  flex: 1;
}

.player-info-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Animations */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== DAY VOTE TALLY ===== */
.vote-tally-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
}

.vote-tally-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  transition: var(--transition-fast);
}

.vote-tally-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.vote-tally-item.most-votes {
  border-color: var(--danger);
  background: rgba(153, 27, 27, 0.12);
  box-shadow: 0 0 12px rgba(153, 27, 27, 0.2);
}

.vote-player-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

.vote-player-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vote-count-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.custom-select-wrapper {
  position: relative;
  flex: 1;
}

.custom-select-wrapper::after {
  content: "▼";
  font-size: 0.7rem;
  color: var(--text-muted);
  position: absolute;
  right: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  transition: var(--transition-fast);
}

.custom-select-wrapper:focus-within::after {
  color: var(--primary);
  transform: translateY(-50%) rotate(180deg);
}

.custom-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 2.5rem 0.9rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.custom-select:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(255, 255, 255, 0.2);
}

.custom-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
  background: rgba(15, 23, 42, 0.9);
}

.custom-select option {
  background: #0f172a;
  color: #fff;
  padding: 1rem;
}

.vote-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.vote-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--primary);
}

.vote-btn.increment:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.vote-btn.decrement:hover {
  border-color: var(--success);
  color: var(--success);
}

.vote-count-badge {
  min-width: 32px;
  text-align: center;
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.vote-count-badge.has-votes {
  color: var(--danger);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet breakpoint */
@media (max-width: 768px) {
  body {
    padding: 1rem 0.5rem;
  }

  .app-header {
    padding: 2rem 1rem 1.5rem;
  }

  .app-header h1 {
    font-size: 2.2rem;
  }

  .app-header h2 {
    font-size: 1rem;
  }

  .header-logo {
    width: 60px;
    height: 60px;
  }

  .setup-form {
    padding: 1.25rem;
  }

  .glass-panel-inner {
    padding: 1rem;
  }

  .box-panel {
    padding: 1rem;
  }

  /* Settings grids → single column */
  .basic-settings-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .role-inputs-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Player link cards → single column */
  .player-links {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .player-link-card {
    padding: 1rem;
  }

  .qr-code-container {
    width: 160px;
    height: 160px;
  }

  /* Tracking grid → stacked */
  .tracking-grid {
    grid-template-columns: 1fr;
  }

  /* Player status items → stack controls below */
  .player-status-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .status-controls {
    justify-content: center;
  }

  /* Night Log action form → fully stacked */
  .action-form {
    flex-direction: column;
  }

  .action-form .custom-select-wrapper {
    min-width: 100%;
  }

  .action-auto-label {
    justify-content: center;
  }

  /* Summary cards */
  .game-summary {
    flex-direction: column;
  }

  .summary-card {
    width: 100%;
  }

  /* Vote tally */
  .vote-tally-item {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Section headings */
  .settings-section h3 {
    font-size: 1.15rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  /* Stat boxes */
  .stat-box {
    padding: 1rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  .stat-box i {
    font-size: 1.6rem;
  }
}

/* Small phone breakpoint */
@media (max-width: 480px) {
  body {
    padding: 0.5rem 0.25rem;
  }

  .app-header {
    padding: 1.5rem 0.75rem 1rem;
  }

  .app-header h1 {
    font-size: 1.75rem;
  }

  .app-header h2 {
    font-size: 0.85rem;
  }

  .header-logo {
    width: 48px;
    height: 48px;
  }

  .setup-form {
    padding: 0.75rem;
  }

  .glass-panel-inner {
    padding: 0.75rem;
    margin-bottom: 1rem;
  }

  .box-panel {
    padding: 0.75rem;
  }

  .role-input-group {
    padding: 0.6rem 0.8rem;
  }

  .player-link-card h3 {
    font-size: 1rem;
  }

  .qr-code-container {
    width: 140px;
    height: 140px;
  }

  .link-actions {
    flex-direction: column;
  }

  .player-status-list {
    max-height: 300px;
  }

  .player-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }

  .player-name {
    font-size: 0.95rem;
  }

  .player-role {
    font-size: 0.75rem;
  }

  .status-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
  }

  .stat-value {
    font-size: 1.6rem;
  }

  .stat-box i {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }

  .custom-select {
    padding: 0.7rem 2rem 0.7rem 0.8rem;
    font-size: 0.85rem;
  }
}
