/* =========================================================
   Rami Compteur - Design System & Modern Styles
   Theme: Luxury Card Table (Deep Emerald, Obsidian & Gold)
   ========================================================= */

:root {
  --bg-dark: #0a110e;
  --bg-card: rgba(18, 32, 26, 0.75);
  --bg-card-hover: rgba(24, 42, 34, 0.85);
  --bg-card-solid: #12201a;
  --bg-input: rgba(10, 20, 16, 0.8);
  --border-glass: rgba(52, 211, 153, 0.15);
  --border-focus: #10b981;

  /* Accent Colors */
  --emerald-primary: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.35);
  --emerald-dark: #065f46;
  
  --gold-accent: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.35);
  --gold-metallic: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  --silver-metallic: linear-gradient(135deg, #e2e8f0 0%, #94a3b8 100%);
  --bronze-metallic: linear-gradient(135deg, #fdba74 0%, #c2410c 100%);

  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.2);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(245, 158, 11, 0.05) 0%, transparent 45%);
}

/* Ambient glow accents */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.bg-glow-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, transparent 70%);
  top: -100px;
  right: -50px;
}
.bg-glow-2 {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(20, 184, 166, 0.12) 0%, transparent 70%);
  bottom: -150px;
  left: -100px;
}

/* =========================================================
   Typography & Base
   ========================================================= */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
}

a {
  color: var(--emerald-primary);
  text-decoration: none;
  transition: color 0.2s;
}

button, input, select, textarea {
  font-family: inherit;
}

/* =========================================================
   Navbar
   ========================================================= */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 17, 14, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  padding: 0.75rem 1.5rem;
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #ffffff;
  box-shadow: 0 0 15px var(--emerald-glow);
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--gold-accent);
  color: #000000;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 4px 6px 4px 10px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
}

.user-avatar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald-primary);
  box-shadow: 0 0 8px var(--emerald-primary);
}

/* =========================================================
   Glass Cards & Containers
   ========================================================= */

.main-content {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.glass-card:hover {
  border-color: rgba(52, 211, 153, 0.28);
}

/* =========================================================
   Buttons & Interactive Elements
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-glass);
  color: #e2e8f0;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(52, 211, 153, 0.3);
  color: #ffffff;
}

.btn-accent {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #000000;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-accent:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.btn-danger-outline {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ffffff;
}

.btn-danger-text {
  color: #f87171;
}

.btn-danger-text:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.85rem 1.6rem;
  font-size: 1.05rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 0.6rem;
  border-radius: var(--radius-md);
}

/* =========================================================
   Forms & Inputs
   ========================================================= */

.app-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #cbd5e1;
}

.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus {
  border-color: var(--emerald-primary);
  box-shadow: 0 0 0 3px var(--emerald-glow);
  background: rgba(14, 28, 22, 0.95);
}

.form-input::placeholder {
  color: var(--text-dim);
}

.label-with-helper {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.threshold-preview {
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold-accent);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.85rem;
}

.slider-input {
  width: 100%;
  accent-color: var(--gold-accent);
  cursor: pointer;
}

.slider-help {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Mode Selector Grid */
.mode-selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .mode-selector-grid {
    grid-template-columns: 1fr;
  }
}

.mode-option-card {
  background: rgba(10, 20, 16, 0.6);
  border: 1.5px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  user-select: none;
}

.mode-option-card:hover {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(16, 32, 26, 0.75);
}

.mode-option-card.active {
  border-color: var(--emerald-primary);
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.mode-option-card.active#mode-card-classic {
  border-color: var(--gold-accent);
  background: rgba(245, 158, 11, 0.12);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}

.mode-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-card-radio-circle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.mode-option-card.active .mode-card-radio-circle {
  border-color: var(--emerald-primary);
  background: var(--emerald-primary);
  box-shadow: inset 0 0 0 2px var(--bg-dark);
}

.mode-option-card.active#mode-card-classic .mode-card-radio-circle {
  border-color: var(--gold-accent);
  background: var(--gold-accent);
  box-shadow: inset 0 0 0 2px var(--bg-dark);
}

.mode-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
}

