/* ===== Mizan Adventure - Islamic Measure Game ===== */
:root {
  --bg: #0a1f18;
  --bg-card: #122c22;
  --text: #e8f5e9;
  --text-muted: #a5d6a7;
  --primary: #2e7d32;
  --primary-light: #4caf50;
  --accent: #c9a227;
  --danger: #c62828;
  --border: #1b5e20;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Themes */
body.theme-light {
  --bg: #f1f8e9;
  --bg-card: #ffffff;
  --text: #1b5e20;
  --text-muted: #558b2f;
  --border: #c8e6c9;
}
body.theme-sepia {
  --bg: #f5e8c7;
  --bg-card: #faf3e0;
  --text: #3e2723;
  --text-muted: #5d4037;
  --primary: #6d4c41;
  --accent: #bf360c;
  --border: #d7ccc8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Loading */
#loading-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.loader { text-align: center; }
.balance-icon { font-size: 4rem; animation: swing 1.5s ease-in-out infinite; }
@keyframes swing {
  0%,100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
.progress-bar {
  width: 200px; height: 6px; background: var(--border);
  border-radius: 3px; margin: 1rem auto; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%; background: var(--primary-light);
  animation: load 1.8s ease-out forwards;
}
@keyframes load { to { width: 100%; } }

.hidden { display: none !important; }

/* Top Bar */
#top-bar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.logo { font-weight: 700; font-size: 1.2rem; color: var(--accent); }
.stats { display: flex; gap: 0.8rem; font-size: 0.9rem; }
#btn-menu {
  background: none; border: none; color: var(--text);
  font-size: 1.4rem; cursor: pointer; padding: 0.3rem;
}

/* Screens */
.screen {
  display: none;
  padding: 1rem;
  max-width: 640px;
  margin: 0 auto;
  min-height: calc(100vh - 110px);
  padding-bottom: 80px;
}
.screen.active { display: block; animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Home */
.hero {
  text-align: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, #0d3b2e 0%, #1a5c40 50%, #0f4c3a 100%);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero h1 { font-size: 1.8rem; color: #fff; margin-bottom: 0.3rem; position: relative; }
.subtitle { color: var(--accent); font-size: 1.1rem; position: relative; }
.desc { color: #c8e6c9; margin-top: 0.8rem; font-size: 0.95rem; position: relative; }

.home-buttons {
  display: flex; flex-direction: column; gap: 0.7rem;
}
.btn {
  display: block; width: 100%;
  padding: 0.9rem 1.2rem;
  border: none; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  text-align: center;
}
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; box-shadow: 0 4px 12px rgba(46,125,50,0.4);
}
.btn.primary:active { transform: scale(0.98); }
.btn.secondary {
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border);
}
.btn.outline {
  background: transparent; color: var(--text-muted);
  border: 1px dashed var(--border);
}
.btn.danger { background: var(--danger); color: #fff; margin-top: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.install-hint {
  margin-top: 1.5rem; text-align: center;
  font-size: 0.85rem; color: var(--text-muted);
  padding: 0.8rem; background: var(--bg-card);
  border-radius: var(--radius); border: 1px solid var(--border);
}

/* Adventure */
#story-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
#scene-bg {
  height: 140px;
  background: linear-gradient(to bottom, #1a3a2a, #0d2818);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
  position: relative;
}
#scene-bg::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 40px;
  background: linear-gradient(transparent, var(--bg-card));
}
#story-text {
  padding: 1.2rem;
  font-size: 1.05rem;
  min-height: 120px;
}
#choices {
  padding: 0 1.2rem 1.2rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.choice-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.85rem 1rem;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.95rem;
}
.choice-btn:hover, .choice-btn:active {
  border-color: var(--primary-light);
  background: rgba(46,125,50,0.15);
}

