/* ==========================================
   CSS RESET & VARIABLES
   ========================================== */
:root {
  /* Font Family */
  --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Theme: Light Mode (Default) */
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  
  --accent: #06b6d4;
  --accent-light: #ecfeff;
  
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --success: #10b981;
  --success-light: #d1fae5;

  /* Sudoku Board Specific Colors */
  --board-bg: #ffffff;
  --board-border-thick: #334155;
  --board-border-thin: #e2e8f0;
  --cell-bg: #ffffff;
  
  --cell-selected: #c7d2fe;
  --cell-highlight: #f1f5f9;
  --cell-same-num: #dbeafe;
  --cell-error: #fca5a5;
  
  --text-original: #0f172a;
  --text-user: #4f46e5;
  --text-error: #dc2626;
  --note-color: #64748b;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-premium: 0 20px 25px -5px rgba(79, 70, 229, 0.1), 0 8px 10px -6px rgba(79, 70, 229, 0.05);
  
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
}

[data-theme="dark"] {
  /* Theme: Dark Mode */
  --bg-app: #0b0f19;
  --bg-card: #151f32;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #1e1b4b;
  
  --accent: #22d3ee;
  --accent-light: #083344;
  
  --danger: #f87171;
  --danger-light: #450a0a;
  --success: #34d399;
  --success-light: #064e3b;

  /* Sudoku Board Specific Colors */
  --board-bg: #151f32;
  --board-border-thick: #94a3b8;
  --board-border-thin: #334155;
  --cell-bg: #151f32;
  
  --cell-selected: #312e81;
  --cell-highlight: #1e293b;
  --cell-same-num: #1e3a8a;
  --cell-error: #7f1d1d;
  
  --text-original: #ffffff;
  --text-user: #818cf8;
  --text-error: #f87171;
  --note-color: #94a3b8;
  
  --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: var(--font-primary);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* ==========================================
   LAYOUT STRUCTURE
   ========================================== */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 540px;
  min-height: 100vh;
  padding: 16px;
  justify-content: space-between;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 16px 0;
  border-bottom: 1px solid var(--board-border-thin);
}

.logo-area h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-main);
}

.logo-area h1 span {
  color: var(--primary);
  font-weight: 400;
  font-size: 1.1rem;
  margin-left: 4px;
  padding: 2px 6px;
  background-color: var(--primary-light);
  border-radius: 4px;
}

.header-controls {
  display: flex;
  gap: 8px;
}

/* ==========================================
   BUTTONS & CONTROLS
   ========================================== */
.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--board-border-thin);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.icon-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  color: var(--primary);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Toggle Sun/Moon icon visibility based on active theme */
#theme-toggle .sun-icon {
  display: block;
}
#theme-toggle .moon-icon {
  display: none;
}

[data-theme="dark"] #theme-toggle .sun-icon {
  display: none;
}
[data-theme="dark"] #theme-toggle .moon-icon {
  display: block;
}

/* Toggle Sound On/Off icon visibility */
#sound-toggle .sound-on-icon {
  display: block;
}
#sound-toggle .sound-off-icon {
  display: none;
}
#sound-toggle.muted .sound-on-icon {
  display: none;
}
#sound-toggle.muted .sound-off-icon {
  display: block;
}

.text-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.text-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.primary-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.primary-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.secondary-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--board-border-thin);
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.secondary-btn:hover {
  background: var(--cell-highlight);
}

.danger-btn {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.danger-btn:hover {
  background: var(--danger);
  color: white;
}

/* ==========================================
   GAME INFO BAR
   ========================================== */
.game-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}

.difficulty-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
}

#current-difficulty-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.status-indicators {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mistakes-counter {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.mistakes-counter span {
  font-weight: 700;
}

#mistakes-count {
  color: var(--danger);
}

.timer-container {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--board-border-thin);
  box-shadow: var(--shadow-sm);
}

.timer-icon {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

#game-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 44px;
  text-align: center;
}

.pause-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 2px;
  transition: color 0.2s ease;
}

.pause-icon-btn:hover {
  color: var(--primary);
}

