:root {
  --bg: #0f1420;
  --panel: #171e2e;
  --panel-2: #1f2840;
  --line: #2c3653;
  --text: #e7ebf5;
  --muted: #8f9bb8;
  --accent: #f5b83d;
  --accent-ink: #1b1405;
  --good: #3ecf8e;
  --bad: #ff6b6b;
  --warn: #f5b83d;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 20% 0%, #1a2340 0, var(--bg) 55%); color: var(--text); min-height: 100vh; }
.hidden { display: none !important; }
h1 { margin: 0 0 .25rem; font-size: 1.6rem; }
h2 { margin: 0 0 .75rem; font-size: 1.05rem; letter-spacing: .02em; }
h2 + * { margin-top: 0; }
.card h2:not(:first-child) { margin-top: 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.error { color: var(--bad); min-height: 1.2em; margin: .5rem 0 0; }
.ok { color: var(--good) !important; }
.grow { flex: 1; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.5rem; border-bottom: 1px solid var(--line); background: rgba(15, 20, 32, .7); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 1.15rem; }
.logo { color: var(--accent); font-size: 1.4rem; }
.userbox { display: flex; gap: .75rem; align-items: center; color: var(--muted); }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.span2 { grid-column: span 2; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }

label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; color: var(--muted); flex: 1; }
input, select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: .6rem .7rem; font-size: 1rem; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input:disabled, select:disabled { opacity: .55; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }

button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: .6rem 1rem; font-size: .95rem; cursor: pointer; font-weight: 600; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.small { padding: .35rem .7rem; font-size: .85rem; }
button.big { padding: .85rem 1.4rem; font-size: 1.05rem; }

.stack { display: flex; flex-direction: column; gap: .9rem; }
.row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.row > label { min-width: 120px; }
.row.compact { flex-wrap: nowrap; align-items: center; }
.row.compact input { flex: 1; }
.unit { color: var(--muted); }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { flex-direction: row; align-items: center; flex: 0 0 auto; gap: .45rem; padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: .9rem; }
.chip input { width: auto; accent-color: var(--accent); margin: 0; }
.chip:has(input:checked) { border-color: var(--accent); background: rgba(245, 184, 61, .12); }

.auth-card { max-width: 460px; margin: 3rem auto; }
.tabs { display: flex; gap: .5rem; margin: 1.25rem 0 1rem; }
.tab { flex: 1; background: transparent; }
.tab.active { background: var(--panel-2); border-color: var(--accent); }

.status-pill { display: inline-block; margin-bottom: 1rem; padding: .35rem .8rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--good); font-size: .85rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .5rem; }
.stat { background: var(--panel-2); border-radius: 10px; padding: .6rem; text-align: center; }
.stat-value { font-size: 1.3rem; font-weight: 700; }
.stat-label { font-size: .75rem; color: var(--muted); }

.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
.list li { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .5rem .6rem; border-radius: 9px; background: var(--panel-2); font-size: .9rem; }
.list.ranked { counter-reset: rank; }
.list.ranked li::before { counter-increment: rank; content: counter(rank) "."; color: var(--accent); font-weight: 700; width: 1.6rem; }
.list li.me { outline: 1px solid var(--accent); }
.badge { font-size: .75rem; padding: .1rem .45rem; border-radius: 6px; background: var(--line); }
.result-win .badge { background: rgba(62, 207, 142, .2); color: var(--good); }
.result-loss .badge { background: rgba(255, 107, 107, .18); color: var(--bad); }

