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

:root {
    --bg-gradient-start: #f5f7fa;
    --bg-gradient-end: #e4e8ec;
    --container-bg: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-label: #34495e;
    --border-color: #dce1e6;
    --input-bg: #fafbfc;
    --header-border: #eee;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --qatar-primary: #8A1538;
    --qatar-dark: #6B102C;
}

body[data-theme="dark"] {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --container-bg: #252542;
    --text-primary: #e4e6eb;
    --text-secondary: #a0a3a8;
    --text-label: #b0b3b8;
    --border-color: #3a3a5c;
    --input-bg: #1e1e38;
    --header-border: #3a3a5c;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    padding: 40px 20px;
    color: var(--text-primary);
    transition: color 0.3s ease;
    position: relative;
    overflow-x: hidden;
}


/* ===================== */
/* Video Backgrounds */
/* ===================== */
.video-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
}

/* Light Mode Video */
.light-video {
    display: block;
}

body[data-theme="dark"] .light-video {
    display: none;
}

/* Dark Mode Video */
.dark-video {
    display: none;
}

body[data-theme="dark"] .dark-video {
    display: block;
}

/* ===================== */
/* Intro Pages */
.intro-page {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    z-index: 3000;
    padding: 20px;
}

.intro-page.hidden {
    display: none !important;
}

.main-app.hidden {
    display: none !important;
}

.intro-container {
    background: var(--container-bg);
    border-radius: 20px;
    padding: 50px 40px;
    text-align: center;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 60px var(--shadow-color);
}

.intro-logo img {
    width: 100px;
    height: auto;
    margin-bottom: 25px;
}

.intro-title {
    color: var(--qatar-primary);
    font-size: 2rem;
    margin-bottom: 10px;
}

.intro-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 35px;
}

.lang-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.lang-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 25px 40px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    background: var(--input-bg);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.lang-btn:hover {
    border-color: var(--qatar-primary);
    background: var(--container-bg);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px var(--shadow-color);
}

.lang-flag {
    font-size: 2.5rem;
}

.lang-flag-img {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Theme Selection Buttons */
.theme-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 20px;
}

.theme-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 30px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    background: var(--input-bg);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.theme-btn:hover {
    border-color: var(--qatar-primary);
    background: var(--container-bg);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px var(--shadow-color);
}

.theme-btn.active {
    border-color: var(--qatar-primary);
    background: var(--qatar-primary);
    color: #fff;
}

.theme-btn.active svg {
    stroke: #fff;
}

.theme-btn svg {
    stroke: var(--text-primary);
}

/* Story Page */
.story-container {
    max-width: 600px;
}

.story-title {
    color: var(--qatar-primary);
    font-size: 1.8rem;
    margin-bottom: 25px;
}

.story-content {
    text-align: left;
    margin-bottom: 30px;
}

[dir="rtl"] .story-content {
    text-align: right;
}

.story-content p {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 18px;
}

.story-question {
    color: var(--qatar-primary) !important;
    font-weight: 600;
    font-size: 1.1rem !important;
    text-align: center !important;
    margin-top: 25px;
}


.ok-btn {
    padding: 16px 60px;
    background: var(--qatar-primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.ok-btn:hover {
    background: var(--qatar-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(138, 21, 56, 0.3);
}

@media (max-width: 540px) {
    .intro-container {
        padding: 35px 25px;
    }

    .lang-buttons {
        flex-direction: column;
        gap: 15px;
    }

    .lang-btn {
        padding: 20px 30px;
        flex-direction: row;
    }

    .lang-flag {
        font-size: 2rem;
    }

    .intro-title {
        font-size: 1.6rem;
    }
}

/* Controls Container */
.controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

[dir="rtl"] .controls {
    right: auto;
    left: 20px;
}

/* Language Toggle Button */
.lang-toggle {
    height: 50px;
    padding: 0 20px;
    border-radius: 25px;
    border: none;
    background: var(--container-bg);
    box-shadow: 0 4px 15px var(--shadow-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--qatar-primary);
}

.lang-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px var(--shadow-color);
}

/* Theme Toggle Button */
.theme-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--container-bg);
    box-shadow: 0 4px 15px var(--shadow-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px var(--shadow-color);
}

.theme-toggle svg {
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

body[data-theme="dark"] .sun-icon {
    display: block;
}

body[data-theme="dark"] .moon-icon {
    display: none;
}

.container {
    max-width: 580px;
    margin: 0 auto;
    background: var(--container-bg);
    padding: 50px;
    border-radius: 16px;
    box-shadow: 0 20px 60px var(--shadow-color);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--header-border);
}

.logo-container {
    margin-bottom: 20px;
}

.qatar-logo {
    width: 80px;
    height: auto;
    border-radius: 4px;
}

h1 {
    color: #8A1538;
    margin-bottom: 8px;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-label);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--input-bg);
    transition: all 0.2s ease;
}

