/* =========================================================
   GAME.CSS — Misi Penjelajah Ramadan: Menembus Gerbang Ar-Rayyan
   Media Pembelajaran Interaktif PAI — Bu Diah Pitaloka, S.Pd.I.
   Style: Islamic Neo-Glassmorphism & Gold Emerald Glow
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Amiri:wght@400;700&display=swap');

:root {
  --bg-dark: #061412;
  --bg-deep: #0a1f1c;
  --primary: #059669;
  --primary-light: #10b981;
  --primary-glow: rgba(16, 185, 129, 0.4);
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --gold-glow: rgba(245, 158, 11, 0.4);
  --accent-cyan: #06b6d4;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --glass-bg: rgba(15, 30, 27, 0.72);
  --glass-border: rgba(16, 185, 129, 0.22);
  --glass-card-border: rgba(251, 191, 36, 0.28);
  --card-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-arabic: 'Amiri', serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background: radial-gradient(circle at 50% 10%, #0d3830 0%, #061513 55%, #020908 100%);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  user-select: none;
}

/* Background Animated Canvas (Stars & Moon) */
#gameBgCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

.game-page-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px 60px;
}

/* ── Top Navigation Bar ── */
.game-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(10, 28, 24, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  margin-bottom: 24px;
}

.game-nav-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.25s ease;
}

.game-nav-back:hover {
  color: #fff;
  background: rgba(16, 185, 129, 0.2);
  transform: translateX(-2px);
}

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

.game-nav-logo {
  font-size: 1.3rem;
  filter: drop-shadow(0 0 8px var(--gold-glow));
}

.game-nav-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #fef3c7, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon-nav {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon-nav:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: var(--primary-light);
  transform: scale(1.08);
}

/* Quick Test / Guru Mode Button */
.btn-quick-test {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.45));
  border: 1.5px solid #f59e0b;
  color: #fef08a;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-quick-test:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  transform: scale(1.06);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.7);
}

/* ── Hero Banner ── */
.game-hero {
  text-align: center;
  margin-bottom: 28px;
}

.game-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.12);
  color: var(--gold-light);
  border: 1px solid rgba(245, 158, 11, 0.3);
  margin-bottom: 12px;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.15);
}

.game-main-title {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 8px;
}

.text-gradient-gold {
  background: linear-gradient(135deg, #fffbeb 0%, #fde68a 30%, #f59e0b 70%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 10px rgba(245, 158, 11, 0.3));
}

.game-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

.game-teacher-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.84rem;
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.12);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

/* ── Active Player Profile Banner (Profil Siswa yang Sedang Bermain) ── */
.active-player-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: radial-gradient(circle at 10% 50%, rgba(16, 185, 129, 0.15) 0%, rgba(10, 31, 28, 0.85) 100%);
  border: 1.5px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 8px 30px -10px rgba(0, 0, 0, 0.7), 0 0 20px rgba(16, 185, 129, 0.15);
  padding: 12px 20px;
  border-radius: 20px;
  max-width: 850px;
  margin: 0 auto 18px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.3s ease;
}

.active-player-banner:hover {
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 10px 35px -8px rgba(0, 0, 0, 0.8), 0 0 25px rgba(245, 158, 11, 0.2);
}

.active-player-avatar-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2.5px solid #f59e0b;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
  flex-shrink: 0;
  background: #052e25;
}

.active-player-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.active-player-avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  background: linear-gradient(135deg, #059669, #047857);
  color: #fde68a;
}

.active-player-status-pulse {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #34d399;
  border: 2.5px solid #06201b;
  box-shadow: 0 0 8px #34d399;
  animation: playerStatusPulse 1.8s infinite;
}

