/* ============ FONT ============ */
@font-face {
    font-family: 'Outfit';
    src: url('fonts/outfit-variable.woff2') format('woff2');
    font-weight: 400 900;
    font-display: swap;
}

/* ============ DESIGN TOKENS ============ */
:root {
    --bg-0: #0b0b16;
    --bg-1: #10101e;
    --bg-2: #161627;
    --green: #34d399;
    --orange: #fbbf24;
    --red: #f43f5e;
    --purple: #a78bfa;
    --accent: #8b5cf6;
    --accent-2: #d946ef;
    --grad-accent: linear-gradient(135deg, #7c3aed, #c026d3);
    --white: #ffffff;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-2: rgba(255, 255, 255, 0.09);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --glass: var(--surface);
    --glass-border: var(--border);
    --text: #f4f4fa;
    --text-60: rgba(244, 244, 250, 0.7);
    --text-40: rgba(244, 244, 250, 0.54);
    --text-20: rgba(244, 244, 250, 0.4);
    --radius: 16px;
    --radius-lg: 22px;
    --radius-xl: 28px;
    --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.35);
    --font: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============ LIGHT THEME ============ */
[data-theme="light"] {
    --bg-0: #eef0f8;
    --bg-1: #f7f8fc;
    --bg-2: #ffffff;
    --white: #1b1226;
    --surface: rgba(20, 12, 45, 0.045);
    --surface-2: rgba(20, 12, 45, 0.085);
    --border: rgba(20, 12, 45, 0.1);
    --border-strong: rgba(20, 12, 45, 0.18);
    --text: #1b1226;
    --text-60: rgba(27, 18, 38, 0.66);
    --text-40: rgba(27, 18, 38, 0.5);
    --text-20: rgba(27, 18, 38, 0.36);
    --shadow-soft: 0 8px 30px rgba(60, 40, 110, 0.18);
}

[data-theme="light"] body {
    background:
        radial-gradient(1100px 700px at 85% -10%, rgba(124, 58, 237, 0.16), transparent 60%),
        radial-gradient(900px 650px at -15% 110%, rgba(217, 70, 239, 0.1), transparent 60%),
        linear-gradient(165deg, #eef0f8, #f5f4fc 55%, #efeafb);
}

[data-theme="light"] .word-card {
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(124, 58, 237, 0.08), rgba(255, 255, 255, 0.6) 60%),
        rgba(255, 255, 255, 0.78);
    border-color: rgba(20, 12, 45, 0.1);
    box-shadow: 0 24px 60px rgba(60, 40, 110, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

[data-theme="light"] .modal-box,
[data-theme="light"] .overlay-box {
    background: rgba(255, 255, 255, 0.96);
}

[data-theme="light"] .segment-control {
    background: rgba(20, 12, 45, 0.06);
}

/* Gefüllte Akzent-/Aktionsflächen behalten im Light-Mode weißen Text */
[data-theme="light"] .btn-start,
[data-theme="light"] .btn-continue,
[data-theme="light"] .segment-btn.active,
[data-theme="light"] .modal-btn.confirm,
[data-theme="light"] .handoff-tap,
[data-theme="light"] .howto-num,
[data-theme="light"] .action-btn,
[data-theme="light"] .action-icon,
[data-theme="light"] .action-label {
    color: #fff;
}

/* ============ RESET & BASE ============ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    width: 100%;
    font-family: var(--font);
    background:
        radial-gradient(1100px 700px at 85% -10%, rgba(124, 58, 237, 0.22), transparent 60%),
        radial-gradient(900px 650px at -15% 110%, rgba(217, 70, 239, 0.13), transparent 60%),
        linear-gradient(165deg, var(--bg-0), var(--bg-1) 55%, #141229);
    background-attachment: fixed;
    color: var(--text);
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: var(--font);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============ SCREENS ============ */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    transform: scale(0.97);
    padding-top: var(--safe-top);
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

/* ============ SCROLLABLE AREAS ============ */
.setup-scroll,
.summary-scroll,
.stats-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 22px calc(40px + var(--safe-bottom));
    -webkit-overflow-scrolling: touch;
}

/* ============ SETUP SCREEN ============ */
.setup-header {
    text-align: center;
    padding: 26px 0 30px;
}

.logo-mark {
    display: inline-block;
    filter: drop-shadow(0 10px 24px rgba(139, 92, 246, 0.35));
    animation: logoIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes logoIn {
    0% {
        transform: scale(0.4) rotate(-12deg);
        opacity: 0;
    }

    60% {
        transform: scale(1.06) rotate(2deg);
        opacity: 1;
    }

    100% {
        transform: scale(1) rotate(0);
    }
}

.logo-title {
    margin-top: 2px;
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -1.2px;
    background: linear-gradient(100deg, #fff 10%, #c4b5fd 55%, #f0abfc 95%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-60);
    margin-top: 4px;
    letter-spacing: 0.2px;
}

.btn-pill {
    margin-top: 14px;
    padding: 8px 18px;
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text);
    font: 600 13px var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-pill:hover {
    background: var(--surface-2);
    transform: translateY(-1px);
}

.setup-section {
    margin-top: 26px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--text-60);
    margin-bottom: 12px;
}

.version-tag {
    text-align: center;
    margin-top: 28px;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--text-20);
}

/* Toggle */
.toggle {
    position: relative;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
}

.toggle input {
    display: none;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform var(--transition);
}

.toggle input:checked+.toggle-slider {
    background: var(--grad-accent);
    border-color: transparent;
}

.toggle input:checked+.toggle-slider::after {
    transform: translateX(22px);
}

.team-count-control {
    margin-top: 12px;
}

.team-names {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    transition: all var(--transition);
}

.team-names .input-field {
    flex: 1 1 calc(50% - 5px);
}

.input-field {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: 500 14px var(--font);
    outline: none;
    transition: all var(--transition);
}

.input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

/* Difficulty Rows */
.difficulty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 16px;
    margin-bottom: 10px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.diff-label {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.diff-name {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.diff-max {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-40);
}

.diff-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stepper-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.stepper-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.stepper-btn:disabled {
    opacity: 0.18;
    cursor: default;
}

.stepper-btn.minus {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text);
}

.stepper-btn.plus {
    color: var(--text);
}

.stepper-val {
    font-size: 20px;
    font-weight: 800;
    width: 38px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Segment Control */
.segment-control {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.segment-btn {
    flex: 1;
    padding: 11px 8px;
    border: none;
    border-radius: 11px;
    font: 600 14px var(--font);
    color: var(--text-60);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition);
}

.segment-btn.active {
    background: var(--grad-accent);
    color: var(--text);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

/* Eigene Rundenzeit (Regler) */
.custom-timer {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 10px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.custom-timer input[type=range] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.14);
    outline: none;
}

.custom-timer input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #d946ef);
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.5);
    cursor: pointer;
}

.custom-timer input[type=range]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #a855f7;
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.5);
    cursor: pointer;
}

