:root {
    color-scheme: dark;
    --bg: #10131c;
    --panel: #1a1f2d;
    --panel-border: #2a3145;
    --text: #f5f7fb;
    --muted: #b7c0d8;
    --accent: #e94560;
    --success: #1fbf75;
    --warning: #f0ad4e;
    --danger: #ff6b6b;
    --held-bg: rgba(233, 69, 96, 0.18);
    --held-border: var(--accent);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #0b0d14 0%, var(--bg) 100%);
    color: var(--text);
}

.app-shell {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem 1rem 4rem;
}

/* ── Header ────────────────────────────────────────────────────────────────── */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0 1rem;
}

.app-title {
    margin: 0;
    font-size: 1.5rem;
}

/* ── Screens ────────────────────────────────────────────────────────────────── */

.screen.hidden {
    display: none;
}

/* ── Panel ──────────────────────────────────────────────────────────────────── */

.panel {
    background: rgba(26, 31, 45, 0.92);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
    margin-bottom: 1rem;
}

.hero-panel {
    text-align: center;
}

.hero-panel h2 {
    margin-top: 0;
}

.lead {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.5rem;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, transform 0.1s;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn:not(:disabled):active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:not(:disabled):hover {
    background: #d63453;
}

.btn-danger {
    background: rgba(255, 107, 107, 0.16);
    color: #ffd7d7;
    border: 1px solid rgba(255, 107, 107, 0.45);
}

.btn-danger:not(:disabled):hover {
    background: rgba(255, 107, 107, 0.24);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border: 1px solid var(--panel-border);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--panel-border);
    padding: 0.4rem 1rem;
}

.btn-sm {
    font-size: 0.85rem;
    padding: 0.3rem 0.8rem;
}

.btn-roll {
    font-size: 1.1rem;
    padding: 0.75rem 2.5rem;
    min-width: 200px;
}

/* ── Start Screen ────────────────────────────────────────────────────────────── */

#resume-area {
    margin-bottom: 1rem;
}

#resume-area.hidden {
    display: none;
}

/* ── Player Setup ───────────────────────────────────────────────────────────── */

.player-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.player-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-input-row label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.95rem;
    flex: 1;
}

.player-name-input {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    padding: 0.4rem 0.75rem;
    flex: 1;
    min-width: 0;
}

.player-name-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.btn-remove-player {
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.player-setup-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ── Game Layout ─────────────────────────────────────────────────────────────── */

.game-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.game-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.game-status-text {
    font-weight: 700;
    font-size: 1rem;
}

/* ── Würfel ──────────────────────────────────────────────────────────────────── */

.dice-tray {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.die {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    padding: 0;
    line-height: 1;
}

.die:not(:disabled):hover {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}

.die[data-held="true"] {
    background: var(--held-bg);
    border-color: var(--held-border);
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.4);
}

.die:disabled {
    opacity: 0.4;
    cursor: default;
}

@keyframes roll {
    0%   { transform: rotate(0deg) scale(1); }
    25%  { transform: rotate(-15deg) scale(0.9); }
    50%  { transform: rotate(15deg) scale(1.1); }
    75%  { transform: rotate(-10deg) scale(0.95); }
    100% { transform: rotate(0deg) scale(1); }
}

.die.rolling {
    animation: roll 0.5s ease-in-out;
}

.roll-controls {
    text-align: center;
    padding-top: 0.5rem;
}

.dice-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
}

/* ── Scorecard ───────────────────────────────────────────────────────────────── */

.scorecard-panel {
    overflow-x: auto;
}

.scorecard-heading {
    margin: 0 0 1rem;
}

