/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --gold: #f5c469;
  --gold-dark: #c89a3a;
  --gold-light: #fde8a0;
  --bg-deep: #0a0704;
  --bg-mid: #140e08;
  --bg-surface: #1e1610;
  --bg-card: rgba(255,255,255,0.055);
  --text-primary: #f5e8c7;
  --text-muted: #a08060;
  --accent-red: #e74c3c;
  --accent-green: #27ae60;
  --border: rgba(245, 196, 105, 0.18);
  --shadow-gold: rgba(245, 196, 105, 0.25);
  --radius: 16px;
  --radius-lg: 24px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--gold-dark); border-radius: 3px; }

/* ===== NAVBAR ===== */
.navbar {
  background: rgba(10, 7, 4, 0.92);
  padding: 1rem 6%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 500;
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 1.8rem;
  animation: spinSlow 8s linear infinite;
}

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

.nav-links { display: flex; gap: 2rem; }
.nav-links a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.nav-links a:hover { color: var(--gold); border-bottom-color: var(--gold); }

/* ===== HERO ===== */
.hero {
  min-height: calc(100vh - 65px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5%;
  padding: 80px 8%;
  position: relative;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 50%, rgba(139, 90, 43, 0.22) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 80% 40%, rgba(245, 196, 105, 0.08) 0%, transparent 60%),
    linear-gradient(160deg, #0a0704 0%, #1a0f06 50%, #0d0905 100%);
  z-index: 0;
}

.hero-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(245,196,105,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 520px;
}

.hero-badge {
  display: inline-block;
  background: rgba(245, 196, 105, 0.12);
  border: 1px solid rgba(245, 196, 105, 0.3);
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 6px 18px;
  border-radius: 100px;
  margin-bottom: 24px;
  animation: fadeUp 0.6s ease both;
}

.hero h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  line-height: 1.1;
  margin-bottom: 1.2rem;
  animation: fadeUp 0.6s 0.1s ease both;
  opacity: 0;
}

.hero h1 span { color: var(--gold); }

.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  animation: fadeUp 0.6s 0.2s ease both;
  opacity: 0;
}

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

.play-btn {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #1a0f06;
  border: none;
  padding: 16px 44px;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  border-radius: 100px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
  box-shadow: 0 8px 32px rgba(245, 196, 105, 0.35);
  animation: fadeUp 0.6s 0.3s ease both;
  opacity: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.play-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 40px rgba(245, 196, 105, 0.5);
}

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

.hero-board-preview {
  position: relative;
  z-index: 1;
  animation: fadeUp 0.8s 0.4s ease both;
  opacity: 0;
  flex-shrink: 0;
}

#preview-canvas {
  border-radius: 16px;
  border: 10px solid #3c2a1f;
  box-shadow: 0 0 60px rgba(245,196,105,0.15), 0 30px 60px rgba(0,0,0,0.8);
}

/* ===== GAME MODES ===== */
.modes-section {
  padding: 80px 6%;
  text-align: center;
  min-height: calc(100vh - 65px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.modes-section h2 {
  font-family: 'Cinzel', serif;
  font-size: 2.4rem;
  color: var(--gold);
  margin-bottom: 8px;
}

.modes-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 50px;
}

.modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 22px;
  max-width: 1000px;
  margin: 0 auto 40px;
}

.mode-card {
  background: var(--bg-card);
  padding: 40px 24px 30px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.mode-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(245,196,105,0.06), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.mode-card:hover::before { opacity: 1; }

.mode-card:hover {
  transform: translateY(-10px);
  border-color: rgba(245, 196, 105, 0.5);
  box-shadow: 0 20px 50px rgba(245, 196, 105, 0.18);
}

.mode-icon {
  width: 72px;
  height: 72px;
  background: rgba(245, 196, 105, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  border: 1px solid rgba(245, 196, 105, 0.25);
  transition: all 0.3s;
}

.mode-card:hover .mode-icon {
  background: rgba(245, 196, 105, 0.2);
  transform: scale(1.1);
}

.mode-icon i { font-size: 2rem; color: var(--gold); }

.mode-card h3 {
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.mode-card p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 18px; }

.mode-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 100px;
  background: rgba(245,196,105,0.1);
  color: var(--gold);
  border: 1px solid rgba(245,196,105,0.2);
}

.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 24px;
  border-radius: 100px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.back-btn:hover { color: var(--gold); border-color: var(--gold); }

/* ===== GAME CONTAINER ===== */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  background: var(--bg-mid);
  min-height: calc(100vh - 65px);
}