input:hover, select:hover {
    border-color: var(--qatar-primary);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--qatar-primary);
    background: var(--container-bg);
    box-shadow: 0 0 0 4px rgba(138, 21, 56, 0.15);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237f8c8d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.btn {
    width: 100%;
    padding: 16px 24px;
    background: var(--qatar-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
}

.btn:hover {
    background: var(--qatar-dark);
    box-shadow: 0 8px 20px rgba(138, 21, 56, 0.3);
    transform: translateY(-1px);
}

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

.alert {
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.alert h2 {
    font-size: 0.8rem;
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
}

.alert.success {
    background: #f0fdf4;
    border: 1px solid #86efac;
}

body[data-theme="dark"] .alert.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.alert.danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

body[data-theme="dark"] .alert.danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert.error {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
}

body[data-theme="dark"] .alert.error {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fcd34d;
}

.result {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.survived {
    color: #166534;
}

body[data-theme="dark"] .survived {
    color: #4ade80;
}

.not-survived {
    color: #991b1b;
}

body[data-theme="dark"] .not-survived {
    color: #f87171;
}

.result-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.result-icon {
    width: 80px;
    height: 80px;
}

.survivor-icon {
    animation: pulse 1.5s ease infinite;
}

.death-icon {
    animation: shake 0.5s ease infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* Blood Drips Effect */
.blood-drips {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    border-radius: 12px;
}

.blood-drip {
    position: absolute;
    top: -20px;
    width: 8px;
    height: 0;
    background: linear-gradient(180deg, #8B0000 0%, #DC143C 50%, #8B0000 100%);
    border-radius: 0 0 4px 4px;
    animation: drip 2s ease-in-out infinite;
}

.blood-drip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: #DC143C;
    border-radius: 50%;
}

.blood-drip:nth-child(1) { left: 10%; animation-delay: 0s; }
.blood-drip:nth-child(2) { left: 30%; animation-delay: 0.4s; }
.blood-drip:nth-child(3) { left: 50%; animation-delay: 0.8s; }
.blood-drip:nth-child(4) { left: 70%; animation-delay: 0.2s; }
.blood-drip:nth-child(5) { left: 90%; animation-delay: 0.6s; }

@keyframes drip {
    0% {
        height: 0;
        top: -20px;
        opacity: 1;
    }
    50% {
        height: 60px;
        top: 20px;
        opacity: 1;
    }
    100% {
        height: 60px;
        top: 100%;
        opacity: 0;
    }
}

.alert.danger {
    position: relative;
    overflow: hidden;
}

.probability {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.probability-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    margin-top: 12px;
    overflow: hidden;
}

.probability-fill {
    height: 100%;
    background: linear-gradient(90deg, #8A1538, #c41e3a);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--header-border);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* New Modal Styles */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999;
}

.modal-backdrop.is-open {
    display: flex;
}

.modal {
    width: min(520px, 100%);
    background: var(--container-bg);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transform: translateY(6px);
    opacity: 0;
    transition: 0.18s ease;
}

.modal-backdrop.is-open .modal {
    transform: translateY(0);
    opacity: 1;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 16px;
    margin: 0;
    color: var(--text-primary);
}

.close-btn {
    border: 0;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 10px;
    color: var(--text-secondary);
}

.close-btn:hover {
    background: var(--input-bg);
}

.modal-body {
    padding: 16px 18px 18px;
}

.modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.modal-card {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 14px;
    background: var(--input-bg);
}

.image-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    aspect-ratio: 1/1;
    overflow: hidden;
}

.image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.modal-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: var(--container-bg);
}

.modal-hint {
    margin: 10px 2px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.modal-btn {
    border: 1px solid var(--border-color);
    background: var(--container-bg);
    padding: 10px 14px;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.modal-btn.primary {
    background: var(--qatar-primary);
    color: #fff;
    border-color: var(--qatar-primary);
}

.modal-btn.primary:hover {
    background: var(--qatar-dark);
}

/* Survival Modal Theme */
.modal-backdrop.survival .modal {
    border: 2px solid #22c55e;
}

.modal-backdrop.survival .modal-header {
    background: linear-gradient(90deg, #f0fdf4 0%, #dcfce7 100%);
    border-bottom-color: #86efac;
}

body[data-theme="dark"] .modal-backdrop.survival .modal-header {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.1) 0%, rgba(34, 197, 94, 0.2) 100%);
}

.modal-backdrop.survival .modal-header h2 {
    color: #166534;
}

body[data-theme="dark"] .modal-backdrop.survival .modal-header h2 {
    color: #4ade80;
}

.survival-image {
    animation: survivalPulse 1.5s ease-in-out infinite;
}

@keyframes survivalPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 40px rgba(34, 197, 94, 0.5);
    }
}

.popup-confetti {
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 2rem;
    margin-top: 15px;
}

.popup-confetti span {
    animation: float 2s ease-in-out infinite;
}

.popup-confetti span:nth-child(1) { animation-delay: 0s; }
.popup-confetti span:nth-child(2) { animation-delay: 0.2s; }
.popup-confetti span:nth-child(3) { animation-delay: 0.4s; }
.popup-confetti span:nth-child(4) { animation-delay: 0.6s; }
.popup-confetti span:nth-child(5) { animation-delay: 0.8s; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Death Modal Theme */
.modal-backdrop.death {
    background: rgba(30, 0, 0, 0.85);
}

.modal-backdrop.death .modal {
    background: linear-gradient(180deg, #1a0000 0%, #2d0000 100%);
    border: 2px solid #8B0000;
}

body[data-theme="dark"] .modal-backdrop.death .modal {
    background: linear-gradient(180deg, #0d0000 0%, #1a0000 100%);
}

.modal-backdrop.death .modal-header {
    background: linear-gradient(90deg, #2d0000 0%, #3d0000 100%);
    border-bottom-color: #8B0000;
}

.modal-backdrop.death .modal-header h2 {
    color: #DC143C;
    text-shadow: 0 0 10px rgba(220, 20, 60, 0.5);
}

.modal-backdrop.death .modal-body {
    color: #999;
}

.modal-backdrop.death .modal-card {
    background: rgba(139, 0, 0, 0.1);
    border-color: #5a0000;
}

.modal-backdrop.death .image-wrap {
    background: #1a0000;
    border-color: #5a0000;
}

.modal-backdrop.death .modal-footer {
    background: #1a0000;
    border-top-color: #8B0000;
}

.modal-backdrop.death .close-btn {
    color: #DC143C;
}

.modal-backdrop.death .close-btn:hover {
    background: #3a0000;
}

.modal-backdrop.death .modal-btn {
    background: #3a0000;
    border-color: #5a0000;
    color: #ccc;
}

.modal-backdrop.death .modal-btn.primary {
    background: #8B0000;
    border-color: #8B0000;
    color: #fff;
}

.modal-backdrop.death .modal-btn.primary:hover {
    background: #DC143C;
}

.death-image {
    filter: grayscale(70%) sepia(30%);
    animation: deathPulse 2s ease-in-out infinite;
}

@keyframes deathPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(139, 0, 0, 0.5);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 40px rgba(139, 0, 0, 0.8);
    }
}

.popup-skulls {
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 2rem;
    margin-top: 15px;
}

.popup-skulls span {
    animation: skullFloat 3s ease-in-out infinite;
}

.popup-skulls span:nth-child(1) { animation-delay: 0s; }
.popup-skulls span:nth-child(2) { animation-delay: 0.3s; }
.popup-skulls span:nth-child(3) { animation-delay: 0.6s; }
.popup-skulls span:nth-child(4) { animation-delay: 0.9s; }
.popup-skulls span:nth-child(5) { animation-delay: 1.2s; }

@keyframes skullFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-5px) rotate(-5deg); }
    75% { transform: translateY(-5px) rotate(5deg); }
}

.blood-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    pointer-events: none;
    border-radius: 16px;
    overflow: hidden;
}

