/* ============================================
   رحلة أبي تمّام - Arabic Narrative Game
   RTL-first, Islamic geometric aesthetic
   ============================================ */

/* --- Fonts & Reset --- */
@import url('https://fonts.googleapis.com/css2?family=Scheherazade+New:wght@400;700&family=Amiri:ital,wght@0,400;0,700;1,400;1,700&family=Noto+Naskh+Arabic:wght@400;500;600;700&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Color palette - Abbasid-era inspired (brightened) */
    --gold: #d4b255;
    --gold-light: #f0dfa0;
    --gold-dark: #9a7d2b;
    --ink: #222240;
    --ink-light: #3a3a58;
    --parchment: #f4e8c1;
    --parchment-dark: #dcc99a;
    --parchment-darker: #c4a96a;
    --blood: #8b1a1a;
    --sky: #1a3a5c;
    --sky-light: #2a5a8c;
    --turquoise: #1a6b6b;
    --turquoise-light: #2a9b9b;
    --white: #faf6eb;
    --shadow: rgba(0, 0, 0, 0.3);
    --brick: #a0734d;
    --cream: #f5ead0;

    /* Typography */
    --font-body: 'Noto Naskh Arabic', 'Amiri', serif;
    --font-display: 'Amiri', serif;
    --font-title: 'Scheherazade New', 'Amiri', serif;

    /* Spacing */
    --gap: 1rem;
    --gap-sm: 0.5rem;
    --gap-lg: 2rem;
    --radius: 8px;
}

html {
    font-size: 18px;
}

body {
    font-family: var(--font-body);
    background: radial-gradient(ellipse at center, #2e2e4a 0%, var(--ink) 70%);
    color: var(--parchment);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    overflow: hidden;
    line-height: 1.8;
}

/* Parchment grain texture overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.028;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 180px 180px;
}

/* --- Screens --- */
.screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.screen.active {
    display: flex;
}

/* --- Islamic Geometric Border --- */
.geometric-border {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Starfield background */
    background:
        radial-gradient(1.5px 1.5px at  8% 12%, rgba(240,223,160,0.85) 0%, transparent 100%),
        radial-gradient(1px   1px   at 17%  4%, rgba(240,223,160,0.6)  0%, transparent 100%),
        radial-gradient(2px   2px   at 28% 19%, rgba(240,223,160,0.45) 0%, transparent 100%),
        radial-gradient(1px   1px   at 40%  8%, rgba(240,223,160,0.7)  0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 52%  3%, rgba(240,223,160,0.55) 0%, transparent 100%),
        radial-gradient(1px   1px   at 63% 14%, rgba(240,223,160,0.8)  0%, transparent 100%),
        radial-gradient(2px   2px   at 74%  6%, rgba(240,223,160,0.5)  0%, transparent 100%),
        radial-gradient(1px   1px   at 85% 18%, rgba(240,223,160,0.65) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 93%  8%, rgba(240,223,160,0.6)  0%, transparent 100%),
        radial-gradient(1px   1px   at  5% 35%, rgba(240,223,160,0.4)  0%, transparent 100%),
        radial-gradient(1px   1px   at 96% 30%, rgba(240,223,160,0.4)  0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 22% 42%, rgba(240,223,160,0.3)  0%, transparent 100%),
        radial-gradient(1px   1px   at 78% 38%, rgba(240,223,160,0.35) 0%, transparent 100%),
        radial-gradient(1px   1px   at 48% 27%, rgba(240,223,160,0.3)  0%, transparent 100%),
        radial-gradient(1px   1px   at 12% 58%, rgba(240,223,160,0.22) 0%, transparent 100%),
        radial-gradient(1px   1px   at 88% 62%, rgba(240,223,160,0.22) 0%, transparent 100%),
        radial-gradient(1px   1px   at 35% 72%, rgba(240,223,160,0.14) 0%, transparent 100%),
        radial-gradient(1px   1px   at 60% 78%, rgba(240,223,160,0.12) 0%, transparent 100%),
        radial-gradient(1px   1px   at 20% 85%, rgba(240,223,160,0.09) 0%, transparent 100%),
        radial-gradient(1px   1px   at 75% 88%, rgba(240,223,160,0.09) 0%, transparent 100%),
        radial-gradient(circle at 20% 20%, rgba(154, 125, 43, 0.22) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(42, 155, 155, 0.16) 0%, transparent 50%),
        linear-gradient(to top, rgba(14,12,30,0.6) 0%, transparent 45%),
        url('../img/title-bg.png') center bottom / cover,
        radial-gradient(ellipse at center, #2e2e4a 0%, var(--ink) 70%);
}

/* L-shaped manuscript corner brackets */
.geometric-border::before {
    content: '';
    position: absolute;
    inset: 18px;
    pointer-events: none;
    background:
        linear-gradient(var(--gold-light), var(--gold-light)) 0    0    / 65px 2px  no-repeat,
        linear-gradient(var(--gold-light), var(--gold-light)) 0    0    / 2px  65px no-repeat,
        linear-gradient(var(--gold-light), var(--gold-light)) 100% 0    / 65px 2px  no-repeat,
        linear-gradient(var(--gold-light), var(--gold-light)) 100% 0    / 2px  65px no-repeat,
        linear-gradient(var(--gold-light), var(--gold-light)) 0    100% / 65px 2px  no-repeat,
        linear-gradient(var(--gold-light), var(--gold-light)) 0    100% / 2px  65px no-repeat,
        linear-gradient(var(--gold-light), var(--gold-light)) 100% 100% / 65px 2px  no-repeat,
        linear-gradient(var(--gold-light), var(--gold-light)) 100% 100% / 2px  65px no-repeat;
}

/* Subtle full inner frame */
.geometric-border::after {
    content: '';
    position: absolute;
    inset: 26px;
    border: 1px solid rgba(212, 178, 85, 0.18);
    pointer-events: none;
}

@keyframes goldShimmer {
    0%, 100% { text-shadow: 0 2px 20px rgba(212,178,85,0.35), 0 1px 4px rgba(0,0,0,0.6); }
    50%       { text-shadow: 0 2px 35px rgba(240,223,160,0.75), 0 0 55px rgba(212,178,85,0.35), 0 1px 4px rgba(0,0,0,0.6); }
}

/* --- Title Screen --- */
.title-content {
    text-align: center;
    padding: var(--gap-lg);
    position: relative;
}

/* Dark vignette behind title text to ensure legibility over illustration */
.title-content::before {
    content: '';
    position: absolute;
    inset: -60px -80px;
    background: radial-gradient(ellipse at center, rgba(8,6,22,0.72) 0%, transparent 68%);
    pointer-events: none;
    z-index: 0;
}

.title-content > * {
    position: relative;
    z-index: 1;
}

/* ── Passcode Screen ─────────────────────────────────── */
.passcode-bg {
    position: absolute;
    inset: 0;
    background: url('../img/title-bg.png') center/cover no-repeat,
                linear-gradient(160deg, #0a0800 0%, #1a1200 60%, #0d0a04 100%);
    filter: brightness(0.45);
    z-index: 0;
}

.passcode-box {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    background: rgba(10, 8, 2, 0.72);
    border: 1px solid rgba(212,178,85,0.35);
    border-radius: 12px;
    padding: 3rem 3.5rem;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 8px 40px rgba(0,0,0,0.7), inset 0 1px 0 rgba(212,178,85,0.15);
}

.passcode-ornament {
    color: var(--gold);
    font-size: 1.1rem;
    letter-spacing: 0.6em;
    opacity: 0.7;
}

.passcode-title {
    font-family: var(--font-title);
    font-size: 2.2rem;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(212,178,85,0.5);
    margin: 0;
}

.passcode-prompt {
    font-size: 1rem;
    color: var(--parchment-dark);
    margin: 0;
    letter-spacing: 0.05em;
}

.passcode-input {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1.5px solid rgba(212,178,85,0.4);
    border-radius: 6px;
    color: var(--gold);
    font-family: var(--font-body);
    font-size: 1.5rem;
    text-align: center;
    letter-spacing: 0.3em;
    padding: 0.65rem 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.passcode-input:focus {
    border-color: rgba(212,178,85,0.85);
    box-shadow: 0 0 12px rgba(212,178,85,0.2);
}

.passcode-btn {
    width: 100%;
    margin-top: 0.3rem;
}

.passcode-error {
    color: #e07070;
    font-size: 0.9rem;
    margin: 0;
    transition: opacity 0.2s;
}

.passcode-error.hidden {
    visibility: hidden;
}

@keyframes passcode-shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-8px); }
    40%       { transform: translateX(8px); }
    60%       { transform: translateX(-5px); }
    80%       { transform: translateX(5px); }
}

.passcode-shake {
    animation: passcode-shake 0.45s ease;
}

/* --- Speaker row: name + optional simplify toggle on one line --- */
#speaker-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* Simplify Toggle — lives inside the speaker row */
#simplify-toggle-area {
    flex-shrink: 0;
}

