/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Modern color palette */
    --primary: #5b47fb;
    --primary-dark: #4936d8;
    --primary-light: #7c6bff;
    --secondary: #00d4aa;
    --danger: #ff5e5e;
    --warning: #ffb347;
    --success: #00c896;

    /* Neutrals */
    --bg-dark: #0f0e17;
    --bg-medium: #1a1825;
    --bg-light: #2d2b3d;
    --surface: #ffffff;
    --surface-hover: #f8f9fa;

    /* Text colors */
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --text-light: #b2bec3;
    --text-white: #ffffff;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1e1e2e 0%, #2d2b3d 100%);
    min-height: 100vh;
    color: var(--text-primary);
    position: relative;
    overflow-x: hidden;
}

/* Add subtle animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(91, 71, 251, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(0, 212, 170, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(124, 107, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    padding: var(--spacing-lg);
    position: relative;
    z-index: 1;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

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

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

/* Welcome Screen */
.welcome-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

#welcome-screen h1 {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -1px;
}

.header-buttons {
    display: flex;
    gap: var(--spacing-sm);
}

.icon-btn-small {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-white);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#settings-btn {
    font-size: 1.25rem;
    padding: var(--spacing-sm) var(--spacing-sm);
}

.icon-btn-small::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.icon-btn-small:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(91, 71, 251, 0.2);
}

.icon-btn-small:hover::before {
    transform: translateX(0);
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-light);
    text-align: center;
    margin-bottom: var(--spacing-2xl);
    font-weight: 400;
}

.level-select {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-xl);
    margin-bottom: var(--spacing-xl);
    position: relative;
    overflow: hidden;
}

.level-select::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    opacity: 0.05;
    border-radius: 50%;
    transform: translate(50px, -50px);
}

.level-select h2 {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-xl);
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.5px;
}

.level-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
}

.level-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-white);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.level-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.6s;
}

.level-btn:hover:not(.locked)::after {
    width: 100%;
    height: 100%;
}

.level-btn:hover:not(.locked) {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(91, 71, 251, 0.3);
}

.level-btn.locked {
    background: var(--surface-hover);
    border: 2px solid #e9ecef;
    cursor: not-allowed;
    opacity: 0.5;
}

.level-btn.locked .level-number,
.level-btn.locked .level-name {
    color: var(--text-secondary);
}

.level-number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.level-name {
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0.95;
}

/* Stats Summary */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

.stat {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    transition: all 0.3s ease;
}

.stat:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Game Screen */
#game-screen {
    display: none;
    flex-direction: column;
    padding: 0;
}

#game-screen.active {
    display: flex;
}

.game-header {
    background: rgba(15, 14, 23, 0.7);
    backdrop-filter: blur(20px);
    padding: var(--spacing-lg) var(--spacing-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-white);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 0 8px 8px;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-white);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.icon-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.icon-btn.disabled:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
    box-shadow: none;
}

.level-indicator {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.current-level {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-white);
}

.level-progress {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.level-progress-bar {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    height: 6px;
    width: 180px;
    overflow: hidden;
    position: relative;
}

.level-progress-fill {
    background: linear-gradient(90deg, var(--secondary), var(--success));
    height: 100%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50px;
    box-shadow: 0 0 10px rgba(0, 212, 170, 0.5);
    position: absolute;
    left: 0;
    top: 0;
}

.level-progress-fill-wrong {
    background: linear-gradient(90deg, var(--danger), #ff7070);
    height: 100%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50px;
    position: absolute;
    right: 0;
    top: 0;
}

.level-progress-text {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
}

/* Level Switcher for Unlocked Mode */
.level-switcher {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-white);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: var(--spacing-sm);
    transition: all 0.2s ease;
}

.level-switcher:hover {
    background: rgba(255, 255, 255, 0.2);
}

.level-switcher:focus {
    outline: none;
    border-color: var(--primary-light);
}

.level-switcher option {
    background: var(--bg-medium);
    color: var(--text-white);
}

.lives-display {
    display: flex;
    gap: var(--spacing-xs);
    font-size: 1.25rem;
    align-items: center;
}

.heart {
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(255, 94, 94, 0.3));
}

.heart.lost {
    opacity: 0.2;
    filter: grayscale(100%) brightness(0.5);
}

.streak-display {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: rgba(255, 179, 71, 0.1);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 179, 71, 0.2);
}

.streak-icon {
    font-size: 1.25rem;
}

#streak-count {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--warning);
}

.timer-display {
    min-width: 80px;
    text-align: center;
    font-size: 1.125rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.1);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Game Container */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
}

.problem-display {
    margin-bottom: var(--spacing-2xl);
    animation: slideIn 0.4s ease;
}

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

.problem-text {
    font-size: 2.75rem;
    font-weight: 600;
    color: var(--text-white);
    text-align: center;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.problem-part {
    color: var(--text-white);
}

.problem-blank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    padding: var(--spacing-xs) var(--spacing-md);
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-sm);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: var(--text-white);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(91, 71, 251, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(91, 71, 251, 0.3);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 6px 16px rgba(91, 71, 251, 0.4);
    }
}

/* Answer Input */
.answer-input-container {
    margin-bottom: var(--spacing-xl);
}

.answer-input {
    font-size: 1.5rem;
    font-weight: 600;
    padding: var(--spacing-md) var(--spacing-xl);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    text-align: center;
    min-width: 320px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.answer-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(91, 71, 251, 0.1), 0 8px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.answer-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Feedback Display */
.feedback-display {
    min-height: 60px;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.feedback-display.correct {
    color: var(--success);
    animation: scaleIn 0.3s ease;
}

.feedback-display.incorrect {
    color: var(--danger);
    animation: shake 0.5s ease;
}

/* Progress Display */
.progress-display {
    margin-top: var(--spacing-xl);
    color: var(--text-light);
    font-size: 1rem;
    font-weight: 500;
}

.progress-label {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.05);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#problems-solved {
    color: var(--secondary);
    font-weight: 700;
}

/* Results Screen */
#results-screen .container {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-xl);
}