.scorecard {
    display: table;
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.scorecard-header,
.scorecard-row {
    display: table-row;
}

.scorecard-header .scorecard-label,
.scorecard-header .scorecard-player {
    display: table-cell;
    padding: 0.3rem 0.5rem;
    font-weight: 700;
    border-bottom: 2px solid var(--panel-border);
    white-space: nowrap;
}

.scorecard-header .scorecard-player.current {
    color: var(--accent);
}

.scorecard-section-label {
    display: table-row;
}

.scorecard-section-label::after {
    display: table-cell;
    content: attr(class);
    padding: 0.5rem 0.5rem 0.2rem;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Fix: section label does not have content attr trick; use a different approach */
.scorecard-section-label {
    display: block;
    padding: 0.5rem 0.5rem 0.2rem;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.scorecard-label {
    display: table-cell;
    padding: 0.35rem 0.5rem;
    color: var(--muted);
    white-space: nowrap;
    vertical-align: middle;
}

.scorecard-cell {
    display: table-cell;
    padding: 0.35rem 0.5rem;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid rgba(42, 49, 69, 0.5);
}

.scorecard-cell[data-state="filled"] {
    color: var(--text);
    font-weight: 600;
}

.scorecard-cell[data-state="empty"] {
    color: var(--panel-border);
}

.scorecard-cell[data-state="bonus"] {
    color: var(--success);
    font-weight: 700;
}

.scorecard-cell[data-state="total"] {
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent);
}

.score-preview-btn {
    background: rgba(233, 69, 96, 0.15);
    border: 1px solid rgba(233, 69, 96, 0.5);
    border-radius: 6px;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    transition: background 0.15s;
}

.score-preview-btn:hover {
    background: rgba(233, 69, 96, 0.3);
}

.scorecard-bonus-row .scorecard-label .muted {
    font-size: 0.75rem;
    color: var(--muted);
}

.scorecard-total-row .scorecard-label {
    font-weight: 700;
    color: var(--text);
}

/* ── Ergebnis ────────────────────────────────────────────────────────────────── */

.result-panel {
    text-align: center;
}

.result-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.result-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    font-size: 1.05rem;
}

.result-entry.winner {
    background: rgba(31, 191, 117, 0.12);
    border: 1px solid rgba(31, 191, 117, 0.4);
}

.result-rank {
    font-size: 1.3rem;
    width: 2rem;
    text-align: center;
}

.result-name {
    flex: 1;
    text-align: left;
    padding-left: 0.75rem;
    font-weight: 600;
}

.result-score {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
}

/* ── Status Badge ─────────────────────────────────────────────────────────────── */

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.75rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
}

