:root {
    --success: #22c55e;
    --error: #ef4444;

    --g-alkalimetall: #ff6b6b;
    --g-erdalkalimetall: #f59e0b;
    --g-uebergangsmetall: #60a5fa;
    --g-nachmetall: #a78bfa;
    --g-halbmetall: #14b8a6;
    --g-nichtmetall: #22c55e;
    --g-halogen: #e879f9;
    --g-edelgas: #facc15;
    --g-default: #64748b;
}

/* ── Sternenhimmel ── */
.star-field {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.star {
    position: absolute;
    border-radius: 50%;
    background: white;
    animation: starPulse var(--duration) ease-in-out infinite alternate;
}

@keyframes starPulse {
    0%   { opacity: var(--min-opacity); }
    100% { opacity: var(--max-opacity); }
}

/* ── Confetti ── */
.confetti-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
}

.confetti {
    position: fixed;
    top: -20px;
    width: 10px;
    height: 16px;
    opacity: 0.95;
    border-radius: 2px;
    animation-name: fall;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
    will-change: transform, opacity;
}

@keyframes fall {
    0% {
        transform: translate3d(0, 0, 0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate3d(var(--drift), 110vh, 0) rotate(720deg);
        opacity: 0;
    }
}

/* ── Element-Kacheln ── */
.tile {
    position: relative;
    min-height: 190px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.12);
    padding: 14px 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.06),
        0 10px 30px rgba(0,0,0,0.25);
}

.tile::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02)),
        radial-gradient(circle at top right, rgba(255,255,255,0.12), transparent 30%);
    pointer-events: none;
    border-radius: 20px;
}

/* ── Steuerungs-Buttons ── */
.quiz-control-btn {
    padding: 0.65rem 1.4rem;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.18);
    transition: background-color 250ms ease, border-color 250ms ease, color 250ms ease, box-shadow 250ms ease;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.4rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.06);
    background-color: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

@media (min-width: 768px) {
    .quiz-control-btn {
        font-size: 1rem;
        line-height: 1.5rem;
        padding: 0.6rem 1.5rem;
    }
}

.quiz-control-btn:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.08);
}

.quiz-control-btn.active {
    background: linear-gradient(135deg, rgba(110, 231, 255, 0.2), rgba(110, 231, 255, 0.08));
    border-color: rgba(110, 231, 255, 0.6);
    color: #6ee7ff;
    box-shadow: 0 0 20px rgba(110, 231, 255, 0.2), 0 4px 12px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
    text-shadow: 0 0 12px rgba(110, 231, 255, 0.4);
}

/* ── Antwort-Buttons ── */
.answer-btn {
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    width: 100%;
    border-radius: 20px;
    transition: transform 0.15s ease;
}

.answer-btn:hover:not(:disabled) .tile {
    transform: translateY(-4px);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.1),
        0 20px 40px rgba(0,0,0,0.35);
    border-color: rgba(255,255,255,0.25);
}

.answer-btn.correct .tile {
    border-color: rgba(34, 197, 94, 0.8);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.1),
        0 0 0 2px rgba(34,197,94,0.12),
        0 18px 36px rgba(34,197,94,0.2),
        0 0 30px rgba(34,197,94,0.08);
}

.answer-btn.wrong .tile {
    border-color: rgba(239, 68, 68, 0.8);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.1),
        0 0 0 2px rgba(239,68,68,0.1),
        0 18px 36px rgba(239,68,68,0.18),
        0 0 30px rgba(239,68,68,0.06);
}

/* ── Kachel-Inhalt ── */
.tile-head,
.tile-number,
.tile-symbol,
.tile-footer {
    position: relative;
    z-index: 1;
}

.tile-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.9;
}

.tile-mini {
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.12);
    font-size: 0.68rem;
}

.tile-number {
    font-size: 1rem;
    font-weight: bold;
    opacity: 0.95;
    margin-top: 12px;
}

.tile-symbol {
    font-size: 3.6rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    letter-spacing: 0.02em;
    margin: 12px 0;
}

.tile-footer {
    min-height: 18px;
}