.blood-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg,
        transparent 0%,
        #8B0000 20%,
        #DC143C 50%,
        #8B0000 80%,
        transparent 100%
    );
    animation: bloodPulse 2s ease-in-out infinite;
}

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

/* Probability display in modal */
.modal-probability {
    text-align: center;
    padding: 10px;
}

.modal-probability .probability-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.modal-backdrop.death .modal-probability .probability-text {
    color: #999;
}

.modal-probability .probability-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.modal-backdrop.death .modal-probability .probability-bar {
    background: #3a0000;
}

.modal-probability .probability-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.modal-backdrop.survival .modal-probability .probability-fill {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.modal-backdrop.death .modal-probability .probability-fill {
    background: linear-gradient(90deg, #8B0000, #DC143C);
}

@media (max-width: 540px) {
    .modal-row {
        grid-template-columns: 1fr;
    }
}

/* RTL Support */
[dir="rtl"] {
    font-family: 'Segoe UI', Tahoma, 'Arial', sans-serif;
}

[dir="rtl"] select {
    background-position: left 16px center;
    padding-left: 40px;
    padding-right: 16px;
}

[dir="rtl"] .probability-fill {
    border-radius: 4px;
}

@media (max-width: 540px) {
    .container {
        padding: 30px 25px;
    }

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

    h1 {
        font-size: 1.4rem;
    }

    .controls {
        top: 10px;
        right: 10px;
        gap: 8px;
    }

    [dir="rtl"] .controls {
        right: auto;
        left: 10px;
    }

    .lang-toggle {
        height: 40px;
        padding: 0 15px;
        font-size: 0.8rem;
    }

    .theme-toggle {
        width: 40px;
        height: 40px;
    }
}