@keyframes playerStatusPulse {
  0% { transform: scale(0.9); box-shadow: 0 0 4px #34d399; }
  50% { transform: scale(1.15); box-shadow: 0 0 12px #34d399; }
  100% { transform: scale(0.9); box-shadow: 0 0 4px #34d399; }
}

.active-player-info {
  flex: 1;
  min-width: 0;
}

.active-player-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.player-role-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.player-school-badge {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.active-player-name {
  font-size: 1.18rem;
  font-weight: 800;
  color: #fef3c7;
  letter-spacing: -0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.active-player-sub {
  font-size: 0.78rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-change-player {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e2e8f0;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-change-player:hover {
  background: rgba(245, 158, 11, 0.25);
  color: #fff;
  border-color: #f59e0b;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* ── Status Bar / HUD ── */
.game-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 850px;
  margin: 0 auto 24px;
}

.hud-item {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 12px 14px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(10px);
}

.hud-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.hud-icon--gold {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.hud-icon--emerald {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.hud-icon--cyan {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.hud-icon--purple {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

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

.hud-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ── Main Layout: Grid vs Clues ── */
.game-stage-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  align-items: start;
}

/* ── Matrix Board Card ── */
.matrix-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-card-border);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 25px rgba(245, 158, 11, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.matrix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.matrix-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fde68a;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* ── Live Selection Tracker Banner (Blok & Kunci Huruf Aktif) ── */
.matrix-selection-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 8px 14px;
  border-radius: 12px;
  margin-bottom: 12px;
  min-height: 42px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.matrix-selection-banner.has-selection {
  border-color: rgba(245, 158, 11, 0.85);
  background: rgba(245, 158, 11, 0.14);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.25);
}

.matrix-selection-banner.is-success {
  border-color: rgba(16, 185, 129, 0.9);
  background: rgba(16, 185, 129, 0.22);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.selection-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.selection-icon {
  font-size: 1.1rem;
}

.selection-word {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  color: #fde68a;
  letter-spacing: 0.05em;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.matrix-selection-banner.has-selection .selection-word {
  color: #fbbf24;
  letter-spacing: 0.12em;
  font-weight: 800;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}

.matrix-selection-banner.is-success .selection-word {
  color: #6ee7b7;
  font-weight: 800;
  text-shadow: 0 0 12px rgba(16, 185, 129, 0.8);
}

.btn-clear-selection {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-clear-selection:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #fff;
  transform: scale(1.05);
}

/* ── Word Search Matrix Grid ── */
.word-matrix {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 5px;
  touch-action: none; /* Crucial for custom touch drag */
  position: relative;
  background: rgba(4, 18, 15, 0.85);
  padding: 12px;
  border-radius: 16px;
  border: 1.5px solid rgba(16, 185, 129, 0.3);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
}

.matrix-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.72rem, 2vw, 1.05rem);
  font-weight: 700;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.matrix-cell:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: #fff;
  transform: scale(1.06);
}

/* Active Drag & Tap Selection (Mengunci / Blok Huruf yang Di-Tap) */
.matrix-cell.selecting {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.85), rgba(217, 119, 6, 0.95)) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  border: 2px solid #fef08a !important;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.85), inset 0 0 10px rgba(255, 255, 255, 0.4) !important;
  transform: scale(1.12) !important;
  z-index: 10;
  animation: cellLockPulse 0.4s ease-out;
}

@keyframes cellLockPulse {
  0% { transform: scale(0.92); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1.12); }
}

/* Found Word Cell Styles (Golden Emerald Glow) */
.matrix-cell.found {
  background: linear-gradient(135deg, #059669, #047857) !important;
  color: #fef08a !important;
  font-weight: 800;
  border: 1px solid #34d399 !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
  animation: foundPop 0.4s ease-out;
}

@keyframes foundPop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ── Clues Card (Misi Ramadan) ── */
.clues-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  max-height: 600px;
  display: flex;
  flex-direction: column;
}

.clues-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.clues-title {
  font-size: 1rem;
  font-weight: 700;
  color: #34d399;
  display: flex;
  align-items: center;
  gap: 8px;
}

.clues-counter {
  font-size: 0.78rem;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-weight: 600;
}

.clues-list {
  list-style: none;
  overflow-y: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.clues-list::-webkit-scrollbar {
  width: 5px;
}
.clues-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}
.clues-list::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.3);
  border-radius: 10px;
}

.clue-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 12px 14px;
  border-radius: 14px;
  transition: all 0.25s ease;
  position: relative;
  cursor: pointer;
}

.clue-item:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  transform: translateX(4px);
}

.clue-item.active-focus {
  border-color: var(--gold-light);
  background: rgba(245, 158, 11, 0.1);
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.2);
}

.clue-num {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold-light);
  margin-right: 6px;
}

.clue-question {
  font-size: 0.88rem;
  color: #e2e8f0;
  line-height: 1.4;
  margin-bottom: 6px;
}

.clue-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}

.clue-letters {
  color: var(--text-muted);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 6px;
}

.clue-status {
  font-weight: 700;
  color: var(--text-muted);
}

/* Clue Solved / Found */
.clue-item.solved {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.2), rgba(6, 78, 59, 0.3));
  border-color: rgba(52, 211, 153, 0.4);
}

.clue-item.solved .clue-question {
  color: #f0fdf4;
  text-decoration: none;
}

.clue-item.solved .clue-answer {
  display: inline-block;
  background: rgba(52, 211, 153, 0.25);
  color: #fef08a;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(254, 240, 138, 0.3);
}

.clue-item.solved .clue-status {
  color: #34d399;
}

/* Hikmah Popup Snippet */
.clue-hikmah {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid var(--gold);
  font-size: 0.76rem;
  color: #fef3c7;
  line-height: 1.4;
  display: none;
  animation: fadeIn 0.3s ease;
}

.clue-item.solved .clue-hikmah {
  display: block;
}

/* ── Player Registration Modal / Welcome Screen ── */
.game-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 10, 8, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.game-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.game-modal-card {
  background: radial-gradient(circle at 50% 0%, #0d3830 0%, #0a1f1c 100%);
  border: 1.5px solid var(--gold);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9), 0 0 40px rgba(245, 158, 11, 0.2);
  border-radius: 28px;
  width: 100%;
  max-width: 520px;
  padding: 32px 28px;
  text-align: center;
  position: relative;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.3s ease;
}

