/* CSS Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #48bb78;
    --success-dark: #38a169;
    --error: #f56565;
    --error-dark: #e53e3e;
    --warning: #ed8936;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-dark: #2d3748;
    --text-light: #718096;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

/* Animated Stars Background */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle 2s infinite ease-in-out;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 600px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Screens */
.screen {
    display: none;
    background: var(--card-bg);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.5s ease-out;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.screen.active {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Typography */
h1 {
    font-size: 2.5rem;
    color: var(--text-dark);
    text-align: center;
    margin-bottom: 10px;
}

h2 {
    font-size: 1.3rem;
    color: var(--text-dark);
    margin-bottom: 15px;
}

.subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 30px;
}

/* Settings Box */
.settings-box {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 25px;
}

/* Row Buttons */
.row-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.row-btn {
    padding: 12px 8px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    color: var(--text-dark);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.row-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.row-btn.selected {
    background: var(--bg-gradient);
    color: white;
    border-color: transparent;
    transform: scale(1.05);
}

.row-btn[data-row="all"] {
    grid-column: span 4;
}

/* Checkbox Styling */
.option-group {
    margin-top: 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-dark);
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: rgba(102, 126, 234, 0.1);
}

.checkbox-label input {
    display: none;
}

.checkmark {
    width: 24px;
    height: 24px;
    border: 2px solid #cbd5e0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.checkbox-label input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input:checked + .checkmark::after {
    content: '✓';
    color: white;
    font-weight: bold;
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 18px 30px;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    background: var(--bg-gradient);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    width: 100%;
    padding: 15px 25px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    background: white;
    border: 2px solid var(--primary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 12px;
}

.secondary-btn:hover {
    background: var(--primary);
    color: white;
}

/* Version Info */
.version-info {
    margin-top: 20px;
    font-size: 0.7rem;
    color: #a0aec0;
    text-align: center;
    opacity: 0.6;
}

.icon-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 12px;
    background: rgba(102, 126, 234, 0.1);
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.3s;
}

.icon-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.progress-info {
    flex: 1;
    margin-right: 15px;
}

#current-row-display {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.95rem;
}

.progress-bar {
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    margin: 8px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #68d391);
    border-radius: 6px;
    width: 0%;
    transition: width 0.5s ease;
}

#progress-text {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Mastery Display */
.mastery-display {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    justify-content: center;
    margin-bottom: 15px;
    padding: 8px 5px;
    background: #f7fafc;
    border-radius: 8px;
}

.mastery-item {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 0.7rem;
    transition: all 0.3s;
    position: relative;
    flex-shrink: 0;
}

.mastery-item.pending {
    background: #edf2f7;
    color: #a0aec0;
}

.mastery-item.locked {
    background: #e2e8f0;
    color: #a0aec0;
    opacity: 0.5;
    font-size: 0.6rem;
}