/* ── Elementgruppen-Farben ── */
.group-alkalimetall     { background: linear-gradient(180deg, rgba(255,107,107,0.28), rgba(255,107,107,0.12)), #1a1014; }
.group-erdalkalimetall  { background: linear-gradient(180deg, rgba(245,158,11,0.28), rgba(245,158,11,0.12)), #1a1610; }
.group-uebergangsmetall { background: linear-gradient(180deg, rgba(96,165,250,0.28), rgba(96,165,250,0.12)), #0f1520; }
.group-nachmetall       { background: linear-gradient(180deg, rgba(167,139,250,0.28), rgba(167,139,250,0.12)), #141024; }
.group-halbmetall       { background: linear-gradient(180deg, rgba(20,184,166,0.28), rgba(20,184,166,0.12)), #0d1c1c; }
.group-nichtmetall      { background: linear-gradient(180deg, rgba(34,197,94,0.28), rgba(34,197,94,0.12)), #0d1a12; }
.group-halogen          { background: linear-gradient(180deg, rgba(232,121,249,0.28), rgba(232,121,249,0.12)), #1a0d20; }
.group-edelgas          { background: linear-gradient(180deg, rgba(250,204,21,0.28), rgba(250,204,21,0.12)), #1c180d; }
.group-default          { background: linear-gradient(180deg, rgba(100,116,139,0.28), rgba(100,116,139,0.12)), #12151c; }

/* ── Feedback ── */
.feedback {
    margin-top: 18px;
    text-align: center;
    min-height: 32px;
    font-size: 1.05rem;
    font-weight: bold;
}

.feedback.success {
    color: var(--success);
    text-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.feedback.error {
    color: var(--error);
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.hint {
    margin-top: 12px;
    color: #64748b;
    font-size: 0.92rem;
    text-align: center;
}

/* ── Ergebnis-Bildschirm ── */
.result-screen {
    display: none;
    margin-top: 24px;
    text-align: center;
    padding: 28px 20px;
    border: 1px solid rgba(110, 231, 255, 0.15);
    border-radius: 20px;
    background: rgba(110, 231, 255, 0.03);
    box-shadow: 0 0 40px rgba(110, 231, 255, 0.04);
}

.result-screen.active {
    display: block;
    animation: resultFadeIn 0.4s ease;
}

@keyframes resultFadeIn {
    0%   { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ── Restart-Button ── */
.quiz-restart-btn {
    padding: 12px 28px;
    border-radius: 14px;
    border: 1px solid rgba(110, 231, 255, 0.3);
    background: rgba(110, 231, 255, 0.1);
    color: #6ee7ff;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 250ms ease, border-color 250ms ease, box-shadow 250ms ease, transform 250ms ease;
    box-shadow: 0 0 16px rgba(110, 231, 255, 0.08);
}

.quiz-restart-btn:hover {
    background: rgba(110, 231, 255, 0.18);
    border-color: rgba(110, 231, 255, 0.5);
    box-shadow: 0 0 24px rgba(110, 231, 255, 0.15);
    transform: translateY(-1px);
}

/* ── Statistik-Pills ── */
.quiz-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    font-size: 0.875rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

/* ── Highscore-Pill ── */
.highscore-pill {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 6px 16px !important;
    border-radius: 999px !important;
    background: linear-gradient(135deg, #fcd34d, #f59e0b) !important;
    color: #451a03 !important;
    font-weight: 700 !important;
    font-size: 0.875rem !important;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4) !important;
    animation: highscore-pill-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

.highscore-pill-icon {
    font-size: 1.1rem;
}

@keyframes highscore-pill-pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Element-Name ── */
#element-name {
    line-height: 1.4;
    padding-bottom: 0.1em;
}

/* ── Responsive ── */
@media (max-width: 800px) {
    .answers {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    #element-name {
        font-size: 1.7rem;
        margin-bottom: 1.5rem;
        display: block;
        overflow: visible;
    }

    .tile {
        min-height: 160px;
    }

    .tile-symbol {
        font-size: 3rem;
    }
}