.custom-timer-label {
    font: 700 15px var(--font);
    min-width: 70px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--purple);
}

.mode-control .segment-btn {
    padding: 15px 10px;
    font-size: 15px;
    font-weight: 700;
}

/* Collapsible Header (Kategorien & Einstellungen) */
.cat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px 16px;
    margin-bottom: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.cat-header:hover {
    background: var(--surface-2);
}

.cat-header-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}

.cat-summary {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-40);
    text-transform: none;
    letter-spacing: 0;
}

.cat-arrow {
    font-size: 17px;
    color: var(--text-40);
    transition: transform 0.3s ease;
}

.cat-arrow.open {
    transform: rotate(180deg);
}

/* Collapsible area */
.cat-collapsible {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
    padding: 0;
}

.cat-collapsible.open {
    max-height: 640px;
    opacity: 1;
    padding-top: 12px;
}

/* Settings Rows */
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 16px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.settings-label {
    font-size: 14px;
    font-weight: 600;
}

.settings-sub {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-40);
    margin-top: 2px;
}

/* Akzentfarben-Auswahl */
.accent-swatches {
    display: flex;
    gap: 9px;
}

.accent-swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform var(--transition), border-color var(--transition);
}

.accent-swatch:hover {
    transform: scale(1.12);
}