.game-modal-overlay.active .game-modal-card {
  transform: translateY(0) scale(1);
}

.modal-icon-badge {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(16, 185, 129, 0.2));
  border: 1.5px solid var(--gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  box-shadow: 0 0 20px var(--gold-glow);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.game-form-group {
  text-align: left;
  margin-bottom: 16px;
}

.game-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.game-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: var(--font-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.game-input:focus {
  border-color: var(--gold-light);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 14px var(--gold-glow);
}

/* ── Avatar / Foto Siswa Picker in Modal ── */
.avatar-select-container {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
}

.avatar-preview-wrap {
  position: relative;
  width: 78px;
  height: 78px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: 3px solid #f59e0b;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.45);
  background: #06201b;
}

.avatar-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.avatar-preview-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.3rem;
  background: linear-gradient(135deg, #059669, #047857);
}

.btn-avatar-camera {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  border: 2.5px solid #0a1f1c;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}

.btn-avatar-camera:hover {
  transform: scale(1.15);
  background: #fde68a;
}

.avatar-select-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fde68a;
  margin-bottom: 2px;
}

.avatar-select-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.avatar-preset-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.avatar-preset-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.avatar-preset-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  transform: scale(1.1);
}

.avatar-preset-btn.active {
  background: rgba(245, 158, 11, 0.35);
  border-color: #fde68a;
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
}

.btn-game-primary {
  width: 100%;
  padding: 14px 24px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  color: #000;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 10px 25px -5px rgba(245, 158, 11, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.btn-game-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -5px rgba(245, 158, 11, 0.6);
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.btn-game-primary:active {
  transform: translateY(1px);
}

.btn-test-modal {
  width: 100%;
  margin-top: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.1);
  border: 1.5px dashed rgba(245, 158, 11, 0.6);
  color: #fde68a;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-test-modal:hover {
  background: rgba(245, 158, 11, 0.25);
  color: #fff;
  border-style: solid;
  border-color: #f59e0b;
  transform: translateY(-1px);
}

/* ── Victory Celebration Modal ── */
.victory-modal-card {
  max-width: 600px;
}

.victory-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 2rem;
  margin-bottom: 12px;
  color: var(--gold-light);
  filter: drop-shadow(0 0 10px var(--gold-glow));
}

.victory-score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.victory-stat-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 12px 10px;
}

.victory-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.victory-stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fde68a;
  margin-top: 4px;
}

/* ── Certificate Preview Container ── */
.cert-preview-wrapper {
  margin: 16px 0;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--gold);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.7);
  background: #000;
}

#certCanvas {
  display: block;
  width: 100%;
  height: auto;
}

.victory-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.btn-action-cert {
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-download-cert {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.btn-download-cert:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
  transform: translateY(-2px);
}

.btn-wa-cert {
  background: #25d366;
  color: #fff;
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.3);
}

.btn-wa-cert:hover {
  background: #20ba5a;
  transform: translateY(-2px);
}

.btn-replay {
  grid-column: span 2;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-replay:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ── Leaderboard Modal ── */
.leaderboard-modal-card {
  max-width: 550px;
}

.leaderboard-table-wrap {
  max-height: 380px;
  overflow-y: auto;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin: 16px 0;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.leaderboard-table th {
  background: rgba(16, 185, 129, 0.15);
  color: #a7f3d0;
  font-weight: 700;
  text-align: left;
  padding: 10px 14px;
  position: sticky;
  top: 0;
}

.leaderboard-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
}

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

.rank-pill {
  font-weight: 800;
  display: inline-block;
  width: 24px;
  text-align: center;
}

.leaderboard-player-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.leaderboard-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(245, 158, 11, 0.6);
  flex-shrink: 0;
  background: #052e25;
}

.leaderboard-avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #059669, #047857);
  color: #fde68a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid rgba(52, 211, 153, 0.4);
  flex-shrink: 0;
}

.rank-1 { color: #facc15; font-size: 1.1rem; }
.rank-2 { color: #cbd5e1; font-size: 1.05rem; }
.rank-3 { color: #d97706; font-size: 1.05rem; }

/* ── Responsive Mobile Optimization ── */
@media (max-width: 860px) {
  .game-stage-container {
    grid-template-columns: 1fr;
  }

  .game-hud {
    grid-template-columns: repeat(2, 1fr);
  }

  .matrix-card {
    padding: 14px;
  }

  .word-matrix {
    gap: 3px;
    padding: 8px;
  }

  .matrix-cell {
    font-size: 0.82rem;
    border-radius: 6px;
  }

  .victory-actions {
    grid-template-columns: 1fr;
  }

  .btn-replay {
    grid-column: span 1;
  }
}

@media (max-width: 480px) {
  .game-page-container {
    padding: 10px 12px 40px;
  }

  .matrix-cell {
    font-size: 0.72rem;
  }

  .hud-val {
    font-size: 1rem;
  }
}