.mastery-item.progress-1 {
    background: linear-gradient(135deg, #fef9c3, #fef08a);
    color: #a16207;
}

.mastery-item.progress-2 {
    background: linear-gradient(135deg, #fed7aa, #fdba74);
    color: #c2410c;
}

.mastery-item.mastered {
    background: linear-gradient(135deg, #bbf7d0, #86efac);
    color: #166534;
    animation: masterPulse 0.5s ease;
}

.mastery-item .streak-indicator {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes masterPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Question Area */
.question-area {
    text-align: center;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.question {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: nowrap;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
    padding: 20px 30px;
    border-radius: 20px;
    border: 3px solid #e2e8f0;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
}

.question.dimmed {
    opacity: 0.3;
    transform: scale(0.95);
}

.question .operator,
.question .equals {
    color: var(--primary);
}

/* Answer Display inline in question */
.question .answer-display {
    min-width: 80px;
    max-width: 110px;
    padding: 10px 15px;
    font-size: 2.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffffff, #f0f4ff);
    border: 3px solid var(--primary);
    border-radius: 14px;
    color: var(--primary);
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 8px rgba(102, 126, 234, 0.1);
}

.question .answer-display.correct {
    border-color: var(--success);
    background: linear-gradient(135deg, #f0fff4, #e6ffed);
    color: var(--success);
    animation: correctShake 0.5s ease;
}

.question .answer-display.wrong {
    border-color: var(--error);
    background: linear-gradient(135deg, #fff5f5, #ffe5e5);
    color: var(--error);
    animation: wrongShake 0.5s ease;
}

/* Input Area */
.input-area {
    display: flex;
    gap: 12px;
    max-width: 300px;
    margin: 0 auto 20px;
    width: 100%;
    box-sizing: border-box;
}

#answer-input {
    flex: 1;
    min-width: 0; /* Wichtig: verhindert Overflow bei flex items */
    padding: 18px 20px;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    border: 3px solid #e2e8f0;
    border-radius: 16px;
    outline: none;
    transition: all 0.3s;
    box-sizing: border-box;
}

#answer-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}

#answer-input.correct {
    border-color: var(--success);
    background: #f0fff4;
    animation: correctShake 0.5s ease;
}

#answer-input.wrong {
    border-color: var(--error);
    background: #fff5f5;
    animation: wrongShake 0.5s ease;
}

@keyframes correctShake {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-5px); }
    75% { transform: translateY(5px); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.submit-btn {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.submit-btn:hover {
    background: var(--success-dark);
    transform: scale(1.05);
}

/* Numpad Container */
.numpad-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.numpad-btn {
    height: 52px;
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    color: var(--text-dark);
    border: 2px solid #cbd5e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.numpad-btn:hover {
    background: linear-gradient(135deg, #edf2f7, #e2e8f0);
    border-color: var(--primary);
    transform: scale(1.02);
}

.numpad-btn:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, #e2e8f0, #cbd5e0);
}

.numpad-btn.backspace {
    background: linear-gradient(135deg, #fed7d7, #feb2b2);
    border-color: #fc8181;
    color: var(--error);
}

.numpad-btn.backspace:hover {
    background: linear-gradient(135deg, #feb2b2, #fc8181);
    border-color: var(--error);
}

.numpad-btn.enter {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    border-color: var(--success-dark);
    color: white;
    font-size: 1.8rem;
}

.numpad-btn.enter:hover {
    background: linear-gradient(135deg, var(--success-dark), #2f855a);
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

/* Numpad disabled state */
.numpad.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.numpad.disabled .numpad-btn {
    cursor: not-allowed;
}

/* Visual Learning Help - Modal Overlay */
.visual-help-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: overlayFadeIn 0.2s ease-out;
}

.visual-help-overlay.show {
    display: flex;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.visual-help {
    background: linear-gradient(135deg, #ffffff, #f0fdf4);
    border: 3px solid #86efac;
    border-radius: 20px;
    padding: 25px 35px;
    max-width: 320px;
    animation: helpAppear 0.3s ease-out;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

@keyframes helpAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.visual-help-equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 2.5rem;
    font-weight: 700;
    color: #166534;
}

.visual-help-title {
    font-size: 2.5rem;
    color: #166534;
    font-weight: 700;
    margin: 0;
}

.dot-grid {
    display: none;
}

.visual-help-result {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    padding: 10px 25px;
    border-radius: 12px;
    display: inline-block;
    min-width: 60px;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.continue-btn {
    padding: 15px 35px;
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    white-space: nowrap;
    animation: pulseBtn 2s ease-in-out infinite;
    margin-top: 5px;
}

.continue-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

@keyframes pulseBtn {
    0%, 100% { box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(102, 126, 234, 0.7); }
}

/* ============================================
   DOG AVATAR STYLES
   ============================================ */

.header-with-dog {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 5px;
}

.header-with-dog h1 {
    margin-bottom: 0;
}

.dog-avatar {
    position: relative;
}

.dog-avatar.start-dog {
    transform: scale(0.7);
}

.dog-avatar.game-dog {
    transform: scale(0.6);
}

.dog-avatar.win-dog {
    transform: scale(0.9);
}

.dog-body {
    position: relative;
    width: 80px;
    height: 70px;
}

/* Ohren */
.dog-ear {
    position: absolute;
    width: 25px;
    height: 35px;
    background: linear-gradient(135deg, #c9a66b, #a67c52);
    border-radius: 50% 50% 40% 40%;
    top: -10px;
}

.dog-ear.left {
    left: 5px;
    transform: rotate(-15deg);
}

.dog-ear.right {
    right: 5px;
    transform: rotate(15deg);
}

/* Kopf */
.dog-head {
    position: absolute;
    width: 70px;
    height: 60px;
    background: linear-gradient(180deg, #d4a96a, #c9a66b);
    border-radius: 50% 50% 45% 45%;
    top: 10px;
    left: 5px;
    box-shadow: inset 0 -5px 10px rgba(0,0,0,0.1);
}

/* Augen */
.dog-eye {
    position: absolute;
    width: 16px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 15px;
    overflow: hidden;
}

.dog-eye.left {
    left: 12px;
}

.dog-eye.right {
    right: 12px;
}

.dog-eye .pupil {
    position: absolute;
    width: 10px;
    height: 12px;
    background: #2d1810;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: all 0.2s;
}

.dog-eye .pupil::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
}

/* Glückliche Augen */
.dog-eye.happy {
    height: 8px;
    border-radius: 0 0 50% 50%;
    background: #2d1810;
}

.dog-eye.happy .pupil {
    display: none;
}

/* Nase */
.dog-nose {
    position: absolute;
    width: 18px;
    height: 12px;
    background: linear-gradient(135deg, #2d1810, #1a0f0a);
    border-radius: 50% 50% 40% 40%;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
}

/* Mund */
.dog-mouth {
    position: absolute;
    width: 20px;
    height: 8px;
    border: 2px solid #8b6914;
    border-top: none;
    border-radius: 0 0 50% 50%;
    top: 42px;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
}

.dog-mouth.happy {
    width: 30px;
    height: 12px;
}

/* Zunge */
.dog-tongue {
    position: absolute;
    width: 12px;
    height: 0;
    background: linear-gradient(180deg, #ff6b8a, #ff4d6a);
    border-radius: 0 0 50% 50%;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    transition: height 0.3s;
    overflow: hidden;
}

.dog-tongue.out {
    height: 15px;
    animation: tongueWag 0.3s ease-in-out infinite alternate;
}

@keyframes tongueWag {
    from { transform: translateX(-50%) rotate(-5deg); }
    to { transform: translateX(-50%) rotate(5deg); }
}

/* Schwanz */
.dog-tail {
    position: absolute;
    width: 12px;
    height: 30px;
    background: linear-gradient(90deg, #c9a66b, #a67c52);
    border-radius: 30px;
    bottom: 5px;
    right: -8px;
    transform-origin: bottom center;
    transform: rotate(-30deg);
    animation: tailWag 0.5s ease-in-out infinite alternate;
}

@keyframes tailWag {
    from { transform: rotate(-30deg); }
    to { transform: rotate(30deg); }
}

.dog-tail.wagging-fast {
    animation: tailWagFast 0.2s ease-in-out infinite alternate;
}

@keyframes tailWagFast {
    from { transform: rotate(-45deg); }
    to { transform: rotate(45deg); }
}

/* Hund-Container im Spiel */
.dog-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

/* Sprechblase */
.dog-speech {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    padding: 8px 15px;
    font-size: 0.9rem;
    color: var(--text-dark);
    max-width: 200px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    animation: speechBounce 0.5s ease-out;
}

.dog-speech::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: white;
}

@keyframes speechBounce {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Hund Animationen */
.dog-body.celebrating {
    animation: dogJump 0.5s ease-in-out infinite;
}

@keyframes dogJump {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.dog-body.sad .dog-ear {
    transform: rotate(-5deg) translateY(5px);
}

.dog-body.sad .dog-ear.right {
    transform: rotate(5deg) translateY(5px);
}

.dog-body.thinking .dog-eye .pupil {
    animation: lookAround 2s ease-in-out infinite;
}

@keyframes lookAround {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(3px); }
    75% { transform: translateX(-3px); }
}

/* Gewinner-Hund Container */
.win-dog-container {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

/* ============================================
   STARS & REWARDS STYLES
   ============================================ */

.stars-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    padding: 10px 20px;
    border-radius: 30px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(251, 191, 36, 0.3);
}

.star-icon {
    font-size: 1.5rem;
    animation: starPulse 2s ease-in-out infinite;
}

@keyframes starPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.star-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #92400e;
}

.star-label {
    font-size: 0.9rem;
    color: #92400e;
}

.game-stars {
    display: flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    padding: 5px 12px;
    border-radius: 20px;
    margin-right: 10px;
}

.game-stars .star-icon {
    font-size: 1.2rem;
}

.game-stars span:last-child {
    font-weight: 700;
    color: #92400e;
}

/* Abzeichen Button */
.badges-btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    background: white;
    border: 2px solid var(--primary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.badges-btn:hover {
    background: var(--primary);
    color: white;
}

/* Reward Display */
.reward-display {
    text-align: center;
    margin-bottom: 15px;
}

.stars-earned {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    padding: 15px 30px;
    border-radius: 20px;
    margin-bottom: 10px;
    animation: rewardPop 0.5s ease-out;
}

@keyframes rewardPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.big-star {
    font-size: 2.5rem;
    animation: starSpin 1s ease-out;
}

@keyframes starSpin {
    from { transform: rotate(0deg) scale(0); }
    to { transform: rotate(360deg) scale(1); }
}

.earned-count {
    font-size: 2rem;
    font-weight: 700;
    color: #92400e;
}

#new-badge-text {
    color: var(--success);
    font-weight: 600;
    font-size: 1.1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.show {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--error);
    color: white;
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 20px;
}

/* Badges Grid */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.badge-item {
    text-align: center;
    padding: 15px 10px;
    border-radius: 15px;
    background: #f7fafc;
    transition: all 0.3s;
}

.badge-item.unlocked {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3);
}

.badge-item.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.badge-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
}

.badge-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dark);
    display: block;
}

.badge-requirement {
    font-size: 0.7rem;
    color: var(--text-light);
}

.badges-progress {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
}

/* Floating Star Animation */
.floating-star {
    position: fixed;
    font-size: 2rem;
    pointer-events: none;
    z-index: 1500;
    animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.5);
    }
}

/* Floating Feedback */
.floating-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    font-weight: 700;
    padding: 20px 40px;
    border-radius: 20px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    text-align: center;
    max-width: 90%;
    white-space: nowrap;
}

.floating-feedback.correct {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    box-shadow: 0 10px 40px rgba(72, 187, 120, 0.5);
}

.floating-feedback.wrong {
    background: linear-gradient(135deg, #f56565, #e53e3e);
    color: white;
    box-shadow: 0 10px 40px rgba(245, 101, 101, 0.5);
}

.floating-feedback.show {
    animation: feedbackFloat 2.5s ease-out forwards;
}

@keyframes feedbackFloat {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(-5deg);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1) rotate(2deg);
    }
    30% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
    70% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(100%, -100%) scale(0.5) rotate(15deg);
    }
}

/* Idle Message */
.idle-message {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.1rem;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.5s;
}

.idle-message.show {
    opacity: 1;
    animation: idleBounce 1s ease infinite;
}

@keyframes idleBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-10px); }
}

/* Streak Display */
.streak-display {
    text-align: center;
    margin-top: 15px;
    font-size: 1rem;
    color: var(--text-light);
}

/* Win Screen */
#win-screen {
    text-align: center;
    position: relative;
    overflow: hidden;
}

#win-screen h1 {
    font-size: 2.8rem;
    margin-bottom: 20px;
    animation: winPulse 1s ease infinite;
}

