:root {
    /* Schnechnen Farbpalette - Orange/Türkis/Violett */
    --primary-orange: #FF6B35;
    --primary-turquoise: #00B4D8;
    --primary-purple: #9D4EDD;
    --primary-pink: #FF006E;
    --primary-teal: #06A77D;
    --gradient-bg: linear-gradient(135deg, #FF6B35 0%, #00B4D8 25%, #9D4EDD 50%, #FF006E 75%, #06A77D 100%);
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --border-radius: 16px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #fff5f0 0%, #e0f7fa 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow: hidden;
}

/* Highscore-Animation */
.highscore-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: linear-gradient(135deg, #FF6B35 0%, #00B4D8 50%, #9D4EDD 100%);
    color: white;
    font-size: 2rem;
    font-weight: 900;
    padding: 30px 50px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(255, 107, 53, 0.4);
    text-align: center;
    opacity: 0;
    pointer-events: none;
    animation: confetti-pop 5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    letter-spacing: 2px;
}

.highscore-animation.hidden {
    display: none;
}

/* Konfetti fallende Animation */
@keyframes confetti-fall {
    0% {
        top: -10px;
        opacity: 1;
        transform: translateX(0) rotate(0deg);
    }
    100% {
        top: 100vh;
        opacity: 0;
        transform: translateX(var(--tx, 0px)) rotate(360deg);
    }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    pointer-events: none;
    z-index: 999;
}

.confetti-piece {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-pop {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    85% {
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 0;
    }
}

.container {
    width: 100%;
    max-width: 500px;
    max-height: 100vh;
    max-height: 100dvh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

@supports (height: 100dvh) {
    .container {
        max-height: 100dvh;
    }
}

.header {
    margin: 1rem 0 0.6rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.logo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--card-shadow);
    position: relative;
}

.logo::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: var(--gradient-bg);
    border-radius: 50%;
    z-index: -1;
}

.logo-content {
    font-size: 2.5rem;
    font-weight: bold;
    background: var(--gradient-bg);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.screen {
    padding: 20px;
    min-height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

@media (max-height: 750px) {
    .screen {
        padding: 15px 12px;
    }
}

.hidden {
    display: none !important;
}

h1 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--gradient-bg);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

h2 {
    color: #333;
    text-align: center;
    margin-bottom: 20px;
    font-weight: 600;
}

h3 {
    color: #333;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
}

#start-screen {
    text-align: center;
}

#start-screen p {
    color: #666;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.level-selection {
    width: 100%;
}

.level-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.level-btn {
    background: var(--gradient-bg);
    color: white;
    border: none;
    padding: 16px;
    font-size: 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
    text-align: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.chaos-btn {
    background: linear-gradient(45deg, #FF006E, #9D4EDD, #5A189A, #00B4D8, #FF006E);
    background-size: 400% 400%;
    animation: chaos-gradient 4s ease infinite;
    box-shadow: 0 8px 32px rgba(255, 0, 110, 0.6), 0 0 20px rgba(157, 78, 221, 0.4), inset 0 0 20px rgba(0, 180, 216, 0.2);
    font-size: 1.3rem;
}

.chaos-btn:hover {
    animation: chaos-gradient 2s ease infinite;
    box-shadow: 0 12px 40px rgba(255, 0, 110, 0.8), 0 0 30px rgba(157, 78, 221, 0.6), inset 0 0 30px rgba(0, 180, 216, 0.3);
}

@keyframes chaos-gradient {
    0% { background-position: 0% 50%; transform: rotate(0deg) scale(1); }
    25% { background-position: 50% 0%; transform: rotate(1deg) scale(1.02); }
    50% { background-position: 100% 50%; transform: rotate(0deg) scale(1); }
    75% { background-position: 50% 100%; transform: rotate(-1deg) scale(1.02); }
    100% { background-position: 0% 50%; transform: rotate(0deg) scale(1); }
}

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

.level-btn:hover::before {
    left: 100%;
}

.level-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.level-btn:active {
    transform: translateY(-2px);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 15px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.08), rgba(0, 180, 216, 0.08));
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.timer {
    font-weight: bold;
    font-size: 1.5rem;
    background: var(--gradient-bg);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-primary {
    padding: 10px 18px;
    font-size: 0.95rem;
    background: linear-gradient(135deg, var(--primary-orange), var(--primary-pink));
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
}

button.btn-primary {
    -webkit-appearance: none;
    appearance: none;
    padding: 10px 18px;
    font-size: 0.95rem;
    background: linear-gradient(135deg, var(--primary-orange), var(--primary-pink));
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
    text-align: center;
}

button.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
}

.game-header .btn-primary {
    all: unset;
    display: inline-block;
    padding: 10px 18px;
    font-size: 0.95rem;
    background: linear-gradient(135deg, var(--primary-orange), var(--primary-pink));
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
    text-align: center;
}

.game-header .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
}

