:root {
    --bg: #fbf3ee;
    --bg-accent: #f6dfe6;
    --card: #ffffff;
    --text: #2b1d24;
    --muted: #7a6a72;
    --primary: #7a2e4f;
    --primary-text: #ffffff;
    --border: #ead7dd;
    --answer: #fbf7f8;
    --correct: #2f8f5b;
    --correct-bg: #e3f4ea;
    --wrong: #c0392b;
    --wrong-bg: #fbe5e2;
    --tile: #f3c64f;
    --tile-text: #3a2a05;
    --tile-empty: #efe6e9;
    --shadow: 0 10px 30px rgba(122, 46, 79, 0.12);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1b1418;
        --bg-accent: #2a1a22;
        --card: #261c21;
        --text: #f4eaee;
        --muted: #b6a3ac;
        --primary: #e07aa5;
        --primary-text: #1b1418;
        --border: #3d2c34;
        --answer: #2e2329;
        --correct: #5fd394;
        --correct-bg: #1d3328;
        --wrong: #ff8a7a;
        --wrong-bg: #3a1f1c;
        --tile: #f3c64f;
        --tile-text: #3a2a05;
        --tile-empty: #352a30;
        --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(circle at top, var(--bg-accent), var(--bg) 60%) fixed;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
}

.app {
    max-width: 640px;
    margin: 0 auto;
    padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.screen { display: none; }
.screen.active { display: block; animation: fade .3s ease; }

@keyframes fade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px 20px;
    box-shadow: var(--shadow);
}

.center { text-align: center; }
.hidden { display: none !important; }

.emoji { font-size: 56px; line-height: 1; margin-bottom: 8px; }

h1 { font-size: 1.7rem; margin: 8px 0 12px; }
h2 { font-size: 1.25rem; line-height: 1.4; margin: 0 0 20px; }

.lead { color: var(--muted); line-height: 1.5; margin: 0 0 24px; }
.hint { color: var(--muted); font-size: .9rem; margin: 16px 0 24px; }

.btn {
    display: block;
    width: 100%;
    font: inherit;
    font-weight: 600;
    font-size: 1.05rem;
    padding: 15px 20px;
    border-radius: 14px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform .1s ease, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn + .btn { margin-top: 12px; }
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--primary); }

/* Kopfzeile mit Fortschritt */
.quiz-head { margin-bottom: 16px; }
.progress-info {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
}
.progress-bar {
    height: 8px;
    background: var(--tile-empty);
    border-radius: 99px;
    overflow: hidden;
}
#progress-fill {
    height: 100%;
    width: 0;
    background: var(--primary);
    border-radius: 99px;
    transition: width .3s ease;
}

/* Antworten */
.answers { display: grid; gap: 10px; }

.answer {
    font: inherit;
    font-size: 1.05rem;
    text-align: left;
    width: 100%;
    min-height: 56px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 2px solid var(--border);
    background: var(--answer);
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.answer:not(:disabled):hover { border-color: var(--primary); }
.answer:disabled { cursor: default; }
.answer.correct { border-color: var(--correct); background: var(--correct-bg); color: var(--correct); font-weight: 600; }
.answer.wrong { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); }
.answer.dim { opacity: .5; }

/* Feedback */
.feedback { text-align: center; margin-top: 20px; }
.feedback p { font-weight: 600; margin: 12px 0 16px; }

.letter-tile {
    width: 72px;
    height: 72px;
    margin: 0 auto;
    display: grid;
    place-items: center;
    font-size: 2.4rem;
    font-weight: 800;
    border-radius: 16px;
    background: var(--tile);
    color: var(--tile-text);
    animation: pop .4s ease;
}
.letter-tile.big { width: 120px; height: 120px; font-size: 4rem; border-radius: 24px; margin: 8px auto 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.letter-tile.empty { background: var(--tile-empty); color: var(--muted); font-size: 1.8rem; }

@keyframes pop {
    0% { transform: scale(.3) rotate(-10deg); opacity: 0; }
    70% { transform: scale(1.1); }
    100% { transform: none; opacity: 1; }
}

/* Timer */
.timer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.timer-num {
    min-width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    font-weight: 800;
    border-radius: 50%;
    background: var(--tile-empty);
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.timer-bar {
    flex: 1;
    height: 6px;
    background: var(--tile-empty);
    border-radius: 99px;
    overflow: hidden;
}
#timer-fill {
    height: 100%;
    width: 100%;
    background: var(--tile);
    border-radius: 99px;
}
.timer.urgent .timer-num { background: var(--wrong-bg); color: var(--wrong); }
.timer.urgent #timer-fill { background: var(--wrong); }

/* Endseite: Collage */
.gallery-title {
    text-align: center;
    font-weight: 700;
    color: var(--muted);
    margin: 0 0 12px;
}
.gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-flow: dense;
    gap: 8px;
    margin-bottom: 16px;
}
.photo {
    margin: 0;
    aspect-ratio: 3 / 4;
    border-radius: 14px;
    overflow: hidden;
    background: var(--tile-empty);
    box-shadow: var(--shadow);
    animation: fade .5s ease both;
}
.photo.wide { grid-column: span 2; aspect-ratio: 3 / 2; }
.photo.hero { grid-column: span 2; }
.photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.final-card .lead { margin-bottom: 0; }

@media (min-width: 600px) {
    .app { padding-top: 48px; }
    .card { padding: 32px; }
    h1 { font-size: 2rem; }
}