.game-header {
  width: min(800px, 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.game-header h2 {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 1.3rem;
}

.exit-btn, .restart-btn {
  padding: 9px 20px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s;
}

.exit-btn { background: rgba(192, 57, 43, 0.8); color: white; }
.exit-btn:hover { background: #c0392b; transform: translateY(-1px); }
.restart-btn { background: rgba(39, 174, 96, 0.8); color: white; }
.restart-btn:hover { background: #27ae60; transform: translateY(-1px); }

.board-wrap {
  position: relative;
  max-width: min(800px, calc(100vw - 32px));
  width: 100%;
}

#carrom-board {
  width: 100%;
  height: auto;
  display: block;
  border: 14px solid #3c2a1f;
  border-radius: 20px;
  box-shadow:
    0 0 0 4px #2a1a0f,
    0 0 80px rgba(0,0,0,0.9),
    inset 0 0 60px rgba(0,0,0,0.4);
}

.status {
  margin-top: 14px;
  font-size: 1.05rem;
  text-align: center;
  color: var(--text-primary);
  min-height: 28px;
}

.score-bar {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.score-pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  padding: 6px 18px;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 700;
  transition: all 0.3s;
}

.score-pill.active-turn {
  background: rgba(245,196,105,0.15);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 16px rgba(245,196,105,0.2);
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
}

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

.modal-content {
  background: linear-gradient(160deg, #1f1a14, #120d08);
  padding: 48px 56px;
  border-radius: var(--radius-lg);
  text-align: center;
  border: 2px solid rgba(245,196,105,0.35);
  max-width: 420px;
  width: 90%;
  box-shadow: 0 30px 80px rgba(0,0,0,0.8), 0 0 40px rgba(245,196,105,0.1);
  animation: scaleIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes scaleIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.trophy-icon { font-size: 4rem; margin-bottom: 16px; }

.modal-content h2 {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 1.9rem;
  margin-bottom: 20px;
}

.final-scores {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px 24px;
  margin-bottom: 28px;
  font-size: 1rem;
  line-height: 2;
  color: var(--text-muted);
}

.final-scores strong { color: var(--text-primary); }

.modal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.modal-btn {
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s;
}

.modal-btn.primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #1a0f06;
  box-shadow: 0 6px 20px rgba(245,196,105,0.3);
}

.modal-btn.primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(245,196,105,0.4); }

.modal-btn.secondary { background: rgba(192,57,43,0.85); color: white; }
.modal-btn.secondary:hover { background: #c0392b; transform: translateY(-2px); }

/* ===== HOW TO PLAY ===== */
.how-to-play {
  min-height: calc(100vh - 65px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 6%;
}

.how-content {
  max-width: 900px;
  width: 100%;
  text-align: center;
}

.how-content h2 {
  font-family: 'Cinzel', serif;
  font-size: 2.4rem;
  color: var(--gold);
  margin-bottom: 50px;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.rule-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
  text-align: left;
}

.rule-num {
  font-family: 'Cinzel', serif;
  font-size: 2.5rem;
  color: rgba(245,196,105,0.2);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 12px;
}

.rule-card h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
}

.rule-card p { font-size: 0.88rem; color: var(--text-muted); line-height: 1.6; }

/* ===== LOADING ===== */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(5, 3, 2, 0.96);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  backdrop-filter: blur(4px);
}

.spinner {
  width: 64px;
  height: 64px;
  border: 4px solid rgba(245,196,105,0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 18px;
}

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

#loading-text {
  color: var(--text-muted);
  font-size: 1rem;
  letter-spacing: 0.5px;
}

/* ===== FOOTER ===== */
.footer {
  background: #060402;
  padding: 48px 6%;
  text-align: center;
  border-top: 1px solid var(--border);
}

.footer-logo {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  color: var(--gold);
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.footer-content p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.footer-content a { color: var(--gold); text-decoration: none; }
.footer-content a:hover { text-decoration: underline; }

.share-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.share-buttons button {
  width: 46px;
  height: 46px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--gold);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
}

.share-buttons button:hover {
  background: var(--gold);
  color: #1a0f06;
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(245,196,105,0.3);
  border-color: var(--gold);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .hero {
    flex-direction: column;
    padding: 60px 6%;
    text-align: center;
  }
  .hero-board-preview { display: none; }
  .hero h1 { font-size: 2.2rem; }
  .game-header { width: 100%; }
  .modal-content { padding: 36px 28px; }
}

@media (max-width: 480px) {
  .navbar { padding: 0.8rem 4%; }
  .logo { font-size: 1.2rem; }
  .modes-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .mode-card { padding: 26px 14px 20px; }
  .mode-icon { width: 52px; height: 52px; }
  .mode-icon i { font-size: 1.5rem; }
}