.btn-secondary {
    padding: 10px 18px;
    font-size: 0.95rem;
    background: linear-gradient(135deg, var(--primary-turquoise), var(--primary-teal));
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 180, 216, 0.3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 180, 216, 0.4);
}

.btn-danger {
    padding: 10px 18px;
    font-size: 0.95rem;
    background: linear-gradient(135deg, #FF4757, #FF3838);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 71, 87, 0.4);
}

.stats-buttons {
    display: flex;
    gap: 15px;
    flex-direction: column;
    margin-top: 10px;
}

.stats-buttons button {
    width: 100%;
}

.problem-container {
    width: 100%;
    margin-bottom: 12px;
    text-align: center;
}

.problem {
    font-size: 2.5rem;
    font-weight: bold;
    color: #333;
    padding: 12px 10px;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: var(--border-radius);
    margin: 0 auto;
    width: fit-content;
    box-shadow: var(--card-shadow);
    position: relative;
}

.problem::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-bg);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.user-answer {
    background: var(--gradient-bg);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 1.5ch;
    display: inline-block;
    text-align: center;
    border-bottom: 4px solid;
    border-image: var(--gradient-bg) 1;
    transition: all 0.3s ease;
}

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

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

.problem.correct {
    animation: correctAnswer 0.6s ease;
    background: linear-gradient(135deg, #c8e6c9, #a5d6a7) !important;
    box-shadow: 0 8px 32px rgba(76, 175, 80, 0.4);
}

.problem.wrong {
    animation: wrongAnswer 0.6s ease;
    background: linear-gradient(135deg, #ffcdd2, #ef9a9a) !important;
    box-shadow: 0 8px 32px rgba(244, 67, 54, 0.4);
}

.dial-pad {
    width: 100%;
    margin-top: 8px;
    margin-bottom: 8px;
}

.dial-row {
    display: flex;
    justify-content: center;
    margin-bottom: 6px;
}

.dial-row-bottom {
    display: grid;
    grid-template-columns: 85px 85px 85px;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
}


.dial-btn {
    width: 85px;
    height: 85px;
    margin: 0 4px;
    font-size: 2rem;
    font-weight: bold;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dial-btn:hover {
    background: linear-gradient(135deg, #e9ecef, #dee2e6);
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.dial-btn:active {
    transform: scale(0.95);
}

.clear-btn {
    background: linear-gradient(135deg, #ff5252, #f44336);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 82, 82, 0.3);
}

.clear-btn:hover {
    background: linear-gradient(135deg, #f44336, #e53935);
    box-shadow: 0 6px 16px rgba(255, 82, 82, 0.4);
}

.backspace-btn {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.backspace-btn:hover {
    background: linear-gradient(135deg, #f57c00, #ef6c00);
    box-shadow: 0 6px 16px rgba(255, 152, 0, 0.4);
}

.result-stats {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: var(--border-radius);
    width: 100%;
    box-shadow: var(--card-shadow);
    position: relative;
}

.result-stats::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-bg);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.result-stats p {
    margin: 10px 0;
    font-size: 1.05rem;
}

.highscore-display {
    margin-top: 15px !important;
    padding-top: 15px;
    border-top: 2px solid #f0f0f0;
    color: var(--primary-orange);
    font-size: 1.1rem !important;
}

.common-mistakes {
    width: 100%;
    margin-bottom: 20px;
}

.common-mistakes h3 {
    margin-bottom: 8px;
}

.mistakes-subtitle {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 12px;
    font-style: italic;
}

#mistake-list {
    list-style: none;
    text-align: left;
    padding: 0;
}

#mistake-list li {
    padding: 12px;
    margin: 8px 0;
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    border-radius: 10px;
    border-left: 5px solid var(--primary-pink);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-size: 1rem;
    font-weight: 500;
}

#restart-btn {
    padding: 18px 30px;
    font-size: 1.2rem;
    background: var(--gradient-bg);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    width: 100%;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

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

#restart-btn:hover::before {
    left: 100%;
}

#restart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

#restart-btn:active {
    transform: translateY(-1px);
}

@media (max-width: 500px) {
    body {
        padding: 5px;
    }
    
    .container {
        border-radius: 15px;
    }
    
    .screen {
        padding: 20px 15px;
    }
    
    .header {
        margin: 1.5rem 0 1rem 0;
    }
    
    .logo {
        width: 90px;
        height: 90px;
    }
    
    .logo-content {
        font-size: 2.2rem;
    }
    
    h1 {
        font-size: 1.6rem;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
    
    .problem {
        font-size: 2.2rem;
        padding: 20px 15px;
    }
    
    .user-answer {
        font-size: 2.2rem;
    }
    
    .dial-btn {
        width: 72px;
        height: 72px;
        font-size: 1.7rem;
        margin: 0 3px;
    }
    
    .dial-row {
        margin-bottom: 7px;
    }
    
    .game-header {
        padding: 14px 16px;
        margin-bottom: 20px;
    }
    
    .timer {
        font-size: 1.2rem;
    }
    
    .level-btn {
        padding: 16px;
        font-size: 1rem;
    }
    
    .level-buttons {
        gap: 0.8rem;
    }
    
    .result-stats, .highscore {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    #restart-btn {
        padding: 15px 25px;
        font-size: 1.1rem;
    }
}

@media (max-width: 375px) {
    .logo {
        width: 80px;
        height: 80px;
    }
    
    .logo-content {
        font-size: 2rem;
    }
    
    h1 {
        font-size: 1.4rem;
    }
    
    .problem {
        font-size: 1.8rem;
        padding: 15px;
    }
    
    .user-answer {
        font-size: 1.8rem;
    }
    
    .dial-btn {
        width: 64px;
        height: 64px;
        font-size: 1.4rem;
        margin: 0 2px;
    }
}

@media (max-height: 600px) {
    .screen {
        padding: 15px 12px;
    }
    
    .header {
        margin: 0.5rem 0;
    }
    
    .logo {
        width: 70px;
        height: 70px;
    }
    
    .logo-content {
        font-size: 1.8rem;
    }
    
    h1 {
        font-size: 1.3rem;
        margin-bottom: 0.5rem;
    }
    
    h2 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    
    .problem {
        font-size: 1.6rem;
        padding: 12px;
        margin-bottom: 10px;
    }
    
    .user-answer {
        font-size: 1.6rem;
    }
    
    .dial-btn {
        width: 60px;
        height: 60px;
        font-size: 1.3rem;
        margin: 0 2px;
    }
    
    .dial-row {
        margin-bottom: 5px;
    }
    
    .dial-row-bottom {
        grid-template-columns: 60px 60px 60px;
        gap: 6px;
    }
    
    .game-header {
        padding: 10px 12px;
        margin-bottom: 10px;
    }
    
    .timer {
        font-size: 1rem;
    }
    
    .level-btn {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .level-buttons {
        gap: 0.6rem;
    }
    
    .result-stats, .highscore {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    #restart-btn {
        padding: 12px 20px;
        font-size: 1rem;
    }
}

@media (max-height: 500px) {
    .screen {
        padding: 12px 10px;
    }
    
    .header {
        margin: 0.3rem 0;
    }
    
    .logo {
        width: 60px;
        height: 60px;
    }
    
    .logo-content {
        font-size: 1.5rem;
    }
    
    h1 {
        font-size: 1.1rem;
        margin-bottom: 0.3rem;
    }
    
    h2 {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }
    
    .problem {
        font-size: 1.4rem;
        padding: 10px;
        margin-bottom: 8px;
    }
    
    .user-answer {
        font-size: 1.4rem;
    }
    
    .dial-btn {
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
        margin: 0 1px;
    }
    
    .dial-row {
        margin-bottom: 4px;
    }
    
    .dial-row-bottom {
        grid-template-columns: 52px 52px 52px;
        gap: 4px;
    }
    
    .game-header {
        padding: 8px 10px;
        margin-bottom: 8px;
    }
    
    .timer {
        font-size: 0.9rem;
    }
    
    .level-btn {
        padding: 10px;
        font-size: 0.8rem;
    }
    
    .level-buttons {
        gap: 0.5rem;
    }
}

/* Statistik-Seite */
.btn-secondary {
    padding: 16px 30px;
    font-size: 1.05rem;
    background: linear-gradient(135deg, #e9ecef, #dee2e6);
    color: #333;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    width: 100%;
    margin-top: 20px;
    box-shadow: var(--card-shadow);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #dee2e6, #ced4da);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.btn-secondary:active {
    transform: translateY(0);
}

.stats-level-selector {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-bottom: 20px;
    width: 100%;
}

.stats-level-btn {
    padding: 8px;
    font-size: 0.8rem;
    font-weight: bold;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.stats-level-btn:hover {
    background: linear-gradient(135deg, #e9ecef, #dee2e6);
    transform: translateY(-2px);
}

.stats-level-btn.active {
    background: var(--gradient-bg);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
}

.stat-card {
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: var(--border-radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--card-shadow);
    position: relative;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-bg);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.stat-card h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    background: var(--gradient-bg);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chart-container {
    width: 100%;
    height: 300px;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
    position: relative;
}

.chart-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-bg);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

/* Statistics mistakes section */
.stats-mistakes {
    width: 100%;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
    position: relative;
}

.stats-mistakes::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-bg);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.stats-mistakes h3 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
    font-size: 1.3rem;
    text-align: center;
}

.stats-mistakes-subtitle {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

#stats-mistake-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#stats-mistake-list li {
    padding: 15px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.1) 0%, rgba(157, 78, 221, 0.1) 100%);
    border-radius: 12px;
    font-size: 1.1rem;
    text-align: center;
    color: var(--text-primary);
    border-left: 4px solid var(--primary-orange);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#stats-mistake-list li:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.2);
}

#stats-mistake-list li .mistake-count {
    display: inline-block;
    margin-left: 10px;
    padding: 4px 12px;
    background: var(--primary-orange);
    color: white;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
}

#stats-mistake-list .no-mistakes {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    background: linear-gradient(135deg, rgba(6, 167, 125, 0.1) 0%, rgba(0, 180, 216, 0.1) 100%);
    border-left: 4px solid var(--primary-teal);
}

/* ==================== Leaderboard Screen ==================== */

#leaderboard-screen {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100%;
    overflow: visible;
}

#leaderboard-screen h2 {
    text-align: center;
    font-size: 2rem;
    background: linear-gradient(135deg, #FF6B35 0%, #00B4D8 50%, #9D4EDD 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.leaderboard-level-selector {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    padding: 0 10px;
}

.leaderboard-level-btn {
    padding: 10px 12px;
    border: 2px solid var(--primary-orange);
    background: white;
    color: var(--primary-orange);
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
}

.leaderboard-level-btn:hover {
    background: var(--primary-orange);
    color: white;
    transform: translateY(-2px);
}

.leaderboard-level-btn.active {
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--primary-turquoise) 100%);
    color: white;
    border-color: var(--primary-turquoise);
}