.accent-swatch.active {
    border-color: var(--text);
    transform: scale(1.12);
}

/* Category Toggle Row */
.category-toggle-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.cat-toggle {
    flex: 1;
    text-align: center;
    margin-top: 0;
}

/* Category Chips */
.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.category-chip {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    font: 500 12.5px var(--font);
    color: var(--text-60);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.category-chip.active {
    border-color: rgba(139, 92, 246, 0.65);
    color: var(--text);
    background: rgba(139, 92, 246, 0.18);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.18);
}

.hint-text {
    font-size: 12px;
    color: var(--text-40);
    margin-top: 8px;
    line-height: 1.45;
}

/* Total Info */
.total-info {
    text-align: center;
    margin-top: 22px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-60);
}

.total-warning {
    color: var(--red);
    font-size: 12px;
    margin-top: 4px;
}

/* Buttons */
.btn-start {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 18px;
    margin-top: 18px;
    border: none;
    border-radius: 18px;
    background: var(--grad-accent);
    color: var(--text);
    font: 700 17px var(--font);
    letter-spacing: 0.2px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: all var(--transition);
    transform: scale(1);
}

.btn-start:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(124, 58, 237, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-start:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-start:disabled {
    opacity: 0.35;
    cursor: default;
    box-shadow: none;
}

.btn-icon {
    font-size: 15px;
}

.btn-stats {
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text-60);
    font: 600 15px var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-stats:hover {
    background: var(--surface-2);
    color: var(--text);
}

/* ============ GAME SCREEN ============ */
/* Level-Wash: der gesamte Spiel-Hintergrund nimmt die Farbe des aktuellen
   Schwierigkeitsgrads an, damit man das Level auch aus der Ferne erkennt.
   Die Farbe (--level-color) wird in app.js gesetzt; sie liegt auf einem
   weichen Verlaufs-Mask, sodass nur die Ränder getönt werden und der Text
   lesbar bleibt. background-color animiert sauber zwischen den Leveln. */
#screen-game {
    --level-color: var(--green);
}

#screen-game::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-color: var(--level-color);
    opacity: 0.26;
    -webkit-mask: radial-gradient(125% 72% at 50% -8%, #000 0%, transparent 60%),
        radial-gradient(110% 55% at 50% 112%, #000 0%, transparent 64%);
    mask: radial-gradient(125% 72% at 50% -8%, #000 0%, transparent 60%),
        radial-gradient(110% 55% at 50% 112%, #000 0%, transparent 64%);
    transition: background-color 0.55s ease;
}

.game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 0;
}

.topbar-left {
    display: flex;
    gap: 8px;
}

.topbar-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface);
    color: var(--text-60);
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

.icon-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.icon-btn:disabled {
    opacity: 0.22;
    cursor: default;
}

.difficulty-badge {
    padding: 7px 15px;
    border-radius: 20px;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.card-counter {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-60);
    font-variant-numeric: tabular-nums;
}

.score-display {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-40);
    font-variant-numeric: tabular-nums;
}

.team-indicator {
    text-align: center;
    padding: 9px;
    margin: 10px 20px 0;
    border-radius: 12px;
    font: 700 14px var(--font);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.streak-indicator {
    text-align: center;
    margin-top: 6px;
    font: 700 13px var(--font);
    color: var(--orange);
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition);
    height: 18px;
}

.streak-indicator.show {
    opacity: 1;
    transform: scale(1);
}

/* Progress */
.progress-area {
    padding: 12px 20px 0;
}