.mode-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.player-input-row {
  display: flex;
  gap: 0.5rem;
}

.player-input-row .form-input {
  flex: 1;
}

.quick-suggestions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.suggestions-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(52, 211, 153, 0.3);
}

.chip-suggestion {
  border-style: dashed;
  color: var(--text-muted);
}

.chip-suggestion:hover {
  color: var(--emerald-primary);
  border-color: var(--emerald-primary);
}

.chip-player {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  color: #ffffff;
}

.chip-remove-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.2rem;
}

.chip-remove-btn:hover {
  color: var(--danger);
}

.players-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-glass);
  align-items: center;
}

.empty-chips-hint {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
  padding: 0.25rem 0.5rem;
}

/* =========================================================
   Callouts & Badges
   ========================================================= */

.info-callout {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  font-size: 0.85rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.callout-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-finished {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.badge-threshold {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-eligible {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-ineligible {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-mode {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-mode.mode-classic {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-disqualified {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-qualified {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.chip-account-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  margin-left: 0.4rem;
  white-space: nowrap;
}

.btn-player-edit-link {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  opacity: 0.7;
  margin-left: 0.35rem;
}

.btn-player-edit-link:hover {
  opacity: 1;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

/* =========================================================
   Auth Screens (Setup & Login)
   ========================================================= */

.auth-card-wrapper {
  max-width: 480px;
  margin: 3rem auto;
}

.auth-card {
  text-align: center;
  padding: 2.5rem 2rem;
}

.card-hero-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 15px rgba(16, 185, 129, 0.4));
}

.auth-title {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1.5rem;
}

.auth-card .app-form {
  text-align: left;
  margin-top: 1.5rem;
}

/* =========================================================
   Lobby & Game Creation Grid
   ========================================================= */

.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.hero-title {
  font-size: 2.25rem;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 0.25rem;
}

.hero-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: #34d399;
}

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.card-title {
  font-size: 1.3rem;
  font-weight: 700;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.games-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 0.75rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: var(--emerald-primary);
  background: rgba(16, 185, 129, 0.12);
}

.games-feed {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.game-item-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.game-item-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(52, 211, 153, 0.3);
  transform: translateX(3px);
}

.game-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.game-item-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff;
}

.game-item-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.game-item-actions {
  display: flex;
  gap: 0.5rem;
}

/* =========================================================
   Game Detail Screen
   ========================================================= */

.game-view-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.game-header-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 1.25rem 1.75rem;
}

.game-header-main {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.game-title-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.game-title {
  font-size: 1.85rem;
  letter-spacing: -0.02em;
}

.game-meta-tags {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.meta-date {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.game-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Stats Overview Bar */
.stats-overview-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 1rem 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  color: #ffffff;
}

.stat-formula {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--emerald-primary);
  background: rgba(16, 185, 129, 0.1);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.stat-divider {
  width: 1px;
  height: 35px;
  background: var(--border-glass);
}

.text-accent {
  color: var(--gold-accent) !important;
}

/* Main Grid: Leaderboard + Rounds */
.game-main-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.95fr;
  gap: 1.5rem;
  align-items: start;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.section-title {
  font-size: 1.35rem;
}

.section-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.sort-indicator {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--emerald-primary);
  background: rgba(16, 185, 129, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* Podium Mini Highlight on Leaderboard */
.podium-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.podium-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.podium-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.podium-card.rank-1::before { background: var(--gold-metallic); }
.podium-card.rank-2::before { background: var(--silver-metallic); }
.podium-card.rank-3::before { background: var(--bronze-metallic); }

.podium-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #ffffff;
  margin-bottom: 0.5rem;
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.podium-badge-icon {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 1rem;
}

.podium-player-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: #ffffff;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-score-val {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--emerald-primary);
  margin-top: 0.2rem;
}

.podium-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* Leaderboard Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.5rem;
}

.leaderboard-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 0.5rem 0.85rem;
}

.leaderboard-table td {
  padding: 0.85rem;
  background: rgba(0, 0, 0, 0.25);
  transition: background 0.15s;
}

.leaderboard-table tr:hover td {
  background: rgba(255, 255, 255, 0.04);
}

.leaderboard-table tr td:first-child {
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}

.leaderboard-table tr td:last-child {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.td-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.td-rank-badge.rank-top-1 {
  background: var(--gold-metallic);
  color: #000000;
  box-shadow: 0 0 12px var(--gold-glow);
}

.td-rank-badge.rank-top-2 {
  background: var(--silver-metallic);
  color: #000000;
}

.td-rank-badge.rank-top-3 {
  background: var(--bronze-metallic);
  color: #ffffff;
}

.player-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.player-avatar-small {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
  flex-shrink: 0;
}

.player-name-text {
  font-weight: 600;
  font-size: 0.95rem;
  color: #ffffff;
}

/* Score Column */
.score-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-main-number {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--emerald-primary);
  line-height: 1;
}

.score-max-tag {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.history-pills-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.history-pill {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.history-pill.rank-1 { background: #d97706; color: #fff; }
.history-pill.rank-2 { background: #64748b; color: #fff; }
.history-pill.rank-3 { background: #ea580c; color: #fff; }
.history-pill.rank-4 { background: #0284c7; color: #fff; }
.history-pill.rank-5 { background: #475569; color: #cbd5e1; }
.history-pill.rank-absent { background: rgba(255, 255, 255, 0.05); color: #64748b; }

.ranking-footer-note {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-glass);
  line-height: 1.45;
}

/* Rounds Cards Column */
.rounds-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 650px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.round-card-item {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.round-card-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--emerald-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.round-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.round-card-number {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.round-status-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.round-status-badge.completed {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.round-status-badge.pending {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.round-winner-line {
  font-size: 0.85rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.round-winner-name {
  font-weight: 700;
  color: #fbbf24;
}

.round-scores-preview-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.mini-score-tag {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

/* =========================================================
   Modal Dialogs
   ========================================================= */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px var(--emerald-glow);
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-card.modal-lg {
  max-width: 760px;
}

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

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.35rem;
}

.modal-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.btn-close:hover {
  color: #ffffff;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
}

.modal-footer-right {
  display: flex;
  gap: 0.75rem;
}

.justify-center {
  justify-content: center !important;
}

/* Round Scoring Editor rows */
.quick-order-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
}

.quick-order-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #cbd5e1;
}

.round-players-form-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.round-player-row {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: all 0.15s;
}

.round-player-row:hover {
  border-color: rgba(52, 211, 153, 0.3);
}

/* Classic Mode Round Scoring UI */
.classic-player-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.classic-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.classic-quick-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.btn-winner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-winner:hover {
  background: rgba(245, 158, 11, 0.25);
}

.btn-winner.active {
  background: var(--gold-metallic);
  color: #000000;
  border-color: var(--gold-accent);
  box-shadow: 0 0 10px var(--gold-glow);
}

.btn-absent-toggle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-absent-toggle:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.btn-absent-toggle.active {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.classic-score-input-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}

.classic-input-label {
  font-size: 0.82rem;
  color: #cbd5e1;
  font-weight: 600;
}

.classic-input-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.classic-pts-input {
  width: 80px;
  text-align: center;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.4rem 0.5rem;
}

.btn-bump {
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-bump:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.btn-bump-clear {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.player-info-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 140px;
}

.rank-buttons-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.btn-rank-selector {
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn-rank-selector small {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.8;
}

.btn-rank-selector:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.btn-rank-selector.selected.r-1 {
  background: var(--gold-metallic);
  color: #000000;
  border-color: #f59e0b;
  box-shadow: 0 0 10px var(--gold-glow);
}

.btn-rank-selector.selected.r-2 {
  background: var(--silver-metallic);
  color: #000000;
  border-color: #94a3b8;
}

.btn-rank-selector.selected.r-3 {
  background: var(--bronze-metallic);
  color: #ffffff;
  border-color: #ea580c;
}

.btn-rank-selector.selected.r-4 {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
}

.btn-rank-selector.selected.r-5 {
  background: #475569;
  color: #ffffff;
  border-color: #64748b;
}

.btn-rank-selector.selected.r-absent {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: #ef4444;
}

.points-legend-grid {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-glass);
}

.legend-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

/* Victory / Podium Modal */
.victory-card {
  text-align: center;
}

.victory-header {
  padding: 2rem 1.5rem 1rem;
}

.trophy-bounce {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  animation: bounce 1.5s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.victory-title {
  font-size: 2.2rem;
  background: var(--gold-metallic);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.victory-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

.grand-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1rem;
  margin: 1.5rem 0;
  padding-bottom: 1rem;
}

.podium-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 140px;
}

.podium-step-block {
  width: 100%;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.5rem;
  font-family: var(--font-heading);
  font-weight: 800;
  color: #000000;
}

.podium-step.step-1 .podium-step-block {
  height: 140px;
  background: var(--gold-metallic);
  box-shadow: 0 0 25px var(--gold-glow);
}

.podium-step.step-2 .podium-step-block {
  height: 105px;
  background: var(--silver-metallic);
}

.podium-step.step-3 .podium-step-block {
  height: 80px;
  background: var(--bronze-metallic);
  color: #ffffff;
}

.final-recap-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: left;
}

.final-recap-title {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  color: #cbd5e1;
}

/* Rules Modal */
.rules-modal-body {
  gap: 1.5rem;
}

.rules-block {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rules-subtitle {
  font-size: 1.1rem;
  color: #ffffff;
}

.rules-points-table {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
}

.rule-row {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
}

.place-tag {
  font-size: 0.85rem;
  font-weight: 700;
}

.place-tag.gold { color: #fbbf24; }
.place-tag.silver { color: #cbd5e1; }
.place-tag.bronze { color: #ea580c; }
.place-tag.standard { color: #38bdf8; }
.place-tag.mute { color: #94a3b8; }

.points-val {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--emerald-primary);
}

.formula-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.math-formula {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--emerald-primary);
  margin-bottom: 0.5rem;
}

.formula-expl {
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.5;
}

/* =========================================================
   Toast Notifications & Spinners
   ========================================================= */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: rgba(18, 32, 26, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  color: #ffffff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success { border-color: var(--emerald-primary); }
.toast-error { border-color: var(--danger); }

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  gap: 1.25rem;
  color: var(--text-muted);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(16, 185, 129, 0.2);
  border-top-color: var(--emerald-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================================
   Mobile Default Utilities (Desktop View)
   ========================================================= */

.mobile-rank-badge {
  display: none;
}

.mobile-col-label {
  display: none;
}

.mobile-game-action-bar {
  display: none;
}

/* =========================================================
   Responsive Design (Tablet & Mobile)
   ========================================================= */

@media (max-width: 1024px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }
  .game-main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .main-content {
    padding: 1rem 0.75rem 5.5rem 0.75rem;
  }

  .navbar {
    padding: 0.65rem 0.85rem;
  }

  .brand-title {
    font-size: 1.15rem;
  }

  .btn-label-mobile-hidden {
    display: none;
  }

  .hero-title {
    font-size: 1.7rem;
  }

  .hero-header {
    margin-bottom: 1.25rem;
  }

  .game-header-card {
    flex-direction: column;
    align-items: stretch;
    padding: 1.1rem;
    gap: 1rem;
  }

  .game-title {
    font-size: 1.5rem;
  }

  /* Desktop action buttons hidden in header on mobile to prevent clutter */
  .game-header-actions {
    display: none;
  }

  .stats-overview-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
    padding: 1rem;
  }

  .stat-divider {
    display: none;
  }

  .stat-rule-explainer {
    grid-column: span 2;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border-glass);
  }

  /* Compact 3-Column Mini Podium */
  .podium-mini-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
    margin-bottom: 1.1rem;
  }

  .podium-card {
    padding: 0.65rem 0.35rem;
  }

  .podium-avatar {
    width: 38px;
    height: 38px;
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
  }

  .podium-score-val {
    font-size: 1.1rem;
  }

  .podium-player-name {
    font-size: 0.8rem;
  }

  .podium-sub {
    font-size: 0.68rem;
  }

  /* Leaderboard Cards on Mobile */
  .leaderboard-table,
  .leaderboard-table thead,
  .leaderboard-table tbody,
  .leaderboard-table tr,
  .leaderboard-table td {
    display: block;
    width: 100%;
  }

  .leaderboard-table thead {
    display: none;
  }

  .leaderboard-table tr {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    padding: 0.85rem;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  }

  .leaderboard-table td {
    padding: 0.2rem 0;
    background: transparent !important;
    border-radius: 0 !important;
  }

  .leaderboard-table td.td-col-rank,
  .td-col-rank {
    display: none !important;
  }

  .mobile-rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    flex-shrink: 0;
  }

  .mobile-rank-badge.rank-top-1 {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.4);
    font-size: 0.95rem;
  }

  .mobile-rank-badge.rank-top-2 {
    background: rgba(226, 232, 240, 0.15);
    border: 1px solid rgba(226, 232, 240, 0.35);
    font-size: 0.95rem;
  }

  .mobile-rank-badge.rank-top-3 {
    background: rgba(253, 186, 116, 0.15);
    border: 1px solid rgba(253, 186, 116, 0.35);
    font-size: 0.95rem;
  }

  .td-col-player {
    padding-right: 5.5rem;
    margin-bottom: 0.4rem;
  }

  .player-cell {
    gap: 0.5rem;
  }

  .td-col-score {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    text-align: right;
    width: auto !important;
  }

  .score-main-number {
    font-size: 1.25rem;
  }

  .mobile-col-label {
    display: inline;
    color: var(--text-dim);
    font-size: 0.76rem;
    font-weight: 500;
  }

  .td-col-points,
  .td-col-rounds,
  .td-col-eligible {
    display: inline-block !important;
    width: auto !important;
    margin-right: 0.65rem;
    vertical-align: middle;
  }

  .td-col-history {
    margin-top: 0.45rem;
    padding-top: 0.4rem !important;
    border-top: 1px dashed rgba(255, 255, 255, 0.07);
  }

  /* Touch-friendly Round Scoring */
  .round-player-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.85rem;
  }

  .player-info-meta {
    width: 100%;
    justify-content: space-between;
  }

  .rank-buttons-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    width: 100%;
  }

  .btn-rank-selector {
    padding: 0.65rem 0.35rem;
    font-size: 0.85rem;
    min-height: 48px;
    justify-content: center;
    border-radius: var(--radius-sm);
    touch-action: manipulation;
  }

  /* Modals: Modern bottom-sheet style on mobile */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    width: 100%;
    margin: 0;
    animation: modalSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-header {
    padding: 1rem 1.25rem;
  }

  .modal-body {
    padding: 1.15rem;
  }

  .modal-footer {
    padding: 0.85rem 1.15rem;
  }

  /* Grand Victory Podium on Mobile */
  .grand-podium {
    gap: 0.4rem;
    padding: 0.5rem 0;
  }

  .podium-step {
    flex: 1;
    width: auto;
    max-width: 110px;
  }

  .podium-step.step-1 .podium-step-block { height: 115px; }
  .podium-step.step-2 .podium-step-block { height: 88px; }
  .podium-step.step-3 .podium-step-block { height: 68px; }

  /* Mobile Bottom Quick Action Bar */
  .mobile-game-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99;
    background: rgba(10, 17, 14, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-glass);
    padding: 0.65rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom)) 0.85rem;
    display: flex;
    gap: 0.5rem;
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.6);
  }

  .mobile-game-action-bar .btn {
    flex: 1;
    padding: 0.75rem 0.4rem;
    font-size: 0.88rem;
    font-weight: 700;
    border-radius: var(--radius-md);
  }

  /* iOS Auto-zoom prevention on inputs */
  .form-input {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 1.5rem;
  }

  .brand-badge {
    display: none;
  }

  .rank-buttons-group {
    grid-template-columns: repeat(3, 1fr);
  }

  .btn-rank-selector span {
    font-size: 0.8rem;
  }
}

/* =========================================================
   PDF Score Sheet Modal & Print Stylesheet
   ========================================================= */

.modal-card.modal-xl {
  max-width: 960px;
  width: 96%;
  max-height: 94vh;
}

.modal-pdf-body {
  overflow-y: auto;
  padding: 1.5rem;
  background: rgba(4, 10, 8, 0.7);
}

.pdf-preview-wrapper {
  display: flex;
  justify-content: center;
}

/* Paper score sheet design (Simulating printed A4 sheet) */
.score-sheet-paper {
  background: #ffffff;
  color: #0f172a;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  border-radius: var(--radius-md);
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.75);
  padding: 2.25rem;
  width: 100%;
  max-width: 880px;
  border: 1px solid #cbd5e1;
  box-sizing: border-box;
}

.sheet-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

.sheet-brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #047857;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sheet-brand-sub {
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.sheet-stamp-box {
  text-align: right;
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.4;
}

.sheet-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.sheet-meta-col p {
  margin: 0.35rem 0;
  color: #334155;
}

.sheet-meta-col strong {
  color: #0f172a;
}

/* Sheet Podium */
.sheet-podium-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.sheet-podium-card {
  flex: 1;
  padding: 0.85rem;
  border-radius: 6px;
  text-align: center;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.sheet-podium-card.p-1 {
  border-color: #f59e0b;
  background: #fffbeb;
}

.sheet-podium-card.p-2 {
  border-color: #94a3b8;
  background: #f8fafc;
}

.sheet-podium-card.p-3 {
  border-color: #d97706;
  background: #fff7ed;
}

.sheet-podium-rank {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.sheet-podium-name {
  font-weight: 800;
  font-size: 1rem;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-podium-score {
  font-size: 0.85rem;
  color: #047857;
  font-weight: 700;
  margin-top: 0.2rem;
}

/* Sheet Section Titles */
.sheet-section-heading {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1.5rem;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-bottom: 1.5px solid #e2e8f0;
  padding-bottom: 0.4rem;
}

/* Sheet Tables */
.sheet-table-wrapper {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
}

.sheet-table th {
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  text-align: left;
}

.sheet-table th.text-center, .sheet-table td.text-center {
  text-align: center;
}

.sheet-table th.text-right, .sheet-table td.text-right {
  text-align: right;
}

.sheet-table td {
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  color: #334155;
}

.sheet-table tr:nth-child(even) td {
  background: #f8fafc;
}

.sheet-badge {
  display: inline-block;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 4px;
}

.sheet-badge-success { background: #dcfce7; color: #166534; }
.sheet-badge-warning { background: #fef9c3; color: #854d0e; }
.sheet-badge-danger  { background: #fee2e2; color: #991b1b; }
.sheet-badge-gold    { background: #fef3c7; color: #92400e; font-weight: 800; }
.sheet-badge-winner  { background: #dcfce7; color: #15803d; font-weight: 800; }
.sheet-badge-absent  { background: #f1f5f9; color: #94a3b8; }

/* Signatures & Notes */
.sheet-sign-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px dashed #cbd5e1;
  font-size: 0.8rem;
  color: #475569;
}

.sign-line {
  margin-top: 2rem;
  border-bottom: 1px solid #94a3b8;
  width: 80%;
}

.sheet-doc-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
}

/* =========================================================
   Native Print Media Query (@media print)
   ========================================================= */
@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  html, body {
    background: #ffffff !important;
    color: #0f172a !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 10pt !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide app header, glow, main views and modals except the printable sheet */
  #main-nav,
  .bg-glow,
  .view-panel,
  .modal-overlay:not(#modal-pdf-sheet),
  .mobile-game-action-bar,
  #toast-container,
  #modal-pdf-sheet .modal-header,
  #modal-pdf-sheet .modal-footer,
  .pdf-modal-footer {
    display: none !important;
  }

  #modal-pdf-sheet {
    display: block !important;
    position: static !important;
    background: #ffffff !important;
    padding: 0 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  #modal-pdf-sheet .modal-card {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    padding: 0 !important;
    overflow: visible !important;
    animation: none !important;
  }

  #modal-pdf-sheet .modal-body {
    background: #ffffff !important;
    padding: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .score-sheet-paper {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    background: #ffffff !important;
    color: #0f172a !important;
  }

  .sheet-table th {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .sheet-podium-row,
  .sheet-meta-grid,
  .sheet-sign-box {
    page-break-inside: avoid !important;
  }

  .sheet-table tr {
    page-break-inside: avoid !important;
  }
}