.simplify-toggle {
    background: transparent;
    border: 1px solid var(--gold-dark);
    color: var(--gold-dark);
    font-family: var(--font-body);
    font-size: 0.7rem;
    padding: 0.15rem 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.simplify-toggle:hover {
    opacity: 1;
    background: rgba(212, 178, 85, 0.12);
    color: var(--gold-light);
    border-color: var(--gold);
}

/* ─────────────────────────────────────────────────── */
.title-main {
    font-family: var(--font-title);
    font-size: 4.5rem;
    color: var(--gold-light);
    margin-bottom: 0.2rem;
    letter-spacing: 0.08em;
    animation: goldShimmer 5s ease-in-out infinite;
    text-shadow: 0 2px 20px rgba(212,178,85,0.35), 0 1px 6px rgba(0,0,0,0.9), 0 0 50px rgba(0,0,0,0.6);
}

.title-sub {
    font-family: var(--font-display);
    font-size: 1.9rem;
    color: var(--parchment);
    margin-bottom: 0.3rem;
    font-style: italic;
    text-shadow: 0 1px 8px rgba(0,0,0,0.95), 0 0 20px rgba(0,0,0,0.7);
}

.title-ornament {
    color: var(--gold);
    font-size: 1.3rem;
    letter-spacing: 0.5em;
    opacity: 0.9;
    margin: 0.4rem 0 0.8rem;
}

.title-desc {
    font-size: 1.2rem;
    color: var(--parchment);
    margin-bottom: 0.6rem;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
    text-shadow: 0 1px 8px rgba(0,0,0,0.95), 0 0 16px rgba(0,0,0,0.7);
}

.title-credit {
    font-size: 1.05rem;
    color: rgba(212,178,85,0.95);
    margin-bottom: var(--gap-lg);
    letter-spacing: 0.04em;
    text-shadow: 0 1px 6px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.7);
}

.title-version {
    font-size: 0.8em;
    opacity: 0.7;
    letter-spacing: 0.08em;
}

.credit-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid rgba(212,178,85,0.35);
    transition: color 0.2s, border-color 0.2s;
}

.credit-link:hover {
    color: rgba(212,178,85,0.95);
    border-color: rgba(212,178,85,0.8);
}

.title-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    align-items: center;
}

.audio-toggle {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
}

/* --- Buttons --- */
.btn {
    font-family: var(--font-body);
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: var(--radius);
    padding: 0.7rem 2rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-dark));
    color: var(--ink);
    font-weight: 700;
    font-size: 1.2rem;
    min-width: 200px;
    box-shadow: 0 4px 20px rgba(212, 178, 85, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
    clip-path: polygon(1.2rem 0%, calc(100% - 1.2rem) 0%, 100% 50%, calc(100% - 1.2rem) 100%, 1.2rem 100%, 0% 50%);
    padding: 0.8rem 3rem;
    border-radius: 0;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201, 168, 76, 0.5);
}

.btn-secondary {
    background: transparent;
    color: var(--parchment-dark);
    border: 1px solid rgba(154,125,43,0.45);
    min-width: 200px;
    clip-path: polygon(1.2rem 0%, calc(100% - 1.2rem) 0%, 100% 50%, calc(100% - 1.2rem) 100%, 1.2rem 100%, 0% 50%);
    padding: 0.8rem 3rem;
    border-radius: 0;
}

.btn-secondary:hover {
    border-color: var(--gold);
    color: var(--gold-light);
    background: rgba(154,125,43,0.08);
}

.btn-icon {
    background: transparent;
    color: var(--parchment);
    font-size: 1.3rem;
    padding: 0.4rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--ink-light);
}

.btn-sm {
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
}

.btn-full {
    width: 100%;
    background: linear-gradient(to left, rgba(42,36,65,0.9), rgba(34,28,55,0.95));
    color: var(--parchment-dark);
    padding: 0.75rem;
    margin-bottom: 0.4rem;
    border: none;
    border-right: 2px solid var(--gold-dark);
    font-family: var(--font-display);
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    text-align: right;
    transition: all 0.2s ease;
}

.btn-full:hover {
    border-right-color: var(--gold);
    color: var(--gold-light);
    background: linear-gradient(to left, rgba(60,50,90,0.95), rgba(42,36,65,0.98));
    padding-right: 1.2rem;
}

.btn-continue {
    background: transparent;
    color: var(--gold-light);
    border: 1px solid var(--gold-dark);
    padding: 0.65rem 2.8rem;
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    text-shadow: 0 0 12px rgba(212,178,85,0.4);
    animation: pulseContinue 2.5s ease-in-out infinite;
    position: relative;
}

/* Small leading ornament */
.btn-continue::before {
    content: '◂';
    margin-left: 0.4rem;
    font-size: 0.75em;
    opacity: 0.7;
}

/* Continue button appended inside poem display */
.poem-done-btn {
    display: block;
    margin: 1.2rem auto 0;
    animation: pulseContinue 2.5s ease-in-out infinite;
}

.btn-continue:hover {
    background: rgba(154,125,43,0.15);
    border-color: var(--gold);
    color: var(--gold-light);
}

@keyframes pulseContinue {
    0%, 100% { border-color: var(--gold-dark); box-shadow: 0 0 0 rgba(212,178,85,0); }
    50% { border-color: var(--gold); box-shadow: 0 0 18px rgba(212,178,85,0.18); }
}

/* --- Top Bar --- */
#top-bar {
    display: flex;
    align-items: center;
    gap: var(--gap);
    padding: 0.6rem var(--gap);
    background: linear-gradient(to bottom, rgba(20,18,40,0.98) 0%, rgba(30,26,52,0.85) 100%);
    border-bottom: 2px solid;
    border-image: linear-gradient(to left, transparent, var(--gold-dark), var(--gold), var(--gold-dark), transparent) 1;
    z-index: 10;
    position: relative;
}

/* Thin gold inner line under top bar */
#top-bar::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(212,178,85,0.3), transparent);
}

.stat {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
}

.stat-label {
    font-family: var(--font-display);
    font-size: 0.7rem;
    color: var(--parchment-darker);
    letter-spacing: 0.04em;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--gold-light);
    font-weight: 700;
    text-shadow: 0 0 8px rgba(212,178,85,0.4);
}

.stat-bar {
    width: 90px;
    height: 6px;
    background: rgba(20,18,40,0.8);
    border: 1px solid rgba(154,125,43,0.4);
    border-radius: 0;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: linear-gradient(to left, var(--gold-light), var(--gold), var(--gold-dark));
    transition: width 0.5s ease;
    width: 30%;
    box-shadow: 0 0 6px rgba(212,178,85,0.5);
}

.episode-label {
    flex: 1;
    text-align: center;
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--parchment-dark);
    font-style: italic;
    letter-spacing: 0.03em;
}

.top-bar-controls {
    display: flex;
    gap: var(--gap-sm);
    margin-right: auto;
}

/* --- Scene Area --- */
#scene-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--gap);
    overflow-y: auto;
    position: relative;
}

/* --- City Backgrounds --- */
#scene-area::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.35;
    pointer-events: none;
    transition: background-image 1.5s ease;
    filter: brightness(1.2);
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
}

/* Photo-based scenes get higher opacity */
#scene-area.bg-damascus::before,
#scene-area.bg-baghdad::before,
#scene-area.bg-armenia::before {
    opacity: 0.55;
    filter: brightness(1.05) saturate(0.85);
}

/* SVG-based scenes need brighter rendering */
#scene-area.bg-samarra::before,
#scene-area.bg-khurasan::before,
#scene-area.bg-mosul::before {
    opacity: 0.75;
    filter: brightness(1.15);
    background-size: cover;
}

/* Damascus — Umayyad Mosque atmosphere */
#scene-area.bg-damascus::before {
    background-image: url('../img/scene-damascus.png');
    background-position: center top;
}