@keyframes winPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.win-message {
    font-size: 1.3rem;
    color: var(--text-dark);
    margin-bottom: 25px;
}

.stats-box {
    background: linear-gradient(135deg, #f7fafc, #edf2f7);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: left;
}

.stats-box p {
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
}

.stats-box p:last-child {
    border-bottom: none;
}

/* Confetti */
.confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 20px;
    top: -20px;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(500px) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 500px) {
    body {
        padding: 8px;
        align-items: flex-start;
    }

    .container {
        width: 100%;
        max-width: 100%;
    }

    .screen {
        padding: 15px 12px;
        border-radius: 16px;
        width: 100%;
        max-width: 100%;
    }

    h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.95rem;
        margin-bottom: 15px;
    }

    .question {
        font-size: 2rem;
        gap: 8px;
        margin-bottom: 15px;
        padding: 12px 15px;
        border-radius: 14px;
        border-width: 2px;
    }

    .question .answer-display {
        min-width: 60px;
        max-width: 80px;
        padding: 6px 10px;
        font-size: 1.8rem;
        border-width: 2px;
        border-radius: 10px;
    }

    .row-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .row-btn[data-row="all"] {
        grid-column: span 3;
    }

    .row-btn {
        padding: 10px 6px;
        font-size: 0.9rem;
    }

    .mastery-display {
        padding: 6px 3px;
        margin-bottom: 10px;
        gap: 3px;
    }

    .mastery-item {
        width: 24px;
        height: 24px;
        font-size: 0.6rem;
        border-radius: 5px;
    }

    /* Input-Bereich kompakter gestalten */
    .question-area {
        padding: 0 5px;
    }

    .input-area {
        max-width: 100%;
        width: 100%;
        gap: 8px;
        margin-bottom: 10px;
        padding: 0;
    }

    #answer-input {
        flex: 1;
        min-width: 0;
        width: auto;
        padding: 12px 10px;
        font-size: 1.3rem;
        border-width: 2px;
    }

    /* Numpad mobile Styles */
    .numpad-container {
        max-width: 220px;
        gap: 8px;
    }

    .numpad {
        gap: 5px;
    }

    .numpad-btn {
        height: 42px;
        font-size: 1.2rem;
        border-radius: 8px;
    }

    .numpad-btn.enter {
        font-size: 1.4rem;
    }

    /* Visual Help Modal mobile */
    .visual-help {
        padding: 20px 25px;
        max-width: 280px;
        gap: 12px;
        border-radius: 16px;
    }

    .visual-help-equation {
        font-size: 2rem;
        gap: 8px;
    }

    .visual-help-title {
        font-size: 2rem;
    }

    .visual-help-result {
        font-size: 2rem;
        padding: 8px 18px;
    }

    .continue-btn {
        padding: 12px 25px;
        font-size: 1rem;
    }

    /* Hund und Sprechblase kleiner */
    .dog-container {
        margin-bottom: 10px;
        gap: 5px;
    }

    .dog-avatar.game-dog {
        transform: scale(0.45);
    }

    .dog-speech {
        font-size: 0.75rem;
        padding: 5px 10px;
        max-width: 150px;
    }

    /* Header kompakter */
    .game-header {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 10px;
    }

    .progress-info {
        flex: 1 1 100%;
        margin-right: 0;
        order: 1;
    }

    .game-stars {
        margin-right: 0;
        order: 2;
    }

    .header-buttons {
        order: 3;
    }

    .icon-btn {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    /* Streak Display */
    .streak-display {
        font-size: 0.85rem;
        margin-top: 10px;
    }

    .floating-feedback {
        font-size: 1.1rem;
        padding: 12px 20px;
        top: 30%;
        white-space: normal;
        max-width: 85%;
    }

    /* Win Screen kompakter */
    #win-screen h1 {
        font-size: 2rem;
        margin-bottom: 10px;
    }

    .win-message {
        font-size: 1rem;
        margin-bottom: 15px;
    }

    .stars-earned {
        padding: 10px 20px;
    }

    .big-star {
        font-size: 2rem;
    }

    .earned-count {
        font-size: 1.5rem;
    }

    .stats-box {
        padding: 15px;
        margin-bottom: 15px;
    }

    .stats-box p {
        font-size: 0.9rem;
        padding: 6px 0;
    }

    .primary-btn {
        padding: 14px 20px;
        font-size: 1.1rem;
    }

    .secondary-btn {
        padding: 12px 18px;
        font-size: 1rem;
    }

    /* Badges Modal */
    .modal-content {
        padding: 20px;
        max-height: 85vh;
    }

    .badges-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .badge-item {
        padding: 10px 5px;
    }

    .badge-icon {
        font-size: 1.8rem;
    }

    .badge-name {
        font-size: 0.65rem;
    }

    /* Pause Overlay */
    .pause-content {
        padding: 25px;
    }

    .pause-content h2 {
        font-size: 1.5rem;
    }

    .pause-message {
        font-size: 0.95rem;
        margin-bottom: 20px;
    }

    /* Settings Box */
    .settings-box {
        padding: 15px;
        margin-bottom: 15px;
    }

    .checkbox-label {
        font-size: 0.85rem;
        padding: 8px;
        gap: 10px;
    }

    .checkmark {
        width: 20px;
        height: 20px;
    }

    /* Stars Display */
    .stars-display {
        padding: 8px 15px;
        margin-bottom: 10px;
    }

    .star-count, .star-icon {
        font-size: 1.2rem;
    }

    .badges-btn {
        padding: 10px;
        font-size: 0.9rem;
        margin-bottom: 15px;
    }

    .fullscreen-start-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
        margin-top: 10px;
    }

    /* Win Dog kleiner */
    .win-dog-container {
        margin-bottom: 5px;
    }

    .dog-avatar.win-dog {
        transform: scale(0.7);
    }

    /* Header Dog kleiner */
    .header-with-dog {
        gap: 8px;
        flex-wrap: wrap;
    }

    .dog-avatar.start-dog {
        transform: scale(0.5);
    }

    #dog-speech-start {
        font-size: 0.7rem;
        max-width: 120px;
    }
}

