/**
 * Quran Quest - Main Styles
 * Core layout, typography, components, and color scheme
 */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* Color Palette */
    --gold: #F59E0B;
    --gold-light: #FCD34D;
    --navy: #0F172A;
    --navy-light: #1E293B;
    --teal: #14B8A6;
    --purple: #8B5CF6;
    --green: #10B981;
    --red: #EF4444;
    --text: #F1F5F9;
    --text-muted: #94A3B8;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
}

/* Body and Layout */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--navy) 0%, #0C1220 100%);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: var(--space-xl) var(--space-md);
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Typography */
h1 {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: var(--space-sm);
}

h2 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-md);
}

h3 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
}

h4 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
}

p {
    line-height: 1.7;
    margin-bottom: var(--space-md);
}

.text-large {
    font-size: 1.25rem;
}

.text-small {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-gold {
    color: var(--gold);
}

/* Arabic Text */
.arabic {
    font-family: 'Amiri', serif;
    font-size: 2rem;
    line-height: 2;
    direction: rtl;
    font-weight: 700;
    overflow-wrap: break-word;
    word-break: break-word;
}

.arabic-large {
    font-size: 2.5rem;
    line-height: 2.2;
}

.arabic-medium {
    font-size: 1.75rem;
    line-height: 1.8;
}

.arabic-small {
    font-size: 1.5rem;
    line-height: 1.6;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: var(--space-md) var(--space-xl);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 56px;
    font-family: inherit;
    text-decoration: none !important;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--purple), #A855F7);
    color: white;
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 12px 25px rgba(139, 92, 246, 0.4);
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--navy);
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.3);
}

.btn-gold:hover {
    box-shadow: 0 12px 25px rgba(245, 158, 11, 0.4);
}

.btn-teal {
    background: linear-gradient(135deg, var(--teal), #0D9488);
    color: white;
    box-shadow: 0 8px 20px rgba(20, 184, 166, 0.3);
}

.btn-teal:hover {
    box-shadow: 0 12px 25px rgba(20, 184, 166, 0.4);
}

.btn-green {
    background: linear-gradient(135deg, var(--green), #059669);
    color: white;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.btn-red {
    background: linear-gradient(135deg, var(--red), #DC2626);
    color: white;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--gold);
    color: var(--gold);
}

.btn-outline:hover {
    background: var(--gold);
    color: var(--navy);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
}

.btn-small {
    padding: 0.5rem 1rem;
    min-height: 40px;
    font-size: 0.875rem;
}

.btn-large {
    padding: 1.25rem 2.5rem;
    min-height: 64px;
    font-size: 1.125rem;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    min-height: auto;
}

/* Cards */
.card {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    transition: all 0.3s ease;
}

.card:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(245, 158, 11, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), 0 0 24px rgba(245, 158, 11, 0.12);
}

.card.clickable:hover {
    box-shadow: var(--shadow-xl), 0 0 28px rgba(245, 158, 11, 0.2);
}

.card.clickable {
    cursor: pointer;
}

/* Cards are sometimes real <a> links now (land/story navigation) rather
   than JS-driven divs - keep them looking and laying out identically. */
a.card {
    display: block;
    text-decoration: none;
    color: inherit;
}

.card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.card-compact {
    padding: var(--space-md);
}

.card-large {
    padding: var(--space-2xl);
}

.card-highlight {
    border-color: var(--gold);
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.25);
    animation: glow 3s ease-in-out infinite;
}

/* Grids */
.grid {
    display: grid;
    gap: var(--space-lg);
}

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

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid-tight {
    gap: var(--space-md);
}

.grid-loose {
    gap: var(--space-2xl);
}

/* Flex Utilities */
.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.items-end {
    align-items: flex-end;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-start {
    justify-content: flex-start;
}

.justify-end {
    justify-content: flex-end;
}

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* Progress Components */
.progress-bar {
    position: relative;
    width: 100%;
    height: 56px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 2px solid rgba(245, 158, 11, 0.2);
    margin: var(--space-xl) 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
    width: 0%;
    transition: width 0.8s ease;
}

/* Centered over the whole track (not tied to the fill's own width) so the
   label never gets squeezed into an unreadable sliver at low percentages -
   it used to render *inside* the narrow fill div itself. */
.progress-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    font-size: 1.125rem;
    pointer-events: none;
}

.progress-ring {
    width: 80px;
    height: 80px;
}

/* Icons */
.icon-large {
    font-size: 5rem;
    display: block;
    margin-bottom: var(--space-md);
}

.icon-medium {
    font-size: 3rem;
}

.icon-small {
    font-size: 1.5rem;
}

.icon-xs {
    font-size: 1rem;
}

/* Audio Components */
.audio-player {
    text-align: center;
    margin: var(--space-xl) 0;
}

.play-button {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--teal), #0D9488);
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(20, 184, 166, 0.4);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(20, 184, 166, 0.5);
}

