/* ===== Bilal Adventure Game - Islamic Educational Style ===== */
:root {
  --bg-main: #f7f3e9;
  --bg-card: #ffffff;
  --text-main: #1a2e28;
  --text-soft: #4a5c55;
  --accent: #1a6b5a;
  --accent-light: #2a9d8f;
  --gold: #c9a227;
  --danger: #8b3a3a;
  --border: #d4c9b0;
  --shadow: 0 8px 24px rgba(26, 46, 40, 0.12);
  --radius: 16px;
  --font-th: 'Noto Sans Thai', sans-serif;
  --font-ar: 'Amiri', serif;
}

/* Eye-care / Night mode */
body.theme-night {
  --bg-main: #0f1c19;
  --bg-card: #1a2e28;
  --text-main: #e8e0d0;
  --text-soft: #a8b5ae;
  --accent: #3dbaa0;
  --accent-light: #5fd4b8;
  --gold: #e0c060;
  --border: #2a4038;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

html, body {
  height: 100%;
  font-family: var(--font-th);
  background: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
  line-height: 1.6;
}

body {
  background-image:
    radial-gradient(ellipse at top, rgba(26, 107, 90, 0.08), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(201, 162, 39, 0.06), transparent 50%);
}

/* Screens */
.screen {
  display: none;
  min-height: 100%;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}
.screen.active {
  display: flex;
}

/* Splash */
#splash {
  justify-content: center;
  align-items: center;
  background: linear-gradient(160deg, #0f2a24 0%, #1a4a3c 50%, #0d221c 100%);
  color: #f5f0e6;
}
.splash-content {
  text-align: center;
  padding: 2rem;
}
.crescent {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: transparent;
  box-shadow: 15px 0 0 0 #e0c060;
  margin: 0 auto 1.5rem;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
.ar-title {
  font-family: var(--font-ar);
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  letter-spacing: 2px;
}
.th-title {
  font-size: 1.4rem;
  font-weight: 500;
  opacity: 0.95;
}
.subtitle {
  margin-top: 0.8rem;
  font-size: 0.95rem;
  opacity: 0.75;
}
.loader {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #e0c060;
  border-radius: 50%;
  margin: 2rem auto 1rem;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Top bar */
.top-bar, .adv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.logo-ar {
  font-family: var(--font-ar);
  font-size: 1.6rem;
  color: var(--accent);
}
.icon-btn {
  background: none;
  border: none;
  font-size: 1.35rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  border-radius: 10px;
  color: var(--text-main);
  transition: background 0.2s;
}
.icon-btn:active { background: rgba(0,0,0,0.08); }
.hidden { display: none !important; }

/* Menu */
.menu-main {
  flex: 1;
  padding: 1.2rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.hero-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  background: linear-gradient(135deg, #1a4a3c, #0f2a24);
  color: #f5f0e6;
  min-height: 160px;
  display: flex;
  align-items: flex-end;
}
.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(201,162,39,0.25), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(42,157,143,0.2), transparent 40%);
  opacity: 0.9;
}
.hero-text {
  position: relative;
  padding: 1.4rem;
  z-index: 1;
}
.hero-text h2 {
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
}
.hero-text p {
  font-size: 0.9rem;
  opacity: 0.85;
  line-height: 1.5;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.btn {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 1.2rem;
  border-radius: 14px;
  border: none;
  font-family: var(--font-th);
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-align: left;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  box-shadow: 0 6px 16px rgba(26, 107, 90, 0.3);
}
.btn.secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.btn.outline {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}
.btn.large {
  justify-content: center;
  padding: 1.2rem;
  font-size: 1.15rem;
}
.btn-icon { font-size: 1.3rem; }

.footer-note {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-soft);
  line-height: 1.5;
}

/* Adventure */
.adv-header {
  gap: 0.8rem;
}
.progress-wrap {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  width: 0%;
  transition: width 0.4s ease;
  border-radius: 3px;
}
.chapter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.story-container {
  flex: 1;
  padding: 1.3rem 1.2rem 1rem;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
}

.story-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  animation: fadeIn 0.45s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.story-card h3 {
  font-size: 1.15rem;
  color: var(--accent);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.story-card p {
  margin-bottom: 0.9rem;
  color: var(--text-main);
  font-size: 0.98rem;
}
.story-card .ar {
  font-family: var(--font-ar);
  font-size: 1.35rem;
  line-height: 1.9;
  text-align: right;
  direction: rtl;
  color: var(--accent);
  background: rgba(26, 107, 90, 0.06);
  padding: 0.9rem 1rem;
  border-radius: 12px;
  margin: 1rem 0;
  border-right: 4px solid var(--gold);
}
.story-card .quote {
  font-style: italic;
  color: var(--text-soft);
  border-left: 3px solid var(--gold);
  padding-left: 0.9rem;
  margin: 1rem 0;
}
.story-card .source {
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-top: 1rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--border);
}

.choices {
  padding: 0.8rem 1.2rem 1.4rem;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.choice-btn {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.95rem 1.1rem;
  font-family: var(--font-th);
  font-size: 0.98rem;
  text-align: right;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-main);
}
.choice-btn:hover, .choice-btn:focus {
  border-color: var(--accent);
  background: rgba(26, 107, 90, 0.06);
}
.choice-btn.correct {
  border-color: var(--accent-light);
  background: rgba(42, 157, 143, 0.12);
}
.choice-btn.wrong {
  border-color: var(--danger);
  background: rgba(139, 58, 58, 0.08);
}

/* Audio bar */
.audio-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 0.7rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
}
#audio-label {
  font-size: 0.85rem;
  color: var(--text-soft);
  flex: 1;
}

