/* ===== CSS Reset & Variables ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-input: #252532;
    --text-primary: #e8e8ec;
    --text-secondary: #9898a8;
    --text-muted: #606070;
    --accent-primary: #7b5cff;
    --accent-secondary: #a78bff;
    --accent-glow: rgba(123, 92, 255, 0.3);
    --success: #4ade80;
    --success-glow: rgba(74, 222, 128, 0.3);
    --error: #f87171;
    --error-glow: rgba(248, 113, 113, 0.3);
    --border-color: #2a2a38;
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Top Banner ===== */
.top-banner {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    position: relative;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.top-banner a {
    color: white;
    text-decoration: underline;
    font-weight: 600;
    margin: 0 0.25rem;
}

.top-banner a:hover {
    color: var(--bg-primary);
}

/* ===== Base Styles ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

/* ===== Animated Background Blobs ===== */
.bg-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background: var(--bg-primary);
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s infinite ease-in-out alternate;
    border-radius: 50%;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: rgba(123, 92, 255, 0.15); /* accent-primary */
    animation-delay: 0s;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: rgba(167, 139, 255, 0.1); /* accent-secondary */
    animation-delay: -5s;
    animation-duration: 25s;
}

.blob-3 {
    top: 40%;
    left: 60%;
    width: 40vw;
    height: 40vw;
    background: rgba(74, 222, 128, 0.08); /* success */
    animation-delay: -10s;
    animation-duration: 22s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(5%, 5%) scale(1.1);
    }
    66% {
        transform: translate(-5%, 10%) scale(0.9);
    }
    100% {
        transform: translate(0, 0) scale(1);
    }
}

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

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

.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ===== Welcome Popup ===== */
.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.5s ease-out;
}

.popup-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 3rem;
    max-width: 550px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: var(--shadow-lg), 0 0 60px var(--accent-glow);
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.popup-content h1 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.popup-text {
    text-align: left;
    margin-bottom: 2rem;
}

.popup-text p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.popup-text h3 {
    color: var(--accent-secondary);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.popup-text ul {
    list-style: none;
    padding-left: 0;
}

.popup-text li {
    color: var(--text-secondary);
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.popup-text li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent-primary);
}

/* ===== Category Selection ===== */
.category-title {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2.5rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}

.category-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    opacity: 0;
    transition: var(--transition-smooth);
}

.category-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--accent-glow);
}

.category-card:hover::before {
    opacity: 0.1;
}

.category-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.category-card h3 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

.category-card p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.category-progress {
    color: var(--accent-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

/* ===== Buttons ===== */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card);
}

.btn-check {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 100%;
}

.btn-check:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

.btn-check:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-hint {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-hint:hover {
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
}

/* ===== Main Container ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Puzzle Header ===== */
.puzzle-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* ===== Progress Section ===== */
.progress-section {
    flex: 1;
}

.progress-text {
    text-align: center;
    margin-bottom: 0.75rem;
}

#progressText {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.progress-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* ===== Puzzle Container ===== */
.puzzle-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.puzzle-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transition: var(--transition-smooth);
}

.puzzle-card.correct {
    border-color: var(--success);
    box-shadow: var(--shadow-lg), 0 0 30px var(--success-glow);
}

.puzzle-card.incorrect {
    animation: shake 0.5s ease-out;
    border-color: var(--error);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-10px); }
    80% { transform: translateX(10px); }
}

.puzzle-title {
    font-size: 1.4rem;
    color: var(--accent-secondary);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.puzzle-category-badge {
    display: inline-block;
    background: rgba(123, 92, 255, 0.15);
    color: var(--accent-secondary);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
    border: 1px solid rgba(123, 92, 255, 0.3);
}

.puzzle-question {
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    line-height: 1.7;
    min-height: 60px;
}

/* ===== Puzzle Type Areas ===== */
.puzzle-type-area {
    min-height: 200px;
}

/* ===== Answer Section ===== */
.answer-section {
    margin-bottom: 1.5rem;
}

.answer-input {
    width: 100%;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    color: var(--text-primary);
    transition: var(--transition-smooth);
}

.answer-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.answer-input::placeholder {
    color: var(--text-muted);
}

/* ===== Sudoku Grid ===== */
.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 1px;
    background: rgba(255, 255, 255, 0.16); /* deutliche, neutrale Linien zwischen den Feldern */
    border: 3px solid rgba(255, 255, 255, 0.4); /* kräftiger Außenrahmen */
    max-width: 450px;
    margin: 0 auto 1.5rem;
    aspect-ratio: 1;
}