/* Samarra — Malwiya spiral minaret, Great Mosque crenellated wall */
#scene-area.bg-samarra::before {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20800%20400%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22sky2%22%20x1%3D%220%22%20y1%3D%220%22%20x2%3D%220%22%20y2%3D%221%22%3E%3Cstop%20offset%3D%220%22%20stop-color%3D%22%230a0815%22%2F%3E%3Cstop%20offset%3D%220.45%22%20stop-color%3D%22%232a1f08%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%235a3a15%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20fill%3D%22url%28%23sky2%29%22%20width%3D%22800%22%20height%3D%22400%22%2F%3E%3Cpath%20d%3D%22M0%20310%20Q200%20295%20400%20305%20Q600%20315%20800%20300%20L800%20400%20L0%20400Z%22%20fill%3D%22%234a2e10%22%20opacity%3D%220.9%22%2F%3E%3Cpath%20d%3D%22M0%20330%20Q200%20318%20400%20325%20Q600%20332%20800%20322%20L800%20400%20L0%20400Z%22%20fill%3D%22%233a2208%22%20opacity%3D%220.8%22%2F%3E%3Crect%20x%3D%2280%22%20y%3D%22228%22%20width%3D%22640%22%20height%3D%22120%22%20fill%3D%22%23c49a50%22%20opacity%3D%220.35%22%2F%3E%3Cg%20fill%3D%22%23c49a50%22%20opacity%3D%220.45%22%3E%3Crect%20x%3D%2288%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22112%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22136%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22160%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22184%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22208%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22232%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22580%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22604%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22628%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22652%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22676%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3Crect%20x%3D%22700%22%20y%3D%22218%22%20width%3D%2214%22%20height%3D%2214%22%2F%3E%3C%2Fg%3E%3Cpath%20d%3D%22M130%20228%20Q165%20205%20200%20228%22%20fill%3D%22none%22%20stroke%3D%22%23d4b255%22%20stroke-width%3D%222%22%20opacity%3D%220.4%22%2F%3E%3Cpath%20d%3D%22M200%20228%20Q235%20205%20270%20228%22%20fill%3D%22none%22%20stroke%3D%22%23d4b255%22%20stroke-width%3D%222%22%20opacity%3D%220.4%22%2F%3E%3Cpath%20d%3D%22M530%20228%20Q565%20205%20600%20228%22%20fill%3D%22none%22%20stroke%3D%22%23d4b255%22%20stroke-width%3D%222%22%20opacity%3D%220.4%22%2F%3E%3Cpath%20d%3D%22M600%20228%20Q635%20205%20670%20228%22%20fill%3D%22none%22%20stroke%3D%22%23d4b255%22%20stroke-width%3D%222%22%20opacity%3D%220.4%22%2F%3E%3Crect%20x%3D%22340%22%20y%3D%22208%22%20width%3D%22120%22%20height%3D%2232%22%20fill%3D%22%23d4b255%22%20opacity%3D%220.6%22%2F%3E%3Crect%20x%3D%22354%22%20y%3D%22180%22%20width%3D%2292%22%20height%3D%2230%22%20fill%3D%22%23d4b255%22%20opacity%3D%220.62%22%2F%3E%3Crect%20x%3D%22367%22%20y%3D%22154%22%20width%3D%2266%22%20height%3D%2228%22%20fill%3D%22%23d4b255%22%20opacity%3D%220.64%22%2F%3E%3Crect%20x%3D%22378%22%20y%3D%22130%22%20width%3D%2244%22%20height%3D%2226%22%20fill%3D%22%23d4b255%22%20opacity%3D%220.66%22%2F%3E%3Crect%20x%3D%22387%22%20y%3D%22109%22%20width%3D%2226%22%20height%3D%2223%22%20fill%3D%22%23d4b255%22%20opacity%3D%220.68%22%2F%3E%3Crect%20x%3D%22394%22%20y%3D%2292%22%20width%3D%2212%22%20height%3D%2219%22%20fill%3D%22%23f0dfa0%22%20opacity%3D%220.6%22%2F%3E%3Cellipse%20cx%3D%22400%22%20cy%3D%2290%22%20rx%3D%229%22%20ry%3D%225%22%20fill%3D%22%23f0dfa0%22%20opacity%3D%220.5%22%2F%3E%3Ccircle%20cx%3D%22400%22%20cy%3D%2283%22%20r%3D%225%22%20fill%3D%22none%22%20stroke%3D%22%23f0dfa0%22%20stroke-width%3D%222%22%20opacity%3D%220.65%22%2F%3E%3Cpath%20d%3D%22M340%20236%20Q372%20208%20400%20182%20Q428%20156%20446%20130%22%20fill%3D%22none%22%20stroke%3D%22%23a07830%22%20stroke-width%3D%222.5%22%20opacity%3D%220.35%22%2F%3E%3Cg%20fill%3D%22%238a6820%22%20opacity%3D%220.25%22%3E%3Crect%20x%3D%22300%22%20y%3D%22200%22%20width%3D%2235%22%20height%3D%2228%22%2F%3E%3Crect%20x%3D%22465%22%20y%3D%22200%22%20width%3D%2235%22%20height%3D%2228%22%2F%3E%3Crect%20x%3D%22260%22%20y%3D%22212%22%20width%3D%2240%22%20height%3D%2216%22%2F%3E%3Crect%20x%3D%22500%22%20y%3D%22212%22%20width%3D%2240%22%20height%3D%2216%22%2F%3E%3C%2Fg%3E%3Cg%20fill%3D%22%23f0dfa0%22%20opacity%3D%220.3%22%3E%3Ccircle%20cx%3D%2270%22%20cy%3D%2255%22%20r%3D%221.5%22%2F%3E%3Ccircle%20cx%3D%22155%22%20cy%3D%2238%22%20r%3D%221%22%2F%3E%3Ccircle%20cx%3D%22240%22%20cy%3D%2270%22%20r%3D%221.5%22%2F%3E%3Ccircle%20cx%3D%22620%22%20cy%3D%2245%22%20r%3D%221%22%2F%3E%3Ccircle%20cx%3D%22715%22%20cy%3D%2268%22%20r%3D%221.5%22%2F%3E%3Ccircle%20cx%3D%22505%22%20cy%3D%2282%22%20r%3D%221%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
}

/* Baghdad — Round City atmosphere */
#scene-area.bg-baghdad::before {
    background-image: url('../img/scene-baghdad.png');
    background-position: center top;
}

/* Armenia — Mountain fortress with snow-capped peaks */
#scene-area.bg-armenia::before {
    background-image: url('../img/scene-armenia.png');
    background-position: center center;
}

/* Khurasan — Eastern frontier: snow mountains, iwan gateway, crescent moon */
#scene-area.bg-khurasan::before {
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20800%20400%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22sky5%22%20x1%3D%220%22%20y1%3D%220%22%20x2%3D%220%22%20y2%3D%221%22%3E%3Cstop%20offset%3D%220%22%20stop-color%3D%22%23060618%22%2F%3E%3Cstop%20offset%3D%220.55%22%20stop-color%3D%22%23101830%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%231e2838%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20fill%3D%22url%28%23sky5%29%22%20width%3D%22800%22%20height%3D%22400%22%2F%3E%3Cpath%20d%3D%22M0%20290%20Q80%20240%20160%20260%20Q240%20200%20320%20235%20Q400%20185%20480%20215%20Q560%20170%20640%20200%20Q720%20155%20800%20185%20L800%20400%20L0%20400Z%22%20fill%3D%22%233a4858%22%20opacity%3D%220.5%22%2F%3E%3Cpath%20d%3D%22M80%20258%20Q110%20238%20130%20256%22%20fill%3D%22none%22%20stroke%3D%22%23c8d8e8%22%20stroke-width%3D%228%22%20stroke-linecap%3D%22round%22%20opacity%3D%220.55%22%2F%3E%3Cpath%20d%3D%22M305%20228%20Q330%20205%20355%20232%22%20fill%3D%22none%22%20stroke%3D%22%23c8d8e8%22%20stroke-width%3D%229%22%20stroke-linecap%3D%22round%22%20opacity%3D%220.6%22%2F%3E%3Cpath%20d%3D%22M550%20193%20Q578%20168%20606%20200%22%20fill%3D%22none%22%20stroke%3D%22%23c8d8e8%22%20stroke-width%3D%228%22%20stroke-linecap%3D%22round%22%20opacity%3D%220.55%22%2F%3E%3Cpath%20d%3D%22M740%20178%20Q760%20162%20780%20180%22%20fill%3D%22none%22%20stroke%3D%22%23c8d8e8%22%20stroke-width%3D%226%22%20stroke-linecap%3D%22round%22%20opacity%3D%220.4%22%2F%3E%3Cpath%20d%3D%22M0%20340%20Q150%20318%20300%20330%20Q450%20315%20600%20328%20Q700%20315%20800%20325%20L800%20400%20L0%20400Z%22%20fill%3D%22%231e2835%22%20opacity%3D%220.85%22%2F%3E%3Crect%20x%3D%220%22%20y%3D%22360%22%20width%3D%22800%22%20height%3D%2240%22%20fill%3D%22%2312181f%22%20opacity%3D%220.9%22%2F%3E%3Cg%20fill%3D%22white%22%20opacity%3D%220.1%22%3E%3Ccircle%20cx%3D%2290%22%20cy%3D%22365%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%22215%22%20cy%3D%22362%22%20r%3D%221.5%22%2F%3E%3Ccircle%20cx%3D%22370%22%20cy%3D%22368%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%22530%22%20cy%3D%22364%22%20r%3D%221.5%22%2F%3E%3Ccircle%20cx%3D%22680%22%20cy%3D%22366%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%22770%22%20cy%3D%22363%22%20r%3D%221.5%22%2F%3E%3C%2Fg%3E%3Crect%20x%3D%22325%22%20y%3D%22195%22%20width%3D%22150%22%20height%3D%22185%22%20fill%3D%22%23d4b255%22%20opacity%3D%220.4%22%2F%3E%3Cpath%20d%3D%22M325%20195%20Q400%20128%20475%20195%22%20fill%3D%22%23d4b255%22%20opacity%3D%220.4%22%2F%3E%3Crect%20x%3D%22345%22%20y%3D%22215%22%20width%3D%22110%22%20height%3D%22165%22%20fill%3D%22%23060618%22%20opacity%3D%220.55%22%2F%3E%3Cpath%20d%3D%22M345%20215%20Q400%20152%20455%20215%22%20fill%3D%22%23060618%22%20opacity%3D%220.55%22%2F%3E%3Cg%20fill%3D%22%23d4b255%22%20opacity%3D%220.3%22%3E%3Ccircle%20cx%3D%22360%22%20cy%3D%22188%22%20r%3D%224%22%2F%3E%3Ccircle%20cx%3D%22440%22%20cy%3D%22188%22%20r%3D%224%22%2F%3E%3Crect%20x%3D%22356%22%20y%3D%22250%22%20width%3D%2212%22%20height%3D%225%22%2F%3E%3Crect%20x%3D%22432%22%20y%3D%22250%22%20width%3D%2212%22%20height%3D%225%22%2F%3E%3Crect%20x%3D%22356%22%20y%3D%22270%22%20width%3D%2212%22%20height%3D%225%22%2F%3E%3Crect%20x%3D%22432%22%20y%3D%22270%22%20width%3D%2212%22%20height%3D%225%22%2F%3E%3C%2Fg%3E%3Crect%20x%3D%22260%22%20y%3D%22248%22%20width%3D%2265%22%20height%3D%22132%22%20fill%3D%22%23c49a50%22%20opacity%3D%220.35%22%2F%3E%3Cellipse%20cx%3D%22293%22%20cy%3D%22248%22%20rx%3D%2233%22%20ry%3D%2216%22%20fill%3D%22%23c49a50%22%20opacity%3D%220.35%22%2F%3E%3Crect%20x%3D%22475%22%20y%3D%22248%22%20width%3D%2265%22%20height%3D%22132%22%20fill%3D%22%23c49a50%22%20opacity%3D%220.35%22%2F%3E%3Cellipse%20cx%3D%22508%22%20cy%3D%22248%22%20rx%3D%2233%22%20ry%3D%2216%22%20fill%3D%22%23c49a50%22%20opacity%3D%220.35%22%2F%3E%3Crect%20x%3D%22200%22%20y%3D%22288%22%20width%3D%22100%22%20height%3D%2292%22%20fill%3D%22%23a07830%22%20opacity%3D%220.25%22%2F%3E%3Cpath%20d%3D%22M200%20288%20Q250%20268%20300%20288%22%20fill%3D%22%23a07830%22%20opacity%3D%220.25%22%2F%3E%3Crect%20x%3D%22500%22%20y%3D%22288%22%20width%3D%22100%22%20height%3D%2292%22%20fill%3D%22%23a07830%22%20opacity%3D%220.25%22%2F%3E%3Cpath%20d%3D%22M500%20288%20Q550%20268%20600%20288%22%20fill%3D%22%23a07830%22%20opacity%3D%220.25%22%2F%3E%3Ccircle%20cx%3D%22660%22%20cy%3D%2272%22%20r%3D%2238%22%20fill%3D%22%23f0dfa0%22%20opacity%3D%220.22%22%2F%3E%3Ccircle%20cx%3D%22675%22%20cy%3D%2266%22%20r%3D%2229%22%20fill%3D%22%23060618%22%20opacity%3D%220.5%22%2F%3E%3Cg%20fill%3D%22%23f0dfa0%22%20opacity%3D%220.45%22%3E%3Ccircle%20cx%3D%22100%22%20cy%3D%2242%22%20r%3D%221.5%22%2F%3E%3Ccircle%20cx%3D%22195%22%20cy%3D%2268%22%20r%3D%221%22%2F%3E%3Ccircle%20cx%3D%22260%22%20cy%3D%2230%22%20r%3D%221.5%22%2F%3E%3Ccircle%20cx%3D%22558%22%20cy%3D%2252%22%20r%3D%221.5%22%2F%3E%3Ccircle%20cx%3D%22725%22%20cy%3D%2238%22%20r%3D%221.5%22%2F%3E%3Ccircle%20cx%3D%22415%22%20cy%3D%2288%22%20r%3D%221%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
}