.progress-bar-bg {
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease, background 0.3s ease;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.25);
}

.level-dots {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 11px;
}

/* Level-Pill: zeigt je Schwierigkeit, wie viele Karten noch übrig sind.
   Das aktuelle Level ist hervorgehoben, erledigte Level zeigen ein ✓. */
.level-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 13px;
    font: 700 13px var(--font);
    font-variant-numeric: tabular-nums;
    color: var(--text-60);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.level-pill .pill-emoji {
    font-size: 12px;
    line-height: 1;
}

.level-pill.current {
    color: var(--text);
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.level-pill.done {
    opacity: 0.45;
}

/* Word Card */
.card-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    position: relative;
    overflow: hidden;
}

/* Swipe Direction Indicators */
.swipe-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 26px;
    font-weight: 900;
    opacity: 0.1;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.2s ease;
}

.swipe-ind-left {
    left: 10px;
    color: var(--red);
}

.swipe-ind-right {
    right: 10px;
    color: var(--green);
}

.swipe-ind-left.glow {
    opacity: 0.75;
    text-shadow: 0 0 14px var(--red);
}

.swipe-ind-right.glow {
    opacity: 0.75;
    text-shadow: 0 0 14px var(--green);
}

/* Feedback Toast */
.feedback-toast {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    padding: 14px 28px;
    border-radius: 18px;
    font: 800 22px var(--font);
    color: #fff;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    transition: none;
    white-space: nowrap;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}

.feedback-toast.show {
    animation: toastPop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.feedback-toast.correct {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.95), rgba(16, 185, 129, 0.95));
}

.feedback-toast.skip,
.feedback-toast.timeout {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.92), rgba(225, 29, 72, 0.92));
}

.feedback-toast.pass {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.92), rgba(245, 158, 11, 0.92));
}

@keyframes toastPop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -50%) scale(1.15);
        opacity: 1;
    }

    40% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -60%) scale(0.9);
        opacity: 0;
    }
}

/* Kartenstapel: zwei angedeutete Karten hinter der aktiven Karte */
.card-stack {
    position: relative;
    width: 100%;
    max-width: 400px;
    isolation: isolate;
}

.card-stack::before,
.card-stack::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: var(--radius-xl);
    background: rgba(22, 22, 39, 0.5);
    border: 1.5px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.card-stack::before {
    transform: rotate(-3.5deg) translateY(7px) scale(0.965);
}

.card-stack::after {
    transform: rotate(3deg) translateY(4px) scale(0.982);
}

[data-theme="light"] .card-stack::before,
[data-theme="light"] .card-stack::after {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(20, 10, 40, 0.08);
}

.word-card {
    width: 100%;
    padding: 42px 28px 34px;
    border-radius: var(--radius-xl);
    text-align: center;
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02) 60%),
        rgba(22, 22, 39, 0.6);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    touch-action: none;
    cursor: grab;
}

.word-card.swiping {
    cursor: grabbing;
}

.word-card.swipe-right {
    border-color: var(--green);
    box-shadow: 0 0 36px rgba(52, 211, 153, 0.35);
}

.word-card.swipe-left {
    border-color: var(--red);
    box-shadow: 0 0 36px rgba(244, 63, 94, 0.35);
}

.word-card.swipe-down {
    border-color: var(--orange);
    box-shadow: 0 0 36px rgba(251, 191, 36, 0.35);
}

/* Wort verdeckt, solange der Übergabe-Screen aktiv ist */
.word-card.word-hidden .card-word,
.word-card.word-hidden .card-category,
.word-card.word-hidden .card-taboo {
    filter: blur(14px);
}

/* Verbotene Wörter (Beschreiben-Modus) */
.card-taboo {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px dashed rgba(244, 63, 94, 0.3);
    transition: filter 0.3s ease;
}

.taboo-word {
    padding: 6px 13px;
    border-radius: 15px;
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.35);
    color: #fda4af;
    font: 600 14px var(--font);
    text-decoration: line-through;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(253, 164, 175, 0.7);
}