.pause-icon-btn svg {
  width: 14px;
  height: 14px;
}

/* ==========================================
   SUDOKU BOARD
   ========================================== */
.board-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 16px;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  border: 3px solid var(--board-border-thick);
  border-radius: var(--border-radius-sm);
  background-color: var(--board-border-thick);
  aspect-ratio: 1 / 1;
  width: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-premium);
  touch-action: manipulation;
}

.sudoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 500;
  user-select: none;
  cursor: pointer;
  background-color: var(--cell-bg);
  border-right: 1px solid var(--board-border-thin);
  border-bottom: 1px solid var(--board-border-thin);
  transition: background-color 0.1s ease, color 0.1s ease, transform 0.05s ease;
}

/* Highlight styles */
.sudoku-cell.cell-highlight {
  background-color: var(--cell-highlight);
}

.sudoku-cell.cell-same-number {
  background-color: var(--cell-same-num);
}

.sudoku-cell.cell-selected {
  background-color: var(--cell-selected);
  /* slight scale animation when selected */
  z-index: 2;
  box-shadow: 0 0 8px rgba(79, 70, 229, 0.4);
}

.sudoku-cell.cell-original {
  font-weight: 800;
  color: var(--text-original);
}

.sudoku-cell.cell-user {
  color: var(--text-user);
}

.sudoku-cell.cell-error {
  color: var(--text-error);
  background-color: var(--cell-error);
}

/* Thicker borders for 3x3 regions */
.sudoku-cell:nth-child(3n) {
  border-right: 2px solid var(--board-border-thick);
}

.sudoku-cell:nth-child(9n) {
  border-right: none;
}

/* Top border row 4 and row 7 */
.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 2px solid var(--board-border-thick);
}

.sudoku-cell:nth-child(n+73):nth-child(-n+81) {
  border-bottom: none;
}

/* Main cell value display */
.cell-value {
  z-index: 1;
  pointer-events: none;
}

/* Pencil / Draft notes grid */
.notes-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 3px;
  pointer-events: none;
}

.note-num {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--note-color);
  line-height: 1;
  opacity: 0.8;
}

/* Adjust cell text size for mobile */
@media (max-width: 400px) {
  .sudoku-cell {
    font-size: 1.5rem;
  }
  .note-num {
    font-size: 0.55rem;
  }
}

/* ==========================================
   CONTROL PANEL
   ========================================== */
.control-panel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.control-action-btn {
  background: var(--bg-card);
  border: 1px solid var(--board-border-thin);
  border-radius: var(--border-radius-sm);
  color: var(--text-main);
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.control-action-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  color: var(--primary);
}

.control-action-btn:active {
  transform: translateY(0);
}

.control-action-btn .icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-action-btn svg {
  width: 22px;
  height: 22px;
}

.control-action-btn span {
  font-size: 0.75rem;
  font-weight: 600;
}

/* Active Pencil badge */
.pencil-badge {
  position: absolute;
  top: -6px;
  right: -18px;
  background: var(--text-muted);
  color: white;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
  text-transform: uppercase;
}

.control-action-btn.active-pencil {
  border-color: var(--primary);
  background-color: var(--primary-light);
  color: var(--primary);
}

.control-action-btn.active-pencil .pencil-badge {
  background: var(--primary);
}

/* ==========================================
   NUMBER PAD
   ========================================== */
.number-pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.num-btn {
  aspect-ratio: 1 / 1.1;
  background: var(--bg-card);
  border: 1px solid var(--board-border-thin);
  border-radius: var(--border-radius-sm);
  color: var(--text-main);
  font-family: var(--font-primary);
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.num-btn:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  background-color: var(--primary-light);
  color: var(--primary);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.15);
}

.num-btn:active {
  transform: translateY(0);
}

.num-btn.active-num {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.num-btn.completed {
  visibility: hidden;
}

/* ==========================================
   MODALS
   ========================================== */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--board-border-thin);
  border-radius: var(--border-radius-md);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text-main);
}

.modal-content p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.modal-content::-webkit-scrollbar {
  width: 6px;
}
.modal-content::-webkit-scrollbar-thumb {
  background-color: var(--board-border-thin);
  border-radius: 3px;
}

