@import url('https://fonts.googleapis.com/css2?family=El+Messiri:wght@400;500;600;700&family=Tajawal:wght@300;400;500;700&display=swap');

:root {
    --white: #ffffff;
    --coral: #f08c7e;
    --peach: #ffa197;
    --coral-dark: #e07b6d;
    --teal: #87baba;
    --light-cyan: #e0f7f7;
    --teal-dark: #77a8a8;
    --navy: #0a0730;
    --navy-light: #1d1a4b;
    --dark-gray: #374151;
    --light-gray: #f8f9fa;
    --transition-speed: 0.4s;

    /* Glass */
    --glass-bg: rgba(13, 10, 50, 0.55);
    --glass-border: rgba(240, 140, 126, 0.18);
    --glass-shadow: 0 8px 48px rgba(10, 7, 48, 0.7);
    --glass-blur: blur(18px);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', 'El Messiri', sans-serif;
    background: var(--navy);
    color: var(--white);
    min-height: 100vh;
    overflow-x: hidden;
    direction: rtl;
}

/* ===== BACKGROUND ===== */
.bg-layer {
    position: fixed;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 1s ease, background-image 1.2s ease;
    z-index: 0;
    filter: brightness(0.45) saturate(0.7);
    transform: scale(1.05);
    animation: subtle-pan 30s ease-in-out infinite alternate;
}

@keyframes subtle-pan {
    from {
        transform: scale(1.05) translate(0, 0);
    }

    to {
        transform: scale(1.1) translate(-1.5%, 1%);
    }
}

.bg-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg,
            rgba(10, 7, 48, 0.82) 0%,
            rgba(10, 7, 48, 0.55) 50%,
            rgba(10, 7, 48, 0.85) 100%);
    z-index: 1;
}

.scanlines {
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(to bottom,
            transparent 0px,
            transparent 3px,
            rgba(0, 0, 0, 0.06) 3px,
            rgba(0, 0, 0, 0.06) 4px);
    z-index: 2;
    pointer-events: none;
}

.vignette {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.75) 100%);
    z-index: 3;
    pointer-events: none;
}

/* ===== PARTICLES ===== */
.particles {
    position: fixed;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: var(--coral);
    opacity: 0;
    animation: float-particle linear infinite;
}

@keyframes float-particle {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }

    10% {
        opacity: 0.4;
    }

    90% {
        opacity: 0.15;
    }

    100% {
        transform: translateY(-10vh) scale(1);
        opacity: 0;
    }
}

/* ===== SCREENS ===== */
.screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.7s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* ===== GLASS CARD ===== */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* ===== SPLASH SCREEN ===== */
#splash-screen {
    padding: 1rem;
}

.splash-content {
    max-width: 800px;
    /* Increased from 500px to give text more horizontal space */
    width: 95%;
    /* Use 95% on smaller screens to ensure it doesn't touch the edges */
    padding: 2.5rem 2rem;
    /* Reduced padding from 3rem 2.5rem */
    text-align: center;
    animation: slide-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
    position: relative;
    overflow: hidden;
}