/* Spiel */
.scoreboard { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 1rem; align-items: center; text-align: center; margin-bottom: 1rem; }
.side .label { color: var(--muted); font-weight: 600; }
.score { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.round { font-size: 1.2rem; font-weight: 700; }
.game-card { text-align: center; padding: 2rem 1.5rem; }
.task { font-size: clamp(2rem, 7vw, 4rem); font-weight: 700; min-height: 1.4em; letter-spacing: .02em; font-variant-numeric: tabular-nums; word-break: break-word; }
.task.solved { color: var(--muted); font-size: clamp(1.4rem, 4vw, 2.4rem); }
.timer { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 1.25rem auto; max-width: 520px; }
#timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--bad), var(--accent), var(--good)); }
.answer-row { display: flex; gap: .6rem; max-width: 420px; margin: 0 auto; }
.answer-row input { font-size: 1.6rem; text-align: center; font-variant-numeric: tabular-nums; }
.answer-row button { min-width: 80px; }
.feedback { min-height: 1.4em; font-weight: 600; margin: 1rem 0 0; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.feedback.warn { color: var(--warn); }
.gameover { text-align: center; margin-top: 1rem; }
.gameover h2 { font-size: 1.8rem; }
.gameover.result-win { border-color: var(--good); }
.gameover.result-loss { border-color: var(--bad); }

/* Profil */
.profile-card { max-width: 640px; margin: 0 auto; }
.profile-card fieldset { border-top: 1px solid var(--line); padding-top: .9rem; }
.handicap-view { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.handicap-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Spielerliste, Dialoge, Verwaltung */
.status-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--good); flex: 0 0 auto; }
.status-dot.playing { background: var(--bad); }
.status-dot.invited, .status-dot.searching { background: var(--warn); }
.list li button { padding: .3rem .65rem; font-size: .8rem; }
.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; width: min(480px, 92vw); }
.dialog::backdrop { background: rgba(5, 8, 15, .7); }
.actions.end { justify-content: flex-end; margin-top: 1rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); padding-bottom: .6rem; }
label.check input { width: auto; accent-color: var(--accent); }
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--accent); padding: .75rem 1.25rem; border-radius: 10px; z-index: 50; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.card-head h2 { margin: 0; }
#user-filter { margin-bottom: 0; flex: 1; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table td.actions-cell { display: flex; gap: .4rem; justify-content: flex-end; }
.table td button { padding: .3rem .6rem; font-size: .8rem; }
button.danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.tag { font-size: .75rem; padding: .1rem .45rem; border-radius: 6px; background: rgba(245, 184, 61, .15); color: var(--accent); }
.version { font-size: .75rem; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: .05rem .4rem; margin-left: .35rem; vertical-align: middle; }

/* Profilbilder */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; flex: 0 0 auto;
  width: 28px; height: 28px; background: var(--line); color: var(--text); font-weight: 700; font-size: .75rem; object-fit: cover; }