.card-emoji {
    font-size: 36px;
    margin-bottom: 14px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.card-word {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.6px;
    word-break: break-word;
    line-height: 1.18;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.3s ease;
}

.card-category {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-60);
    margin-top: 10px;
    padding: 4px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    transition: filter 0.3s ease;
}

.card-hint {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-40);
    margin-top: 18px;
    letter-spacing: 0.3px;
}

/* Card animations */
.card-exit-left {
    animation: cardExitLeft 0.3s ease forwards;
}

.card-exit-right {
    animation: cardExitRight 0.3s ease forwards;
}

.card-exit-down {
    animation: cardExitDown 0.3s ease forwards;
}

.card-enter {
    animation: cardEnter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cardExitLeft {
    to {
        transform: translateX(-120%) rotate(-15deg);
        opacity: 0;
    }
}

@keyframes cardExitRight {
    to {
        transform: translateX(120%) rotate(15deg);
        opacity: 0;
    }
}

@keyframes cardExitDown {
    to {
        transform: translateY(100%) scale(0.9);
        opacity: 0;
    }
}

@keyframes cardEnter {
    from {
        transform: scale(0.85) translateY(26px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Timer */
.timer-display {
    text-align: center;
    padding: 12px 0;
    font: 700 19px var(--font);
    font-variant-numeric: tabular-nums;
}

.timer-capsule {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 22px;
    border-radius: 22px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: all var(--transition);
}

.timer-pulse {
    animation: pulse 1s ease infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

/* Swipe Hint */
.swipe-hint {
    display: flex;
    justify-content: space-around;
    padding: 0 20px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-20);
    letter-spacing: 0.3px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    padding: 12px 18px calc(24px + var(--safe-bottom));
}

.action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 15px 8px;
    border: none;
    border-radius: 17px;
    color: var(--text);
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    transform: scale(1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.action-btn:hover {
    transform: translateY(-2px);
}

.action-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.action-btn:disabled {
    opacity: 0.28;
    cursor: default;
    transform: none;
}

.action-btn.correct {
    background: linear-gradient(150deg, #34d399, #0d9f6e);
    box-shadow: 0 6px 18px rgba(52, 211, 153, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.action-btn.pass {
    background: linear-gradient(150deg, #fbbf24, #d97706);
    box-shadow: 0 6px 18px rgba(251, 191, 36, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.action-btn.skip {
    background: linear-gradient(150deg, #f43f5e, #be123c);
    box-shadow: 0 6px 18px rgba(244, 63, 94, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.action-icon {
    font-size: 21px;
    font-weight: 700;
}

.action-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* ============ TRANSITION SCREEN ============ */
.transition-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.transition-emoji {
    font-size: 76px;
    filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.4));
    animation: bounceIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.transition-msg {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.6px;
    margin-top: 20px;
}

.transition-next {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-60);
    margin-top: 8px;
}

.recap-section {
    width: 100%;
    max-width: 400px;
    margin-top: 30px;
}

.recap-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-60);
    margin-bottom: 10px;
    text-align: center;
}

.recap-chips {
    display: flex;
    gap: 10px;
}

.recap-chip {
    flex: 1;
    text-align: center;
    padding: 12px 8px;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.recap-chip-val {
    font-size: 21px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.recap-chip-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-60);
    margin-top: 2px;
}

.btn-continue {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 400px;
    padding: 18px;
    margin-top: 30px;
    border: none;
    border-radius: 18px;
    color: var(--text);
    font: 700 17px var(--font);
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all var(--transition);
}

.btn-continue:hover {
    transform: translateY(-2px);
}

/* ============ SUMMARY SCREEN ============ */
.summary-celebration {
    text-align: center;
    padding: 20px 0 10px;
}

.celebration-emoji {
    font-size: 68px;
    filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.4));
    animation: bounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.celebration-title {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.8px;
    margin-top: 10px;
    background: linear-gradient(100deg, #fbbf24, #f43f5e 60%, #d946ef);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.celebration-sub {
    font-size: 15px;
    color: var(--text-60);
    margin-top: 4px;
}

.score-big {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
}

.summary-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.summary-badge {
    padding: 7px 15px;
    border-radius: 18px;
    background: rgba(251, 191, 36, 0.14);
    border: 1px solid rgba(251, 191, 36, 0.4);
    color: var(--orange);
    font: 700 13px var(--font);
    animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Konfetti */
.confetti-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 5;
}

.confetti-piece {
    position: absolute;
    top: -20px;
    border-radius: 2px;
    opacity: 0;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0.6;
    }
}

.team-winner {
    text-align: center;
    padding: 16px;
    margin: 16px 0;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font: 700 18px var(--font);
}

.level-summary {
    padding: 15px 16px;
    margin-bottom: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.level-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.level-summary-name {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.level-summary-count {
    font-size: 13px;
    color: var(--text-60);
}

.result-chips {
    display: flex;
    gap: 8px;
}

.result-chip {
    flex: 1;
    text-align: center;
    padding: 9px 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.result-chip-val {
    font-size: 17px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.result-chip-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-60);
    margin-top: 2px;
}

.summary-total {
    padding: 15px 16px;
    margin-top: 16px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
}

.summary-total .level-summary-name {
    background: linear-gradient(100deg, var(--orange), var(--red));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============ STATS SCREEN ============ */
.stats-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.6px;
    text-align: center;
    margin-bottom: 24px;
}

.stats-subtitle {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--text-60);
    margin: 26px 0 12px;
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat-card {
    padding: 18px 14px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    text-align: center;
}

.stat-val {
    font-size: 27px;
    font-weight: 800;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-60);
    margin-top: 4px;
}

.history-item {
    padding: 13px 16px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.history-date {
    color: var(--text-40);
}

.history-score {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.history-detail {
    font-size: 12px;
    color: var(--text-60);
    margin-top: 4px;
}

.history-empty {
    text-align: center;
    padding: 40px 0;
    color: var(--text-40);
    font-size: 14px;
}

.btn-clear-history {
    display: block;
    width: 100%;
    padding: 13px;
    margin-top: 16px;
    border: 1px solid rgba(244, 63, 94, 0.35);
    border-radius: var(--radius);
    background: rgba(244, 63, 94, 0.08);
    color: var(--red);
    font: 600 14px var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-clear-history:hover {
    background: rgba(244, 63, 94, 0.16);
}

.btn-back {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: 600 15px var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-back:hover {
    background: var(--surface-2);
}

/* ============ OVERLAYS ============ */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 12, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-box {
    text-align: center;
    padding: 32px 42px;
    border-radius: var(--radius-lg);
    background: rgba(22, 22, 39, 0.92);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-soft);
}

.overlay-emoji {
    font-size: 52px;
    margin-bottom: 10px;
}

.overlay-box h3 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.4px;
}

.overlay-box p {
    font-size: 14px;
    color: var(--text-60);
    margin-top: 6px;
}

/* Übergabe-Screen (Team-Modus) */
.overlay.handoff {
    background: rgba(5, 5, 12, 0.78);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    cursor: pointer;
}

.handoff-box {
    border-color: rgba(139, 92, 246, 0.45);
    box-shadow: 0 0 50px rgba(124, 58, 237, 0.25);
}

.roundend-next {
    font-size: 13px;
    color: var(--text-40);
    margin-top: 4px;
}

.handoff-tap {
    margin-top: 18px;
    padding: 11px 26px;
    border-radius: 15px;
    background: var(--grad-accent);
    color: var(--text);
    font: 700 15px var(--font);
    display: inline-block;
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.4);
    animation: pulse 1.4s ease infinite;
}

/* ============ MODALS ============ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 12, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-box {
    width: 90%;
    max-width: 360px;
    padding: 28px;
    border-radius: var(--radius-lg);
    background: var(--bg-2);
    border: 1px solid var(--border-strong);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.modal-box.wide {
    max-width: 420px;
}

.modal-box h3 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.4px;
    margin-bottom: 8px;
}

.modal-box p {
    font-size: 14px;
    color: var(--text-60);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 13px;
    border: none;
    border-radius: 13px;
    font: 700 14px var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.modal-btn.cancel {
    background: var(--surface-2);
    color: var(--text);
}

.modal-btn.confirm {
    background: var(--grad-accent);
    color: var(--text);
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
}

.modal-btn:hover {
    transform: translateY(-1px);
}

#modal-quit .modal-btn.confirm,
#modal-clear-history .modal-btn.confirm {
    background: linear-gradient(150deg, #f43f5e, #be123c);
    box-shadow: 0 6px 18px rgba(244, 63, 94, 0.3);
}

/* How to play */
.howto-steps {
    margin: 16px 0;
}

.howto-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
}

.howto-num {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    flex-shrink: 0;
    background: var(--grad-accent);
    color: var(--text);
    font: 700 13px var(--font);
    display: flex;
    align-items: center;
    justify-content: center;
}

.howto-row span:last-child {
    font-size: 14px;
    color: var(--text-60);
    line-height: 1.45;
}

/* ============ EIGENE WÖRTER ============ */
.custom-open {
    width: 100%;
    margin-top: 12px;
    text-align: center;
}

.custom-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}

.select-field {
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-60) 50%), linear-gradient(135deg, var(--text-60) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
}

.select-field option {
    background: var(--bg-2);
    color: var(--text);
}

.custom-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.custom-empty {
    text-align: center;
    color: var(--text-40);
    font-size: 13px;
    padding: 18px 0;
}

.custom-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.custom-item-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.custom-item-word {
    font-size: 14px;
    font-weight: 700;
}

.custom-item-meta {
    font-size: 11px;
    color: var(--text-40);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-del {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: none;
    border-radius: 9px;
    background: rgba(244, 63, 94, 0.14);
    color: var(--red);
    font-size: 13px;
    cursor: pointer;
}

/* Foul-Button (Beschreiben-Modus) */
.foul-btn {
    display: block;
    margin: 2px auto 0;
    padding: 8px 18px;
    border: 1px solid rgba(244, 63, 94, 0.4);
    border-radius: 14px;
    background: rgba(244, 63, 94, 0.12);
    color: #fda4af;
    font: 700 13px var(--font);
    cursor: pointer;
    transition: transform var(--transition), background var(--transition);
}

.foul-btn:hover {
    background: rgba(244, 63, 94, 0.2);
}

.foul-btn:active {
    transform: scale(0.95);
}

/* Einstellungs-Zeile mit Steuerung unter dem Label */
.settings-row-col {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

/* ============ UPDATE-BANNER ============ */
.update-toast {
    position: fixed;
    left: 50%;
    bottom: calc(18px + var(--safe-bottom));
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px 12px 18px;
    border-radius: 16px;
    background: rgba(22, 22, 39, 0.96);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: calc(100vw - 32px);
    animation: fadeInUp 0.4s ease;
}

.update-text {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.update-btn {
    padding: 9px 16px;
    border: none;
    border-radius: 12px;
    background: var(--grad-accent);
    color: #fff;
    font: 700 13px var(--font);
    cursor: pointer;
}

.update-dismiss {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-60);
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
}

/* ============ UTILITIES ============ */
.hidden {
    display: none !important;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    60% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.5s ease forwards;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 380px) {
    .card-word {
        font-size: 27px;
    }

    .action-btn {
        padding: 13px 6px;
    }

    .btn-start {
        padding: 16px;
        font-size: 16px;
    }
}

@media (min-width: 600px) {

    .setup-scroll,
    .summary-scroll,
    .stats-scroll {
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
    }

    .card-area {
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
    }
}
