/* ============================================
   Guess The Font - Main Stylesheet
   Dark Mode | Minimal Modern | Typography-Focused
   ============================================ */

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

:root {
  --bg-primary: #f0f2f8;
  --bg-secondary: #ffffff;
  --bg-card: #f4f5fb;
  --bg-hover: #e8eaf2;
  --text-primary: #1a1a2e;
  --text-secondary: #6b6b80;
  --text-muted: #a0a0b0;
  --accent: #7c5cfc;
  --accent-hover: #6a48f0;
  --accent-glow: rgba(124, 92, 252, 0.15);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.15);
  --error: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --border: #d8dbe5;
  --border-light: #c8cbd6;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: "Poppins", sans-serif;
}

[data-theme="dark"] {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a26;
  --bg-hover: #22223a;
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55556a;
  --accent: #7c5cfc;
  --accent-hover: #6a48f0;
  --accent-glow: rgba(124, 92, 252, 0.3);
  --success: #34d399;
  --success-glow: rgba(52, 211, 153, 0.3);
  --error: #f87171;
  --error-glow: rgba(248, 113, 113, 0.3);
  --warning: #fbbf24;
  --border: #2a2a3a;
  --border-light: #3a3a4a;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition:
    background 0.3s ease,
    color 0.3s ease;
}