.play-button.playing {
    animation: tealGlow 1.6s ease-in-out infinite;
}

@keyframes tealGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(20, 184, 166, 0.5); }
    50% { box-shadow: 0 0 28px rgba(20, 184, 166, 0.8), 0 0 40px rgba(20, 184, 166, 0.4); }
}

.play-button:active {
    transform: translateY(0) scale(0.95);
}

.play-button.playing {
    background: linear-gradient(135deg, var(--red), #DC2626);
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4);
}

/* Loading States */
.loading {
    text-align: center;
    padding: 4rem 2rem;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(245, 158, 11, 0.2);
    border-top: 4px solid var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-md);
}

.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: var(--space-md);
}

/* Stats and Metrics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin: var(--space-xl) 0;
}

.stat-card {
    text-align: center;
}

.stat-value {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--gold);
    display: block;
    line-height: 1;
}

.stat-label {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
}

/* Spacing Utilities */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.ml-0 { margin-left: 0; }
.mr-0 { margin-right: 0; }

.m-sm { margin: var(--space-sm); }
.mt-sm { margin-top: var(--space-sm); }
.mb-sm { margin-bottom: var(--space-sm); }
.ml-sm { margin-left: var(--space-sm); }
.mr-sm { margin-right: var(--space-sm); }

.m-md { margin: var(--space-md); }
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }
.ml-md { margin-left: var(--space-md); }
.mr-md { margin-right: var(--space-md); }

.m-lg { margin: var(--space-lg); }
.mt-lg { margin-top: var(--space-lg); }
.mb-lg { margin-bottom: var(--space-lg); }
.ml-lg { margin-left: var(--space-lg); }
.mr-lg { margin-right: var(--space-lg); }

.m-xl { margin: var(--space-xl); }
.mt-xl { margin-top: var(--space-xl); }
.mb-xl { margin-bottom: var(--space-xl); }
.ml-xl { margin-left: var(--space-xl); }
.mr-xl { margin-right: var(--space-xl); }

.p-0 { padding: 0; }
.pt-0 { padding-top: 0; }
.pb-0 { padding-bottom: 0; }
.pl-0 { padding-left: 0; }
.pr-0 { padding-right: 0; }

.p-sm { padding: var(--space-sm); }
.pt-sm { padding-top: var(--space-sm); }
.pb-sm { padding-bottom: var(--space-sm); }
.pl-sm { padding-left: var(--space-sm); }
.pr-sm { padding-right: var(--space-sm); }

.p-md { padding: var(--space-md); }
.pt-md { padding-top: var(--space-md); }
.pb-md { padding-bottom: var(--space-md); }
.pl-md { padding-left: var(--space-md); }
.pr-md { padding-right: var(--space-md); }

.p-lg { padding: var(--space-lg); }
.pt-lg { padding-top: var(--space-lg); }
.pb-lg { padding-bottom: var(--space-lg); }
.pl-lg { padding-left: var(--space-lg); }
.pr-lg { padding-right: var(--space-lg); }

.p-xl { padding: var(--space-xl); }
.pt-xl { padding-top: var(--space-xl); }
.pb-xl { padding-bottom: var(--space-xl); }
.pl-xl { padding-left: var(--space-xl); }
.pr-xl { padding-right: var(--space-xl); }

/* Display Utilities */
.hidden { display: none !important; }
.visible { display: block !important; }
.invisible { visibility: hidden; }

/* Position Utilities */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }

