:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.6);
    --secondary: #ec4899;
    --accent: #8b5cf6;
    --background: #0f172a;
    --surface: rgba(30, 41, 59, 0.7);
    --surface-light: rgba(51, 65, 85, 0.8);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --gold: #fbbf24;
    --silver: #e2e8f0;
    --diamond: #06b6d4;

    --font-main: 'Outfit', sans-serif;
    --radius: 16px;
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --glass: blur(12px) saturate(180%);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--background);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Background Animation */
.background-anim {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, var(--primary-glow) 0%, transparent 20%),
        radial-gradient(circle at 80% 20%, rgba(236, 72, 153, 0.4) 0%, transparent 20%);
    animation: rotateBg 20s linear infinite;
    z-index: -2;
}

@keyframes rotateBg {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    z-index: -1;
}

/* Container */
.app-container {
    width: 90%;
    max-width: 800px;
    min-height: 600px;
    background: var(--surface);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Screens */
.screen {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: flex;
}

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

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

/* Typography & Common */
h1 {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    letter-spacing: -1px;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.hidden {
    display: none !important;
}

/* Information Card */
.info-card {
    background: var(--surface-light);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: left;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.info-card h3 {
    margin-bottom: 1rem;
    color: var(--secondary);
}

.info-card ul {
    list-style-position: inside;
    line-height: 1.6;
}

/* Buttons */
.primary-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.25rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.6);
}

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

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

/* Mode Selection */
.mode-selection {
    margin-top: 1rem;
    width: 100%;
}

.mode-selection p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mode-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-btn {
    background: var(--surface-light);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 160px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.mode-btn i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.2rem;
    transition: transform 0.2s;
}

.mode-btn:hover {
    background: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(99, 102, 241, 0.4);
    border-color: var(--primary);
}

.mode-btn:hover i {
    color: white;
    transform: scale(1.1);
}

/* Login Screen */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 300px;
}

#username-input,
#password-input {
    background: var(--surface-light);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 1.5rem;
    border-radius: 50px;
    color: var(--text);
    font-size: 1.1rem;
    outline: none;
    text-align: center;
    transition: all 0.2s;
    font-family: var(--font-main);
}

#username-input:focus,
#password-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.auth-toggle {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-toggle a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* Game Interface */
.game-header,
.boss-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.stage-indicator span,
.score-indicator span {
    color: var(--primary);
    font-size: 1.4rem;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--success);
    width: 0%;
    /* JS will update */
    transition: width 0.3s ease;
}

.question-container {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
}

.question-text {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    line-height: 1.4;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    width: 100%;
}

.option-btn {
    background: var(--surface-light);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.option-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
}

.option-btn.correct {
    background: var(--success) !important;
    border-color: var(--success) !important;
}

.option-btn.wrong {
    background: var(--danger) !important;
    border-color: var(--danger) !important;
}

/* Boss Mode Specifics */
.boss-title {
    color: var(--danger);
    font-weight: 800;
    letter-spacing: 2px;
    animation: flicker 2s infinite;
}

@keyframes flicker {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

.boss-stats {
    width: 100%;
    display: flex;
    justify-content: space-around;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    color: var(--danger);
}

.timer-container span {
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    font-size: 1.5rem;
    color: var(--gold);
}

/* Result Screen */
.medal-display {
    width: 120px;
    height: 120px;
    background: var(--surface-light);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    margin: 0 auto 1.5rem auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

/* Medal Styles */
.medal-silver {
    background: linear-gradient(135deg, #e2e8f0, #94a3b8);
    color: #0f172a;
    box-shadow: 0 0 20px rgba(226, 232, 240, 0.4);
}

.medal-gold {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: #78350f;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
}

.medal-diamond {
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
    color: white;
    box-shadow: 0 0 25px rgba(6, 182, 212, 0.5);
}

.medal-none {
    background: var(--surface-light);
    border: 2px dashed var(--text-muted);
}

.stats-grid {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0;
}

.stat-box {
    display: flex;
    flex-direction: column;
}

.stat-box .label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.stat-box .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

/* Responsive */
/* Responsive */
@media (max-width: 768px) {
    .app-container {
        width: 95%;
        padding: 1.5rem;
        min-height: auto;
    }

    h1 {
        font-size: 2.5rem;
    }

    .mode-buttons {
        gap: 0.8rem;
    }

    .mode-btn {
        flex: 1 1 calc(50% - 1rem);
        /* 2 columns on tablet */
        min-width: 120px;
    }

    .boss-stats {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }
}

@media (max-width: 480px) {
    :root {
        --radius: 12px;
    }

    .app-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        border: none;
        padding: 1rem;
        justify-content: flex-start;
        overflow-y: auto;
    }

    .screen {
        width: 100%;
        padding-top: 2rem;
    }

    h1 {
        font-size: 2rem;
        margin-top: 1rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .login-form {
        max-width: 100%;
    }

    .mode-buttons {
        flex-direction: column;
    }

    .mode-btn {
        width: 100%;
        flex: 1 1 100%;
    }

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

    .game-header,
    .boss-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
        text-align: center;
    }

    .stats-grid {
        flex-direction: column;
        gap: 1rem;
    }

    .medal-display {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }
}

/* Admin Responsive */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 1.5rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-table {
    margin-top: 0;
    /* Handled by container */
    min-width: 600px;
    /* Force scroll on small screens */
}

@media (max-width: 600px) {
    .admin-container {
        width: 95%;
        padding: 1rem;
        margin: 1rem auto;
    }

    .refresh-btn {
        float: none;
        width: 100%;
        margin-bottom: 1rem;
        text-align: center;
    }
}