/* Extra kleine Displays (z.B. iPhone SE) */
@media (max-width: 380px) {
    .screen {
        padding: 15px 12px;
    }

    h1 {
        font-size: 1.4rem;
    }

    .question {
        font-size: 1.6rem;
        padding: 10px 12px;
        gap: 5px;
    }

    .question .answer-display {
        min-width: 50px;
        max-width: 65px;
        font-size: 1.5rem;
    }

    .mastery-display {
        gap: 2px;
        padding: 5px 2px;
    }

    .mastery-item {
        width: 22px;
        height: 22px;
        font-size: 0.55rem;
    }

    .row-buttons {
        gap: 4px;
    }

    .row-btn {
        padding: 8px 4px;
        font-size: 0.8rem;
    }

    .header-with-dog h1 {
        font-size: 1.3rem;
    }
}

/* Keyboard erscheint - Layout anpassen */
@media (max-height: 500px) and (max-width: 768px) {
    body {
        align-items: flex-start;
        padding: 5px;
    }

    .screen {
        padding: 10px;
    }

    /* Im Spielmodus nur das Wichtigste zeigen */
    #game-screen .dog-container {
        display: none;
    }

    #game-screen .mastery-display {
        display: none;
    }

    #game-screen .streak-display {
        display: none;
    }

    .game-header {
        margin-bottom: 5px;
    }

    .question {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }

    .input-area {
        margin-bottom: 5px;
    }
}

