/* ==========================================================================
   Taiwan GeoPuzzle - Modern Design System & Game Styles
   ========================================================================== */

:root {
  /* Typography */
  --font-main: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', 'Noto Sans TC', sans-serif;

  /* Theme: Dark Obsidian / Pure Black (Default) */
  --bg-primary: #090a0f;
  --bg-secondary: #12141c;
  --bg-surface: rgba(18, 20, 28, 0.85);
  --bg-surface-hover: rgba(28, 32, 44, 0.92);
  --border-color: rgba(255, 255, 255, 0.12);
  --border-highlight: rgba(56, 189, 248, 0.55);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #38bdf8;
  --accent-blue: #0284c7;
  --accent-gold: #facc15;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-emerald: #10b981;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.35);

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

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Theme: Dark Obsidian (Default) */
body.theme-dark {
  --bg-primary: #090a0f;
  --bg-secondary: #12141c;
  --bg-surface: rgba(18, 20, 28, 0.85);
  --bg-surface-hover: rgba(28, 32, 44, 0.92);
  --border-color: rgba(255, 255, 255, 0.12);
  --border-highlight: rgba(56, 189, 248, 0.55);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #38bdf8;
  --accent-blue: #0284c7;
  --shadow-glow: 0 0 22px rgba(56, 189, 248, 0.35);
}

/* Theme: Ocean Modern */
body.theme-ocean {
  --bg-primary: #071828;
  --bg-secondary: #0f2b48;
  --bg-surface: rgba(15, 43, 72, 0.75);
  --bg-surface-hover: rgba(22, 60, 100, 0.85);
  --border-color: rgba(56, 189, 248, 0.25);
  --border-highlight: rgba(56, 189, 248, 0.6);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #38bdf8;
  --accent-blue: #0284c7;
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.4);
}

/* Theme: Parchment Vintage Atlas */
body.theme-parchment {
  --bg-primary: #1c1917;
  --bg-secondary: #292524;
  --bg-surface: rgba(41, 37, 36, 0.85);
  --bg-surface-hover: rgba(68, 64, 60, 0.9);
  --border-color: rgba(217, 119, 6, 0.3);
  --border-highlight: rgba(217, 119, 6, 0.7);
  --text-primary: #fef3c7;
  --text-secondary: #d6d3d1;
  --text-muted: #a8a29e;
  --accent-cyan: #fbbf24;
  --accent-blue: #d97706;
  --shadow-glow: 0 0 20px rgba(251, 191, 36, 0.35);
}

/* Theme: Cyber Night Glow */
body.theme-cyber {
  --bg-primary: #05050b;
  --bg-secondary: #0d0f1d;
  --bg-surface: rgba(13, 15, 29, 0.85);
  --bg-surface-hover: rgba(26, 29, 54, 0.9);
  --border-color: rgba(236, 72, 153, 0.35);
  --border-highlight: rgba(236, 72, 153, 0.8);
  --text-primary: #fdf4ff;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --accent-cyan: #f43f5e;
  --accent-blue: #a855f7;
  --shadow-glow: 0 0 25px rgba(236, 72, 153, 0.45);
}

/* Global Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  touch-action: manipulation;
}

/* Main Container Layout */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

/* ==========================================================================
   Top Navigation HUD
   ========================================================================== */

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 200;
  flex-shrink: 0;
}

/* Brand */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-size: 26px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}

.brand-en {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stage-tag {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  gap: 4px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.4);
}

/* Live HUD Cards */
.hud-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.05);
}

.hud-icon {
  font-size: 16px;
}

.hud-content {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hud-value {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 0.5px;
}

.timer-card .hud-value {
  color: var(--accent-gold);
  min-width: 68px;
}

/* Combo Badge */
.combo-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: linear-gradient(135deg, #f43f5e, #fb923c);
  color: #ffffff;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 800;
  animation: pulseCombo 0.8s infinite alternate;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.5);
}

@keyframes pulseCombo {
  0% { transform: scale(0.96); }
  100% { transform: scale(1.06); }
}

/* Action Tools */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
}

.action-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-highlight);
}

.action-btn.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.action-btn.icon-only {
  padding: 6px 9px;
  font-size: 15px;
}

/* ==========================================================================
   Main Game Board Stage
   ========================================================================== */

