.math-game-layout { display: flex; gap: 20px; align-items: flex-start; justify-content: center; max-width: 800px; margin: 0 auto 50px; flex-wrap: wrap; }
.math-game-layout.no-sidebar { max-width: 560px; }
.math-game { background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 4px 20px rgba(0,0,0,0.10); max-width: 560px; flex: 1 1 400px; margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; color: #222; }
.math-game * { box-sizing: border-box; }
.math-game button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; min-height: 44px; }
.math-game h3 { margin: 0 0 6px; font-size: 22px; text-align: center; color: #1e293b; }
.math-game-sub { text-align: center; color: #6b7280; font-size: 14px; margin-bottom: 20px; }

.math-game-step { display: none; }
.math-game-step.is-active { display: block; }

.math-game-name-input {
    display: block; width: 100%; max-width: 260px; margin: 0 auto 14px; padding: 10px 14px;
    border: 2px solid #d1d5db; border-radius: 100px; font-size: 16px; text-align: center; font-weight: 600;
}
.math-game-name-input:focus { outline: none; border-color: #6366f1; }
.math-game-greeting { text-align: center; font-weight: 700; color: #6366f1; margin-bottom: 10px; font-size: 15px; }

/* ---- Bestenlisten-Seitenleiste (bleibt kompakt, wächst nicht mit der Seite mit) ---- */
.math-game-sidebar {
    background: #fdf9ee; border: 2px solid #ffe4a3; border-radius: 16px; padding: 18px 18px 10px;
    width: 240px; flex: 0 0 240px; box-sizing: border-box; max-height: 420px; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.math-game-sidebar .math-game-choice-label { margin-top: 0; text-align: center; }
.math-game-lb-list { list-style: none; margin: 8px 0 0; padding: 0; }
.math-game-lb-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13.5px; border-bottom: 1px solid #f5e8c4; }
.math-game-lb-list li:last-child { border-bottom: none; }
.math-game-lb-rank { width: 24px; text-align: center; font-weight: 700; flex-shrink: 0; }
.math-game-lb-name { flex: 1; font-weight: 600; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.math-game-lb-points { font-weight: 700; color: #d97706; white-space: nowrap; }
.math-game-lb-empty { font-size: 13px; color: #92702c; text-align: center; margin: 10px 0 6px; }

.math-game-choice-label { font-weight: 700; font-size: 14px; margin: 16px 0 8px; color: #374151; }
.math-game-choice-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.math-game-choice-btn {
    border: 2px solid #d1d5db; background: #f9fafb; border-radius: 12px; padding: 14px 18px; cursor: pointer;
    font-size: 18px; font-weight: 700; min-width: 64px; min-height: 48px; transition: all 0.15s;
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.math-game-choice-btn:hover { border-color: #6366f1; background: #eef0ff; }
.math-game-choice-btn.is-selected { border-color: #6366f1; background: #6366f1; color: #fff; }

.math-game-start-btn {
    display: block; margin: 24px auto 0; background: #16a34a; color: #fff; border: none; border-radius: 100px;
    padding: 14px 36px; font-size: 17px; font-weight: 700; cursor: pointer; transition: background 0.15s;
}
.math-game-start-btn:hover { background: #15803d; }
.math-game-start-btn:disabled { background: #d1d5db; cursor: not-allowed; }

.math-game-score { display: flex; justify-content: center; gap: 24px; margin-bottom: 18px; font-size: 14px; font-weight: 700; }
.math-game-score-correct { color: #16a34a; }
.math-game-score-wrong { color: #dc2626; }

.math-game-problem-box { text-align: center; padding: 20px 0; }
.math-game-problem { font-size: 42px; font-weight: 800; color: #1e293b; margin-bottom: 20px; letter-spacing: 1px; }

/* ---- Schriftliche Rechnung: Zahlen untereinander (Addition/Subtraktion ab Klasse 2) ---- */
.math-vertical { display: inline-flex; flex-direction: column; align-items: stretch; font-weight: 800; color: #1e293b; }
.math-vertical-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 34px; line-height: 1.25; }
.math-vertical-op { width: 22px; text-align: left; color: #6366f1; font-size: 30px; }
.math-vertical-num { min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.math-vertical-rule { border-top: 4px solid #1e293b; border-radius: 2px; margin: 4px 0 2px; }
.math-game-problem.is-word-problem { font-size: 17px; font-weight: 600; letter-spacing: normal; line-height: 1.5; text-align: left; background: #f9fafb; border-radius: 12px; padding: 16px 18px; }
.math-game-answer-row { display: flex; gap: 10px; justify-content: center; align-items: center; }
.math-game-answer-input {
    width: 110px; font-size: 26px; text-align: center; padding: 10px; border: 2px solid #d1d5db; border-radius: 10px;
    font-weight: 700;
}
.math-game-answer-input:focus { outline: none; border-color: #6366f1; }
.math-game-check-btn {
    background: #6366f1; color: #fff; border: none; border-radius: 10px; padding: 12px 24px; font-size: 18px;
    font-weight: 700; cursor: pointer;
}
.math-game-check-btn:hover { background: #4f46e5; }

.math-game-feedback { text-align: center; min-height: 90px; padding-top: 10px; }
.math-game-feedback-emoji { font-size: 60px; display: inline-block; animation: mg-pop 0.4s ease; }
@keyframes mg-pop { 0% { transform: scale(0.3); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
.math-game-feedback-text { font-size: 17px; font-weight: 700; margin-top: 8px; }
.math-game-feedback-text.is-correct { color: #16a34a; }
.math-game-feedback-text.is-wrong { color: #dc2626; }

.math-game-back-btn { display: block; margin: 18px auto 0; background: none; border: none; color: #6b7280; font-size: 13px; cursor: pointer; text-decoration: underline; }

@media (max-width: 480px) {
    .math-game-problem { font-size: 32px; }
    .math-game-answer-input { width: 90px; font-size: 22px; }
    .math-vertical-row { font-size: 26px; }
    .math-vertical-op { font-size: 22px; width: 18px; }
    .math-vertical-num { min-width: 54px; }
}
@media (max-width: 700px) {
    .math-game-layout { flex-direction: column; align-items: stretch; }
    .math-game-sidebar { width: 100%; flex-basis: auto; max-height: 220px; order: 2; }
}

/* ---- Vollbild-Modus beim Üben ---- */
.game-focus-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.97); z-index: 200;
    display: flex; align-items: center; justify-content: center; overflow-y: auto;
    padding: calc(70px + env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
}
.game-focus-overlay .math-game-layout { margin: 0 auto; }
.game-focus-close {
    position: fixed; top: calc(16px + env(safe-area-inset-top)); right: calc(16px + env(safe-area-inset-right));
    z-index: 201; background: #ef4444; color: #fff; border: none;
    border-radius: 100px; padding: 12px 22px; font-size: 15px; font-weight: 700; cursor: pointer;
    min-height: 44px; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.game-focus-close:hover { background: #dc2626; }
body.game-focus-active { overflow: hidden; }