.avatar.md { width: 40px; height: 40px; font-size: .95rem; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; margin: 0 auto .35rem; }
.avatar.xl { width: 120px; height: 120px; font-size: 2.4rem; border: 2px solid var(--accent); }
.avatar-slot { display: inline-flex; }
.avatar-editor { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.avatar-row { display: flex; align-items: center; gap: .75rem; }
.invite-head { display: flex; align-items: center; gap: .75rem; }
.invite-head p { margin: 0; }
.side .avatar-slot { justify-content: center; width: 100%; }
.camera-frame { border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; }
.camera-frame video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

/* Spitzname & Chat */
.notice { background: rgba(245, 184, 61, .12); border: 1px solid var(--accent); border-radius: 10px; padding: .75rem 1rem; margin: 0 0 1rem; }
.chat-card { display: flex; flex-direction: column; }
.chat-list { list-style: none; margin: 0 0 .75rem; padding: .25rem; height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem;
  background: var(--panel-2); border-radius: 10px; }
.chat-list li { display: flex; gap: .6rem; align-items: flex-start; padding: .35rem .5rem; border-radius: 8px; }
.chat-list li.mine { background: rgba(245, 184, 61, .08); }
.chat-list .chat-body { flex: 1; min-width: 0; }
.chat-list .chat-meta { display: flex; gap: .5rem; align-items: baseline; }
.chat-list .chat-text { white-space: pre-wrap; word-break: break-word; margin-top: .1rem; }
.chat-name { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; font-size: .9rem; cursor: pointer; }
.chat-name:hover:not(:disabled) { text-decoration: underline; }
.chat-name:disabled { color: var(--text); opacity: 1; cursor: default; }
.chat-form { display: flex; gap: .5rem; }
.chat-form input { flex: 1; }
.player-name { background: none; border: 0; padding: 0; color: var(--text); font-weight: 600; cursor: pointer; text-align: left; font-size: .9rem; }
.player-name:hover { color: var(--accent); }
.chat-delete { margin-left: auto; padding: .1rem .45rem; font-size: .72rem; border-color: var(--bad); color: var(--bad); background: transparent; opacity: .7; }
.chat-delete:hover { opacity: 1; }
.copyright { font-size: .75rem; font-weight: 400; color: var(--muted); margin-left: .6rem; vertical-align: middle; }
@media (max-width: 640px) { .copyright { display: block; margin: .15rem 0 0; } }

/* Rangliste, Spielerkarte */
.rank-badge { font-size: .72rem; font-weight: 800; color: var(--accent); min-width: 2.1rem; text-align: right; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.rank-badge.none { color: transparent; }
.avatar-btn { background: none; border: 0; padding: 0; border-radius: 50%; cursor: pointer; display: inline-flex; flex: 0 0 auto; }
.avatar-btn:hover .avatar, .avatar-btn:focus-visible .avatar { outline: 2px solid var(--accent); outline-offset: 1px; }
.list.ranking { max-height: 420px; overflow-y: auto; }
.list.ranking .rank-badge { font-size: .85rem; min-width: 2.4rem; }
.player-dialog { width: min(560px, 94vw); }
.player-card { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 1rem; }
.player-card .avatar.xl { width: 160px; height: 160px; font-size: 3rem; }
.player-card-info { flex: 1; min-width: 180px; }
.player-card-info h2 { font-size: 1.5rem; margin-bottom: .35rem; word-break: break-word; }
.player-rank { color: var(--accent); font-weight: 700; margin: 0 0 .35rem; }
.player-bio { white-space: pre-wrap; word-break: break-word; margin: .5rem 0 0; font-style: italic; }
.player-bio:empty { display: none; }
textarea { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: .6rem .7rem; font: inherit; font-size: 1rem; width: 100%; resize: vertical; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.counter { align-self: flex-end; }
.tag-mod { background: rgba(62, 207, 142, .15); color: var(--good); }
.filter-row { margin-bottom: 1rem; }
.filter-row select { width: auto; flex: 0 0 auto; }

/* Statistik-Minifenster */
.stat.has-details { cursor: help; position: relative; }
.stat.has-details:hover, .stat.has-details.active { outline: 1px solid var(--accent); }
.stat-popover { position: fixed; z-index: 100; max-width: 340px; min-width: 220px; background: var(--panel); border: 1px solid var(--accent);
  border-radius: 10px; padding: .55rem .7rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-size: .78rem; pointer-events: none; }
.stat-popover h4 { margin: 0 0 .35rem; font-size: .78rem; color: var(--accent); }
.stat-popover ol { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .15rem; }
.stat-popover li { line-height: 1.3; }
.stat-popover .pop-meta { color: var(--muted); }
.stat-popover .pop-win { color: var(--good); }
.stat-popover .pop-loss { color: var(--bad); }

/* Rechtsseiten, Fußzeile */
.legal { max-width: 820px; margin: 0 auto; line-height: 1.6; }
.legal h1 { margin-bottom: .75rem; }
.legal h2 { margin-top: 1.4rem; font-size: 1.05rem; color: var(--accent); }
.legal ul { padding-left: 1.2rem; }
.legal a, .legal-footer a, .app-footer a { color: var(--accent); }
.legal-missing { color: var(--bad); font-style: italic; }
.legal-footer, .app-footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem 2rem; }
.brand-link { color: var(--text); text-decoration: none; }
.ghost-link { color: var(--muted); text-decoration: none; font-size: .9rem; }
.delete-form { max-width: 420px; margin: 1.25rem 0; }
.delete-form button { align-self: flex-start; }

/* Melden, Blockieren, Moderation, Konto löschen */
.terms-check { align-items: flex-start; }
.terms-check span a, .notice a, .dialog a { color: var(--accent); }
.count-badge { display: inline-block; min-width: 1.2rem; padding: 0 .35rem; border-radius: 999px; background: var(--bad); color: #fff;
  font-size: .72rem; text-align: center; margin-left: .2rem; }
.profile-extra { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.danger-zone h2 { color: var(--bad); }
.chat-report { padding: .1rem .4rem; font-size: .7rem; background: transparent; color: var(--muted); border-color: var(--line); }
.chat-report:hover { color: var(--bad); border-color: var(--bad); }
.report-preview { background: var(--panel-2); border-radius: 8px; padding: .5rem .7rem; font-style: italic; word-break: break-word; white-space: pre-wrap; }
.report-preview:empty { display: none; }
.report-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.report-list li { background: var(--panel-2); border-radius: 10px; padding: .75rem .9rem; border-left: 3px solid var(--bad); }
.report-list li.resolved { border-left-color: var(--good); opacity: .8; }
.report-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; font-size: .85rem; }
.report-content { margin: .45rem 0; white-space: pre-wrap; word-break: break-word; }
.report-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.report-actions button { padding: .3rem .7rem; font-size: .8rem; }
#view-moderation .card-head select { width: auto; }
.player-dialog .actions { align-items: center; }