/* Mosul - al-Hadba leaning minaret, citadel on mound, Nuri dome, Tigris bridge, crescent */
#scene-area.bg-mosul::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 400'%3E%3Cdefs%3E%3ClinearGradient id='sky6' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23222240'/%3E%3Cstop offset='0.5' stop-color='%238b1a1a' stop-opacity='0.12'/%3E%3Cstop offset='1' stop-color='%23a0734d' stop-opacity='0.15'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect fill='url(%23sky6)' width='800' height='400'/%3E%3Cpath d='M0 350 Q150 325 300 345 Q450 365 600 340 Q700 330 800 350 L800 400 L0 400Z' fill='%232a9b9b' opacity='0.2'/%3E%3Cg fill='%23d4b255' opacity='0.5'%3E%3Cpath d='M180 350 Q220 345 260 350 Q300 345 340 350 Q380 345 420 350 Q460 345 500 350' fill='none' stroke='%23d4b255' stroke-width='2.5'/%3E%3Crect x='220' y='345' width='8' height='12'/%3E%3Crect x='300' y='345' width='8' height='12'/%3E%3Crect x='380' y='345' width='8' height='12'/%3E%3Crect x='460' y='345' width='8' height='12'/%3E%3C/g%3E%3Cg fill='%23d4b255'%3E%3Cpath d='M200 350 L200 200 Q250 180 400 180 Q550 180 600 200 L600 350Z' opacity='0.55'/%3E%3Cellipse cx='400' cy='180' rx='200' ry='15' opacity='0.3'/%3E%3Cg opacity='0.8'%3E%3Crect x='340' y='160' width='14' height='100' transform='rotate(-3 347 210)'/%3E%3Crect x='341' y='150' width='12' height='14' transform='rotate(-3 347 157)'/%3E%3Crect x='344' y='136' width='6' height='18' transform='rotate(-3 347 145)'/%3E%3Ccircle cx='347' cy='133' r='4'/%3E%3Crect x='338' y='175' width='18' height='5' opacity='0.5' transform='rotate(-3 347 177)'/%3E%3Crect x='338' y='195' width='18' height='5' opacity='0.5' transform='rotate(-3 347 197)'/%3E%3Crect x='338' y='215' width='18' height='5' opacity='0.5' transform='rotate(-3 347 217)'/%3E%3C/g%3E%3Cg opacity='0.7'%3E%3Cellipse cx='480' cy='195' rx='45' ry='35'/%3E%3Cellipse cx='480' cy='200' rx='40' ry='20' fill='%23222240' opacity='0.25'/%3E%3Crect x='476' y='165' width='8' height='35'/%3E%3Ccircle cx='480' cy='162' r='4'/%3E%3C/g%3E%3Cg opacity='0.5'%3E%3Cpath d='M250 220 Q270 195 290 220' fill='none' stroke='%23222240' stroke-width='1.5'/%3E%3Cpath d='M300 220 Q320 195 340 220' fill='none' stroke='%23222240' stroke-width='1.5'/%3E%3Cpath d='M450 230 Q470 205 490 230' fill='none' stroke='%23222240' stroke-width='1.5'/%3E%3Cpath d='M500 230 Q520 205 540 230' fill='none' stroke='%23222240' stroke-width='1.5'/%3E%3C/g%3E%3C/g%3E%3Ccircle cx='670' cy='80' r='40' fill='%23f0dfa0' opacity='0.3'/%3E%3Ccircle cx='685' cy='75' r='30' fill='%23222240' opacity='0.45'/%3E%3Cg fill='%23f0dfa0' opacity='0.25'%3E%3Ccircle cx='100' cy='50' r='1.5'/%3E%3Ccircle cx='200' cy='30' r='1'/%3E%3Ccircle cx='550' cy='40' r='1.5'/%3E%3Ccircle cx='750' cy='55' r='1'/%3E%3Ccircle cx='400' cy='60' r='1'/%3E%3C/g%3E%3C/svg%3E");
}

/* --- Portraits --- */
/* Absolutely positioned so they overlay the scene image
   without consuming flex space — lets the text panel grow freely */
#portrait-area {
    display: flex;
    justify-content: space-between;
    padding: 0 var(--gap-lg);
    position: absolute;
    top: var(--gap);
    left: 0;
    right: 0;
    height: 200px;
    z-index: 2;
    pointer-events: none;
}

.portrait {
    pointer-events: auto;
}

.portrait {
    width: 140px;
    height: 180px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: all 0.5s ease;
    opacity: 0;
    pointer-events: auto;
}

.portrait.visible {
    opacity: 1;
}

.portrait svg {
    width: 100%;
    height: 100%;
}

.portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    border-radius: 6px;
    display: block;
}

.portrait.speaking .portrait-img {
    filter: drop-shadow(0 0 12px rgba(201, 168, 76, 0.8));
}

.portrait.speaking {
    filter: drop-shadow(0 0 15px var(--gold));
}

/* --- Text Area --- */
#text-area {
    background: linear-gradient(135deg, rgba(48, 42, 70, 0.97), rgba(58, 52, 82, 0.95));
    border: 1px solid rgba(212, 178, 85, 0.35);
    border-right: 3px solid rgba(212, 178, 85, 0.7);
    border-radius: var(--radius);
    padding: 1.2rem 1.8rem;
    margin: var(--gap) 0;
    flex: 1 1 auto;
    max-height: 42vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    box-shadow:
        0 4px 30px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(212, 178, 85, 0.12);
    backdrop-filter: blur(10px);
}