.sudoku-cell {
    background: var(--bg-input);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.sudoku-cell input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    outline: none;
}

.sudoku-cell.given {
    background: var(--bg-card);
    color: var(--accent-secondary);
    cursor: default;
}

.sudoku-cell.given input {
    color: var(--accent-secondary);
    cursor: default;
}

.sudoku-cell:not(.given):hover {
    background: var(--bg-card);
}

/* Deutlich kräftigere Trennlinien zwischen den 3x3-Blöcken als zwischen normalen Feldern */
.sudoku-cell:nth-child(3n) {
    border-right: 3px solid rgba(255, 255, 255, 0.4);
}

.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 3px solid rgba(255, 255, 255, 0.4);
}

/* ===== Sudoku Cell States (Richtig/Falsch wird erst beim Verlassen des Felds sichtbar) ===== */
.sudoku-cell.correct {
    background: rgba(74, 222, 128, 0.25);
}

.sudoku-cell.incorrect {
    background: rgba(248, 113, 113, 0.28);
}

.sudoku-cell.row-complete,
.sudoku-cell.col-complete,
.sudoku-cell.box-complete {
    background: rgba(74, 222, 128, 0.14);
    box-shadow: inset 0 0 0 2px var(--success);
}

/* ===== Sudoku Toolbar (Timer, Notizen, Fehlerlimit) ===== */
.sudoku-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.sudoku-timer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.5rem 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.sudoku-timer svg {
    width: 16px;
    height: 16px;
    color: var(--accent-secondary);
    flex-shrink: 0;
}

.sudoku-tool-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.sudoku-tool-btn:hover {
    border-color: var(--accent-primary);
}

.sudoku-tool-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.sudoku-error-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.sudoku-error-toggle input {
    accent-color: var(--accent-primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ===== Sudoku Cell Highlighting ===== */
/* Zeile/Spalte/Block: neutraler blauer Ton -- rein strukturell, "du bist in diesem Bereich" */
.sudoku-cell.same-row,
.sudoku-cell.same-col,
.sudoku-cell.same-box {
    background: rgba(56, 189, 248, 0.12);
}

.sudoku-cell.given.same-row,
.sudoku-cell.given.same-col,
.sudoku-cell.given.same-box {
    background: rgba(56, 189, 248, 0.18);
}

/* Gleiche Zahl (Hauptfeature): warmes Gold -- deutlich vom blauen Bereichs-Highlight abgesetzt */
.sudoku-cell.same-number {
    background: rgba(250, 204, 21, 0.32);
}

.sudoku-cell.given.same-number {
    background: rgba(250, 204, 21, 0.4);
}

/* Aktuell ausgewähltes Feld: kräftiges Lila mit dickem Rahmen -- klar von allem anderen abgesetzt */
.sudoku-cell.selected {
    background: rgba(123, 92, 255, 0.45);
    box-shadow: inset 0 0 0 3px var(--accent-primary);
}

.sudoku-cell.given.selected {
    background: rgba(167, 139, 255, 0.45);
    box-shadow: inset 0 0 0 3px var(--accent-secondary);
}

/* ===== Sudoku Pencil Notes ===== */
.sudoku-notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 2px;
    pointer-events: none;
}

.sudoku-notes span {
    font-size: 0.55rem;
    line-height: 1;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Sudoku Number Pad ===== */
.sudoku-number-pad {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 0.35rem;
    max-width: 450px;
    margin: 0 auto;
}

.sudoku-pad-btn {
    aspect-ratio: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    line-height: 1;
}

.sudoku-pad-btn:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card);
}

