:root {
    /* Base Colors - WARM DARK + FRIENDLY GOLD */
    --bg-main: #0F172A;
    /* main background (soft dark navy) */
    --bg-card: #1E293B;
    /* cards, modals, panels */
    --bg-overlay: rgba(15, 23, 42, 0.85);

    /* Text Colors */
    --text-main: #F8FAFC;
    /* primary text */
    --text-muted: #94A3B8;
    /* secondary text */

    /* Accent Colors */
    --accent-gold: #F7C948;
    /* primary accent, buttons, winners */
    --accent-green: #22C55E;
    /* success, correct, win */
    --accent-red: #EF4444;
    /* elimination, error */
    --accent-blue: #60A5FA;
    /* waiting, turn indicator, info */
    --accent-gray: #64748B;
    /* disabled, locked */

    /* Glass Effects */
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Tajawal', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-main);
}

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

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

.text-danger {
    color: var(--accent-red);
}

.text-success {
    color: var(--accent-green);
}

/* Layout & Containers */
.container {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Cinematic Card Base */
.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    transition: var(--transition-normal);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-normal);
    border: 2px solid transparent;
    font-size: 1rem;
    text-decoration: none;
    gap: 0.5rem;
    outline: none;
}

.btn:active {
    transform: scale(0.96);
}

/* Primary Button - Gold Theme */
.btn-primary {
    background: var(--accent-gold);
    color: #0F172A;
    /* dark navy */
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(247, 201, 72, 0.3);
    background: #FFD666;
}

/* Secondary Button - Outlined Gold */
.btn-secondary {
    background: transparent;
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(247, 201, 72, 0.1);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.btn-danger:hover:not(:disabled) {
    background: var(--accent-red);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--accent-gray);
    border-color: transparent;
    color: var(--bg-main);
}

/* Forms & Inputs */
.input-group {
    margin-bottom: 1.25rem;
}

.input-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
}

input[type="text"],
input[type="number"],
input[type="password"] {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-main);
    font-size: 1rem;
    transition: var(--transition-fast);
}

input:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(247, 201, 72, 0.1);
    background: rgba(15, 23, 42, 0.8);
}

/* Input Error State */
input.input-error {
    border-color: var(--accent-red) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.input-error-msg {
    color: var(--accent-red);
    font-size: 0.8rem;
    margin-top: 0.35rem;
    display: none;
}

.input-error-msg.visible {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* Header */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
}

.header-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--accent-gold);
    text-decoration: none;
}

/* RTL Styles */
[dir="rtl"] {
    text-align: right;
}

[dir="ltr"] {
    text-align: left;
}

/* Utilities */
.screen {
    display: none;
    animation: fadeIn var(--transition-normal);
    min-height: 100vh;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

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

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

.flex-1 {
    flex: 1;
}

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

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

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

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

.w-full {
    width: 100%;
}

.mt-sm {
    margin-top: 0.75rem;
}

.mt-md {
    margin-top: 1.5rem;
}

.mt-lg {
    margin-top: 2rem;
}

.mt-xl {
    margin-top: 3rem;
}

.mb-sm {
    margin-bottom: 0.75rem;
}

.mb-md {
    margin-bottom: 1.5rem;
}

.mb-lg {
    margin-bottom: 2rem;
}

.mb-xl {
    margin-bottom: 3rem;
}

.gap-sm {
    gap: 0.75rem;
}

.gap-md {
    gap: 1.5rem;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==================== Global Toast Notifications ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border-radius: 8px;
    border-left: 4px solid var(--accent-gold);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: toastSlideIn 0.3s ease;
    max-width: 350px;
}

[dir="rtl"] .toast {
    border-left: none;
    border-right: 4px solid var(--accent-gold);
}

/* ERROR TOAST - BRIGHT RED FOR VISIBILITY */
.toast.error {
    border-color: #e74c3c;
    background: #e74c3c;
    color: #ffffff;
    font-weight: 600;
}

.toast.success {
    border-color: var(--accent-green);
}

.toast.info {
    border-color: var(--accent-blue);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

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

[dir="rtl"] .toast {
    animation-name: toastSlideInRtl;
}

@keyframes toastSlideInRtl {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }

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

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

@keyframes toastFadeOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* ==================== Shared Header & Menu ==================== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(10, 10, 24, 0.9);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.header-logo h1 {
    font-size: 1.8rem;
    margin: 0;
    background: linear-gradient(135deg, var(--accent-gold), #FFD666);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.menu-toggle {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    color: var(--accent-gold);
    width: 45px;
    height: 45px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: 1.5rem;
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-gold);
    transform: scale(1.05);
}

.nav-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1001;
}

[dir="rtl"] .nav-dropdown {
    right: auto;
    left: 0;
}

.nav-dropdown.active {
    display: flex;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.menu-item {
    padding: 0.875rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: 500;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-gold);
}

.menu-item .icon {
    font-size: 1.2rem;
    width: 24px;
}

/* ==================== Premium Lobby Styles ==================== */
.lobby-screen {
    padding-top: 100px !important;
    padding-bottom: 40px;
}

.game-icon-lg {
    font-size: 4rem;
    margin-bottom: 1rem;
    text-align: center;
    display: block;
}

.game-title-lg {
    font-size: 2.22rem;
    font-weight: 900;
    color: var(--accent-gold);
    text-align: center;
    text-shadow: 0 0 20px rgba(247, 201, 72, 0.2);
    margin-bottom: 0.5rem;
}

.game-subtitle-lg {
    font-size: 1.1rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 2.5rem;
}

.lobby-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    max-width: 500px;
    margin: 0 auto;
}

.lobby-card h3 {
    margin-bottom: 1.5rem;
    color: var(--accent-gold);
    text-align: center;
}

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

.btn-premium {
    padding: 1.1rem;
    font-size: 1.15rem;
    width: 100%;
}

.input-premium {
    background: rgba(15, 23, 42, 0.6) !important;
    border: 1px solid var(--glass-border) !important;
    font-size: 1.1rem !important;
    padding: 1.1rem !important;
    text-align: center;
    margin-bottom: 1rem;
}

.input-premium:focus {
    border-color: var(--accent-gold) !important;
    box-shadow: 0 0 0 3px rgba(247, 201, 72, 0.1) !important;
}

.btn-back-ghost {
    background: transparent;
    color: var(--text-muted);
    border: none;
    margin-top: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    text-align: center;
}

/* ==================== Modal Styles ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

[dir="rtl"] .modal-close {
    right: auto;
    left: 1.5rem;
}

.modal-close:hover {
    color: var(--accent-red);
}

.modal-header {
    margin-bottom: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 1rem;
}

.modal-header h2 {
    color: var(--accent-gold);
    font-size: 1.5rem;
}

.modal-body {
    color: var(--text-main);
    line-height: 1.7;
    font-size: 1.05rem;
    text-align: center;
}

.modal-body p {
    margin-bottom: 1rem;
}

.btn-how-to {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn-how-to:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}