.splash-content::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(240, 140, 126, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.splash-content::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: -40px;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(135, 186, 186, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Logo */
.logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    margin-bottom: 1.5rem;
}

.logo-icon svg {
    width: 56px;
    height: 56px;
    filter: drop-shadow(0 0 12px rgba(240, 140, 126, 0.5));
    animation: logo-pulse 3s ease-in-out infinite;
}

@keyframes logo-pulse {

    0%,
    100% {
        filter: drop-shadow(0 0 10px rgba(240, 140, 126, 0.4));
    }

    50% {
        filter: drop-shadow(0 0 22px rgba(240, 140, 126, 0.8));
    }
}

.logo-text {
    font-family: 'El Messiri', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--coral) 0%, var(--teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 3px;
}

.splash-badge {
    display: inline-block;
    background: rgba(240, 140, 126, 0.15);
    border: 1px solid rgba(240, 140, 126, 0.3);
    color: var(--coral);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3rem 1rem;
    border-radius: 50px;
    letter-spacing: 2px;
    margin-bottom: 1rem;
}

.splash-title {
    font-family: 'El Messiri', sans-serif;
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 0.4rem;
    background: linear-gradient(135deg, #fff 0%, var(--coral) 60%, var(--teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

.splash-subtitle {
    font-size: 0.9rem;
    color: var(--teal);
    letter-spacing: 1px;
    margin-bottom: 1.2rem;
}

.splash-desc {
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.splash-divider {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.8rem;
}

.splash-divider span:first-child,
.splash-divider span:last-child {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(240, 140, 126, 0.4), transparent);
}

.divider-icon {
    color: var(--coral);
    font-size: 0.75rem;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: linear-gradient(135deg, var(--coral) 0%, var(--coral-dark) 100%);
    color: white;
    font-family: 'El Messiri', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.85rem 2.2rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 24px rgba(240, 140, 126, 0.35);
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(240, 140, 126, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(135, 186, 186, 0.12);
    color: var(--teal);
    border: 1px solid rgba(135, 186, 186, 0.3);
    font-family: 'El Messiri', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.7rem 1.8rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(135, 186, 186, 0.22);
    transform: translateY(-2px);
}

.pulse-glow {
    animation: pulse-glow-anim 2.5s ease-in-out infinite;
}

@keyframes pulse-glow-anim {

    0%,
    100% {
        box-shadow: 0 4px 24px rgba(240, 140, 126, 0.35);
    }

    50% {
        box-shadow: 0 4px 40px rgba(240, 140, 126, 0.65), 0 0 0 8px rgba(240, 140, 126, 0.1);
    }
}

.audio-hint {
    margin-top: 1.2rem;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

/* ===== GAME SCREEN ===== */
#game-screen {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    overflow-y: auto;
    padding: 0;
}

/* TOP BAR */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.2rem;
    border-radius: 0 0 16px 16px;
    border-top: none;
    margin: 0 0.5rem;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.top-bar-left,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.top-bar-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.logo-mini {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.3s;
}

.logo-mini:hover {
    opacity: 1;
}

.logo-mini svg {
    width: 28px;
    height: 28px;
}

.logo-mini span {
    font-family: 'El Messiri', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    background: linear-gradient(135deg, var(--coral), var(--teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.scene-indicator {
    font-family: 'Tajawal', sans-serif;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.scene-indicator #scene-num {
    color: var(--coral);
    font-weight: 600;
}

.scene-sep {
    color: rgba(255, 255, 255, 0.3);
}

.progress-bar-wrap {
    width: 100%;
    max-width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--teal-dark), var(--coral));
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 8px rgba(240, 140, 126, 0.5);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: rgba(240, 140, 126, 0.15);
    border-color: rgba(240, 140, 126, 0.3);
    color: var(--coral);
    transform: scale(1.1);
}

/* GAME MAIN */
.game-main {
    flex: 1;
    padding: 1rem 1.5rem 2rem;
    max-width: 1000px;
    /* Increased from 800px */
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    overflow-y: visible;
    /* Let the parent #game-screen handle scroll */
}

/* SCENE CARD */
.scene-card {
    padding: 1.5rem 2rem;
    /* Reduced from 2rem padding */
    animation: scene-enter 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes scene-enter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.scene-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
    /* Reduced from 1.2rem */
    padding-bottom: 0.6rem;
    /* Reduced from 1rem */
    border-bottom: 1px solid rgba(240, 140, 126, 0.15);
}

.scene-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, rgba(240, 140, 126, 0.2), rgba(240, 140, 126, 0.08));
    border: 1px solid rgba(240, 140, 126, 0.3);
    color: var(--coral);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.8rem;
    border-radius: 50px;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.scene-title {
    font-family: 'El Messiri', sans-serif;
    font-size: clamp(1rem, 3vw, 1.25rem);
    font-weight: 600;
    color: var(--white);
    line-height: 1.4;
}

.scene-text {
    font-family: 'Tajawal', sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    line-height: 2;
    color: rgba(255, 255, 255, 0.82);
    text-align: justify;
    animation: text-fade 0.8s ease both 0.3s;
    /* Limit height of long story texts */
    max-height: 35vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom scrollbar for text */
.scene-text::-webkit-scrollbar {
    width: 6px;
}

.scene-text::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.scene-text::-webkit-scrollbar-thumb {
    background: var(--coral);
    border-radius: 4px;
}

@keyframes text-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Typing cursor effect */
.scene-text.typing::after {
    content: '|';
    animation: blink 0.8s step-end infinite;
    color: var(--coral);
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* CHOICES */
.choices-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    animation: choices-enter 0.5s ease both 0.5s;
    /* Limit height and allow scrolling inside the choices area */
    max-height: 45vh;
    overflow-y: auto;
    padding-right: 0.5rem;
    /* Add small padding so scrollbar doesn't overlap text */
}

/* Custom scrollbar for choices */
.choices-container::-webkit-scrollbar {
    width: 6px;
}

.choices-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.choices-container::-webkit-scrollbar-thumb {
    background: var(--teal);
    border-radius: 4px;
}

@keyframes choices-enter {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.choice-btn {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: rgba(13, 10, 50, 0.5);
    border: 1px solid rgba(240, 140, 126, 0.15);
    border-radius: 14px;
    padding: 1.1rem 1.3rem;
    cursor: pointer;
    text-align: right;
    transition: all 0.35s ease;
    overflow: hidden;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.7;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: choice-slide 0.4s ease both;
}

.choice-btn:nth-child(1) {
    animation-delay: 0.1s;
}

.choice-btn:nth-child(2) {
    animation-delay: 0.2s;
}

.choice-btn:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes choice-slide {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.choice-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(240, 140, 126, 0.08), rgba(135, 186, 186, 0.05));
    opacity: 0;
    transition: opacity 0.35s ease;
}

.choice-btn::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 0;
    background: linear-gradient(to bottom, var(--coral), var(--teal));
    border-radius: 0 14px 14px 0;
    transition: height 0.35s ease;
}

.choice-btn:hover {
    border-color: rgba(240, 140, 126, 0.4);
    transform: translateX(-4px);
    box-shadow: 0 4px 24px rgba(10, 7, 48, 0.5), 4px 0 16px rgba(240, 140, 126, 0.15);
    color: white;
}

.choice-btn:hover::before {
    opacity: 1;
}

.choice-btn:hover::after {
    height: 100%;
}

.choice-btn:active {
    transform: translateX(-2px) scale(0.99);
}

.choice-num {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    background: linear-gradient(135deg, rgba(240, 140, 126, 0.2), rgba(240, 140, 126, 0.08));
    border: 1px solid rgba(240, 140, 126, 0.3);
    border-radius: 50%;
    font-family: 'El Messiri', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--coral);
    flex-shrink: 0;
    margin-top: 0.1rem;
    transition: all 0.3s ease;
}

.choice-btn:hover .choice-num {
    background: var(--coral);
    color: white;
    border-color: var(--coral);
}

.choice-content {
    flex: 1;
}

.choice-action {
    color: var(--teal);
    font-weight: 600;
    font-size: 0.88rem;
    display: block;
    margin-bottom: 0.3rem;
}

.choice-result {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* ENDING PANEL */
.ending-panel {
    text-align: center;
    padding: 2.5rem 2rem;
    animation: scene-enter 0.6s ease both;
    border-color: rgba(240, 140, 126, 0.3);
}

.ending-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: icon-bounce 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.2s;
}

@keyframes icon-bounce {
    from {
        opacity: 0;
        transform: scale(0.3);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ending-title {
    font-family: 'El Messiri', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--coral);
    margin-bottom: 0.8rem;
}

.ending-text {
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.9;
    max-width: 500px;
    margin: 0 auto 1.8rem;
}

.ending-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fade-in 0.2s ease;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    max-width: 340px;
    width: 90%;
    padding: 2rem;
    text-align: center;
    animation: slide-up 0.3s ease;
}

.modal p {
    font-family: 'El Messiri', sans-serif;
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

.modal-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
}

.modal-actions .btn-primary {
    max-width: 100px;
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
}

.modal-actions .btn-secondary {
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
}

/* UTILITY */
.hidden {
    display: none !important;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--coral-dark), var(--teal-dark));
    border-radius: 10px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .splash-content {
        padding: 2rem 1.5rem;
    }

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

    .top-bar {
        margin: 0;
        border-radius: 0;
    }

    .scene-card {
        padding: 1.4rem 1.2rem;
    }

    .scene-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .scene-title {
        font-size: 1rem;
    }

    .scene-text {
        font-size: 0.88rem;
        line-height: 1.9;
    }

    .choice-btn {
        padding: 0.9rem 1rem;
        font-size: 0.875rem;
    }

    .choice-action {
        font-size: 0.83rem;
    }

    .choice-result {
        font-size: 0.8rem;
    }

    .game-main {
        padding: 0.8rem 0.6rem 2rem;
        gap: 0.8rem;
    }
}

@media (max-width: 400px) {
    .logo-mini span {
        display: none;
    }

    .progress-bar-wrap {
        max-width: 120px;
    }
}