:root {
    --bg-dark: #09090b;
    --card-bg: rgba(24, 24, 27, 0.6);
    --border: rgba(255, 255, 255, 0.1);
    --text-primary: #fafafa;
    --text-muted: #a1a1aa;
    --accent: #d946ef;
    --accent-glow: rgba(217, 70, 239, 0.5);
    --correct: #10b981;
    --correct-glow: rgba(16, 185, 129, 0.5);
    --wrong: #ef4444;
    --wrong-glow: rgba(239, 68, 68, 0.5);
    --font-ui: 'Outfit', sans-serif;
    --font-text: 'Lora', serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-ui);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
}

/* Extravagant Background Blobs */
.bg-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    filter: blur(80px);
}

.blob {
    position: absolute;
    border-radius: 50%;
    animation: float 20s infinite alternate ease-in-out;
    opacity: 0.6;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #8b5cf6, transparent 70%);
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #d946ef, transparent 70%);
    bottom: -10%;
    right: -5%;
    animation-delay: -5s;
}

.blob-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #3b82f6, transparent 70%);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

.app-container {
    width: 100%;
    max-width: 900px;
    padding: 2rem;
    position: relative;
    z-index: 10;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fade-in 0.5s ease-out forwards;
}

.screen.active {
    display: flex;
}

.hidden {
    display: none !important;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Start Screen */
.hero {
    text-align: center;
    margin-bottom: 4rem;
    margin-top: 2rem;
}

.main-title {
    font-size: 4rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #fff, #a1a1aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 30px rgba(255, 255, 255, 0.1);
    letter-spacing: -1px;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    font-weight: 300;
}

/* Level Cards */
.level-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2rem;
    width: 100%;
}

.level-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--card-gradient, var(--accent));
    transition: height 0.3s ease;
    opacity: 0.8;
}

.level-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.level-card:hover::before {
    height: 100%;
    opacity: 0.1;
}

.level-card h3 {
    font-size: 1.8rem;
    font-weight: 600;
}

.level-card p {
    color: var(--text-muted);
    line-height: 1.5;
    font-size: 1.05rem;
}

/* Game Screen */
.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: all 0.2s;
    font-weight: 600;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.level-badge {
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-info {
    font-weight: 600;
    color: var(--text-muted);
}

.dictation-card {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 3rem 4rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    margin-bottom: 2rem;
}

.dictation-content {
    font-family: var(--font-text);
    font-size: 1.6rem;
    line-height: 2.2;
    color: #e4e4e7;
    text-align: justify;
}

.gap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    height: 40px;
    padding: 0 12px;
    margin: 0 6px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    vertical-align: middle;
    color: transparent;
    position: relative;
    user-select: none;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 1.3rem;
    top: -2px;
}

.gap::after {
    content: '......';
    position: absolute;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 2px;
}

.gap:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.05);
}

.gap.filled {
    border-style: solid;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.gap.filled::after {
    content: none;
}

.gap.focused {
    box-shadow: 0 0 0 3px var(--accent-glow);
    border-color: var(--accent);
}

.gap.correct {
    border-color: var(--correct);
    background: rgba(16, 185, 129, 0.1);
    box-shadow: 0 0 15px var(--correct-glow);
}

.gap.wrong {
    border-color: var(--wrong);
    background: rgba(239, 68, 68, 0.1);
    box-shadow: 0 0 15px var(--wrong-glow);
    text-decoration: line-through;
    color: var(--wrong);
}

.gap.corrected {
    border-color: var(--correct);
    background: rgba(16, 185, 129, 0.1);
    color: var(--correct);
    margin-left: 8px;
    box-shadow: 0 0 15px var(--correct-glow);
}

/* Highlight specifically the trick letters */
.gap.filled .highlight {
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
    font-weight: 800;
}

.gap.correct .highlight,
.gap.corrected .highlight {
    color: var(--correct);
    text-shadow: 0 0 10px var(--correct-glow);
}

.primary-btn {
    background: linear-gradient(135deg, #d946ef 0%, #8b5cf6 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 16px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 10px 20px rgba(139, 92, 246, 0.3);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(139, 92, 246, 0.5);
    filter: brightness(1.1);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    color: var(--text-muted);
}

/* Overlay and Popover */
#options-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fade-in 0.2s ease-out;
}

#options-popover {
    background: rgba(24, 24, 27, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 320px;
    text-align: center;
    transform: scale(0.95);
    animation: popover-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popover-in {
    to {
        transform: scale(1);
    }
}

.popover-title {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 400;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.option-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 1.2rem 2rem;
    border-radius: 16px;
    font-size: 1.8rem;
    font-family: var(--font-text);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.option-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.option-btn:hover::before {
    transform: translateX(100%);
}

.option-btn .highlight {
    color: var(--accent);
    font-weight: 800;
    text-shadow: 0 0 15px var(--accent-glow);
}

.close-popover-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 1rem;
    margin-top: 1rem;
    transition: color 0.2s;
}

.close-popover-btn:hover {
    color: white;
}

/* Results Screen */
.results-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 3rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    width: 100%;
    text-align: center;
}

.stat-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 8px solid var(--accent);
    box-shadow: 0 0 30px var(--accent-glow), inset 0 0 30px var(--accent-glow);
}

.stat-circle span {
    font-size: 3.5rem;
    font-weight: 800;
}

.stat-circle small {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.score-msg {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    font-weight: 600;
}

.mistakes-list {
    text-align: left;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.mistake-item {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mistake-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.mistake-wrong {
    color: var(--wrong);
    text-decoration: line-through;
    margin-right: 1rem;
}

.mistake-correct {
    color: var(--correct);
    font-weight: bold;
}

/* Utilities */
.mt-4 {
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .main-title {
        font-size: 3rem;
    }

    .dictation-card {
        padding: 2rem;
    }

    .dictation-content {
        font-size: 1.2rem;
        line-height: 2;
    }

    .level-badge {
        display: none;
    }

    .option-btn {
        font-size: 1.4rem;
        padding: 1rem;
    }
}