/* Difficulty Option Cards */
.difficulty-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.diff-opt-btn {
  background: var(--bg-card);
  border: 1px solid var(--board-border-thin);
  border-radius: var(--border-radius-sm);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.diff-opt-btn:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
  transform: translateX(4px);
}

.diff-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.diff-opt-btn:hover .diff-title {
  color: var(--primary);
}

.diff-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Pause Modal specific styling */
.pause-modal .modal-content {
  max-width: 340px;
}

.pause-icon {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 16px;
  animation: pulse 2s infinite;
}

.pause-icon svg {
  width: 48px;
  height: 48px;
}

.text-center {
  text-align: center;
}

/* Victory / Game Over Modals */
.victory-icon {
  font-size: 4rem;
  margin-bottom: 12px;
  display: inline-block;
  animation: bounce 1s infinite alternate;
}

.game-over-icon {
  font-size: 4rem;
  margin-bottom: 12px;
  display: inline-block;
}

.victory-stats {
  background: var(--bg-app);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.victory-stat-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
}

.stat-label {
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  color: var(--text-main);
  font-weight: 700;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions-right {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Statistics Tab Navigation */
.stats-tabs {
  display: flex;
  background: var(--bg-app);
  padding: 4px;
  border-radius: var(--border-radius-sm);
  margin-bottom: 20px;
}

.stats-tab-btn {
  flex: 1;
  background: none;
  border: none;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 0;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.stats-tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-app);
  border: 1px solid var(--board-border-thin);
  border-radius: var(--border-radius-sm);
  padding: 16px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
}

.card-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Help Info styling */
.instruction-body {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.instruction-body p {
  margin-bottom: 0;
}

.instruction-body ol, .instruction-body ul {
  padding-left: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.instruction-body li {
  margin-bottom: 6px;
}

/* ==========================================
   FOOTER
   ========================================== */
.app-footer {
  text-align: center;
  padding: 16px 0 8px 0;
  border-top: 1px solid var(--board-border-thin);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==========================================
   ANIMATIONS & UTILITIES
   ========================================== */
.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

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

/* Responsive Scaling for larger screens */
@media (min-width: 576px) {
  .app-container {
    padding: 24px 0;
  }
  
  .logo-area h1 {
    font-size: 1.6rem;
  }
}

/* Mobile optimizations to fit completely on small screens without scrolling */
@media (max-width: 480px) {
  .app-container {
    padding: 8px;
    justify-content: flex-start;
    gap: 8px;
  }
  
  .app-header {
    padding: 2px 0 6px 0;
  }
  
  .logo-area h1 {
    font-size: 1.15rem;
  }
  
  .logo-area h1 span {
    font-size: 0.9rem;
    padding: 1px 4px;
  }
  
  .icon-btn {
    width: 34px;
    height: 34px;
  }
  
  .icon-btn svg {
    width: 16px;
    height: 16px;
  }
  
  .game-info-bar {
    padding: 4px 0;
  }
  
  .difficulty-indicator {
    gap: 8px;
  }
  
  #current-difficulty-label {
    font-size: 0.85rem;
  }
  
  .text-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
  }
  
  .mistakes-counter {
    font-size: 0.8rem;
  }
  
  .timer-container {
    padding: 4px 8px;
  }
  
  #game-timer {
    font-size: 0.85rem;
    min-width: 38px;
  }
  
  .board-wrapper {
    margin-bottom: 6px;
  }
  
  .sudoku-cell {
    font-size: 1.35rem;
  }
  
  .note-num {
    font-size: 0.5rem;
  }
  
  .control-panel {
    gap: 6px;
    margin-bottom: 8px;
  }
  
  .control-action-btn {
    padding: 6px 2px;
    gap: 3px;
  }
  
  .control-action-btn svg {
    width: 18px;
    height: 18px;
  }
  
  .control-action-btn span {
    font-size: 0.65rem;
  }
  
  .pencil-badge {
    top: -4px;
    right: -10px;
    font-size: 0.5rem;
  }
  
  .number-pad {
    gap: 4px;
    margin-bottom: 8px;
  }
  
  .num-btn {
    font-size: 1.2rem;
    aspect-ratio: 1 / 1;
  }
  
  .app-footer {
    padding: 6px 0 2px 0;
    font-size: 0.65rem;
  }
}

/* Extra small height/width screen optimizations */
@media (max-height: 680px) and (max-width: 480px) {
  .app-container {
    gap: 4px;
  }
  .num-btn {
    font-size: 1.1rem;
  }
  .sudoku-cell {
    font-size: 1.25rem;
  }
}

/* Daily Challenge Button Styles */
.daily-challenge-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
}