/* Mini Game - Weighing */
#mini-game-area {
  margin-top: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.2rem;
  border: 1px solid var(--border);
}
.scale-container {
  display: flex; justify-content: space-around; align-items: flex-end;
  height: 160px; margin: 1rem 0;
  position: relative;
}
.scale-pan {
  width: 90px; height: 20px;
  background: #8d6e63;
  border-radius: 4px;
  position: relative;
  transition: transform 0.4s;
}
.scale-pan .weight {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  font-size: 1.5rem;
}
.scale-beam {
  position: absolute; top: 30px; left: 10%; right: 10%;
  height: 8px; background: #5d4037;
  border-radius: 4px;
  transform-origin: center;
  transition: transform 0.4s;
}
.scale-stand {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 12px; height: 80px; background: #5d4037;
}

/* Cards */
.card-list { display: flex; flex-direction: column; gap: 0.8rem; margin-bottom: 1rem; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.card:hover { border-color: var(--primary-light); }
.card h3 { color: var(--accent); margin-bottom: 0.3rem; font-size: 1.05rem; }
.card p { font-size: 0.9rem; color: var(--text-muted); }

/* Quran / Hadith Box */
.ayah-box, .hadith-box {
  background: rgba(46,125,50,0.1);
  border-right: 4px solid var(--accent);
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 0 8px 8px 0;
  direction: rtl;
}
.ayah-ar {
  font-size: 1.3rem;
  line-height: 2;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-family: 'Amiri', 'Scheherazade New', serif;
}
.ayah-th, .hadith-th {
  direction: ltr;
  font-size: 0.95rem;
  color: var(--text);
}
.ref {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}
.audio-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

/* Settings */
.settings-group {
  margin-bottom: 1.2rem;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.settings-group label {
  display: block; margin-bottom: 0.5rem; font-weight: 600;
}
.settings-group select, .settings-group input[type="checkbox"] {
  font-size: 1rem;
  padding: 0.4rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Bottom Nav */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 0.4rem 0;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}
#bottom-nav button {
  background: none; border: none;
  font-size: 1.5rem; padding: 0.4rem 0.8rem;
  color: var(--text-muted); cursor: pointer;
}
#bottom-nav button:active { color: var(--primary-light); }

/* Font sizes */
body.font-large { font-size: 1.1rem; }
body.font-xlarge { font-size: 1.2rem; }

/* Quiz */
.quiz-question {
  background: var(--bg-card);
  padding: 1.2rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.quiz-options { display: flex; flex-direction: column; gap: 0.5rem; }
.quiz-option {
  padding: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.quiz-option.correct { border-color: #4caf50; background: rgba(76,175,80,0.2); }
.quiz-option.wrong { border-color: #c62828; background: rgba(198,40,40,0.2); }

/* Responsive */
@media (min-width: 600px) {
  .home-buttons { max-width: 400px; margin: 0 auto; }
  #bottom-nav { display: none; }
  .screen { padding-bottom: 2rem; }
}

/* Side Menu */
#side-menu {
  position: fixed; inset: 0; z-index: 1000;
  pointer-events: none; opacity: 0;
  transition: opacity 0.25s;
}
#side-menu.open {
  pointer-events: auto; opacity: 1;
}
.side-menu-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
}
.side-menu-panel {
  position: absolute; top: 0; right: 0;
  width: 280px; max-width: 85vw; height: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.4);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex; flex-direction: column;
  padding: 0;
}
#side-menu.open .side-menu-panel {
  transform: translateX(0);
}
.side-menu-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 1.1rem; color: var(--accent);
}
.side-menu-header button {
  background: none; border: none; color: var(--text);
  font-size: 1.3rem; cursor: pointer; padding: 0.2rem 0.5rem;
}
.side-menu-item {
  display: block; width: 100%;
  padding: 0.95rem 1.2rem;
  background: none; border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text); text-align: left;
  font-size: 1rem; cursor: pointer;
  transition: background 0.2s;
}
.side-menu-item:hover, .side-menu-item:active {
  background: rgba(46,125,50,0.15);
}