.game-stage {
  flex: 1;
  position: relative;
  width: 100%;
  height: calc(100vh - 64px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.puzzle-canvas {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: calc(100vh - 64px);
  display: block;
  touch-action: none;
}

.particle-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 90;
}

/* ==========================================================================
   SVG Puzzle Pieces & Outlines
   ========================================================================== */

/* Ghost Target Outlines */
.ghost-outline {
  fill: rgba(15, 43, 72, 0.25);
  stroke: rgba(56, 189, 248, 0.35);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  transition: stroke 0.2s ease, fill 0.2s ease;
  pointer-events: none;
}

.ghost-outline.active-proximity {
  stroke: #facc15;
  stroke-width: 3;
  stroke-dasharray: none;
  fill: rgba(250, 204, 21, 0.2);
  filter: drop-shadow(0 0 10px rgba(250, 204, 21, 0.6));
  animation: pulseTarget 0.6s infinite alternate;
}

@keyframes pulseTarget {
  0% { stroke-width: 2; }
  100% { stroke-width: 4; }
}

.county-backdrop-outline {
  fill: rgba(15, 43, 72, 0.4);
  stroke: rgba(56, 189, 248, 0.6);
  stroke-width: 2.5;
  pointer-events: none;
}

/* Puzzle Piece SVG Group */
.puzzle-piece {
  cursor: grab;
  transition: filter 0.2s ease;
}

.piece-hit-area {
  pointer-events: stroke;
  cursor: grab;
}

.puzzle-piece.dragging .piece-hit-area {
  cursor: grabbing;
}

.puzzle-piece.locked .piece-hit-area {
  pointer-events: none;
}

.puzzle-piece .piece-path {
  stroke: #ffffff;
  stroke-width: 1.8;
  stroke-linejoin: round;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
  transition: stroke 0.15s ease, filter 0.15s ease;
}

/* Piece Labels - Hidden while unplaced, revealed only when locked (snapped correctly) */
.puzzle-piece .piece-label {
  font-family: var(--font-main);
  font-weight: 700;
  fill: #ffffff;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: scale(0.6);
  transform-origin: center;
  transition: opacity 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Revealed only when snapped and locked into place */
.puzzle-piece.locked .piece-label {
  opacity: 1;
  transform: scale(1);
}

.hide-labels .piece-label {
  display: none !important;
}

/* Hover & Selected States */
.puzzle-piece:hover .piece-path {
  stroke: #38bdf8;
  stroke-width: 2.5;
  filter: drop-shadow(0 6px 14px rgba(56, 189, 248, 0.5));
}

.puzzle-piece.selected .piece-path {
  stroke: #facc15;
  stroke-width: 3;
  filter: drop-shadow(0 8px 20px rgba(250, 204, 21, 0.6));
}

.puzzle-piece.dragging {
  cursor: grabbing;
}

.puzzle-piece.dragging .piece-path {
  stroke: #38bdf8;
  stroke-width: 3.5;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 12px rgba(56, 189, 248, 0.6));
}

/* Rotation Handle */
.piece-rotate-handle {
  display: none;
  cursor: crosshair;
}

.puzzle-piece.selected .piece-rotate-handle {
  display: block;
}

.piece-rotate-handle circle {
  transition: transform 0.15s ease, fill 0.15s ease;
}

.piece-rotate-handle:hover circle {
  fill: #0ea5e9;
  transform: scale(1.15);
}

/* Locked (Snapped) State */
.puzzle-piece.locked {
  cursor: default;
  pointer-events: none;
}

.puzzle-piece.locked .piece-path {
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 1.2;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.puzzle-piece.locked .piece-rotate-handle {
  display: none !important;
}

/* Snap Flash Animation */
@keyframes snapFlashAnim {
  0% {
    stroke: #ffffff;
    stroke-width: 6;
    filter: drop-shadow(0 0 18px #facc15) brightness(1.6);
  }
  100% {
    stroke: rgba(255, 255, 255, 0.85);
    stroke-width: 1.2;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) brightness(1);
  }
}

.snap-flash {
  animation: snapFlashAnim 0.5s ease-out;
}

/* ==========================================================================
   Floating Rotation Controls Bar
   ========================================================================== */

.floating-controls {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 35px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  gap: 10px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  z-index: 80;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.25s ease;
}

.floating-controls.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.float-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.float-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.float-btn:active {
  transform: scale(0.95);
}

.float-btn.primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

.float-btn.primary:hover {
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.6);
}

.float-btn.float-close {
  color: var(--text-muted);
  padding: 6px 8px;
}

.float-btn.float-close:hover {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.15);
}

.float-icon {
  font-size: 20px;
  line-height: 1;
}

.float-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.float-divider {
  width: 1px;
  height: 28px;
  background: var(--border-color);
}

/* ==========================================================================
   Toast Trivia Notification
   ========================================================================== */