.daily-challenge-btn:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
  transform: translateY(-1px);
}

.daily-challenge-btn.completed-challenge {
  background: var(--success) !important;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2) !important;
  cursor: not-allowed;
  transform: none !important;
}

/* Hints Badge and Reward Ad Modal Styles */
.hints-badge {
  position: absolute;
  top: -6px;
  right: -18px;
  background: var(--primary);
  color: white;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.control-action-btn:hover .hints-badge {
  background: var(--primary-hover);
}

.ad-video-container {
  background: #000;
  color: #fff;
  border-radius: var(--border-radius-sm);
  aspect-ratio: 16 / 9;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

.ad-video-placeholder {
  text-align: center;
  padding: 20px;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.1);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border-left-color: var(--primary);
  animation: spin 1s linear infinite;
  margin: 0 auto 12px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.revive-ad-btn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
}

.revive-ad-btn:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary));
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ==========================================
   FIREBASE AUTH & LEADERBOARD STYLING
   ========================================== */
.auth-section {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--board-border-thin);
}

.google-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--board-border-thin);
  border-radius: var(--border-radius-sm);
  padding: 10px 20px;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.google-login-btn:hover {
  background: var(--cell-highlight);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.google-icon {
  width: 18px;
  height: 18px;
}

.user-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

.user-info-detail {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  object-fit: cover;
}

.user-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.logout-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-family: var(--font-primary);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.logout-btn:hover {
  background-color: var(--danger-light);
}

/* Modal Main Tabs */
.modal-main-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--board-border-thin);
}

.main-tab-btn {
  flex: 1;
  background: none;
  border: none;
  font-family: var(--font-primary);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-muted);
  padding: 8px 0 12px 0;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.main-tab-btn.active {
  color: var(--primary);
}

.main-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
}

/* Leaderboard Tab Panels */
.tab-panel.hidden {
  display: none !important;
}

.leaderboard-tabs {
  display: flex;
  background: var(--bg-app);
  padding: 3px;
  border-radius: var(--border-radius-sm);
  margin-bottom: 16px;
  gap: 2px;
}

.leaderboard-tab-btn {
  flex: 1;
  background: none;
  border: none;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 6px 0;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.leaderboard-tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.leaderboard-list-container {
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 10px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--board-border-thin);
  background: var(--bg-app);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--board-border-thin);
  transition: background-color 0.15s ease;
}

.leaderboard-item:last-child {
  border-bottom: none;
}

.leaderboard-item:hover {
  background-color: var(--cell-highlight);
}

.leaderboard-item.current-user-rank {
  background-color: var(--primary-light);
  border-left: 3px solid var(--primary);
}

.leaderboard-player-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0; /* allows text truncation */
}

.leaderboard-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-muted);
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.leaderboard-rank.rank-1 {
  background: #f59e0b; /* Gold */
}
.leaderboard-rank.rank-2 {
  background: #94a3b8; /* Silver */
}
.leaderboard-rank.rank-3 {
  background: #b45309; /* Bronze */
}

.leaderboard-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.leaderboard-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-time {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--primary);
  flex-shrink: 0;
  margin-left: 8px;
}

/* Helpers for scrollbars in leaderboard container */
.leaderboard-list-container::-webkit-scrollbar {
  width: 5px;
}
.leaderboard-list-container::-webkit-scrollbar-thumb {
  background-color: var(--board-border-thin);
  border-radius: 3px;
}