.sudoku-pad-btn:active {
    transform: scale(0.93);
}

.sudoku-pad-btn.depleted {
    opacity: 0.3;
    pointer-events: none;
}

.sudoku-pad-btn .sudoku-pad-remaining {
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 2px;
}

.sudoku-pad-btn.eraser {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* ===== Sudoku Game Over (Fehlerlimit) Overlay ===== */
.sudoku-gameover-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1.5rem;
}

.sudoku-gameover-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    max-width: 320px;
    box-shadow: var(--shadow-lg);
}

.sudoku-gameover-box h3 {
    margin-bottom: 0.5rem;
}

.sudoku-gameover-box p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* ===== Sudoku Win Confetti ===== */
.sudoku-confetti-piece {
    position: fixed;
    top: -12px;
    width: 8px;
    height: 14px;
    opacity: 0.9;
    z-index: 999;
    pointer-events: none;
    animation-name: sudokuConfettiFall;
    animation-timing-function: ease-in;
    animation-fill-mode: forwards;
}

@keyframes sudokuConfettiFall {
    to {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0.5;
    }
}

/* ===== Tournament Mode ===== */
.tournament-header {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.tournament-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
}

.tournament-timer svg {
    width: 24px;
    height: 24px;
}

.tournament-score {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tournament-score-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tournament-score-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--success);
}

.tournament-mode-badge {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.tournament-complete {
    text-align: center;
    padding: 2rem;
}

.tournament-complete h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--success), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tournament-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.tournament-stat {
    background: var(--bg-input);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.tournament-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-secondary);
}

.tournament-stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ===== Controls Section ===== */
.controls-section {
    margin-bottom: 1.5rem;
}

/* ===== Feedback Message ===== */
.feedback-message {
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
    font-weight: 500;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease-out;
}