.status-badge[data-state="online"]   { background: rgba(31, 191, 117, 0.16); color: #8cf0bf; }
.status-badge[data-state="offline"]  { background: rgba(240, 173, 78, 0.16); color: #ffd28b; }
.status-badge[data-state="error"]    { background: rgba(255, 107, 107, 0.16); color: #ffb4b4; }
.status-badge[data-state="checking"] { background: rgba(233, 69, 96, 0.16); color: #ff9db1; }

/* ── Error Banner ────────────────────────────────────────────────────────────── */

.error-banner {
    margin-top: 1rem;
    border-color: rgba(255, 107, 107, 0.5);
    color: #ffd3d3;
}

.sync-toast {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    width: min(92vw, 34rem);
    padding: 0.85rem 1rem;
    border-radius: 14px;
    border: 1px solid rgba(240, 173, 78, 0.45);
    background: rgba(240, 173, 78, 0.18);
    color: #ffe3b5;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    z-index: 20;
}

.hidden {
    display: none !important;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */

@media (min-width: 640px) {
    .die {
        width: 4rem;
        height: 4rem;
        font-size: 2.4rem;
    }
}

@media (max-width: 480px) {
    .player-setup-actions {
        flex-direction: column-reverse;
    }

    .btn-roll {
        width: 100%;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #0b0d14 0%, var(--bg) 100%);
    color: var(--text);
}

.app-shell {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
}

.hero,
.panel {
    background: rgba(26, 31, 45, 0.92);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.hero {
    margin-bottom: 1.5rem;
}

.eyebrow {
    margin: 0 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-size: 0.85rem;
}

h1,
h2,
p {
    margin-top: 0;
}

.lead {
    margin-bottom: 0;
    color: var(--muted);
}

.panel-header {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 0;
}

.status-grid dt {
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.status-grid dd {
    margin: 0;
    font-weight: 600;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
}

.status-badge[data-state="online"] { background: rgba(31, 191, 117, 0.16); color: #8cf0bf; }
.status-badge[data-state="offline"] { background: rgba(240, 173, 78, 0.16); color: #ffd28b; }
.status-badge[data-state="error"] { background: rgba(255, 107, 107, 0.16); color: #ffb4b4; }
.status-badge[data-state="checking"] { background: rgba(233, 69, 96, 0.16); color: #ff9db1; }

.error-banner {
    margin-top: 1.5rem;
    border-color: rgba(255, 107, 107, 0.5);
    color: #ffd3d3;
}

.hidden {
    display: none;
}

@media (max-width: 640px) {
    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* ── Phase 6: Online-Spiel ─────────────────────────────────────────────────── */

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-badge {
    font-size: 0.8rem;
    font-weight: 700;
    color: #8cf0bf;
    padding: 0.2rem 0.5rem;
    background: rgba(31, 191, 117, 0.12);
    border-radius: 999px;
}

.start-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Auth-Screen */
.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.auth-tab {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--muted);
    border-radius: 8px;
    padding: 0.4rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
    background: rgba(233, 69, 96, 0.18);
    color: var(--accent);
    border-color: rgba(233, 69, 96, 0.4);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.form-field input {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text);
    padding: 0.55rem 0.75rem;
    font-size: 1rem;
    width: 100%;
}

.form-field input:focus {
    outline: 2px solid rgba(233, 69, 96, 0.55);
    border-color: transparent;
}

.form-error {
    color: #ffd3d3;
    font-size: 0.88rem;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.35);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
}

/* Online-Menü */
.online-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.25rem 0;
}

.join-form {
    display: flex;
    gap: 0.5rem;
}

.join-code-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text);
    padding: 0.55rem 0.75rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.join-code-input:focus {
    outline: 2px solid rgba(233, 69, 96, 0.55);
    border-color: transparent;
}

/* Lobby */
.join-code-display {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 0.22em;
    text-align: center;
    color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
    border: 2px dashed rgba(233, 69, 96, 0.4);
    border-radius: 14px;
    padding: 1rem 1.5rem;
    margin: 1rem 0;
}

.lobby-player-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.lobby-player {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    font-weight: 600;
}

.lobby-hint {
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
    margin: 0.5rem 0 1rem;
}

/* Game-Top-Actions (online leave + quit in a row) */
.game-top-actions {
    display: flex;
    gap: 0.5rem;
}

/* ── Dark Mode / Light Mode ────────────────────────────────────────────────── */

body.light-mode {
    color-scheme: light;
    --bg: #f0f2f8;
    --panel: #ffffff;
    --panel-border: #d0d7e8;
    --text: #1a1f2d;
    --muted: #5a6484;
    --accent: #d63050;
    --success: #16a35e;
    --warning: #d48f00;
    --danger: #d9534f;
    --held-bg: rgba(214, 48, 80, 0.12);
    --held-border: var(--accent);
    background: linear-gradient(180deg, #e8eaf2 0%, var(--bg) 100%);
}

body.light-mode .panel {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.btn-icon {
    padding: 0.45rem 0.65rem;
    font-size: 1.1rem;
}

/* ── Stats Grid ─────────────────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

body.light-mode .stat-card {
    background: rgba(0, 0, 0, 0.04);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 0.3rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
}

/* ── History List ───────────────────────────────────────────────────────────── */

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.history-entry {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
}

body.light-mode .history-entry {
    background: rgba(0, 0, 0, 0.03);
}

.history-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.history-date {
    color: var(--muted);
    font-size: 0.82rem;
}

.history-type {
    font-size: 0.75rem;
    background: var(--panel-border);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    color: var(--muted);
}

.history-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.history-score-entry {
    font-size: 0.85rem;
    font-weight: 600;
}

.history-score-entry.winner {
    color: var(--accent);
}

/* ── Leaderboard ────────────────────────────────────────────────────────────── */

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 0.65rem 1rem;
}

body.light-mode .leaderboard-entry {
    background: rgba(0, 0, 0, 0.03);
}

.leaderboard-entry.top-3 {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.08);
}

.leaderboard-rank {
    font-size: 1.2rem;
    font-weight: 800;
    min-width: 2rem;
    text-align: center;
}

.leaderboard-username {
    flex: 1;
    font-weight: 600;
}

.leaderboard-score {
    font-weight: 800;
    color: var(--accent);
}

.leaderboard-games {
    font-size: 0.8rem;
    color: var(--muted);
}

.your-rank {
    background: rgba(233, 69, 96, 0.12);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
}

/* ── Achievements ───────────────────────────────────────────────────────────── */

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.achievement-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    transition: opacity 0.2s;
}

body.light-mode .achievement-card {
    background: rgba(0, 0, 0, 0.03);
}

.achievement-card.locked {
    opacity: 0.45;
    filter: grayscale(0.6);
}

.achievement-icon {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 0.4rem;
}

.achievement-title {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.achievement-desc {
    font-size: 0.78rem;
    color: var(--muted);
}

.achievement-unlocked-at {
    font-size: 0.72rem;
    color: var(--success);
    margin-top: 0.3rem;
}

/* ── Friends ─────────────────────────────────────────────────────────────────── */

.friend-add-form {
    margin-bottom: 1.5rem;
}

.friend-add-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.friend-add-row input {
    flex: 1;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-size: 1rem;
}

body.light-mode .friend-add-row input {
    background: rgba(0, 0, 0, 0.04);
}

.friends-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    min-height: 1.5rem;
}

.friend-entry {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 0.6rem 1rem;
}

body.light-mode .friend-entry {
    background: rgba(0, 0, 0, 0.03);
}

.friend-name {
    flex: 1;
    font-weight: 600;
}

.friend-status {
    font-size: 0.78rem;
    color: var(--muted);
}

/* ── Profile Screen ─────────────────────────────────────────────────────────── */

.profile-username {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 1.5rem;
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* ── Settings ───────────────────────────────────────────────────────────────── */

.settings-group {
    margin-bottom: 1rem;
}

.settings-toggle {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    cursor: pointer;
}

.settings-toggle input[type="checkbox"] {
    margin-right: 0.5rem;
}

.settings-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin-left: 1.5rem;
}

.dangerous-toggle {
    gap: 0.5rem;
}

.danger-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    color: #ffd7d7;
}

/* ── Form Success ───────────────────────────────────────────────────────────── */

.form-success {
    color: var(--success);
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: rgba(31, 191, 117, 0.1);
    border: 1px solid rgba(31, 191, 117, 0.3);
    margin-bottom: 0.75rem;
}

/* ── Result Achievements ────────────────────────────────────────────────────── */

.result-achievements {
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid rgba(233, 69, 96, 0.3);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.result-achievements h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: var(--accent);
}

.new-achievement-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 600;
    margin: 0.2rem;
}

/* ── Pagination ─────────────────────────────────────────────────────────────── */

.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

/* ── Legal Pages ────────────────────────────────────────────────────────────── */

.legal-panel h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.legal-panel ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.legal-panel p {
    line-height: 1.7;
    color: var(--muted);
}

.title-link {
    color: inherit;
    text-decoration: none;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */

.app-footer {
    text-align: center;
    padding: 1rem 0 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.app-footer a {
    color: var(--muted);
    text-decoration: none;
}

.app-footer a:hover {
    color: var(--accent);
}

/* ── Muted text helper ──────────────────────────────────────────────────────── */

.muted {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ── KI-Spiel-Toggle ────────────────────────────────────────────────────────── */

.ai-game-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
}

.ai-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

/* ── Turniermodus ───────────────────────────────────────────────────────────── */

.tournament-actions {
    margin-bottom: 1rem;
}

.tournament-join-form {
    margin: 0.5rem 0;
}

.tournament-open-list {
    margin-top: 1rem;
}

.tournament-list-item {
    padding: 0.75rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.15s;
}

.tournament-list-item:hover {
    background: rgba(255, 255, 255, 0.09);
}

body.light-mode .tournament-list-item {
    background: rgba(0, 0, 0, 0.03);
}

body.light-mode .tournament-list-item:hover {
    background: rgba(0, 0, 0, 0.07);
}

.tournament-list-name {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.tournament-list-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.tournament-detail-header {
    margin-bottom: 1rem;
}

.tournament-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.tournament-meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.tournament-participants {
    font-size: 0.9rem;
}

.tournament-detail-actions {
    margin-top: 1rem;
}

.tournament-bracket {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bracket-round {
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius);
    padding: 0.75rem;
}

body.light-mode .bracket-round {
    background: rgba(0, 0, 0, 0.03);
}

.bracket-round-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.bracket-match {
    padding: 0.6rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

body.light-mode .bracket-match {
    background: rgba(0, 0, 0, 0.03);
}

.bracket-match.my-match {
    border-left: 3px solid var(--accent);
}

.bracket-match.finished {
    opacity: 0.75;
}

.bracket-players {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.bracket-vs {
    font-size: 0.75rem;
    color: var(--muted);
    padding: 0 0.25rem;
}

.bracket-winner {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

.btn-sm {
    padding: 0.25rem 0.7rem;
    font-size: 0.8rem;
}
