/**
 * ============================================================================
 * STYLE.CSS - Global Design Tokens, Reset, Typography, Utilities, & Base UI
 * ============================================================================
 */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Palet Warna Edukasi Modern & Colorful */
  --primary: #1d70b8;
  --primary-dark: #004f98;
  --primary-light: #4ba3e3;
  --secondary: #ff9f1c;
  --secondary-dark: #e88c00;
  --accent: #2ec4b6;
  --danger: #e71d36;
  --success: #2bb673;
  --warning: #ffb703;
  --dark: #1b263b;
  --light: #f8f9fa;
  --white: #ffffff;
  --border-color: #e2e8f0;

  /* Gradien Cerah & Bawah Laut */
  --sea-gradient: linear-gradient(180deg, #3a86ff 0%, #0077b6 35%, #023e8a 70%, #03045e 100%);
  --sky-gradient: linear-gradient(180deg, #70d6ff 0%, #b8f2e6 100%);
  --sand-gradient: linear-gradient(180deg, #dda15e 0%, #bc6c25 100%);
  --card-gradient: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);

  /* Font Families */
  --font-heading: 'Fredoka', cursive, sans-serif;
  --font-body: 'Poppins', sans-serif;

  /* Box Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 6px 14px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.16);
  --shadow-cartoon: 0 8px 0 rgba(0, 0, 0, 0.18);
  --shadow-cartoon-btn: 0 6px 0 rgba(0, 0, 0, 0.2);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --transition-fast: 0.18s ease;
  --transition-normal: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
  font-family: var(--font-body);
  background-color: #f0f7ff;
  color: var(--dark);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Screen Switcher (Single Page Application) */
.view-screen {
  display: none;
  width: 100%;
  min-height: 100vh;
}

.view-screen.active {
  display: block;
}

/* Global Top Utility Bar */
.global-bar {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 9999;
  display: flex;
  gap: 8px;
  transition: all 0.3s ease;
}

/* Saat di arena permainan, reposisi ke pojok kanan bawah agar tidak menutupi nama & skor pemain */
body.in-game .global-bar,
body:has(#view-game-versus.active) .global-bar,
body:has(#view-game-mancing.active) .global-bar,
body:has(#view-game-tarik.active) .global-bar {
  top: auto !important;
  bottom: 12px !important;
  right: 16px !important;
  z-index: 999 !important;
  transform: scale(0.88);
  transform-origin: bottom right;
  opacity: 0.85;
}

body.in-game .global-bar:hover,
body:has(#view-game-versus.active) .global-bar:hover,
body:has(#view-game-mancing.active) .global-bar:hover,
body:has(#view-game-tarik.active) .global-bar:hover {
  opacity: 1;
}

.btn-utility {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--dark);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.btn-utility:hover {
  background: #ffffff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-utility.audio-muted {
  background: #ffe3e3;
  border-color: #ff8787;
  color: var(--danger);
}

/* Tipografi & Judul */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.25;
}

/* Tombol Kartun & Interaktif */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-cartoon-btn);
  position: relative;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.btn-primary {
  background: #3a86ff;
  color: var(--white);
  border-bottom: 4px solid #1a57c2;
}

.btn-primary:hover {
  background: #4d94ff;
}

.btn-secondary {
  background: #ff9f1c;
  color: var(--white);
  border-bottom: 4px solid #d47e00;
}

.btn-secondary:hover {
  background: #ffa834;
}

.btn-success {
  background: #2ec4b6;
  color: var(--white);
  border-bottom: 4px solid #1a877d;
}

.btn-success:hover {
  background: #3fd3c5;
}

.btn-danger {
  background: #e71d36;
  color: var(--white);
  border-bottom: 4px solid #b50e23;
}

.btn-danger:hover {
  background: #ff334b;
}

.btn-warning {
  background: #f59e0b;
  color: var(--white);
  border-bottom: 4px solid #b45309;
}

.btn-warning:hover {
  background: #fbbf24;
}

.btn-outline-primary {
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

.btn-outline-primary:hover {
  background: #e8f3ff;
}

.btn-outline-danger {
  background: var(--white);
  color: var(--danger);
  border: 2px solid var(--danger);
  box-shadow: var(--shadow-sm);
}

.btn-outline-danger:hover {
  background: #ffebeb;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.88rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}

.btn-lg {
  padding: 16px 36px;
  font-size: 1.35rem;
  border-radius: var(--radius-lg);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
}

.badge-primary { background: #e0edff; color: var(--primary); }
.badge-success { background: #d8f8f2; color: #167a70; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #ffe3e3; color: var(--danger); }
.badge-info { background: #e3f2fd; color: #0d47a1; }
.badge-materi { background: #ede7f6; color: #512da8; }
.badge-correct { background: #c8e6c9; color: #2e7d32; font-weight: 700; }

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: #64748b; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

/* Modal Global System */
.app-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 16px;
}

.app-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 4px solid #cbd5e1;
  animation: modalPopIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPopIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}

.modal-header h3 {
  font-size: 1.35rem;
  color: var(--primary-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #94a3b8;
  line-height: 1;
  transition: var(--transition-fast);
}

.modal-close:hover {
  color: var(--danger);
  transform: scale(1.15);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 2px solid #e2e8f0;
}

/* Toast Notifications */
#app-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 11000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  border-left: 6px solid var(--primary);
  animation: toastSlideIn 0.3s ease;
  min-width: 260px;
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--primary); }

.toast-fadeout {
  opacity: 0;
  transform: translateX(50px);
  transition: all 0.3s ease;
}

@keyframes toastSlideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .btn-lg {
    padding: 14px 24px;
    font-size: 1.1rem;
  }
}

/* ==========================================================================
   GLOBAL GAME COUNTDOWN OVERLAY (Hitungan 3, 2, 1, MULAI!)
   ========================================================================== */
.game-countdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: all;
  transition: opacity 0.25s ease;
}

.game-countdown-overlay.active {
  display: flex;
  opacity: 1;
}

.game-countdown-overlay .countdown-card {
  text-align: center;
  background: radial-gradient(circle, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 3px solid rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 50px rgba(245, 158, 11, 0.35), 0 20px 40px rgba(0, 0, 0, 0.6);
  border-radius: 28px;
  padding: 36px 50px;
  min-width: 320px;
  max-width: 90vw;
  user-select: none;
}

.game-countdown-overlay .countdown-subtitle {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
}

.game-countdown-overlay .countdown-number {
  font-family: var(--font-heading);
  font-size: 7.5rem;
  font-weight: 900;
  line-height: 1;
  color: #fbbf24;
  background: linear-gradient(135deg, #fef08a 0%, #f59e0b 50%, #ea580c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 14px rgba(245, 158, 11, 0.5));
  margin: 10px 0;
  display: inline-block;
}

.game-countdown-overlay .countdown-number.start-text {
  font-size: 4.8rem;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #a7f3d0 0%, #10b981 50%, #059669 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 18px rgba(16, 185, 129, 0.6));
}

.game-countdown-overlay .pulse-anim {
  animation: countdownPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes countdownPop {
  0% {
    transform: scale(0.35);
    opacity: 0;
  }
  65% {
    transform: scale(1.18);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.game-countdown-overlay .countdown-tip {
  font-family: var(--font-body);
  font-size: 1rem;
  color: #94a3b8;
  font-weight: 600;
  margin-top: 14px;
}

@media (max-width: 640px) {
  .game-countdown-overlay .countdown-card {
    padding: 24px 30px;
    min-width: 260px;
  }
  .game-countdown-overlay .countdown-number {
    font-size: 5.5rem;
  }
  .game-countdown-overlay .countdown-number.start-text {
    font-size: 3.5rem;
  }
  .game-countdown-overlay .countdown-subtitle {
    font-size: 1rem;
  }
}