body *,
body *::before,
body *::after {
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

/* ---------- Container ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav {
  display: flex;
  gap: 24px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
}

.nav a::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width var(--transition);
}

.nav a:hover {
  color: var(--text-primary);
}

.nav a:hover::after {
  width: 100%;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 100px;
  width: 44px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  color: var(--text-secondary);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle .icon {
  position: absolute;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.theme-toggle .icon-sun {
  opacity: 1;
  transform: translateY(0);
}

.theme-toggle .icon-moon {
  opacity: 0;
  transform: translateY(20px);
}

[data-theme="dark"] .theme-toggle .icon-sun {
  opacity: 0;
  transform: translateY(-20px);
}

[data-theme="dark"] .theme-toggle .icon-moon {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-glow {
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-glow:hover {
  box-shadow:
    0 0 30px var(--accent-glow),
    0 0 60px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
}

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

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
  min-height: 70vh;
  padding: 40px 0 80px;
}

.hero-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.1;
}

.hero-title-line {
  display: block;
  font-size: 4rem;
  letter-spacing: -0.03em;
}

.hero-title-line--accent {
  background: linear-gradient(135deg, var(--accent), #a78bfa, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 4.5rem;
}

.hero-desc {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 420px;
  line-height: 1.7;
}

.hero-actions {
  margin-top: 12px;
}

.hero-visual {
  display: flex;
  align-items: center;
  justify-content: center;
}

.font-carousel {
  position: relative;
  width: 280px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.font-sample {
  position: absolute;
  font-size: 6rem;
  font-weight: 700;
  color: var(--text-primary);
  opacity: 0.15;
  transition: all 0.5s ease;
}

.font-sample:nth-child(1) {
  animation: floatFont 6s ease-in-out infinite;
  opacity: 0.2;
}

.font-sample:nth-child(2) {
  animation: floatFont 6s ease-in-out infinite 2s;
  opacity: 0.15;
}

.font-sample:nth-child(3) {
  animation: floatFont 6s ease-in-out infinite 4s;
  opacity: 0.1;
}

@keyframes floatFont {
  0%,
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.15;
  }
  50% {
    transform: translateY(-30px) scale(1.1);
    opacity: 0.3;
  }
}

/* ---------- Sections ---------- */
.section {
  padding: 60px 0;
}

.section-header {
  text-align: center;
  margin-bottom: 40px;
  position: relative;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-sub {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 8px;
}

.back-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* ---------- Leaderboard ---------- */
.leaderboard-container {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.leaderboard-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-muted);
}

.leaderboard-empty-icon {
  font-size: 3rem;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th {
  padding: 16px 20px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.leaderboard-table td {
  padding: 14px 20px;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.leaderboard-table tr:last-child td {
  border-bottom: none;
}

.leaderboard-table tr:hover td {
  background: rgba(124, 92, 252, 0.05);
}

.leaderboard-rank {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.leaderboard-rank.top-1 {
  color: #fbbf24;
}

.leaderboard-rank.top-2 {
  color: #a0a0c0;
}

.leaderboard-rank.top-3 {
  color: #d97706;
}

.leaderboard-name {
  font-weight: 600;
}

.leaderboard-score {
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-display);
}

.leaderboard-accuracy {
  color: var(--success);
}

.leaderboard-level {
  color: var(--warning);
}

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

.leaderboard-actions {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

/* ---------- Game Cards ---------- */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  transition: all var(--transition);
  cursor: default;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  background: var(--bg-hover);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.game-card-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.game-card h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.game-card p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ---------- Name Modal ---------- */
.name-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.name-modal.active {
  opacity: 1;
  pointer-events: all;
}

.name-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.name-modal-content h2 {
  font-family: var(--font-display);
  font-weight: 700;
  margin-bottom: 8px;
}

.name-modal-sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.input {
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: border-color var(--transition);
  outline: none;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.name-modal-actions {
  margin-top: 20px;
}

.name-modal-actions .btn {
  width: 100%;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 40px 0;
  border-top: 1px solid var(--border);
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================
   GAME PAGE STYLES
   ============================================ */
.game-body {
  background: var(--bg-primary);
  overflow-x: hidden;
}

.game-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 24px;
  min-height: 100vh;
}

/* Game Header */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-bottom: 16px;
}

.game-header-left,
.game-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.game-header-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-player-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Lives */
.lives {
  display: flex;
  gap: 6px;
}

.heart {
  font-size: 1.3rem;
  transition: all 0.3s ease;
}

.heart.lost {
  filter: grayscale(1);
  opacity: 0.2;
  transform: scale(0.8);
}

/* Stats */
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-sm {
  flex-direction: row;
  gap: 6px;
}

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

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
}

.timer-value {
  color: var(--accent);
  transition: color 0.3s ease;
}

.timer-value.warning {
  color: var(--warning);
}

.timer-value.danger {
  color: var(--error);
  animation: pulse 0.5s ease infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Difficulty Bar */
.game-difficulty-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.diff-btn {
  padding: 8px 20px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--transition);
}

.diff-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.diff-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 15px var(--accent-glow);
}

/* Progress Bar */
.game-progress {
  height: 3px;
  background: var(--border);
  border-radius: 100px;
  margin-bottom: 32px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 100px;
  transition: width 1s linear;
}

/* Question Number */
.question-number {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 20px;
}

/* Font Display */
.font-display {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 60px 32px;
  margin-bottom: 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .font-display {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.font-display::before {
  content: "Font?";
  position: absolute;
  top: 16px;
  left: 20px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
}

.font-text {
  font-size: 2rem;
  line-height: 1.4;
  word-break: break-word;
  max-width: 100%;
  padding: 0 16px;
}

/* Options */
.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 0;
}

.option-btn {
  padding: 16px 20px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  display: block;
  opacity: 1;
  visibility: visible;
}

.option-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .option-btn {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .option-btn:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

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

.option-btn.selected {
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.1);
}

.option-btn.correct {
  background: rgba(52, 211, 153, 0.15) !important;
  border-color: var(--success) !important;
  color: var(--success);
  box-shadow: 0 0 20px var(--success-glow);
}

.option-btn.wrong {
  background: rgba(248, 113, 113, 0.15) !important;
  border-color: var(--error) !important;
  color: var(--error);
  animation: shake 0.5s ease;
}

.option-btn.disabled {
  pointer-events: none;
  opacity: 1;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-4px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(4px);
  }
}

/* Combo Popup */
.combo-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 3rem;
  color: var(--warning);
  pointer-events: none;
  z-index: 100;
  text-shadow: 0 0 30px rgba(251, 191, 36, 0.3);
}

/* XP Gain */
.xp-gain {
  position: fixed;
  pointer-events: none;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  z-index: 100;
}

/* Score Pop */
.score-pop {
  position: fixed;
  top: 80px;
  right: 40px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--success);
  font-size: 1.5rem;
  pointer-events: none;
  z-index: 100;
}

/* Game Over Overlay */
.gameover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.gameover-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.gameover-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  max-width: 480px;
  width: 90%;
  text-align: center;
}

.gameover-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--error), #fca5a5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gameover-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 32px 0;
}

.gameover-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
}

.gameover-stat-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.gameover-stat-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.gameover-actions .btn,
.gameover-actions a {
  width: 100%;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 32px;
    text-align: center;
    min-height: auto;
    padding: 20px 0 40px;
  }

  .hero-desc {
    margin: 0 auto;
  }

  .hero-title-line {
    font-size: 2.8rem;
  }

  .hero-title-line--accent {
    font-size: 3.2rem;
  }

  .hero-actions {
    justify-content: center;
  }

  .font-carousel {
    width: 200px;
    height: 200px;
  }

  .font-sample {
    font-size: 4rem;
  }

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

  .font-text {
    font-size: 1.5rem;
  }

  .game-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .back-btn {
    position: static;
    transform: none;
    margin-bottom: 12px;
  }

  .section-header {
    padding-top: 40px;
  }
}

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

  .hero-title-line--accent {
    font-size: 2.6rem;
  }

  .gameover-stats {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .gameover-modal {
    padding: 32px 20px;
  }

  .name-modal-content {
    padding: 32px 24px;
  }
}