#text-area::before {
    content: '';
    position: absolute;
    top: -1px;
    right: 30px;
    width: 80px;
    height: 3px;
    background: linear-gradient(to left, var(--gold), transparent);
    border-radius: 0 0 3px 3px;
}

#text-area::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 30px;
    width: 80px;
    height: 3px;
    background: linear-gradient(to right, var(--gold), transparent);
    border-radius: 0 0 3px 3px;
}

#speaker-name {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-shadow: 0 0 18px rgba(201, 168, 76, 0.45);
}

#speaker-name:empty {
    display: none;
}

#text-content {
    font-size: 1.2rem;
    line-height: 2.1;
    color: var(--white);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.02em;
}

/* Typewriter cursor */
#text-content.typing::after {
    content: '|';
    animation: blink 0.7s infinite;
    color: var(--gold);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Poetry Display --- */
#poem-area {
    background: linear-gradient(160deg, rgba(35,28,58,0.98) 0%, rgba(28,22,48,0.99) 100%);
    border: 1px solid rgba(154,125,43,0.5);
    border-top: 2px solid var(--gold);
    border-bottom: 2px solid var(--gold);
    padding: var(--gap-lg);
    margin: var(--gap) 0;
    text-align: center;
    position: relative;
    box-shadow:
        0 0 0 1px rgba(154,125,43,0.15),
        0 8px 40px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(240,223,160,0.08);
}

/* Double-rule top ornament */
#poem-area::before {
    content: '❧  ✦  ❧';
    position: absolute;
    top: -0.75rem;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(to bottom, rgba(35,28,58,1), rgba(28,22,48,1));
    color: var(--gold);
    font-size: 0.85rem;
    padding: 0 0.8rem;
    letter-spacing: 0.5em;
    opacity: 0.85;
}

/* Corner ticks */
#poem-area::after {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(212,178,85,0.12);
    pointer-events: none;
}

.poem-frame {
    position: relative;
}

#poem-verses {
    font-family: var(--font-display);
    font-size: 1.5rem;
    line-height: 2.8;
    color: var(--gold-light);
    text-shadow: 0 2px 8px rgba(201, 168, 76, 0.2);
}

#poem-verses .verse {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.8s ease;
    margin-bottom: var(--gap);
    padding: var(--gap-sm) 0;
    border-bottom: 1px solid rgba(201, 168, 76, 0.1);
}

#poem-verses .verse.revealed {
    opacity: 1;
    transform: translateY(0);
}

#poem-verses .verse.highlighted {
    color: var(--gold);
    text-shadow: 0 0 20px rgba(201, 168, 76, 0.4);
    font-size: 1.5rem;
}

/* Hemistich display */
.verse .hemistich {
    display: inline-block;
}

.verse .hemistich-separator {
    display: inline-block;
    width: 3rem;
}

/* --- Reaction Meter --- */
#poem-reaction {
    margin-top: var(--gap);
    padding-top: var(--gap);
    border-top: 1px solid var(--gold-dark);
}

.reaction-bar {
    width: 200px;
    height: 10px;
    background: var(--ink-light);
    border-radius: 5px;
    margin: 0 auto var(--gap-sm);
    overflow: hidden;
}

.reaction-fill {
    height: 100%;
    background: linear-gradient(to left, var(--gold), var(--turquoise-light));
    border-radius: 5px;
    transition: width 0.8s ease;
    width: 50%;
}

#reaction-label {
    font-size: 0.85rem;
    color: var(--parchment-dark);
}

#recitation-slot {
    margin-top: var(--gap);
    padding: var(--gap-sm);
    border: 1px dashed var(--parchment-darker);
    border-radius: var(--radius);
    color: var(--parchment-darker);
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s;
}

#recitation-slot:hover {
    opacity: 1;
}

/* --- Choices --- */
#choice-area {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.8rem 0;
    flex-shrink: 0;
}

.choice-btn {
    font-family: var(--font-display);
    font-size: 1.08rem;
    background: linear-gradient(to left, rgba(42,36,65,0.96) 0%, rgba(34,28,55,0.98) 100%);
    color: var(--parchment);
    border: none;
    border-right: 3px solid var(--gold-dark);
    border-bottom: 1px solid rgba(154,125,43,0.25);
    padding: 1rem 1.4rem 1rem 1rem;
    cursor: pointer;
    text-align: right;
    transition: all 0.25s ease;
    line-height: 2.1;
    position: relative;
    backdrop-filter: blur(8px);
}

/* Gold bullet ornament at text-start (right side in RTL) */
.choice-btn::before {
    content: '◆';
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.55rem;
    color: var(--gold-dark);
    transition: color 0.25s ease;
}

/* Top shimmer line */
.choice-btn::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 1px;
    background: linear-gradient(to left, rgba(212,178,85,0.35), transparent 60%);
}

.choice-btn:hover {
    border-right-color: var(--gold-light);
    color: var(--gold-light);
    background: linear-gradient(to left, rgba(60,50,90,0.97) 0%, rgba(42,36,65,0.99) 100%);
    padding-right: 1.8rem;
    box-shadow: inset 0 0 30px rgba(212,178,85,0.06), 4px 0 0 var(--gold) inset;
}

.choice-btn:hover::before {
    color: var(--gold-light);
}

.choice-btn.selected {
    border-right-color: var(--gold);
    background: linear-gradient(to left, rgba(80,65,30,0.4) 0%, rgba(50,44,70,0.98) 100%);
    color: var(--gold);
}

/* --- Continue --- */
#continue-area {
    text-align: center;
    padding: var(--gap) 0;
    flex-shrink: 0;
}

/* --- Overlays --- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 6, 20, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(6px);
}

.overlay-content {
    background: linear-gradient(160deg, rgba(36,30,60,0.99) 0%, rgba(24,20,44,0.99) 100%);
    border: 1px solid rgba(154,125,43,0.5);
    padding: var(--gap-lg);
    min-width: 300px;
    max-width: 420px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(212,178,85,0.08);
}

/* L-corner manuscript brackets on overlays */
.overlay-content::before {
    content: '';
    position: absolute;
    inset: 12px;
    pointer-events: none;
    background:
        linear-gradient(var(--gold-dark), var(--gold-dark)) 0    0    / 40px 1px  no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 0    0    / 1px  40px no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 100% 0    / 40px 1px  no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 100% 0    / 1px  40px no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 0    100% / 40px 1px  no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 0    100% / 1px  40px no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 100% 100% / 40px 1px  no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 100% 100% / 1px  40px no-repeat;
}

.overlay-content h2 {
    font-family: var(--font-title);
    font-size: 1.6rem;
    color: var(--gold-light);
    margin-bottom: var(--gap);
    letter-spacing: 0.06em;
    text-shadow: 0 0 20px rgba(212,178,85,0.3);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--gap);
    gap: var(--gap);
}

.setting-row label {
    font-size: 0.9rem;
    color: var(--parchment-dark);
}

.setting-row input[type="range"] {
    flex: 1;
    accent-color: var(--gold);
}

/* --- Intro / Character Screen --- */
#screen-intro {
    overflow: hidden;
    flex-direction: column;
}

/* Full-bleed scholarly scene as atmosphere */
.intro-bg {
    position: absolute;
    inset: 0;
    background-image: url('../img/scene-scholar.png');
    background-size: cover;
    background-position: center center;
    filter: brightness(0.32) saturate(0.65);
    z-index: 0;
}

/* Layered vignette: strong at edges, clear in centre */
#screen-intro::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to left,  rgba(14,12,30,0.85) 0%, transparent 38%),
        linear-gradient(to right, rgba(14,12,30,0.85) 0%, transparent 38%),
        linear-gradient(to bottom, rgba(14,12,30,0.6) 0%, transparent 18%, transparent 75%, rgba(14,12,30,0.9) 100%);
    z-index: 1;
    pointer-events: none;
}

/* Gold top rule */
#screen-intro::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
    z-index: 3;
}

/* Layout: portrait column (visual right in RTL) + info column (visual left) */
.intro-layout {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    padding: 0.7rem 0.8rem 0.5rem;
    gap: 0.8rem;
    flex: 1;
    min-height: 0;
    overflow: visible;
}

/* ---- Portrait column (visual RIGHT in RTL, fixed width) ---- */
.intro-portrait-col {
    flex: 0 0 185px;
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: flex-start;
}

/* ---- Info column (visual LEFT in RTL, takes remaining space) ---- */
.intro-info-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: linear-gradient(160deg, rgba(22,18,44,0.92) 0%, rgba(16,14,34,0.96) 100%);
    border: 1px solid rgba(154,125,43,0.35);
    padding: 0.7rem 0.85rem 0.5rem;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(154,125,43,0.3) transparent;
}