.trivia-toast {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  max-width: 340px;
  box-shadow: var(--shadow-md), 0 0 16px rgba(250, 204, 21, 0.3);
  z-index: 95;
  animation: slideInToast 0.4s var(--transition-bounce);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes slideInToast {
  0% { opacity: 0; transform: translateX(40px) scale(0.9); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

.toast-icon {
  font-size: 24px;
}

.toast-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-gold);
  line-height: 1.2;
}

.toast-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
}

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 10, 20, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.modal-card {
  background: var(--bg-surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: modalPop 0.35s var(--transition-bounce);
}

@keyframes modalPop {
  0% { opacity: 0; transform: scale(0.92) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Modal 1: County Selection Grid
   ========================================================================== */

.select-modal-card {
  max-width: 820px;
}

.featured-random-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.5), rgba(56, 189, 248, 0.25));
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  cursor: pointer;
  transition: var(--transition-normal);
}

.featured-random-banner:hover {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.7), rgba(56, 189, 248, 0.4));
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.35);
}

.random-icon {
  font-size: 36px;
}

.random-text h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.random-text p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.btn-play-random {
  background: #ffffff;
  color: #0369a1;
  border: none;
  font-family: var(--font-main);
  font-weight: 800;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: var(--transition-fast);
}

.btn-play-random:hover {
  background: var(--accent-gold);
  color: #1e293b;
  transform: scale(1.05);
}

/* County Category Grid */
.county-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.county-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.county-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent-cyan);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.25);
}

.county-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.county-card-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.county-card-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
}

.county-card-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.county-card-stars {
  color: var(--accent-gold);
  font-size: 11px;
}

.county-card-best {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--accent-gold);
}

/* ==========================================================================
   Modal 2: Victory & Settlement
   ========================================================================== */

.victory-modal-card {
  text-align: center;
  max-width: 520px;
  align-items: center;
}

.victory-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.trophy-icon {
  font-size: 54px;
  animation: bounceTrophy 1s infinite alternate;
  filter: drop-shadow(0 0 20px rgba(250, 204, 21, 0.6));
}

@keyframes bounceTrophy {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-8px) scale(1.08); }
}

.victory-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 900;
  background: linear-gradient(135deg, #fef08a, #facc15, #fb923c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.victory-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Stars Animation */
.stars-container {
  display: flex;
  gap: 12px;
  font-size: 38px;
  margin: 6px 0;
}

.star {
  opacity: 0.2;
  transform: scale(0.5);
  transition: all 0.5s var(--transition-bounce);
}

.star.active {
  opacity: 1;
  transform: scale(1);
  filter: drop-shadow(0 0 14px rgba(250, 204, 21, 0.8));
}

/* Victory Stats Grid */
.victory-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.vstat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  position: relative;
}

.vstat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.vstat-val {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 4px;
}

#vstat-time {
  color: var(--accent-gold);
}

.new-record-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  background: linear-gradient(135deg, #f43f5e, #fb923c);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px rgba(244, 63, 94, 0.4);
  animation: pulseCombo 0.8s infinite alternate;
}

/* Victory Trivia Card */
.victory-trivia-card {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  text-align: left;
  width: 100%;
}

.vtrivia-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.vtrivia-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.vtrivia-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
}

.vtrivia-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.vtrivia-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.vtrivia-tag {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-cyan);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

/* Victory Action Buttons */
.victory-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.btn-action {
  width: 100%;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  border: none;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-action.primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.4);
}

.btn-action.primary:hover {
  box-shadow: 0 6px 24px rgba(56, 189, 248, 0.6);
  transform: translateY(-2px);
}

.btn-action.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-action.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   Modal 3: Records & Leaderboards
   ========================================================================== */

.records-modal-card {
  max-width: 700px;
}

.record-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-heading {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-cyan);
}

.record-summary-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.rsum-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.rsum-val {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-gold);
  margin-top: 4px;
  display: block;
}

.records-table-wrapper {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.records-table th, .records-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.records-table th {
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-muted);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 5;
}

.records-table tr:hover td {
  background: rgba(56, 189, 248, 0.08);
}