.feedback-message.success {
    background: rgba(74, 222, 128, 0.15);
    color: var(--success);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.feedback-message.error {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

/* ===== Hints Section ===== */
.hints-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    text-align: center;
}

.hint-content {
    background: var(--bg-input);
    border-radius: 10px;
    padding: 1rem;
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease-out;
}

.hint-content.unavailable {
    color: var(--text-muted);
    font-style: italic;
}

/* ===== Completion Message ===== */
.completion-message {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.completion-message h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--success), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.completion-message p {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

/* ===== Klicktrainer ===== */
.clicktrainer-info {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.clicktrainer-stat {
    flex: 1;
    background: var(--bg-input);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    text-align: center;
}

.clicktrainer-stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.clicktrainer-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-secondary);
    font-variant-numeric: tabular-nums;
}

.clicktrainer-arena {
    position: relative;
    width: 100%;
    height: 340px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    touch-action: manipulation;
}

.clicktrainer-target {
    position: absolute;
    border-radius: 50%;
    border: none;
    padding: 0;
    background: radial-gradient(circle at 35% 35%, var(--accent-secondary), var(--accent-primary));
    box-shadow: 0 0 20px var(--accent-glow);
    cursor: pointer;
    touch-action: manipulation;
    animation: clicktrainerPop 0.15s ease-out;
}

.clicktrainer-best {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* ===== Emoji-Rätsel ===== */
.puzzle-question.emoji-question {
    font-size: 3rem;
    text-align: center;
    letter-spacing: 0.4rem;
    line-height: 1.5;
}

/* ===== Wordle ===== */
.wordle-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 340px;
    margin: 0 auto 1.5rem;
}

.wordle-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.wordle-row.wordle-shake {
    animation: shake 0.4s ease-in-out;
}

.wordle-tile {
    aspect-ratio: 1;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
}

.wordle-tile.filled {
    border-color: rgba(255, 255, 255, 0.45);
}

.wordle-tile.flip {
    animation: wordleFlip 0.5s ease;
}

@keyframes wordleFlip {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

.wordle-tile.correct {
    background: var(--success);
    border-color: var(--success);
    color: #0a0a0f;
}

.wordle-tile.present {
    background: #eab308;
    border-color: #eab308;
    color: #0a0a0f;
}

.wordle-tile.absent {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.wordle-message {
    text-align: center;
    min-height: 1.4rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.wordle-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 500px;
    margin: 0 auto;
}

.wordle-keyboard-row {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.wordle-key {
    flex: 1;
    max-width: 42px;
    height: 52px;
    border: none;
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    touch-action: manipulation;
}

.wordle-key:hover {
    background: var(--bg-card);
}

.wordle-key:active {
    transform: scale(0.92);
}

.wordle-key-wide {
    max-width: 64px;
    font-size: 0.7rem;
}

.wordle-key.key-correct {
    background: var(--success);
    color: #0a0a0f;
}

.wordle-key.key-present {
    background: #eab308;
    color: #0a0a0f;
}

.wordle-key.key-absent {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

/* ===== Mastermind ===== */
.mastermind-intro {
    max-width: 380px;
    margin: 0 auto 1.25rem;
    text-align: center;
}

.mastermind-legend {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.mastermind-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.mastermind-legend-item .mastermind-feedback-dot {
    width: 12px;
    height: 12px;
}

.mastermind-help-toggle {
    background: none;
    border: none;
    color: var(--accent-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.mastermind-help-toggle:hover {
    text-decoration: underline;
}

.mastermind-help {
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.mastermind-help p {
    margin-bottom: 0.6rem;
}

.mastermind-help p:last-child {
    margin-bottom: 0;
}

.mastermind-help ul {
    margin: 0 0 0.6rem 1.1rem;
    padding: 0;
}

.mastermind-help li {
    margin-bottom: 0.3rem;
}

.mastermind-board {
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
    max-width: 360px;
    margin: 0 auto 1rem;
}

.mastermind-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
}

.mastermind-row.mastermind-shake {
    animation: shake 0.4s ease-in-out;
}

.mastermind-pegs {
    display: flex;
    gap: 8px;
}

.mastermind-peg {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    transition: var(--transition-smooth);
}

.mastermind-peg.empty {
    background: rgba(255, 255, 255, 0.05) !important;
    border-style: dashed;
}

.mastermind-feedback {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    flex-shrink: 0;
}

.mastermind-feedback-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.mastermind-feedback-dot.black {
    background: #0a0a0f;
    border-color: rgba(255, 255, 255, 0.4);
}

.mastermind-feedback-dot.white {
    background: #f4f4f5;
    border-color: rgba(255, 255, 255, 0.6);
}

.mastermind-controls {
    max-width: 360px;
    margin: 0 auto;
}

.mastermind-picker {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.mastermind-color-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    transition: var(--transition-smooth);
    touch-action: manipulation;
}

.mastermind-color-btn:hover {
    transform: scale(1.08);
    border-color: rgba(255, 255, 255, 0.6);
}

.mastermind-color-btn:active {
    transform: scale(0.92);
}

.mastermind-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.mastermind-actions .btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== 2048 ===== */
.game2048-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.game2048-score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    min-width: 90px;
}

.game2048-score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.game2048-score-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.game2048-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-width: 380px;
    margin: 0 auto 1.25rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    touch-action: none;
}

.game2048-cell {
    aspect-ratio: 1;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    user-select: none;
}

.game2048-tile[data-value="2"] { background: #3d3d52; color: #e5e5f0; }
.game2048-tile[data-value="4"] { background: #4a4a68; color: #e5e5f0; }
.game2048-tile[data-value="8"] { background: #7b5cff; color: #fff; }
.game2048-tile[data-value="16"] { background: #9b6cff; color: #fff; }
.game2048-tile[data-value="32"] { background: #c77dff; color: #fff; }
.game2048-tile[data-value="64"] { background: #f97316; color: #fff; }
.game2048-tile[data-value="128"] { background: #fb923c; color: #fff; font-size: 1.25rem; }
.game2048-tile[data-value="256"] { background: #facc15; color: #1a1a1a; font-size: 1.25rem; }
.game2048-tile[data-value="512"] { background: #eab308; color: #1a1a1a; font-size: 1.25rem; }
.game2048-tile[data-value="1024"] { background: #4ade80; color: #1a1a1a; font-size: 1.1rem; }
.game2048-tile[data-value="2048"] {
    background: linear-gradient(135deg, #facc15, #f97316);
    color: #1a1a1a;
    font-size: 1.1rem;
    box-shadow: 0 0 20px rgba(250, 204, 21, 0.6);
}
.game2048-tile[data-value="super"] {
    background: #12121a;
    color: #facc15;
    font-size: 1rem;
    border: 2px solid #facc15;
}

@keyframes game2048Pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.game2048-tile.new {
    animation: game2048Pop 0.2s ease-out;
}

@keyframes game2048Merge {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.game2048-tile.merged {
    animation: game2048Merge 0.2s ease-out;
}

.game2048-dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: 180px;
    margin: 0 auto;
}

.game2048-dpad-row {
    display: flex;
    gap: 6px;
}

.game2048-dpad-btn {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    touch-action: manipulation;
    transition: var(--transition-smooth);
}

.game2048-dpad-btn:hover {
    background: var(--bg-card);
}

.game2048-dpad-btn:active {
    transform: scale(0.9);
    background: var(--accent-primary);
}

.game2048-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.75rem;
}

.game2048-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1.5rem;
}

.game2048-overlay-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    max-width: 340px;
    box-shadow: var(--shadow-lg);
}

.game2048-overlay-box h3 {
    margin-bottom: 0.5rem;
}

.game2048-overlay-box p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.game2048-overlay-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.clicktrainer-target:active {
    transform: scale(0.85);
}

@keyframes clicktrainerPop {
    0% { transform: scale(0.3); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.clicktrainer-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 1.5rem;
    text-align: center;
    background: rgba(10, 10, 15, 0.85);
    animation: fadeIn 0.3s ease-out;
}

.clicktrainer-overlay p {
    font-size: 1.1rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.clicktrainer-overlay.success p {
    color: var(--success);
    font-size: 1.3rem;
    font-weight: 600;
}

.clicktrainer-overlay.fail p {
    color: var(--error);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .category-grid {
        grid-template-columns: 1fr;
    }
    
    .puzzle-header {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 600px) {
    .popup-content {
        padding: 1.5rem;
    }
    
    .popup-content h1 {
        font-size: 1.3rem;
    }
    
    .container {
        padding: 0.5rem;
    }
    
    .puzzle-card {
        padding: 1rem;
    }
    
    .puzzle-title {
        font-size: 1.1rem;
    }
    
    .clicktrainer-arena {
        height: 260px;
    }
    
    .puzzle-question {
        font-size: 0.95rem;
    }
    
    .sudoku-grid {
        max-width: 100%;
    }
    
    .sudoku-cell input {
        font-size: 1rem;
    }

    .sudoku-notes span {
        font-size: 0.48rem;
    }

    .sudoku-number-pad {
        max-width: 100%;
        gap: 0.25rem;
    }

    .sudoku-pad-btn {
        font-size: 0.95rem;
    }

    .sudoku-pad-btn .sudoku-pad-remaining {
        font-size: 0.5rem;
    }

    .sudoku-toolbar {
        gap: 0.4rem;
    }

    .sudoku-timer,
    .sudoku-tool-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }

    .sudoku-error-toggle {
        font-size: 0.75rem;
    }
}

/* ===== Transition Animations ===== */
.slide-out-left {
    animation: slideOutLeft 0.4s ease-out forwards;
}

.slide-in-right {
    animation: slideInRight 0.4s ease-out forwards;
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50px);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== 20 Questions / Chat UI ===== */
.api-key-section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.api-key-section p {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.questions-remaining {
    text-align: right;
    font-weight: bold;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
}

.chat-history {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    height: 300px;
    overflow-y: auto;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.chat-message {
    max-width: 80%;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    line-height: 1.4;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--accent-primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-message.ai {
    align-self: flex-start;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.chat-input-section {
    display: flex;
    gap: 0.5rem;
}

.chat-input-section input {
    flex: 1;
    margin-bottom: 0;
}

.chat-input-section button {
    width: auto;
    padding: 0 1.5rem;
}

.whoami-giveup-btn {
    display: block;
    margin: 0.75rem auto 0;
    font-size: 0.85rem;
    padding: 0.5rem 1.25rem;
    opacity: 0.75;
}

.whoami-giveup-btn:hover {
    opacity: 1;
}

/* ===== Who Am I Styles ===== */
.whoami-clues {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.whoami-clue {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.whoami-clue:last-child {
    border-bottom: none;
}

/* ===== Combination Puzzle Styles ===== */
.combination-questions {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 2rem;
}

.combination-question-block {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.combination-question-text {
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.combination-answer-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.combination-letter-boxes {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.combination-letter-box {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    transition: var(--transition-smooth);
    cursor: text;
    text-align: center; /* Fix letter alignment */
    padding: 0; /* Fix letter alignment */
}

.combination-letter-box:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.combination-letter-box.highlighted {
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.1);
}

.combination-letter-box.correct {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.1);
    pointer-events: none;
}

.combination-letter-box.locked {
    opacity: 0.6;
    pointer-events: none;
}

.combination-letter-box.shake {
    border-color: var(--error);
    background: rgba(248, 113, 113, 0.15);
    animation: shake 0.4s ease-in-out;
}

.combination-check-icon {
    font-size: 1.5rem;
    opacity: 0;
    transition: var(--transition-smooth);
}

.combination-check-icon.visible {
    opacity: 1;
}

.combination-final {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.combination-final-label {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--accent-secondary);
}

.combination-final-input {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.combination-final-box {
    width: 3rem;
    height: 3rem;
    background: var(--bg-input);
    border: 2px solid var(--accent-primary);
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    transition: var(--transition-smooth);
    cursor: text;
    box-shadow: 0 0 0 2px var(--accent-glow);
    text-align: center; /* Fix letter alignment */
    padding: 0; /* Fix letter alignment */
}

.combination-final-box:focus {
    outline: none;
    border-color: var(--accent-secondary);
    box-shadow: 0 0 0 4px var(--accent-glow);
    transform: scale(1.05);
}

.combination-final-box.correct {
    border-color: var(--success);
    background: rgba(74, 222, 128, 0.1);
    box-shadow: 0 0 0 3px var(--success-glow);
}

.combination-final-box.incorrect {
    border-color: var(--error);
    background: rgba(248, 113, 113, 0.1);
    box-shadow: 0 0 0 3px var(--error-glow);
    animation: shake 0.4s ease-in-out;
}

@media (max-width: 768px) {
    .popup-content {
        padding: 1.5rem;
    }
    
    .popup-content h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .popup-text {
        margin-bottom: 1.5rem;
    }
    
    .popup-text p, .popup-text li {
        font-size: 0.9rem;
    }

    .combination-letter-box {
        width: 2rem;
        height: 2rem;
        font-size: 1rem;
    }
    
    .combination-final-box {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .combination-letter-box {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.9rem;
    }
    
    .combination-final-box {
        width: 2rem;
        height: 2rem;
        font-size: 1.1rem;
    }
    
    .combination-answer-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .combination-check-icon {
        align-self: flex-end;
    }

    .wordle-key {
        max-width: 32px;
        height: 46px;
        font-size: 0.8rem;
    }

    .wordle-key-wide {
        max-width: 48px;
        font-size: 0.6rem;
    }

    .wordle-tile {
        font-size: 1.3rem;
    }

    .puzzle-question.emoji-question {
        font-size: 2.2rem;
        letter-spacing: 0.25rem;
    }

    .mastermind-peg {
        width: 26px;
        height: 26px;
    }

    .mastermind-color-btn {
        width: 38px;
        height: 38px;
    }

    .mastermind-row {
        padding: 0.4rem 0.5rem;
        gap: 0.5rem;
    }
}