.leaderboard-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 20px 10px;
    min-height: 200px;
    width: 100%;
    overflow: auto;
    flex: 1;
}

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

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    gap: 15px;
}

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

.leaderboard-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--primary-turquoise) 100%);
    color: white;
    font-weight: 900;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.leaderboard-rank.rank-1 {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.leaderboard-rank.rank-2 {
    background: linear-gradient(135deg, #C0C0C0 0%, #A9A9A9 100%);
    box-shadow: 0 4px 12px rgba(192, 192, 192, 0.4);
}

.leaderboard-rank.rank-3 {
    background: linear-gradient(135deg, #CD7F32 0%, #8B4513 100%);
    box-shadow: 0 4px 12px rgba(205, 127, 50, 0.4);
}

.leaderboard-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    background: linear-gradient(135deg, rgba(157, 78, 221, 0.1) 0%, rgba(6, 167, 125, 0.1) 100%);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin: 10px 0 5px 0;
    flex-shrink: 0;
}

.leaderboard-info p {
    margin: 0;
    font-size: 0.95rem;
}

.leaderboard-info strong {
    color: var(--primary-purple);
    font-weight: 700;
}

.leaderboard-player-name {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.leaderboard-player-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.leaderboard-player-info .leaderboard-player-name {
    flex: none;
    gap: 0;
    font-weight: 600;
    font-size: 1rem;
}

.leaderboard-player-info .leaderboard-date {
    font-size: 0.8rem;
    color: #999;
    font-weight: normal;
}

.leaderboard-player-score {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.leaderboard-score {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-turquoise);
}

.leaderboard-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-style: italic;
}

.leaderboard-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.leaderboard-buttons {
    display: flex;
    gap: 10px;
    padding: 0 10px;
    justify-content: center;
    flex-shrink: 0;
}

#player-reset-name-btn {
    padding: 10px 16px;
    font-size: 0.9rem;
    white-space: nowrap;
}

@media (max-width: 500px) {
    .leaderboard-level-selector {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .leaderboard-level-btn {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
    
    #leaderboard-screen h2 {
        font-size: 1.5rem;
    }
    
    .leaderboard-container {
        min-height: 100px;
        padding: 15px 8px;
    }
    
    .leaderboard-item {
        padding: 8px 0;
        flex-wrap: wrap;
    }
    
    .leaderboard-info {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 15px;
        margin: 8px 0;
        gap: 8px;
    }
    
    .leaderboard-info p {
        margin: 0;
        font-size: 0.9rem;
    }
    
    .leaderboard-buttons {
        flex-direction: column;
        padding: 0;
        gap: 8px;
    }
    
    .leaderboard-buttons button {
        width: 100%;
        padding: 12px 16px;
    }
}

@media (max-height: 700px) {
    #leaderboard-screen {
        gap: 12px;
    }
    
    .leaderboard-container {
        min-height: 80px;
        padding: 12px 8px;
    }
    
    .leaderboard-info {
        padding: 10px 12px;
        margin: 6px 0;
        gap: 6px;
    }
    
    .leaderboard-buttons {
        padding: 0;
        gap: 6px;
    }
}