/* L-corner brackets on info column */
.intro-info-col::before {
    content: '';
    position: absolute;
    inset: 7px;
    pointer-events: none;
    z-index: 0;
    background:
        linear-gradient(var(--gold-dark), var(--gold-dark)) 0    0    / 20px 1px  no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 0    0    / 1px  20px no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 100% 0    / 20px 1px  no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 100% 0    / 1px  20px no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 0    100% / 20px 1px  no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 0    100% / 1px  20px no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 100% 100% / 20px 1px  no-repeat,
        linear-gradient(var(--gold-dark), var(--gold-dark)) 100% 100% / 1px  20px no-repeat;
}

/* ---- Section header (used inside info col) ---- */
.intro-section-header {
    font-family: var(--font-title);
    font-size: 0.88rem;
    color: var(--gold-light);
    letter-spacing: 0.08em;
    padding-bottom: 0.4rem;
    margin-bottom: 0.55rem;
    border-bottom: 1px solid rgba(154,125,43,0.35);
    position: relative;
    z-index: 1;
}

.portrait-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    overflow: hidden;
    border: 2px solid var(--gold-dark);
    box-shadow: 0 0 0 1px rgba(212,178,85,0.15), 0 12px 40px rgba(0,0,0,0.75);
    flex-shrink: 0;
}

.intro-portrait {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
    filter: sepia(0.12) brightness(1.1) contrast(1.05);
}

.portrait-nameplate {
    width: 100%;
    background: linear-gradient(to left, rgba(16,14,34,0.98), rgba(28,22,52,0.98));
    border: 1px solid rgba(154,125,43,0.5);
    border-top: 2px solid var(--gold);
    padding: 0.45rem 0.7rem;
    text-align: center;
    margin-top: -2px;
    flex-shrink: 0;
}

.nameplate-title {
    font-family: var(--font-title);
    font-size: 1.5rem;
    color: var(--gold-light);
    letter-spacing: 0.06em;
    text-shadow: 0 0 25px rgba(212,178,85,0.45);
    line-height: 1.2;
}

.nameplate-sub {
    font-family: var(--font-display);
    font-size: 0.82rem;
    color: var(--parchment-darker);
    margin-top: 0.15rem;
    font-style: italic;
}

/* ---- Stat pips ---- */
.stat-block { display: flex; flex-direction: column; gap: 0.45rem; position: relative; z-index: 1; }

.stat-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stat-name {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--parchment-dark);
    width: 48px;
    flex-shrink: 0;
    text-align: right;
}

.stat-pips {
    display: flex;
    gap: 2px;
    flex: 1;
    direction: ltr;
}

.pip {
    width: 9px;
    height: 9px;
    border: 1px solid rgba(154,125,43,0.45);
    background: rgba(20,18,40,0.6);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    flex-shrink: 0;
}

.pip.filled {
    background: var(--gold);
    border-color: var(--gold-light);
    box-shadow: 0 0 3px rgba(212,178,85,0.5);
}

.stat-num {
    font-family: var(--font-display);
    font-size: 0.72rem;
    color: var(--gold);
    width: 16px;
    text-align: center;
    direction: ltr;
    flex-shrink: 0;
}

/* ---- Tags ---- */
.intro-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.6rem;
    margin-bottom: 0.6rem;
    justify-content: flex-end;
    position: relative;
    z-index: 1;
}

.tag {
    font-family: var(--font-display);
    font-size: 0.68rem;
    color: var(--gold-dark);
    border: 1px solid rgba(154,125,43,0.4);
    padding: 0.15rem 0.5rem;
    letter-spacing: 0.03em;
    background: rgba(22,18,42,0.7);
}

/* ---- Biography facts ---- */
.bio-facts {
    display: flex;
    flex-direction: column;
    gap: 0;
    font-size: 0.74rem;
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

.bio-facts dt {
    color: var(--gold-dark);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    margin-top: 0.45rem;
}

.bio-facts dd {
    color: var(--parchment-dark);
    border-bottom: 1px solid rgba(154,125,43,0.1);
    padding-bottom: 0.3rem;
    margin-right: 0;
}

.intro-verse {
    margin-top: 0.65rem;
    padding: 0.5rem 0.7rem;
    border-right: 2px solid var(--gold-dark);
    background: rgba(154,125,43,0.07);
    font-family: var(--font-title);
    font-size: 0.82rem;
    color: var(--gold-light);
    font-style: normal;
    line-height: 1.75;
    position: relative;
    z-index: 1;
}

.intro-verse cite {
    display: block;
    font-size: 0.68rem;
    color: var(--parchment-darker);
    margin-top: 0.3rem;
    font-style: italic;
}

/* ---- Action button row at bottom of info col ---- */
.intro-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    text-align: center;
    padding: 0.8rem 0 0.4rem;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(to bottom, transparent, rgba(16,14,34,0.97) 40%);
}

.intro-divider {
    color: var(--gold-dark);
    font-size: 0.85rem;
    letter-spacing: 0.55em;
    opacity: 0.65;
}

/* --- Map Screen --- */
#map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem var(--gap);
    background: linear-gradient(to bottom, rgba(20,18,40,0.98), rgba(30,26,52,0.85));
    border-bottom: 2px solid;
    border-image: linear-gradient(to left, transparent, var(--gold-dark), var(--gold), var(--gold-dark), transparent) 1;
}

#map-header h2 {
    font-family: var(--font-title);
    font-size: 1.5rem;
    color: var(--gold-light);
    letter-spacing: 0.06em;
    text-shadow: 0 0 15px rgba(212,178,85,0.3);
}

#map-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--gap);
    position: relative;
    background-image: url('../img/map-bg.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: var(--radius);
}

/* --- Status --- */
#status-details {
    text-align: right;
}

.status-section {
    margin-bottom: var(--gap);
}

.status-section h3 {
    color: var(--gold);
    font-size: 0.95rem;
    margin-bottom: var(--gap-sm);
    font-family: var(--font-display);
}

.patron-item {
    display: flex;
    justify-content: space-between;
    padding: var(--gap-sm) 0;
    border-bottom: 1px solid var(--ink-light);
    font-size: 0.85rem;
}

/* --- Utility Classes --- */
.hidden {
    display: none !important;
}

/* --- Transitions --- */
.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

.slide-up {
    animation: slideUp 0.5s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Gold shimmer for rewards */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.reward-text {
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-light), var(--gold), var(--gold-light), var(--gold-dark));
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 3s linear infinite;
    font-size: 1.3rem;
    font-weight: 700;
}

/* Coin animation for rewards */
@keyframes coinDrop {
    0% { transform: translateY(-30px) rotate(0deg); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(0) rotate(360deg); opacity: 1; }
}

.coin {
    display: inline-block;
    animation: coinDrop 0.6s ease forwards;
    font-size: 1.5rem;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    html {
        font-size: 16px;
    }

    .title-main {
        font-size: 2.5rem;
    }

    #poem-verses {
        font-size: 1.2rem;
    }

    #portrait-area {
        min-height: 100px;
    }

    .portrait {
        width: 80px;
        height: 100px;
    }

    #text-area {
        padding: var(--gap);
    }

    .overlay-content {
        margin: var(--gap);
        min-width: auto;
    }
}

/* --- Poem Puzzle --- */
#poem-area.puzzle-mode {
    background: linear-gradient(160deg, rgba(28,20,52,0.99) 0%, rgba(20,14,40,0.99) 100%);
    border: 1px solid rgba(212,178,85,0.5);
    border-top: 2px solid var(--gold);
    border-bottom: 2px solid var(--gold);
    padding: 0;
    flex-shrink: 0;
}

.puzzle-frame {
    padding: 1.2rem 1.6rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.puzzle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(212,178,85,0.2);
    padding-bottom: 0.5rem;
}

.puzzle-title {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--gold-dark);
    font-style: italic;
}

.puzzle-progress {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--gold);
    font-weight: 700;
    letter-spacing: 0.1em;
}

.puzzle-prompt-label {
    font-size: 0.95rem;
    color: var(--parchment);
    text-align: center;
    letter-spacing: 0.04em;
}

.puzzle-hemistich {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--gold-light);
    text-align: center;
    line-height: 1.7;
    min-height: 2.5rem;
    text-shadow: 0 0 20px rgba(212,178,85,0.25);
}

.puzzle-hemistich.revealing {
    opacity: 0.85;
}

/* Second hemistich — shown for device questions (full verse visible) */
.puzzle-hemistich2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--gold);
    text-align: center;
    line-height: 1.7;
    opacity: 0.85;
    text-shadow: 0 0 16px rgba(212,178,85,0.2);
    border-top: 1px solid rgba(212,178,85,0.15);
    padding-top: 0.3rem;
    margin-top: -0.2rem;
}

/* Device question: choices are 4 short labels — display in a 2×2 grid */
.puzzle-choices.device-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
}

/* Device feedback highlight labels */
.fb-correct-label {
    font-weight: 700;
    color: #7dde92;
    margin-left: 0.4em;
}
.fb-wrong-label {
    font-weight: 700;
    color: #e07070;
    margin-left: 0.4em;
}

.puzzle-separator {
    text-align: center;
    color: var(--gold-dark);
    font-size: 0.9rem;
    opacity: 0.5;
}

