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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    position: relative;
}

.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

h1 {
    color: #2c3e50;
    font-size: 2.5em;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.score-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 12px 24px;
    border-radius: 25px;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.score-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.score-value {
    font-size: 1.5em;
    font-weight: 700;
}

.screen {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    min-height: 200px;
    position: relative;
}

.upper-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.lower-screen {
    background: #ffffff;
    border: 2px solid #dee2e6;
}

.screen-label {
    font-size: 0.9em;
    font-weight: 600;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}

.upper-screen .screen-label {
    color: rgba(255, 255, 255, 0.9);
}

.lower-screen .screen-label {
    color: #6c757d;
}

.formula-display {
    font-size: 2em;
    text-align: center;
    padding: 20px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.formula-display .MathJax {
    color: white !important;
}

.user-preview {
    font-size: 1.8em;
    text-align: center;
    padding: 20px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 10px;
    margin-top: 10px;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.user-preview:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.user-preview.correct {
    background: #d4edda;
    border: 2px solid #28a745;
    border-style: solid;
}

.user-preview.incorrect {
    background: #f8d7da;
    border: 2px solid #dc3545;
    border-style: solid;
}

.user-preview .MathJax {
    color: #2c3e50 !important;
}

.user-preview.correct .MathJax {
    color: #155724 !important;
}

.user-preview.incorrect .MathJax {
    color: #721c24 !important;
}

.preview-placeholder {
    color: #adb5bd;
    font-style: italic;
    font-size: 0.6em;
}

.preview-error {
    color: #dc3545;
    font-size: 0.8em;
    font-weight: 500;
}

.question-score {
    text-align: center;
    margin-top: 15px;
    font-weight: 600;
    color: #afafaf;
    font-size: 1.1em;
    display: none;
}

.question-score.visible {
    display: block;
}

.input-container {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

#latex-input {
    flex: 1;
    padding: 15px 20px;
    font-size: 1.1em;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#latex-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.hint-button, #new-question-button, .debug-button {
    padding: 15px 30px;
    font-size: 1.1em;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
    white-space: nowrap;
}

.hint-button:hover, #new-question-button:hover, .debug-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.debug-button {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.hint-button:active, #new-question-button:active, .debug-button:active {
    transform: translateY(0);
}

#new-question-button {
    width: 100%;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}

#new-question-button:hover {
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.feedback {
    margin-top: 20px;
    padding: 15px;
    border-radius: 10px;
    font-weight: 500;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.feedback.empty {
    display: none;
}

/* Sprechblase für Tipps */
.tip-bubble {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 20px;
    max-width: 300px;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    border: 2px solid #667eea;
}

.tip-bubble.hidden {
    display: none;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

.tip-content {
    position: relative;
}

.tip-header {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.tip-text {
    color: #333;
    line-height: 1.6;
}

.tip-arrow {
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    border-left: 15px solid #667eea;
}

.tip-arrow::after {
    content: '';
    position: absolute;
    right: 2px;
    top: -13px;
    width: 0;
    height: 0;
    border-top: 13px solid transparent;
    border-bottom: 13px solid transparent;
    border-left: 13px solid white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .header-section {
        flex-direction: column;
        text-align: center;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .formula-display {
        font-size: 1.5em;
    }
    
    .user-preview {
        font-size: 1.3em;
        min-height: 80px;
    }
    
    .input-container {
        flex-direction: column;
    }
    
    .hint-button {
        width: 100%;
    }
    
    .tip-bubble {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        max-width: 100%;
        margin-top: 20px;
    }
    
    .tip-arrow {
        display: none;
    }
}

/* Username Display */
.username-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 12px 24px;
    border-radius: 25px;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
    font-size: 0.95em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.scores-link {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
    transition: all 0.3s ease;
}

.scores-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

/* Scoreboard Styles */
.scoreboard-container {
    margin-top: 30px;
}

.scoreboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.scoreboard-header h2 {
    color: #2c3e50;
    font-size: 1.8em;
    margin: 0;
}

.clear-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
    transition: all 0.3s ease;
    font-size: 1em;
}

.clear-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.back-button {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.back-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

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

.score-entry {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 15px;
    align-items: center;
    padding: 20px;
    margin-bottom: 15px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    transition: all 0.3s ease;
}

.score-entry:hover {
    background: #f0f4ff;
    border-color: #667eea;
    transform: translateX(5px);
}

.score-entry .rank {
    font-weight: 700;
    font-size: 1.2em;
    color: #667eea;
    min-width: 60px;
}

.score-entry .username {
    font-weight: 600;
    font-size: 1.1em;
    color: #2c3e50;
}

.score-entry .score {
    font-weight: 700;
    font-size: 1.3em;
    color: #28a745;
    text-align: right;
}

.score-entry .solved {
    font-size: 0.9em;
    color: #6c757d;
    text-align: right;
}

.no-scores {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-size: 1.2em;
}

@media (max-width: 768px) {
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .username-display {
        order: 1;
        width: 100%;
        justify-content: center;
    }
    
    .score-display {
        order: 2;
    }
    
    .scores-link {
        order: 3;
        width: 100%;
        text-align: center;
    }
    
    .score-entry {
        grid-template-columns: auto 1fr;
        gap: 10px;
    }
    
    .score-entry .score,
    .score-entry .solved {
        grid-column: 2;
        text-align: left;
    }
}