#results-screen h1 {
    font-size: 2.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: var(--spacing-2xl);
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.result-stat {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.result-stat.large {
    grid-column: span 1;
}

.result-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

.result-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.result-stat:not(.large) .result-value {
    font-size: 1.5rem;
}

/* Buttons */
.results-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
}

.primary-btn,
.secondary-btn {
    padding: var(--spacing-md) var(--spacing-2xl);
    font-size: 0.95rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--text-white);
    box-shadow: 0 4px 12px rgba(91, 71, 251, 0.3);
}

.primary-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.3s ease;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(91, 71, 251, 0.4);
}

.primary-btn:hover::before {
    left: 0;
}

.secondary-btn {
    background: var(--surface-hover);
    color: var(--text-primary);
    border: 2px solid #e9ecef;
}

.secondary-btn:hover {
    background: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Animations */
@keyframes scaleIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

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

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

/* Timer warning */
.timer-display.warning {
    background: rgba(255, 179, 71, 0.2);
    border-color: var(--warning);
    color: var(--warning);
    animation: timePulse 1s ease infinite;
}

.timer-display.danger {
    background: rgba(255, 94, 94, 0.2);
    border-color: var(--danger);
    color: var(--danger);
    animation: timePulse 0.5s ease infinite;
}

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

/* Correct/Incorrect input states */
.answer-input.correct {
    background: rgba(0, 200, 150, 0.1);
    border-color: var(--success);
    color: var(--text-primary);
}

.answer-input.incorrect {
    background: rgba(255, 94, 94, 0.1);
    border-color: var(--danger);
    animation: shake 0.5s ease;
}

/* Blur effect when modal is open */
.blur-target.blurred {
    filter: blur(6px);
    pointer-events: none;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 14, 23, 0.8);
    backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal.active ~ .blur-target {
    filter: blur(6px);
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xl) var(--spacing-xl);
    border-bottom: 1px solid #e9ecef;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--surface-hover);
    color: var(--danger);
    transform: rotate(90deg);
}

.modal-body {
    padding: var(--spacing-xl);
}

/* Settings Modal */
.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
}

.timer-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

/* Save Code Modal */
.code-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.code-box {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    color: #333;
    background: #f8f8ff;
}

.code-box:focus {
    outline: none;
    border-color: #764ba2;
    background: white;
}

/* The code runs to about 90 characters, so let it wrap rather than
   scroll out of sight - it is there to be read and copied down */
.code-out {
    resize: none;
    line-height: 1.5;
    word-break: break-all;
    overflow-wrap: anywhere;
}

.code-row .primary-btn,
.code-row .secondary-btn {
    flex: 0 0 auto;
    padding: 12px 22px;
    font-size: 0.95rem;
}

.code-message {
    margin-top: 10px;
    min-height: 1.3em;
    text-align: center;
    font-weight: bold;
}

.code-message.good {
    color: #16a34a;
}

.code-message.bad {
    color: #dc2626;
}

.timer-btn {
    padding: 15px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.timer-btn:hover {
    background: #f0f0ff;
}

.timer-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.timer-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.setting-note {
    font-size: 0.95rem;
    color: #666;
    margin: 10px 0;
}

/* Stats Modal */
.detailed-stats {
    font-size: 1rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid #e5e7eb;
}

.stat-row-label {
    font-weight: 500;
    color: #555;
}

.stat-row-value {
    font-weight: bold;
    color: #667eea;
}

.level-stat-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

.level-stat-card h4 {
    margin: 0 0 10px 0;
    color: #667eea;
}

.level-stat-row {
    display: flex;
    justify-content: space-between;
    margin: 5px 0;
    font-size: 0.9rem;
}

/* Mode Selection Modal */
.mode-modal-content {
    max-width: 900px;
}

.mode-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-lg);
}

.mode-btn {
    background: var(--surface);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl) var(--spacing-lg);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.mode-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mode-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(91, 71, 251, 0.2);
}

.mode-btn:hover::before {
    opacity: 0.05;
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    position: relative;
}

.mode-btn h3 {
    font-size: 1.25rem;
    color: var(--primary);
    margin: 0 0 var(--spacing-sm) 0;
    font-weight: 700;
    position: relative;
}

.mode-btn p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
    position: relative;
}

/* Responsive Design */
@media (max-width: 768px) {
    #welcome-screen h1 {
        font-size: 2.5rem;
    }

    .welcome-header {
        flex-direction: column;
        gap: 15px;
    }

    .subtitle {
        font-size: 1rem;
    }

    .level-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-summary {
        grid-template-columns: 1fr;
    }

    .code-row {
        flex-direction: column;
    }

    .code-row .primary-btn,
    .code-row .secondary-btn {
        width: 100%;
    }

    .problem-text {
        font-size: 2rem;
    }

    .answer-input {
        font-size: 1.5rem;
        min-width: 200px;
    }

    .results-summary {
        grid-template-columns: 1fr;
    }

    .result-stat.large {
        grid-column: span 1;
    }

    .results-actions {
        flex-direction: column;
    }

    .primary-btn,
    .secondary-btn {
        width: 100%;
    }

    .timer-options {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header,
    .modal-body {
        padding: 20px;
    }
}

/* Footer */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: center;
    z-index: 100;
}

.site-footer a {
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.site-footer a:hover {
    color: var(--primary-light);
}