.puzzle-choices {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.puzzle-choice-btn {
    background: rgba(42,35,68,0.7);
    border: 1px solid rgba(154,125,43,0.3);
    border-radius: 6px;
    color: var(--parchment);
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.9;
    padding: 0.7rem 1.1rem;
    cursor: pointer;
    text-align: right;
    direction: rtl;
    width: 100%;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    animation: slideUp 0.25s ease both;
}

.puzzle-choice-btn:hover:not(:disabled) {
    background: rgba(62,52,95,0.85);
    border-color: rgba(212,178,85,0.5);
    transform: translateX(-2px);
}

.puzzle-choice-btn.puzzle-correct {
    background: rgba(30,80,40,0.7) !important;
    border-color: #4caf50 !important;
    color: #a8ffb0;
    box-shadow: 0 0 12px rgba(76,175,80,0.3);
}

.puzzle-choice-btn.puzzle-wrong {
    background: rgba(80,20,20,0.7) !important;
    border-color: #e53935 !important;
    color: #ffaaaa;
}

.puzzle-choice-btn:disabled {
    cursor: default;
}

.puzzle-feedback {
    font-size: 0.85rem;
    text-align: center;
    min-height: 1.2rem;
    font-family: var(--font-display);
    transition: color 0.2s;
}

.feedback-correct { color: #8fff98; }
.feedback-wrong { color: #ff8888; }

/* Result screen */
.puzzle-result {
    text-align: center;
    align-items: center;
    padding: 1.5rem 1.6rem;
}

.puzzle-result-stars {
    font-size: 1.6rem;
    color: var(--gold);
    letter-spacing: 0.15em;
    text-shadow: 0 0 10px rgba(212,178,85,0.4);
}

.puzzle-result-grade {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--parchment);
    font-weight: 700;
}

.puzzle-result-sub {
    font-size: 0.78rem;
    color: var(--parchment-dark);
    margin-top: 0.3rem;
}

.puzzle-reaction-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 0.3rem 0;
}

.puzzle-reaction-fill {
    height: 100%;
    background: linear-gradient(to right, var(--gold-dark), var(--gold));
    border-radius: 4px;
    transition: width 0.8s ease;
}

.puzzle-result-reward {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--gold);
    font-weight: 700;
}

.puzzle-continue-btn {
    margin-top: 0.5rem;
    min-width: 140px;
}

/* --- Travel Cutscreen --- */
.travel-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #151530 0%, #222240 40%, #3a2a1a 75%, #a0734d 100%);
    background-size: cover;
    background-position: center 40%;
    background-repeat: no-repeat;
    animation: travelFadeIn 1s ease forwards;
    overflow: hidden;
}

.travel-overlay.has-bg {
    background-blend-mode: overlay;
}

.travel-overlay.has-bg .travel-rider,
.travel-overlay.has-bg .travel-dunes-far,
.travel-overlay.has-bg .travel-dunes-mid,
.travel-overlay.has-bg .travel-ground,
.travel-overlay.has-bg .travel-moon,
.travel-overlay.has-bg .travel-dust,
.travel-overlay.has-bg .travel-city-from,
.travel-overlay.has-bg .travel-city-to {
    display: none;
}

.travel-overlay.exiting {
    animation: travelFadeOut 0.8s ease forwards;
}

@keyframes travelFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes travelFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.travel-scene {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    overflow: hidden;
}

/* Parallax dune layers */
.travel-dunes-far {
    position: absolute;
    bottom: 18%;
    width: 200%;
    height: 120px;
    animation: scrollDunesFar 16s linear infinite;
}

.travel-dunes-mid {
    position: absolute;
    bottom: 10%;
    width: 200%;
    height: 100px;
    animation: scrollDunesMid 10s linear infinite;
}

.travel-ground {
    position: absolute;
    bottom: 0;
    width: 200%;
    height: 80px;
    animation: scrollGround 5s linear infinite;
}

@keyframes scrollDunesFar {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@keyframes scrollDunesMid {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@keyframes scrollGround {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* Rider */
.travel-rider {
    position: absolute;
    bottom: 16%;
    left: 50%;
    transform: translateX(-50%);
    animation: riderSway 2s ease-in-out infinite;
    z-index: 10;
}

@keyframes riderSway {
    0%, 100% { transform: translateX(-50%) translateY(0) rotate(0deg); }
    25% { transform: translateX(-50%) translateY(-4px) rotate(0.5deg); }
    50% { transform: translateX(-50%) translateY(-8px) rotate(0deg); }
    75% { transform: translateX(-50%) translateY(-4px) rotate(-0.5deg); }
}

/* Stars */
.travel-stars {
    position: absolute;
    top: 0;
    width: 100%;
    height: 55%;
    z-index: 1;
}

.travel-star {
    position: absolute;
    background: var(--gold-light);
    border-radius: 50%;
    animation: twinkle 2s ease-in-out infinite;
}

.travel-star.bright {
    box-shadow: 0 0 6px 2px rgba(240, 223, 160, 0.5);
}

@keyframes twinkle {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

/* Crescent moon */
.travel-moon {
    position: absolute;
    top: 8%;
    right: 12%;
    z-index: 2;
}

/* Dust particles */
.travel-dust {
    position: absolute;
    width: 3px;
    height: 3px;
    background: rgba(160, 115, 77, 0.4);
    border-radius: 50%;
    animation: dustDrift linear infinite;
}

@keyframes dustDrift {
    from { transform: translateX(100vw) translateY(0); opacity: 0; }
    10% { opacity: 0.6; }
    90% { opacity: 0.3; }
    to { transform: translateX(-100vw) translateY(-30px); opacity: 0; }
}

/* City silhouettes scrolling */
.travel-city-from {
    position: absolute;
    bottom: 15%;
    right: -5%;
    opacity: 0.3;
    animation: cityScrollOff 5s ease-in forwards;
    z-index: 5;
}

.travel-city-to {
    position: absolute;
    bottom: 15%;
    left: -30%;
    opacity: 0;
    animation: cityScrollIn 5s ease-out 3s forwards;
    z-index: 5;
}

@keyframes cityScrollOff {
    from { right: -5%; opacity: 0.3; }
    to { right: 110%; opacity: 0; }
}

@keyframes cityScrollIn {
    from { left: -30%; opacity: 0; }
    to { left: 5%; opacity: 0.35; }
}

/* Text overlay */
.travel-text-container {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    text-align: center;
    padding: 1.5rem 3rem;
    background: rgba(34, 34, 64, 0.6);
    border: 1px solid rgba(212, 178, 85, 0.3);
    border-radius: var(--radius);
    backdrop-filter: blur(8px);
}

.travel-text-container::before {
    content: '';
    position: absolute;
    top: -1px;
    right: 20%;
    width: 60%;
    height: 2px;
    background: linear-gradient(to left, transparent, var(--gold), transparent);
}

.travel-text-container::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: 20%;
    width: 60%;
    height: 2px;
    background: linear-gradient(to left, transparent, var(--gold), transparent);
}

.travel-text {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--gold);
    text-shadow: 0 2px 20px rgba(212, 178, 85, 0.5);
    margin-bottom: 0.5rem;
}

.travel-cities {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--parchment-dark);
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

/* "من" and "إلى" prepositions — small, muted, linking */
.travel-cities .travel-prep {
    color: var(--parchment-darker);
    font-size: 0.95rem;
    font-style: italic;
}

/* Departure city — slightly dimmer, the place left behind */
.travel-cities .city-from {
    color: var(--parchment-dark);
    font-size: 1.25rem;
}

/* Destination city — bright gold, the goal ahead */
.travel-cities .city-to {
    color: var(--gold-light);
    font-size: 1.35rem;
    font-weight: 700;
    text-shadow: 0 0 12px rgba(240, 223, 160, 0.35);
}

/* --- Episode Intro Card --- */
.episode-intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #3d3a55 0%, var(--ink) 70%);
    text-align: center;
    padding: var(--gap-lg);
}

.episode-intro-overlay .ep-star {
    opacity: 0;
    animation: epFadeIn 0.8s ease 0.2s forwards;
}

.episode-intro-overlay .ep-date {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--turquoise-light);
    margin-bottom: 0.5rem;
    letter-spacing: 0.1em;
    opacity: 0;
    animation: epFadeIn 0.8s ease 0.5s forwards;
}

.episode-intro-overlay .ep-divider {
    width: 120px;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
    margin: 0.8rem auto;
    opacity: 0;
    animation: epFadeIn 0.6s ease 0.8s forwards;
}

.episode-intro-overlay .ep-title {
    font-family: var(--font-display);
    font-size: 2.4rem;
    color: var(--gold);
    text-shadow: 0 2px 25px rgba(212, 178, 85, 0.5);
    margin-bottom: var(--gap);
    opacity: 0;
    animation: epFadeIn 0.8s ease 1s forwards;
}

