:root {
  --bg: #14130f; --panel: #1d1c18; --panel2: #27251f; --line: #36332c;
  --text: #f0efec; --text2: #c3c2b7; --muted: #8f8d85;
  --accent: #e3a53b; --accent-ink: #1b1405;
  --good: #0ca30c; --bad: #d03b3b; --blue: #3987e5;
  --sq-light: #ecdcbf; --sq-dark: #a9794f;
  --nav-w: 216px; --side-w: 380px;
  --bs: clamp(280px, min(calc(100vw - var(--nav-w) - var(--side-w) - 80px), calc(100dvh - 150px)), 900px);
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; padding-left: var(--nav-w); }
h1 { font-size: 28px; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 19px; margin: 0 0 6px; }
h3 { font-size: 15px; margin: 0 0 10px; }
p { margin: 0 0 10px; }
a { color: inherit; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.lead { color: var(--text2); max-width: 70ch; margin-bottom: 18px; }
.error, .bad { color: #ee6b6b; } .good { color: #53c653; }
.empty { color: var(--muted); padding: 22px 0; text-align: center; font-size: 14px; }

/* Navigation */
#nav { position: fixed; inset: 0 auto 0 0; width: var(--nav-w); background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; gap: 14px; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 19px; text-decoration: none; padding: 4px 8px; }
.brand img { width: 34px; height: 34px; }
.nav-links { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-links a { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 8px; text-decoration: none; color: var(--text2); font-weight: 600; }
.nav-links a:hover { background: var(--panel2); color: var(--text); }
.nav-links a.on { background: var(--panel2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav-icon { font-size: 21px; width: 26px; text-align: center; }
.nav-short { display: none; }
.nav-account { margin-top: auto; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px !important; }
.nav-user { display: block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-hint { display: block; font-size: 12px; font-weight: 500; color: var(--accent); line-height: 1.2; }
.nav-sound { align-self: flex-start; background: none; border: 0; font-size: 18px; cursor: pointer; padding: 6px 10px; }

/* Grundbausteine */
.page { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
.page.narrow { max-width: 560px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 12px 20px; font-size: 16px; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger:hover { border-color: var(--bad); color: #ee6b6b; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.lbl { display: block; font-weight: 600; color: var(--text2); margin: 14px 0 6px; font-size: 13px; }
select, textarea, input[type=range] { width: 100%; font: inherit; }
select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
textarea { resize: vertical; margin-bottom: 8px; font-family: ui-monospace, monospace; font-size: 13px; }
input[type=range] { accent-color: var(--accent); }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; margin-bottom: 16px; }
.seg button, .seg a { flex: 1; text-align: center; text-decoration: none; background: none; border: 0; color: var(--text2); font: inherit; font-weight: 600; padding: 7px 4px; border-radius: 6px; cursor: pointer; }
.seg button.on, .seg a.on { background: var(--panel2); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.tag, .pill, .chip { display: inline-block; border-radius: 6px; padding: 1px 8px; font-size: 12.5px; font-weight: 700; color: #fff; white-space: nowrap; }
.pill.win { background: #0b7d0b; } .pill.loss { background: #b52f2f; } .pill.draw { background: #5d5b55; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; } .chip { background: var(--panel2); color: var(--text2); border: 1px solid var(--line); font-weight: 600; }
.progress { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin: 8px 0 18px; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .2s; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td.wide { min-width: 140px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi-num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.kpi-label { color: var(--text2); font-size: 13px; font-weight: 600; }

/* Konto */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { max-width: 440px; display: flex; flex-direction: column; gap: 10px; text-align: center; padding: 26px; }
.modal-logo { width: 72px; height: 72px; margin: 0 auto; }
.btn.link { background: none; border-color: transparent; color: var(--text2); font-weight: 500; text-decoration: underline; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; } .field > span { font-weight: 600; font-size: 13.5px; color: var(--text2); }
.field input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; width: 100%; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.page.narrow .card { margin-bottom: 14px; }
.acct { display: flex; align-items: center; gap: 14px; } .acct > div:nth-child(2) { flex: 1; min-width: 0; } .acct h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.acct-face { font-size: 30px; width: 54px; height: 54px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; }

.acct h3 { margin: 0; }
.invite-new { border-color: var(--good); margin: 14px 0; }
.copy-row { display: flex; gap: 8px; } .copy-row input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 13px ui-monospace, monospace; }
body.gate { padding: 16px; min-height: 100dvh; display: grid; place-items: center; }
.gate .modal-box { width: min(100%, 420px); text-align: left; } .gate h1, .gate .lead, .gate .modal-logo { text-align: center; }
.gate details { border-top: 1px solid var(--line); padding-top: 12px; } .gate summary { cursor: pointer; color: var(--text2); font-weight: 600; margin-bottom: 12px; }

/* Startseite */
.hero { padding: 26px 0 30px; }
.hero h1 { font-size: 42px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; text-decoration: none; transition: transform .12s, border-color .12s; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile-icon { font-size: 34px; } .tile h3 { font-size: 17px; margin: 6px 0 4px; } .tile p { color: var(--text2); font-size: 14px; }
.tile-meta { color: var(--accent); font-weight: 600; font-size: 13px; }

/* Brett */
.board { position: relative; width: 100%; aspect-ratio: 1; border-radius: 6px; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; box-shadow: 0 6px 24px rgba(0,0,0,.45); flex: 1; }
.b-squares, .b-pieces, .b-arrows, .b-badges { position: absolute; inset: 0; }
.b-pieces, .b-arrows, .b-badges { pointer-events: none; }
.b-arrows { width: 100%; height: 100%; }
.sq { position: absolute; width: 12.5%; height: 12.5%; }
.sq.light { background: var(--sq-light); } .sq.dark { background: var(--sq-dark); }
.sq.light.last { background: #f1df83; } .sq.dark.last { background: #d0ae48; }
.sq.light.sel { background: #c3d98f; } .sq.dark.sel { background: #93b15c; }
.sq.check { background-image: radial-gradient(circle, #ff3b3b 0%, #e02c2c 35%, transparent 75%); }
.sq.hint { box-shadow: inset 0 0 0 4px #199e70; }
.sq.dot::after, .sq.ring::after { content: ''; position: absolute; border-radius: 50%; }
.sq.dot::after { inset: 36%; background: rgba(20,20,15,.28); }
.sq.ring::after { inset: 4%; border: 5px solid rgba(20,20,15,.28); }
.coord { position: absolute; font-size: 11px; font-weight: 700; line-height: 1; opacity: .85; }
.coord.rank { top: 3px; left: 3px; } .coord.file { bottom: 2px; right: 3px; }
.sq.light .coord { color: var(--sq-dark); } .sq.dark .coord { color: var(--sq-light); }
.piece { position: absolute; top: 0; left: 0; width: 12.5%; height: 12.5%; background-size: 100% 100%; will-change: transform; }
.piece.anim { transition: transform .17s ease-out; }
.piece.drag { z-index: 5; transition: none; filter: drop-shadow(0 4px 6px rgba(0,0,0,.4)); }
.badge { position: absolute; transform: translate(-75%, -25%); width: clamp(18px, 3.4vmin, 28px); height: clamp(18px, 3.4vmin, 28px); border-radius: 50%; color: #fff; font-weight: 800; font-size: clamp(10px, 1.7vmin, 14px); display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.5); z-index: 3; }
.promo { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 10; }
.promo-box { display: flex; gap: 8px; background: var(--panel); padding: 10px; border-radius: 12px; }
.promo-box button { width: clamp(48px, 9vmin, 76px); aspect-ratio: 1; background-color: var(--sq-light); background-size: cover; border: 0; border-radius: 8px; cursor: pointer; }
.promo-box button:hover { background-color: #f1df83; }

/* Spielansicht */
.play { display: flex; gap: 20px; padding: 16px 20px; align-items: flex-start; justify-content: center; }
.board-wrap { flex: none; }
.board-col { width: var(--bs); display: flex; flex-direction: column; gap: 6px; }
.board-row { display: flex; gap: 8px; }
.side { width: var(--side-w); flex: none; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pbar { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 2px 4px; border-radius: 8px; }
.pbar.active .pbar-face { box-shadow: 0 0 0 2px var(--accent); }
.pbar-face { width: 38px; height: 38px; border-radius: 8px; background: var(--panel2); display: grid; place-items: center; font-size: 22px; flex: none; }
.pbar-name { font-weight: 700; } .pbar-sub { color: var(--muted); font-weight: 500; margin-left: 8px; font-size: 13px; }
.pbar-caps { display: flex; align-items: center; height: 18px; } .pbar-caps img { width: 17px; height: 17px; margin-right: -5px; }
.pbar-adv { margin-left: 10px; font-size: 12px; color: var(--text2); font-weight: 600; }
.evalbar { position: relative; width: 22px; flex: none; background: #3b3832; border-radius: 5px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.evalbar.flipped { justify-content: flex-start; }
.evalbar-fill { background: #f0efec; transition: height .35s ease; }
.evalbar-label { position: absolute; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 700; }
.evalbar-label.for-w { bottom: 3px; color: #27251f; } .evalbar-label.for-b { top: 3px; color: #f0efec; }
.evalbar.flipped .evalbar-label.for-w { bottom: auto; top: 3px; } .evalbar.flipped .evalbar-label.for-b { top: auto; bottom: 3px; }
.status { font-weight: 600; color: var(--text2); padding: 0 2px; }
.moves { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; overflow-y: auto; flex: none; height: clamp(110px, 28dvh, 300px); font-variant-numeric: tabular-nums; }
.mv-row { display: grid; grid-template-columns: 36px 1fr 1fr; align-items: center; border-radius: 4px; }
.mv-row:nth-child(odd) { background: rgba(255,255,255,.025); }
.mv-num { color: var(--muted); font-size: 13px; padding-left: 6px; }
.mv { padding: 3px 6px; border-radius: 4px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.mv.pick { cursor: pointer; } .mv.pick:hover { background: var(--panel2); }
.mv.cur { background: var(--accent); color: var(--accent-ink); }
.mv-mark { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 3px; border-radius: 9px; color: #fff; font-size: 10.5px; font-weight: 800; margin-right: 6px; flex: none; }
.mv .mv-mark { margin: 0; }
.coach { display: flex; gap: 10px; align-items: flex-start; }
.coach-face { font-size: 32px; width: 46px; height: 46px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; flex: none; }
.bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 10px 14px; flex: 1; min-height: 46px; font-size: 14.5px; }
.bubble-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.bubble-more { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--text2); font-size: 13.5px; }
.result { text-align: center; } .result.win { border-color: var(--good); } .result.loss { border-color: var(--bad); }
.result-btns { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.back { color: var(--text2); text-decoration: none; font-weight: 600; font-size: 14px; } .back:hover { color: var(--text); }

/* Gegnerwahl */
.setup { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.bot-list { display: grid; gap: 6px; }
.bot { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.bot:hover { border-color: var(--muted); } .bot.on { border-color: var(--accent); background: var(--panel2); }
.bot-face { font-size: 26px; } .bot-name { flex: 1; font-weight: 700; } .bot-elo { color: var(--muted); font-variant-numeric: tabular-nums; }
.setup-side { display: flex; flex-direction: column; } .setup-side .btn { margin-top: 8px; }
.bot-big { font-size: 56px; line-height: 1.1; }

/* Analyse */
.sum-head { display: grid; grid-template-columns: 1fr auto 1fr; text-align: center; align-items: center; margin-bottom: 8px; }
.sum-acc { font-size: 24px; font-weight: 800; } .sum-mid { font-weight: 600; color: var(--text2); font-size: 13px; }
.sum-row { display: grid; grid-template-columns: 1fr 190px 1fr; text-align: center; font-size: 13.5px; padding: 1px 0; }
.sum-label { text-align: left; color: var(--text2); display: flex; align-items: center; } .sum-n { font-weight: 700; font-variant-numeric: tabular-nums; }
.summary, .graph-card, .explain { padding: 12px 14px; }
.ex-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.explain p { margin: 0 0 6px; font-size: 14.5px; } .explain { min-height: 96px; }
.graph { position: relative; height: 84px; margin-top: 6px; cursor: pointer; border-radius: 6px; background: #3b3832; touch-action: pan-y; }
.graph svg, .c-plot svg { display: block; width: 100%; height: 100%; border-radius: 6px; overflow: visible; }
.g-area { fill: #e8e6df; } .g-mid { stroke: #898781; stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 3 3; }
.g-cursor { stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.g-hover { stroke: #898781; stroke-width: 1; vector-effect: non-scaling-stroke; }
.g-dot { position: absolute; width: 9px; height: 9px; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 2px #1d1c18; pointer-events: none; }
.tip { position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%); background: #0d0d0b; border: 1px solid var(--line); color: var(--text); padding: 3px 9px; border-radius: 6px; font-size: 12.5px; white-space: nowrap; pointer-events: none; z-index: 5; }

/* Aufgaben + Lektionen */
.pz-info { min-height: 120px; } .pz-info h2 { font-size: 22px; }
.course { margin-bottom: 14px; }
.course-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; } .course-head > div { flex: 1; }
.course-icon { font-size: 30px; width: 50px; height: 50px; display: grid; place-items: center; background: var(--panel2); border-radius: 12px; }
.course-count { color: var(--muted); font-weight: 700; }
.lesson-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.lesson { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); text-decoration: none; font-weight: 600; }
.lesson:hover { border-color: var(--accent); }
.lesson-n { width: 24px; height: 24px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-size: 12.5px; color: var(--text2); flex: none; }
.lesson.done .lesson-n { background: #0b7d0b; color: #fff; }
.steps { display: flex; gap: 5px; margin: 8px 0 12px; } .step { height: 5px; flex: 1; border-radius: 3px; background: var(--panel2); }
.step.done { background: #0b7d0b; } .step.cur { background: var(--accent); }
.lesson-text { font-size: 15.5px; } .lesson-fb { margin-top: 10px; font-weight: 600; min-height: 22px; }
.quiz { display: grid; gap: 6px; margin-top: 12px; } .quiz .btn { justify-content: flex-start; text-align: left; font-weight: 500; }

/* Statistik */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart { display: flex; gap: 8px; }
.c-axis { display: flex; flex-direction: column; justify-content: space-between; height: 160px; color: var(--muted); font-size: 11.5px; text-align: right; min-width: 34px; font-variant-numeric: tabular-nums; }
.c-main { flex: 1; min-width: 0; padding-right: 6px; } .c-plot { position: relative; height: 160px; }
.c-grid { stroke: #2c2c2a; stroke-width: 1; vector-effect: non-scaling-stroke; }
.c-dot { position: absolute; width: 9px; height: 9px; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 2px var(--panel); pointer-events: none; }
.c-x { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; } .c-x b { color: var(--text); }
.wdl { display: flex; gap: 2px; height: 22px; flex: 1; min-width: 80px; }
.wdl-seg { display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; border-radius: 4px; min-width: 16px; }
.wdl-seg.win, .legend i.win { background: #0b7d0b; } .wdl-seg.draw, .legend i.draw { background: #6a6861; } .wdl-seg.loss, .legend i.loss { background: #b52f2f; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text2); margin-bottom: 10px; }
.legend span { display: flex; align-items: center; gap: 6px; } .legend i { width: 10px; height: 10px; border-radius: 3px; }
.rows { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 100px 1fr; align-items: center; gap: 10px; font-size: 14px; }
.row.q { grid-template-columns: 170px 1fr 92px; } .row > span:first-child { display: flex; align-items: center; color: var(--text2); }
.row .num { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text2); }
.hbar { height: 10px; background: var(--panel2); border-radius: 4px; overflow: hidden; } .hbar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 0; }

/* Schmale Bildschirme */
@media (max-width: 1000px) {
  :root { --bs: clamp(260px, min(calc(100vw - 20px), calc(100dvh - 190px)), 720px); }
  body { padding-left: 0; padding-bottom: 62px; }
  #nav { inset: auto 0 0 0; width: auto; flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); gap: 0; }
  .brand, .nav-sound { display: none; }
  .nav-links { flex-direction: row; min-width: 0; width: 100%; }
  .nav-label { display: none; } .nav-short { display: block; }
  .nav-account { margin-top: 0; border-top: 0; }
  .nav-links a { flex-direction: column; gap: 0; padding: 4px 2px; flex: 1; font-size: 10px; min-width: 0; }
  .nav-links a.on { box-shadow: inset 0 3px 0 var(--accent); }
  .play { flex-direction: column; align-items: center; padding: 10px; gap: 12px; }
  .side { width: min(100%, max(var(--bs), 420px)); max-height: none; }
  .moves { height: auto; min-height: 44px; max-height: 170px; }
  .setup, .grid2 { grid-template-columns: 1fr; }
  .page { padding: 18px 14px 40px; }
  .hero h1 { font-size: 32px; }
  .row.q { grid-template-columns: 130px 1fr 84px; }
}