.top-0 { top: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }

/* Width and Height */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-hidden { overflow-x: hidden; }
.overflow-y-auto { overflow-y: auto; }

/* Z-index */
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

/* Border Radius */
.rounded { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: 9999px; }

/* Opacity */
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* Transform */
.scale-95 { transform: scale(0.95); }
.scale-100 { transform: scale(1); }
.scale-105 { transform: scale(1.05); }

/* Transition */
.transition { transition: all 0.2s ease; }
.transition-fast { transition: all 0.15s ease; }
.transition-slow { transition: all 0.3s ease; }

/* Selection */
::selection {
    background: var(--gold);
    color: var(--navy);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--navy-light);
}

::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-light);
}

/* Focus States */
.btn:focus,
.card.clickable:focus {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .btn, .card {
        box-shadow: none !important;
    }

    .screen {
        padding: 1rem !important;
    }
}

/* ==========================================================================
   Game-Specific Components
   (main menu, daily ayah card, option cards, nav buttons, modal, story reader)
   ========================================================================== */

#mainMenu {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}

.logo {
    font-size: 6rem;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 0 18px rgba(245, 158, 11, 0.45));
}

.title {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: textGlow 3s ease-in-out infinite;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

.land-preview {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.land-preview span {
    font-size: 1.75rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 50%;
    transition: all 0.25s;
}

.land-preview span:hover {
    background: rgba(245, 158, 11, 0.18);
    border-color: var(--gold);
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.4);
    transform: translateY(-2px);
}

/* Daily Ayah */
.daily-ayah {
    position: fixed;
    top: 6rem; /* clears the settings button's row instead of covering it */
    right: 2rem;
    max-width: 400px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.daily-ayah.hidden {
    display: none;
}

.daily-ayah .card {
    background: linear-gradient(135deg, var(--purple), #7C3AED);
    border: none;
    color: white;
    box-shadow: 0 10px 40px rgba(139, 92, 246, 0.35);
}

.daily-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
}

/* Option Cards (quiz/puzzle choices) */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.option-card {
    padding: 1.5rem;
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 1rem;
    line-height: 1.6;
}

.option-card:hover {
    background: rgba(30, 41, 59, 0.9);
    border-color: var(--gold);
}

.option-card.correct {
    background: linear-gradient(135deg, var(--green), #059669);
    border-color: var(--green);
    box-shadow: 0 0 24px rgba(16, 185, 129, 0.4);
}

.option-card.incorrect {
    background: linear-gradient(135deg, var(--red), #DC2626);
    border-color: var(--red);
    animation: shake 0.3s;
    box-shadow: 0 0 24px rgba(239, 68, 68, 0.35);
}

/* Word Bank (Hifz word-order reconstruction - variable-width tiles that
   wrap like text, unlike the fixed-grid option-card component above) */
.word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    direction: rtl;
    margin: 1.5rem 0;
}

.word-tile {
    padding: 0.75rem 1.25rem;
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    cursor: pointer;
    font-family: 'Amiri', serif;
    font-size: 1.5rem;
    transition: all 0.2s;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.word-tile:hover {
    background: rgba(30, 41, 59, 0.9);
    border-color: var(--gold);
}

.word-tile.used {
    visibility: hidden;
}

.word-tile.incorrect {
    background: linear-gradient(135deg, var(--red), #DC2626);
    border-color: var(--red);
    animation: shake 0.3s;
}

/* Fixed Navigation Buttons */
.back-btn, .settings-btn {
    position: fixed;
    top: 2rem;
    z-index: 999;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-block;
    text-decoration: none;
}

.back-btn {
    left: 2rem;
}

.settings-btn {
    right: 2rem;
}

.volume-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Collapsed Daily Ayah toggle - bottom-left is the one fixed-nav corner
   the volume button (bottom-right) and back/settings buttons (top) don't
   already use, so it can never overlap them. */
.ayah-badge {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--navy-light);
    border-radius: 1.5rem;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toggle {
    width: 50px;
    height: 28px;
    background: #374151;
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle.active {
    background: var(--green);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: left 0.3s;
}

.toggle.active::after {
    left: 24px;
}

/* Story Reader */
.story-content {
    font-size: 1.125rem;
    line-height: 2;
}

.story-content p {
    margin-bottom: 1.5rem;
    transition: background 0.3s, box-shadow 0.3s;
    border-radius: 0.5rem;
}

.story-content p.narrating {
    background: rgba(245, 158, 11, 0.1);
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25);
    padding: 0.5rem 0.75rem;
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

/* Verbatim Ayah Quote (always visually distinct from house-written narrative) */
.ayah-quote {
    position: relative;
    background: rgba(245, 158, 11, 0.08);
    border-left: 3px solid var(--gold);
    border-radius: 0.5rem;
    padding: 1.25rem 1.5rem;
    padding-right: 4rem;
    margin-bottom: 1.25rem;
}

.ayah-play-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(20, 184, 166, 0.15);
    border: 1px solid var(--teal);
    color: var(--teal);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ayah-play-btn:hover {
    background: rgba(20, 184, 166, 0.3);
}

.ayah-play-btn.playing {
    background: var(--teal);
    color: white;
    animation: tealGlow 1.6s ease-in-out infinite;
}

.ayah-quote .arabic {
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
}

.ayah-translit {
    font-style: italic;
    color: var(--gold-light, #FBBF24);
    line-height: 1.6;
    margin-bottom: 0.6rem;
    font-size: 1rem;
    overflow-wrap: break-word;
}

.ayah-quote .ayah-translation {
    color: var(--text-muted);
    line-height: 1.7;
}

.ayah-quote .ayah-ref {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--gold);
    font-weight: 600;
}
/* Growth: player card, level bar, daily quests, toast */
.player-card {
    max-width: 520px;
    margin: 1.5rem auto;
    text-align: left;
}
.player-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.player-level {
    width: 56px; height: 56px; flex-shrink: 0; border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--gold-light, #FBBF24));
    color: var(--navy); display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.45);
}
.player-level-num { font-weight: 800; font-size: 1.5rem; }
.player-meta { flex: 1; min-width: 0; }
.player-title { font-weight: 800; font-size: 1.15rem; color: var(--gold); }
.player-lp { font-size: 0.85rem; color: var(--text-muted); }
.player-streak { font-size: 1.25rem; white-space: nowrap; }
.xp-bar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-bottom: 1.25rem; }
.xp-fill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); border-radius: 999px; transition: width 0.8s ease; }
.daily-goals-head { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; font-weight: 700; font-size: 0.9rem; margin-bottom: 0.5rem; }
.daily-goals-head span:last-child { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; }
.daily-goals { list-style: none; margin: 0; padding: 0; }
.daily-goal { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.daily-goal-text { flex: 1; font-size: 0.95rem; }
.daily-goal-lp { color: var(--gold); font-weight: 700; font-size: 0.85rem; }
.daily-goal.done .daily-goal-text { text-decoration: line-through; opacity: 0.6; }
.reward-growth { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }
.reward-lp { font-size: 1.5rem; font-weight: 800; color: var(--gold); }
.reward-levelup { font-size: 1.25rem; font-weight: 800; color: var(--teal); animation: glow 2s ease-in-out infinite; }
.reward-goal { color: var(--text-muted); }
.toast {
    position: fixed; top: 1rem; left: 50%; transform: translateX(-50%);
    z-index: 3000; max-width: calc(100vw - 2rem);
    background: rgba(15, 23, 42, 0.95); color: var(--text);
    border: 1px solid var(--gold); border-radius: 999px;
    padding: 0.75rem 1.5rem; font-weight: 700; text-align: center;
    box-shadow: 0 0 24px rgba(245, 158, 11, 0.4);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.toast-out { opacity: 0; transform: translate(-50%, -12px); }

/* ===== Atmosphere: per-land themes, ambient sky, richer cards ===== */
body {
    --accent: var(--gold);
    background:
        radial-gradient(1200px 600px at 15% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
        radial-gradient(900px 500px at 100% 110%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
        linear-gradient(135deg, var(--navy) 0%, #0C1220 100%);
    background-attachment: fixed;
}
body[data-land="garden"]   { --accent: #14B8A6; }
body[data-land="village"]  { --accent: #F59E0B; }
body[data-land="desert"]   { --accent: #F97316; }
body[data-land="mountain"] { --accent: #818CF8; }
body[data-land="ocean"]    { --accent: #38BDF8; }
body[data-land="city"]     { --accent: #C084FC; }
body[data-land="stories"]  { --accent: #F472B6; }
body[data-land="home"]     { --accent: #A855F7; }

/* Twinkling stars + faint geometric lattice behind everything */
body::before {
    content: "";
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background-image:
        radial-gradient(1.5px 1.5px at 20px 30px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 90px 120px, rgba(252,211,77,0.8), transparent),
        radial-gradient(1.5px 1.5px at 160px 60px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 230px 170px, rgba(255,255,255,0.6), transparent);
    background-size: 260px 200px;
    animation: twinkle 6s ease-in-out infinite alternate;
    opacity: 0.55;
}
body::after {
    content: "";
    position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath d='M40 4l9 22 22 9-22 9-9 22-9-22-22-9 22-9z' fill='none' stroke='%23F59E0B' stroke-width='1.2'/%3E%3C/svg%3E");
    background-size: 80px 80px;
}
@keyframes twinkle { from { opacity: 0.25; } to { opacity: 0.7; } }
.screen, #gameContainer { position: relative; z-index: 1; }

h2 {
    color: color-mix(in srgb, var(--accent) 25%, #fff);
    text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* Land / story cards */
.land-card {
    position: relative; overflow: hidden;
    background:
        radial-gradient(400px 220px at 0% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
        rgba(30, 41, 59, 0.85);
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.land-card::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
    background: linear-gradient(90deg, var(--accent), transparent);
}
.land-card:hover { border-color: var(--accent); box-shadow: var(--shadow-xl), 0 0 32px color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-4px); }
.land-card .land-icon { animation: floatSlow 5s ease-in-out infinite; filter: drop-shadow(0 6px 14px color-mix(in srgb, var(--accent) 60%, transparent)); }
.land-card .land-name { color: var(--accent); margin-bottom: 0.5rem; }
.land-card .land-desc { color: var(--text-muted); margin-bottom: 0.75rem; }
.land-card.locked { filter: grayscale(0.7); }
.land-card.locked .land-icon { animation: none; }
.land-card.locked .land-name { color: var(--text-muted); }
.land-go { display: inline-block; margin-top: 0.75rem; font-weight: 700; color: var(--accent); opacity: 0.85; transition: transform 0.2s; }
.land-card:hover .land-go { transform: translateX(6px); opacity: 1; }
.pips { display: flex; gap: 0.25rem; }
.pip { filter: grayscale(1) opacity(0.35); font-size: 1.15rem; }
.pip.on { filter: none; text-shadow: 0 0 10px rgba(56, 189, 248, 0.9); animation: pulse 2.4s ease-in-out infinite; }
.story-surah { color: var(--accent); font-size: 0.85rem; font-weight: 600; }
.read-badge { position: absolute; top: 1rem; right: 1rem; padding: 0.2rem 0.7rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; background: rgba(16,185,129,0.2); color: #6EE7B7; border: 1px solid rgba(16,185,129,0.5); }
.read-badge.new { background: color-mix(in srgb, var(--accent) 25%, transparent); color: #fff; border-color: var(--accent); }
.stories-progress { text-align: center; color: var(--accent); font-weight: 700; margin-bottom: 1.5rem; }

/* Quest card (Village etc.): themed dark glass instead of a white slab */
.quest-card {
    background:
        radial-gradient(500px 260px at 50% 0%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%),
        rgba(30, 41, 59, 0.9);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    box-shadow: 0 0 40px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* Particles */
.particle {
    position: fixed; z-index: 4000; pointer-events: none; line-height: 1;
    animation: particleOut 1.2s ease-out forwards;
}
.particle-fall { animation: particleFall 2.4s ease-in forwards; }
@keyframes particleOut {
    0% { transform: translate(-50%, -50%) scale(0.4) rotate(0); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(var(--rot)); opacity: 0; }
}
@keyframes particleFall {
    0% { transform: translate(0, 0) rotate(0); opacity: 1; }
    85% { opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    body::before, .land-card .land-icon, .pip.on { animation: none; }
}

/* Word by word + recite tools */
.ayah-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; }
.tool-btn {
    font-family: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer;
    padding: 0.5rem 0.9rem; border-radius: 999px; min-height: 40px;
    background: rgba(255,255,255,0.06); color: var(--text);
    border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
    transition: all 0.2s;
}
.tool-btn:hover { background: color-mix(in srgb, var(--accent) 25%, transparent); box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 40%, transparent); }
.ayah-panel { margin-top: 0.85rem; padding: 1rem; border-radius: var(--radius-md); background: rgba(0,0,0,0.25); border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent); }
.wbw { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: flex-start; }
.wbw-word {
    display: flex; flex-direction: column; align-items: center; gap: 0.15rem; text-align: center;
    min-width: 72px; padding: 0.6rem 0.7rem; cursor: pointer; font-family: inherit;
    background: rgba(255,255,255,0.05); color: var(--text);
    border: 1px solid rgba(255,255,255,0.14); border-radius: 0.8rem;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.wbw-word:hover { transform: translateY(-2px); border-color: var(--accent); }
.wbw-word.active { border-color: var(--gold); background: rgba(245,158,11,0.18); box-shadow: 0 0 20px rgba(245,158,11,0.5); transform: scale(1.06); }
.wbw-ar { font-family: 'Amiri', serif; font-size: 1.75rem; line-height: 1.5; font-weight: 700; }
.wbw-tr { font-style: italic; color: var(--gold-light); font-size: 0.85rem; }
.wbw-en { color: var(--text-muted); font-size: 0.78rem; max-width: 110px; line-height: 1.25; }
.wbw-bar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 0.85rem; }
.wbw-hint { color: var(--text-muted); font-size: 0.8rem; margin: 0; }
.recite-panel { display: flex; flex-direction: column; gap: 0.75rem; }
.recite-status { font-weight: 600; font-size: 0.95rem; }
.recite-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.recite-btn {
    font-family: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer;
    padding: 0.6rem 1rem; min-height: 44px; border-radius: 0.8rem;
    background: linear-gradient(135deg, var(--teal), #0D9488); color: #fff; border: none;
}
.recite-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.recite-btn.recording { background: linear-gradient(135deg, #EF4444, #DC2626); animation: pulse 1s ease-in-out infinite; }
.recitation-tools { margin-top: 1.5rem; }
.tools-title { text-align: center; color: var(--gold); font-weight: 700; margin-bottom: 0.5rem; }
.recitation-tools .ayah-tools { justify-content: center; }
.daily-ayah .tool-btn { color: #fff; border-color: rgba(255,255,255,0.5); }
.daily-ayah .ayah-panel { max-height: 40vh; overflow-y: auto; }

/* Daily Ayah: always readable, however long the verse is */
.daily-ayah .card { max-height: calc(100vh - 8rem); overflow-y: auto; overscroll-behavior: contain; }
.daily-ayah #dailyArabic { overflow-wrap: anywhere; line-height: 2; }
.daily-ayah #dailyArabic.long { font-size: 1.3rem !important; line-height: 2.05; }
.daily-ayah #dailyArabic.xlong { font-size: 1.1rem !important; line-height: 2.1; }
.daily-ayah #dailyTranslation, .daily-ayah #dailyTranslit { overflow-wrap: anywhere; }
.share-btn {
    display: block; width: 100%; margin-top: 1rem; min-height: 44px; cursor: pointer;
    font-family: inherit; font-weight: 700; font-size: 0.95rem;
    color: var(--navy); background: linear-gradient(135deg, var(--gold), var(--gold-light));
    border: none; border-radius: 0.8rem; padding: 0.7rem 1rem;
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35);
}
.share-btn:disabled { opacity: 0.7; cursor: progress; }

/* Long verses everywhere else: wrap instead of overflowing */
.ayah-quote .arabic, .ayah-quote .ayah-translation, .ayah-translit { overflow-wrap: anywhere; }
#arabicVerse { overflow-wrap: anywhere; }
#arabicVerse.long { font-size: 1.6rem; }
#arabicVerse.xlong { font-size: 1.3rem; }