/* Number input - hide spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Particles effect */
.particle {
    position: fixed;
    pointer-events: none;
    border-radius: 50%;
    animation: particleFade 1s ease-out forwards;
}

@keyframes particleFade {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0);
    }
}

/* ============================================
   HEADER BUTTONS (Pause, Fullscreen, Home)
   ============================================ */

.header-buttons {
    display: flex;
    gap: 8px;
}

/* ============================================
   FULLSCREEN BUTTON (Start Screen)
   ============================================ */

.fullscreen-start-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
    background: transparent;
    border: 2px dashed #cbd5e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
}

.fullscreen-start-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(102, 126, 234, 0.05);
}

/* Fullscreen active state */
body:fullscreen .fullscreen-start-btn,
body:-webkit-full-screen .fullscreen-start-btn {
    border-style: solid;
    border-color: var(--success);
    color: var(--success);
}

/* ============================================
   PAUSE OVERLAY
   ============================================ */

.pause-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.pause-overlay.show {
    display: flex;
    animation: pauseFadeIn 0.3s ease-out;
}

@keyframes pauseFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pause-content {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: pauseSlideIn 0.4s ease-out;
}

@keyframes pauseSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.pause-dog {
    margin-bottom: 15px;
}

.pause-dog .dog-avatar {
    transform: scale(0.8);
    display: inline-block;
}

.pause-content h2 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.pause-message {
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 25px;
}

.pause-content .primary-btn {
    margin-bottom: 0;
}

.pause-content .secondary-btn {
    margin-top: 12px;
}

/* Pause-Icon Animation */
#pause-btn.paused {
    background: var(--warning);
    animation: pausePulse 1s ease-in-out infinite;
}

@keyframes pausePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Fullscreen button active state */
#fullscreen-btn.active {
    background: var(--success);
}

/* ============================================
   FULLSCREEN ADJUSTMENTS
   ============================================ */

body:fullscreen,
body:-webkit-full-screen {
    background: var(--bg-gradient);
}

body:fullscreen .container,
body:-webkit-full-screen .container {
    max-width: 700px;
}

body:fullscreen .screen,
body:-webkit-full-screen .screen {
    max-height: 95vh;
    overflow-y: auto;
}
