/* Modern Glassmorphism Design System */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --text-color: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --accent-color: #ff6b6b;
    --success-color: #4ade80;
    --error-color: #ff8787;
    --font-main: 'Outfit', sans-serif;
}

body {
    font-family: var(--font-main);
    background: var(--primary-gradient);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    color: var(--text-color);
    overflow-x: hidden;
}

/* Background Shapes for Depth */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    z-index: -1;
    filter: blur(60px);
}

body::before {
    width: 400px;
    height: 400px;
    background: rgba(255, 105, 180, 0.3);
    top: -100px;
    left: -100px;
    animation: float 15s infinite alternate;
}

body::after {
    width: 300px;
    height: 300px;
    background: rgba(64, 224, 208, 0.3);
    bottom: -50px;
    right: -50px;
    animation: float 12s infinite alternate-reverse;
}

@keyframes float {
    0% { transform: translate(0, 0); }
    100% { transform: translate(30px, 30px); }
}

.container {
    max-width: 480px;
    margin: 40px auto;
    background: var(--glass-bg);
    padding: 40px;
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    position: relative;
    animation: slideUp 0.8s ease-out;
}

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

h1 {
    text-align: center;
    color: #fff;
    font-size: 2.5em;
    margin-bottom: 16px;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.level, .timer, .score, .highscore {
    text-align: center;
    margin-top: 12px;
    font-weight: 500;
    font-size: 1.1em;
    color: var(--text-secondary);
}

.question {
    font-size: 2.2em;
    margin: 32px 0 24px 0;
    text-align: center;
    color: #fff;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

select, input[type="number"] {
    width: 100%;
    padding: 14px;
    font-size: 1.1em;
    margin-bottom: 20px;
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    box-sizing: border-box;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-family: var(--font-main);
    transition: all 0.3s ease;
}

select option {
    background: #333;
    color: #fff;
}

select:focus, input[type="number"]:focus {
    border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.2);
    outline: none;
    box-shadow: 0 0 15px rgba(255,255,255,0.1);
}

button {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1.2em;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.5);
    background: linear-gradient(135deg, #ff8e53 0%, #ff6b6b 100%);
}

button:active {
    transform: translateY(-1px);
}

.feedback {
    text-align: center;
    margin-top: 20px;
    font-size: 1.2em;
    font-weight: 600;
    min-height: 60px;
    padding: 12px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.progress-container {
    background: rgba(0,0,0,0.2);
    padding: 16px;
    border-radius: 16px;
    margin-top: 24px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-bar-bg {
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    height: 10px;
    width: 100%;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar div {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #2ecc71);
    border-radius: 8px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

/* Pulsing animation for streaks */
#streak-progress {
    background: linear-gradient(90deg, #ffd700, #ffaa00);
    animation: pulse 1.5s infinite alternate;
}

@keyframes pulse {
    0% { opacity: 0.8; box-shadow: 0 0 5px rgba(255, 215, 0, 0.5); }
    100% { opacity: 1; box-shadow: 0 0 15px rgba(255, 215, 0, 0.8); }
}

.timer {
    font-size: 1.3em;
    color: #ff8787;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.leaderboard {
    margin-top: 40px;
    background: rgba(0,0,0,0.2);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(255,255,255,0.05);
}

.leaderboard h2 {
    text-align: center;
    color: #fff;
    font-size: 1.4em;
    margin-bottom: 16px;
}

.leaderboard ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.leaderboard li {
    background: rgba(255,255,255,0.1);
    margin: 8px 0;
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.05em;
    color: #fff;
    transition: transform 0.2s;
}

.leaderboard li:hover {
    transform: scale(1.02);
    background: rgba(255,255,255,0.15);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

/* Responsive */
@media (max-width: 500px) {
    .container {
        margin: 20px auto;
        padding: 24px;
        width: 90%;
    }
    h1 { font-size: 2em; }
    .question { font-size: 1.8em; }
}

/* 2026 quality pass: premium math arcade skin. */
:root {
    --primary-gradient:
        radial-gradient(circle at 14% 10%, rgba(84, 222, 255, 0.2), transparent 34%),
        radial-gradient(circle at 86% 12%, rgba(255, 203, 92, 0.15), transparent 30%),
        linear-gradient(180deg, #07111b 0%, #111b2a 55%, #180f20 100%);
    --glass-bg: rgba(255, 246, 220, 0.08);
    --glass-border: rgba(255, 246, 220, 0.14);
    --glass-shadow: 0 28px 78px rgba(0, 0, 0, 0.42);
    --text-color: #fff4df;
    --text-secondary: rgba(255, 244, 223, 0.72);
    --accent-color: #ff934d;
    --success-color: #61e6a1;
    --error-color: #ff755c;
}

body::before,
body::after {
    display: none;
}

.container {
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 246, 220, 0.11), rgba(255, 246, 220, 0.045)),
        rgba(7, 17, 27, 0.8);
    box-shadow:
        var(--glass-shadow),
        inset 0 1px 0 rgba(255, 246, 220, 0.08);
}

h1 {
    color: var(--text-color);
    font-size: clamp(2.2em, 8vw, 3.2em);
}

.level,
.timer,
.score,
.highscore,
.feedback,
.leaderboard li {
    color: var(--text-secondary);
}

.question {
    border: 1px solid rgba(84, 222, 255, 0.16);
    border-radius: 16px;
    padding: 22px;
    background: rgba(5, 12, 18, 0.42);
    color: var(--text-color);
    box-shadow: inset 0 1px 0 rgba(255, 246, 220, 0.08);
}

select,
input[type="number"],
.progress-container,
.leaderboard {
    border: 1px solid rgba(255, 246, 220, 0.12);
    background: rgba(5, 12, 18, 0.42);
}

button {
    border-radius: 999px;
    color: #1a1008;
    background: linear-gradient(180deg, #ffd36d, #ff934d);
    box-shadow: 0 14px 30px rgba(255, 147, 77, 0.24);
}

button:hover {
    background: linear-gradient(180deg, #ffe08a, #ff9d5c);
}

.leaderboard li {
    border: 1px solid rgba(255, 246, 220, 0.1);
    background: rgba(255, 246, 220, 0.07);
}

/* Final quality override: keep controls inside the stage and prevent overlap. */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    display: grid;
    grid-template-columns: minmax(0, 520px) minmax(240px, 320px);
    gap: 30px;
    align-items: start;
    justify-content: center;
    padding: 32px 18px;
    background: var(--primary-gradient) !important;
}

.customization {
    order: 2;
    position: sticky !important;
    top: 24px !important;
    right: auto !important;
    z-index: 1 !important;
    align-self: start;
    min-width: 0 !important;
    width: 100% !important;
    padding: 18px !important;
    border: 1px solid rgba(255, 246, 220, 0.14) !important;
    border-radius: 18px !important;
    background:
        linear-gradient(180deg, rgba(255, 246, 220, 0.1), rgba(255, 246, 220, 0.045)),
        rgba(7, 17, 27, 0.82) !important;
    box-shadow: 0 22px 58px rgba(0, 0, 0, 0.32) !important;
    color: var(--text-color);
}

.customization label {
    display: block;
    margin: 0 0 7px !important;
    color: var(--text-secondary);
    font-size: 0.86rem;
    text-align: left;
}

.customization select {
    margin: 0 0 14px !important;
    border-color: rgba(255, 246, 220, 0.14) !important;
    background: rgba(5, 12, 18, 0.52) !important;
}

#avatar-display {
    display: grid;
    place-items: center;
    width: 78px;
    height: 78px;
    margin: 6px auto 0 !important;
    border: 1px solid rgba(255, 246, 220, 0.14);
    border-radius: 18px;
    background: rgba(255, 246, 220, 0.08);
}

.container {
    order: 1;
    width: 100%;
    max-width: 520px;
    margin: 0;
}

#auth-form {
    border: 1px solid rgba(255, 246, 220, 0.12) !important;
    background: rgba(5, 12, 18, 0.42) !important;
}

#auth-title,
#toggle-auth {
    color: #ffd36d !important;
}

@media (max-width: 900px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    body {
        display: block;
        padding: 12px;
    }

    .customization {
        position: static !important;
        width: 100% !important;
        max-width: 520px;
        margin: 0 auto 16px !important;
    }

    .container {
        width: 100%;
        max-width: 520px;
        margin: 0 auto;
    }

    #customization select,
    #auth-form,
    #auth-form input,
    #auth-form button {
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 420px) {
    body {
        padding: 8px;
    }

    .customization,
    .container {
        border-radius: 16px !important;
    }

    .container {
        padding: 18px;
    }
}