/* Timeline */
.timeline-list {
  padding: 1.2rem;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}
.tl-item {
  position: relative;
  padding: 0 0 1.5rem 1.8rem;
  border-left: 3px solid var(--accent);
}
.tl-item:last-child { border-left-color: transparent; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 4px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--bg-main);
}
.tl-year {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.tl-title {
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.tl-desc {
  font-size: 0.9rem;
  color: var(--text-soft);
}

/* Knowledge & Sources */
.knowledge-content, .sources-content {
  padding: 1.2rem;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}
.k-card, .s-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.k-card h3, .s-card h3 {
  color: var(--accent);
  margin-bottom: 0.6rem;
  font-size: 1.05rem;
}
.k-card .ar {
  font-family: var(--font-ar);
  font-size: 1.25rem;
  direction: rtl;
  text-align: right;
  margin: 0.7rem 0;
  line-height: 1.85;
}
.play-hadith {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  color: var(--accent);
  background: none;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

/* Final Adhan */
#final-adhan {
  justify-content: center;
  align-items: center;
  background: linear-gradient(160deg, #0f2a24, #1a4a3c);
  color: #f5f0e6;
  text-align: center;
  padding: 2rem;
}
.adhan-content h2 {
  font-family: var(--font-ar);
  font-size: 3rem;
  margin-bottom: 0.8rem;
}
.adhan-note {
  margin: 1.5rem 0;
  font-size: 0.85rem;
  opacity: 0.75;
}
.btn-back-final {
  margin-top: 1rem;
  color: #f5f0e6;
  border-color: rgba(255,255,255,0.4);
}

/* Responsive */
@media (min-width: 600px) {
  .menu-main, .story-container, .choices, .timeline-list,
  .knowledge-content, .sources-content {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
  .ar-title { font-size: 3.2rem; }
}

/* Utility */
.fade-out {
  animation: fadeOut 0.4s forwards;
}
@keyframes fadeOut {
  to { opacity: 0; }
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 0.9rem 1.3rem;
  box-shadow: var(--shadow);
  z-index: 999;
  opacity: 0;
  transition: all 0.35s ease;
  text-align: center;
  max-width: 90%;
  font-size: 0.95rem;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast span { font-size: 1.4rem; margin-left: 0.3rem; }

.feedback {
  margin-top: 0.5rem;
  color: var(--accent);
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease;
}

.k-card.locked {
  opacity: 0.55;
  filter: grayscale(0.4);
}

.choice-btn.correct {
  border-color: var(--accent-light);
  background: rgba(42, 157, 143, 0.15);
}