.btn-table-play {
  background: var(--accent-blue);
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-table-play:hover {
  background: var(--accent-cyan);
}

.records-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-danger-outline {
  background: transparent;
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.4);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-danger-outline:hover {
  background: rgba(244, 63, 94, 0.15);
}

/* Utilities */
.hidden {
  display: none !important;
}

/* ==========================================================================
   Mobile Collapsible Menu & Responsive Design
   ========================================================================== */

.nav-collapsible-panel {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-nav-tools {
  display: none;
}

.mobile-panel-header {
  display: none;
}

.mobile-menu-backdrop {
  display: none;
}

.desktop-only {
  display: flex;
}

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

@media (max-width: 960px) {
  .brand-en {
    display: none;
  }

  .stage-tag {
    display: none;
  }
}

@media (max-width: 850px) {
  .app-container {
    height: 100dvh;
  }

  .top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    height: 52px;
    gap: 8px;
  }

  .nav-brand {
    gap: 6px;
    flex-shrink: 0;
  }

  .brand-logo {
    font-size: 20px;
  }

  .brand-title {
    font-size: 14px;
    font-weight: 800;
  }

  .hud-stats {
    gap: 6px;
  }

  .hud-card {
    padding: 3px 8px;
    gap: 5px;
  }

  .hud-icon {
    font-size: 13px;
  }

  .hud-label {
    display: none;
  }

  .hud-value {
    font-size: 13px;
    min-width: unset !important;
  }

  .combo-badge {
    padding: 2px 7px;
    font-size: 11px;
  }

  /* Mobile Quick Actions & Menu Toggle */
  .mobile-nav-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .mobile-hint-btn {
    padding: 6px 9px;
    border-radius: var(--radius-full);
    background: rgba(250, 204, 21, 0.15);
    border: 1px solid rgba(250, 204, 21, 0.4);
    color: #facc15;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-hint-btn:active {
    transform: scale(0.92);
  }

  .menu-toggle-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(2, 132, 199, 0.28));
    border: 1px solid var(--border-highlight);
    color: #ffffff;
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-normal);
  }

  .menu-toggle-btn:hover {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.3), rgba(2, 132, 199, 0.4));
  }

  .menu-toggle-btn.active {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.5);
  }

  .menu-toggle-icon {
    font-size: 14px;
  }

  .menu-toggle-text {
    font-size: 12px;
    letter-spacing: 0.5px;
  }

  /* Mobile Collapsible Panel / Sheet */
  .nav-collapsible-panel {
    position: fixed;
    top: 58px;
    left: 10px;
    right: 10px;
    max-height: calc(100dvh - 75px);
    overflow-y: auto;
    background: var(--bg-surface);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    padding: 14px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.75), var(--shadow-glow);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-12px) scale(0.96);
    transition: opacity 0.22s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.22s ease;
    pointer-events: none;
  }

  .nav-collapsible-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }

  .mobile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
  }

  .mobile-panel-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
  }

  .mobile-panel-close {
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 4px;
  }

  .mobile-panel-close:hover {
    color: var(--accent-rose);
  }

  /* Mode tabs in mobile menu */
  .mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    gap: 4px;
    padding: 3px;
  }

  .tab-btn {
    flex: 1;
    justify-content: center;
    padding: 7px 4px;
    font-size: 12px;
    gap: 4px;
  }

  .tab-icon {
    font-size: 13px;
  }

  .tab-label {
    display: inline;
    font-size: 11px;
    font-weight: 700;
  }

  /* Action Tools in mobile menu */
  .nav-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
  }

  .desktop-only {
    display: none !important;
  }

  .action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border-radius: var(--radius-md);
    gap: 3px;
    font-size: 12px;
  }

  .action-btn .action-icon {
    font-size: 16px;
  }

  .action-btn .action-text {
    display: inline !important;
    font-size: 11px;
    font-weight: 700;
  }

  /* Mobile Backdrop */
  .mobile-menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 190;
    opacity: 1;
    transition: opacity 0.25s ease;
  }

  .mobile-menu-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
  }

  /* Main Stage & Board */
  .game-stage {
    height: calc(100dvh - 52px);
  }

  .puzzle-canvas {
    max-height: calc(100dvh - 52px);
  }

  .floating-controls {
    bottom: 12px;
    padding: 4px 10px;
    gap: 6px;
  }

  .float-btn {
    padding: 4px 8px;
  }

  .float-icon {
    font-size: 17px;
  }

  .float-label {
    font-size: 9px;
  }

  .county-grid-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .modal-card {
    padding: 18px 14px;
  }
}

@media (max-width: 480px) {
  .top-nav {
    padding: 6px 10px;
  }

  .brand-title {
    font-size: 13px;
  }

  .hud-stats {
    gap: 4px;
  }

  .hud-card {
    padding: 2px 6px;
  }

  .hud-value {
    font-size: 12px;
  }

  .menu-toggle-btn {
    padding: 5px 10px;
    font-size: 12px;
  }

  .nav-collapsible-panel {
    top: 52px;
    padding: 12px 10px 14px;
  }

  .nav-actions {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .action-btn {
    padding: 6px 4px;
  }

  .action-btn .action-text {
    font-size: 10px;
  }
}

  .victory-stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .vstat-card {
    padding: 8px 4px;
  }

  .vstat-val {
    font-size: 14px;
  }

  .trophy-icon {
    font-size: 40px;
  }

  .victory-title {
    font-size: 20px;
  }
}