.episode-intro-overlay .ep-desc {
    font-size: 1.15rem;
    color: var(--parchment);
    max-width: 500px;
    line-height: 2.1;
    opacity: 0;
    animation: epFadeIn 0.8s ease 1.4s forwards;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

@keyframes epFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

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

/* ================================================================
   ENDING / SCORE CERTIFICATE
   ================================================================ */

#screen-ending {
    overflow-y: auto;
    background: radial-gradient(ellipse at center, #2a2540 0%, #1a1a2e 100%);
    padding: 2rem 1rem 3rem;
    direction: rtl;
}

.cert-scroll-wrap {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

/* The printable certificate card */
.certificate {
    width: 100%;
    background: linear-gradient(160deg, #0f0f1e 0%, #1a1532 50%, #0f0f1e 100%);
    border: 2px solid var(--gold-dark);
    border-radius: 12px;
    padding: 2.4rem 2rem;
    box-shadow:
        0 0 0 1px rgba(201,168,76,0.15),
        0 0 40px rgba(201,168,76,0.08),
        inset 0 0 60px rgba(0,0,0,0.4);
    text-align: center;
    position: relative;
}

/* Corner ornaments via pseudo-elements */
.certificate::before,
.certificate::after {
    content: '✦';
    position: absolute;
    color: var(--gold-dark);
    font-size: 1.2rem;
    opacity: 0.5;
}
.certificate::before { top: 0.8rem; right: 0.8rem; }
.certificate::after  { bottom: 0.8rem; left: 0.8rem; }

/* Top / bottom ornament rows */
.cert-top-ornament,
.cert-bottom-ornament {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    justify-content: center;
    margin-bottom: 1rem;
}
.cert-bottom-ornament { margin-top: 1rem; margin-bottom: 0; }
.cert-ornament-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
    max-width: 140px;
}
.cert-star-cluster {
    color: var(--gold);
    font-size: 0.9rem;
    letter-spacing: 0.3em;
}

/* Header text */
.cert-label-top {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    color: var(--turquoise);
    text-transform: uppercase;
    margin: 0 0 0.3rem;
}
.cert-game-title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    color: var(--gold-light);
    margin: 0 0 0.2rem;
    text-shadow: 0 0 20px rgba(201,168,76,0.5);
}
.cert-subtitle-line {
    font-size: 0.85rem;
    color: rgba(212,178,85,0.6);
    margin: 0 0 1.2rem;
}

/* Portrait */
.cert-portrait-wrap {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--gold-dark);
    margin: 0 auto 1rem;
    box-shadow: 0 0 20px rgba(201,168,76,0.3);
}
.cert-portrait {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

/* Rank */
.cert-rank-wrap {
    margin-bottom: 0.8rem;
}
.cert-rank {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 1.35rem;
    padding: 0.3rem 1.4rem;
    border-radius: 4px;
    margin-bottom: 0.4rem;
    letter-spacing: 0.05em;
}
.rank-5 { color: #fff; background: linear-gradient(135deg, #b8860b, #ffd700, #b8860b); }
.rank-4 { color: #1a1a2e; background: linear-gradient(135deg, #a8a8a8, #e8e8e8, #a8a8a8); }
.rank-3 { color: #fff; background: linear-gradient(135deg, #8b4513, #cd853f, #8b4513); }
.rank-2 { color: var(--gold-light); background: rgba(201,168,76,0.15); border: 1px solid var(--gold-dark); }
.rank-1 { color: rgba(212,178,85,0.7); background: rgba(201,168,76,0.08); border: 1px solid rgba(201,168,76,0.3); }
.cert-stars {
    font-size: 1.4rem;
    color: var(--gold);
    letter-spacing: 0.1em;
}

/* Divider */
.cert-divider {
    color: var(--gold-dark);
    letter-spacing: 0.5em;
    margin: 1rem 0;
    font-size: 0.75rem;
    opacity: 0.6;
}

/* Stats grid */
.cert-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin: 0 0 1.4rem;
}
.cert-stat-cell {
    background: rgba(201,168,76,0.06);
    border: 1px solid rgba(201,168,76,0.2);
    border-radius: 8px;
    padding: 0.7rem 0.4rem;
}
.cert-stat-icon { font-size: 1.2rem; margin-bottom: 0.2rem; }
.cert-stat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--gold-light);
    line-height: 1;
    margin-bottom: 0.2rem;
}
.cert-stat-label {
    font-size: 0.65rem;
    color: rgba(212,178,85,0.6);
    letter-spacing: 0.03em;
}

/* Section titles */
.cert-section-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: var(--turquoise);
    margin: 0.6rem 0 0.4rem;
}

/* Journey path */
.cert-journey {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.2rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}
.cert-city {
    color: var(--gold-light);
    background: rgba(201,168,76,0.1);
    border: 1px solid rgba(201,168,76,0.25);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
}
.cert-arrow {
    color: var(--gold-dark);
    opacity: 0.6;
    font-size: 0.75rem;
}

/* Patron badges */
.cert-patrons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
}
.cert-patron-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    border: 1px solid transparent;
}
.patron-great { color: #fff; background: rgba(100,200,100,0.2); border-color: rgba(100,200,100,0.5); }
.patron-good  { color: var(--gold-light); background: rgba(201,168,76,0.15); border-color: var(--gold-dark); }
.patron-low   { color: rgba(212,178,85,0.5); background: rgba(201,168,76,0.05); border-color: rgba(201,168,76,0.15); }

/* Score bar */
.cert-score-bar-wrap {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
    direction: ltr;
}
.cert-score-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
}
.cert-score-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--turquoise), var(--gold));
    border-radius: 4px;
    transition: width 1s ease;
}
.cert-score-pct {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--gold-light);
    min-width: 3rem;
    text-align: right;
    direction: rtl;
}

/* Closing verse */
.cert-verse {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: rgba(212,178,85,0.75);
    border-right: 3px solid var(--gold-dark);
    padding-right: 1rem;
    margin: 1rem auto;
    max-width: 500px;
    text-align: right;
    line-height: 2;
}
.cert-verse cite {
    display: block;
    font-size: 0.7rem;
    color: rgba(212,178,85,0.45);
    margin-top: 0.3rem;
    font-style: normal;
}

.cert-date-line {
    font-size: 0.7rem;
    color: rgba(212,178,85,0.4);
    margin-top: 0.5rem;
    letter-spacing: 0.05em;
}

.cert-developer {
    font-size: 1rem;
    color: rgba(212,178,85,0.95);
    margin-top: 0.6rem;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}

/* Action buttons (below the card) */
.cert-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}
.cert-btn-pdf {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: var(--ink);
    font-weight: 700;
    padding: 0.7rem 2rem;
}
.cert-btn-pdf:hover {
    filter: brightness(1.1);
}

/* ================================================================
   PRINT / PDF STYLES
   ================================================================ */

@media print {
    /* Hide everything except the certificate */
    body > * { display: none !important; }
    #screen-ending { display: block !important; }
    #screen-ending * { display: revert !important; }
    .no-print { display: none !important; }

    /* Override game colours with clean light palette */
    body, #screen-ending {
        background: #fff !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .cert-scroll-wrap {
        max-width: 100% !important;
        padding: 0 !important;
    }

    .certificate {
        background: #fff !important;
        border: 2px solid #c9a84c !important;
        box-shadow: none !important;
        border-radius: 8px !important;
        padding: 1.5cm !important;
        page-break-inside: avoid;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .certificate::before,
    .certificate::after { color: #c9a84c !important; opacity: 0.5 !important; }

    /* Text colours for print */
    .cert-game-title  { color: #1a1a2e !important; text-shadow: none !important; }
    .cert-label-top,
    .cert-section-title { color: #4a7c8a !important; }
    .cert-subtitle-line { color: #888 !important; }
    .cert-stat-value  { color: #1a1a2e !important; }
    .cert-stat-label  { color: #555 !important; }
    .cert-stars       { color: #c9a84c !important; }
    .cert-city        { color: #1a1a2e !important; background: #f5ead0 !important; border-color: #c9a84c !important; }
    .cert-arrow       { color: #c9a84c !important; }
    .cert-verse       { color: #333 !important; border-right-color: #c9a84c !important; }
    .cert-verse cite  { color: #888 !important; }
    .cert-date-line   { color: #888 !important; }
    .cert-divider     { color: #c9a84c !important; }
    .cert-star-cluster,
    .cert-ornament-line { filter: none; background: #c9a84c !important; }

    .cert-stat-cell {
        background: #f9f3e8 !important;
        border-color: #c9a84c !important;
    }

    .cert-score-bar   { background: #eee !important; }
    .cert-score-fill  { background: linear-gradient(90deg, #4a7c8a, #c9a84c) !important; }
    .cert-score-pct   { color: #1a1a2e !important; }

    .rank-5 { color: #1a1a2e !important; }
    .rank-2,
    .rank-1 { color: #1a1a2e !important; background: #f5ead0 !important; border-color: #c9a84c !important; }

    .patron-great { color: #2a6b2a !important; background: #e8f5e8 !important; border-color: #4a9a4a !important; }
    .patron-good  { color: #7a5c00 !important; background: #f9f3e8 !important; border-color: #c9a84c !important; }
    .patron-low   { color: #888 !important; background: #f5f5f5 !important; border-color: #ccc !important; }

    .cert-portrait-wrap { border-color: #c9a84c !important; box-shadow: none !important; }
}
