/* tschaki — Schach online
   Stil: warmes Fast-Schwarz, Fläche nur über Helligkeit, eine Datenfarbe (Turniergrün).
   Schriften: Bricolage Grotesque (Marke, Titel, Bedenkzeiten) · Hanken Grotesk (Oberfläche).
   Raster: Seitenleiste 224px + 1px Linie; Inhalt mit 29px Rand; Startseite 6 Spalten, 14px Abstand. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-latin-wght-normal.woff2") format("woff2-variations"), url("../fonts/bricolage-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-latin-ext-wght-normal.woff2") format("woff2-variations"), url("../fonts/bricolage-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("../fonts/hanken-latin-wght-normal.woff2") format("woff2-variations"), url("../fonts/hanken-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("../fonts/hanken-latin-ext-wght-normal.woff2") format("woff2-variations"), url("../fonts/hanken-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ground: #0e0d0c;
  --surface: #181716;
  --raised: #24221f;
  --raised-2: #2f2d29;
  --border: #22201e;
  --rule: #23211e;
  --control: #4a4743;
  --text: #f3f2ef;
  --muted: #b8b2a7;
  --faint: #9b958b;
  --accent: #a3d672;
  --positive: #a3d672;
  --negative: #e5484d;
  --warning: #e5a93b;
  --pill-positive-bg: #1f2915; --pill-positive-ink: #b4e08a;
  --pill-negative-bg: #2e1a1a; --pill-negative-ink: #f2898b;
  --logo-sq: #38352f;

  --font-brand: "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius-card: 20px;
  --radius-inner: 14px;
  --radius-sm: 10px;
  --gap: 14px;
  --pad: 22px;
  --edge: 29px;
  --sidebar: 224px;
  --bar: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Brett: Turnier (Vinyl grün/creme) */
  --sq-light: #ebe9d4;
  --sq-dark: #77945a;
  --sq-last: rgba(246, 226, 92, 0.5);
  --sq-selected: rgba(246, 226, 92, 0.72);
  --sq-hint: rgba(96, 170, 240, 0.6);
}

body[data-board-theme="wood"] {
  --sq-light: #e8d2ad;
  --sq-dark: #b08458;
  --sq-last: rgba(214, 238, 120, 0.42);
  --sq-selected: rgba(163, 214, 114, 0.7);
}

body[data-board-theme="slate"] {
  --sq-light: #dcdedf;
  --sq-dark: #7a828a;
  --sq-last: rgba(163, 214, 114, 0.5);
  --sq-selected: rgba(163, 214, 114, 0.75);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--text); text-decoration: none; }
::selection { background: var(--accent); color: var(--ground); }

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

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.mt-sm { margin-top: 10px; }
.mt-md { margin-top: 18px; }
.mt-lg { margin-top: 28px; }
.ml-sm { margin-left: 8px; }

.ic {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Shell: Seitenleiste + Kopfzeile ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: flex-end;
  height: var(--bar);
  padding: 0 22px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: block;
}

.brand-word {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 31px;
  line-height: 0.8;
  letter-spacing: -0.045em;
  margin-left: -7px;
  padding-bottom: 1px;
}

.brand:hover .brand-mark { transform: rotate(-6deg); }
.brand-mark { transition: transform .3s var(--ease); }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: color .15s, background-color .15s;
}

.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); background: var(--surface); font-weight: 600; }

.side-foot {
  margin: auto 0 0;
  padding: 18px 24px 22px;
  color: var(--faint);
  font-size: 13px;
}

.frame { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--bar);
  padding: 0 var(--edge);
  background: var(--ground);
  border-bottom: 1px solid var(--border);
}

.brand-compact { display: none; }

.view-title {
  font-family: var(--font-brand);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px 0 10px;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--raised);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: help;
}
.status-chip .ic { width: 15px; height: 15px; }

.auth-area {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  margin-left: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 5px;
  border: 0;
  border-radius: 999px;
  background: var(--raised);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s;
}
.user-chip:hover { background: var(--raised-2); }

.main-content {
  flex: 1;
  width: 100%;
  max-width: 1360px;
  padding: var(--edge);
}

.view { display: none; }
.view.active { display: block; animation: view-in .28s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Bedienelemente ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, color .15s, transform .12s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn .ic { width: 17px; height: 17px; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13.5px; }
.btn-sm .ic { width: 16px; height: 16px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn-full { width: 100%; }

.btn-primary { background: var(--text); color: var(--ground); }
.btn-primary:hover { background: #ffffff; }
.btn-secondary { background: var(--raised); color: var(--text); }
.btn-secondary:hover { background: var(--raised-2); }
.btn-ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--control); }
.btn-ghost:hover { background: var(--raised); }
.btn-danger { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.btn-danger:hover { background: #3a1f1f; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color .15s, color .15s, transform .12s var(--ease);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .ic { width: 19px; height: 19px; }
.icon-btn-sm { width: 34px; height: 34px; }
.icon-btn-sm .ic { width: 17px; height: 17px; }
.icon-btn-primary { background: var(--text); color: var(--ground); }
.icon-btn-primary:hover { background: #fff; color: var(--ground); }
.side-card .icon-btn-sm, .game-top-actions .icon-btn-sm { box-shadow: inset 0 0 0 1px var(--control); color: var(--text); }

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--raised);
}
.segmented-full { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }

.pill {
  height: 30px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.pill:hover { color: var(--text); }
.pill.active { background: var(--text); color: var(--ground); }

.tag, .tag-gold {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tag { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.tag-gold { background: var(--raised); color: var(--text); }

.meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--faint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.meta strong { color: var(--text); font-weight: 600; }

/* ---------- Karten ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: var(--pad);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  margin-bottom: 16px;
}
.card-head h2 { font-size: 16px; }
.card-head-end { display: flex; align-items: center; gap: 10px; }
.card h3 { font-size: 14px; margin-bottom: 10px; }

.empty { color: var(--faint); font-size: 14px; margin: 6px 0; }

/* ---------- Startseite ---------- */

.home-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--gap);
}

.quick-card-wrap { grid-column: span 4; display: flex; flex-direction: column; }
.daily-card { grid-column: span 2; display: flex; flex-direction: column; }
.ai-strip { grid-column: span 6; }

.quick-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 10px;
}

.quick-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  min-height: 150px;
  padding: 18px 20px;
  border: 0;
  border-radius: var(--radius-inner);
  background: var(--raised);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: background-color .18s, transform .18s var(--ease);
}
.quick-tile:hover { background: var(--raised-2); transform: translateY(-2px); }
.quick-tile:active { transform: scale(.98); }

.quick-time {
  font-family: var(--font-brand);
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.quick-label { color: var(--muted); font-size: 14px; font-weight: 500; }

.tc-ring {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 56px;
  height: 56px;
  transform: rotate(-90deg);
}
.tc-ring circle { fill: none; stroke-width: 4; }
.tc-track { stroke: var(--control); opacity: .55; }
.tc-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s var(--ease); }
.quick-tile:hover .tc-ring { transform: rotate(-90deg) scale(1.06); }
.tc-ring { transition: transform .25s var(--ease); }

.daily-title { margin: -6px 0 14px; font-size: 17px; font-weight: 600; }

.mini-board-wrap {
  width: 100%;
  aspect-ratio: 1;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.mini-board-wrap .coord-rank, .mini-board-wrap .coord-file { display: none; }
.daily-card .btn { margin-top: auto; }

.level-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.level-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 18px;
  border: 0;
  border-radius: var(--radius-inner);
  background: var(--raised);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background-color .18s, transform .18s var(--ease);
}
.level-tile:hover { background: var(--raised-2); transform: translateY(-2px); }
.level-tile:active { transform: scale(.98); }
.level-name { font-size: 15px; font-weight: 600; }
.level-elo { color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }

.pips { display: flex; gap: 4px; }
.pips i { width: 14px; height: 4px; border-radius: 2px; background: var(--control); }
.level-tile:nth-child(1) .pips i:nth-child(-n+1),
.level-tile:nth-child(2) .pips i:nth-child(-n+2),
.level-tile:nth-child(3) .pips i:nth-child(-n+3),
.level-tile:nth-child(4) .pips i:nth-child(-n+4),
.level-tile:nth-child(5) .pips i:nth-child(-n+5) { background: var(--accent); }
.level-foot { display: flex; align-items: center; justify-content: space-between; width: 100%; }

/* ---------- Spiel-Layouts ---------- */

.mp-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.lb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(280px, 620px) minmax(300px, 1fr);
  gap: var(--gap);
  align-items: start;
}

.board-column { display: flex; flex-direction: column; gap: 10px; }

.board-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-inner);
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
}

.sq { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sq.light { background: var(--sq-light); color: var(--sq-dark); }
.sq.dark { background: var(--sq-dark); color: var(--sq-light); }

.sq.last-move::before, .sq.selected::before, .sq.hint-sq::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.sq.last-move::before { background: var(--sq-last); }
.sq.selected::before { background: var(--sq-selected); }
.sq.hint-sq::before { background: var(--sq-hint); }
.sq.in-check { background: #e0574f !important; }

.sq.legal-dot::after {
  content: "";
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(14, 13, 12, 0.24);
  pointer-events: none;
}
.sq.legal-capture::after {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  border: 5px solid rgba(14, 13, 12, 0.26);
  pointer-events: none;
}

.coord-rank, .coord-file {
  position: absolute;
  z-index: 2;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.coord-rank { top: 4px; left: 4px; }
.coord-file { bottom: 4px; right: 5px; }

.piece {
  position: relative;
  z-index: 3;
  width: 90%;
  height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s var(--ease);
}
.piece svg { width: 100%; height: 100%; }
.piece.dragging { opacity: 0.4; }

.promo-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 13, 12, 0.78);
}
.promo-box { background: var(--surface); border-radius: var(--radius-inner); padding: 16px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
.promo-title { font-weight: 600; margin-bottom: 12px; }
.promo-choices { display: flex; gap: 8px; }
.promo-btn {
  width: 58px;
  height: 58px;
  padding: 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--sq-light);
  cursor: pointer;
  transition: transform .12s var(--ease);
}
.promo-btn:hover { transform: scale(1.06); }

.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 12px;
  border-radius: var(--radius-inner);
  background: var(--surface);
}

.player-meta { display: flex; align-items: center; gap: 12px; min-width: 0; }

.avatar-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--raised);
  color: var(--ground);
  font-size: 14px;
  font-weight: 700;
}
.avatar-icon { color: var(--muted); }
.avatar-icon .ic { width: 18px; height: 18px; }
#mp-top-avatar, #mp-bottom-avatar { color: var(--text); }

.player-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.captured-row {
  display: flex;
  align-items: center;
  gap: 1px;
  min-height: 18px;
  color: var(--faint);
  font-size: 15px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.clock {
  min-width: 92px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: background-color .2s, color .2s;
}
.clock.active-turn { background: var(--text); color: var(--ground); }
.clock.low-time { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }

/* ---------- Seitenspalte ---------- */

.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--raised);
  font-size: 14.5px;
  font-weight: 500;
}
.status-banner::before {
  content: "";
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--muted);
}
.status-banner.success { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.status-banner.success::before { background: var(--positive); }
.status-banner.error { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.status-banner.error::before { background: var(--negative); }

.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.action-row-top { margin-top: 0; }

.side-h { margin: 22px 0 10px !important; color: var(--muted); font-size: 13px !important; font-weight: 600; }

.moves-box {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  gap: 2px 6px;
  align-content: start;
  height: 210px;
  padding: 10px 12px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  background: var(--raised);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.move-num { color: var(--faint); padding: 2px 0; }
.move-san { padding: 2px 6px; border-radius: 6px; font-weight: 500; }
.move-san.latest { background: var(--text); color: var(--ground); font-weight: 600; }

.chat-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 150px;
  padding: 10px 12px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  background: var(--raised);
  font-size: 14px;
}
.chat-form { display: flex; gap: 8px; margin-top: 8px; }
.chat-form input { flex: 1; border-radius: 999px; padding-left: 16px; }

/* ---------- Formulare ---------- */

.stack-form { display: flex; flex-direction: column; gap: 14px; }

.stack-form label, .ai-settings label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.ai-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.ai-settings .span-2 { grid-column: span 2; }

input[type="text"], input[type="email"], input[type="password"], select, textarea {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--control);
  border-radius: var(--radius-sm);
  background: var(--ground);
  color: var(--text);
  font-size: 15px;
  transition: border-color .15s;
}
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b8b2a7' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  cursor: pointer;
}
input:hover, select:hover { border-color: #625e58; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text); }
input::placeholder { color: var(--faint); }

.field-rule { color: var(--faint); font-size: 12px; font-weight: 400; }

.checkbox-row { flex-direction: row !important; align-items: center; gap: 10px !important; color: var(--text) !important; font-size: 14px !important; cursor: pointer; }
.checkbox-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* ---------- Listen ---------- */

.table-list, .list-stack, .puzzle-list { display: flex; flex-direction: column; }

.row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background-color .15s;
}
.row-item + .row-item { box-shadow: 0 -1px 0 var(--rule); }
.row-item.clickable { cursor: pointer; }
.row-item.clickable:hover, .row-item.active { background: var(--raised); box-shadow: none; }
.row-item.clickable:hover + .row-item, .row-item.active + .row-item { box-shadow: none; }
.row-item strong { font-weight: 600; }
.row-item .ic { width: 15px; height: 15px; vertical-align: -2px; color: var(--positive); margin-right: 4px; }

.puzzle-list { max-height: 420px; overflow-y: auto; margin-right: -6px; padding-right: 6px; }

.puzzle-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px 10px 12px;
  border-radius: var(--radius-inner);
  background: var(--surface);
}
.pz-head-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pz-head-main strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pz-head-end { display: flex; align-items: center; gap: 16px; }
.streak .ic { width: 16px; height: 16px; color: var(--warning); }

.game-top-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: var(--gap); }
.game-top-actions { display: flex; gap: 8px; }

.dot-online { width: 8px; height: 8px; border-radius: 50%; background: var(--positive); }

/* ---------- Profil ---------- */

#profile-content h3 { font-family: var(--font-brand); font-size: 22px; letter-spacing: -0.02em; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 18px 0; }
.stat-box { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--raised); }
.stat-label { color: var(--faint); font-size: 12px; }
.stat-val { font-family: var(--font-brand); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; }
.stat-val .ic { width: 20px; height: 20px; color: var(--warning); }

/* ---------- Dialog ---------- */

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 4, 0.78); }
.modal-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  animation: modal-in .24s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.modal-head h2 { font-family: var(--font-brand); font-size: 22px; letter-spacing: -0.02em; }
.modal-head .icon-btn { margin-left: auto; }
.modal-mark { width: 30px; height: 30px; }
.auth-tabs { margin-bottom: 18px; }

.form-error {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
  font-size: 14px;
}

/* ---------- Toast ---------- */

.toast-container { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-inner);
  background: var(--raised-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  animation: toast-in .24s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Mobile Navigation ---------- */

.nav-mobile { display: none; }

@media (max-width: 1180px) {
  .play-layout { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
  .ai-settings { grid-template-columns: 1fr; }
  .ai-settings .span-2 { grid-column: auto; }
}

@media (max-width: 960px) {
  :root { --edge: 16px; --bar: 56px; --pad: 18px; --radius-card: 18px; }

  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .brand-compact { display: flex; align-items: center; height: auto; padding: 0; border: 0; }
  .brand-compact .brand-mark { width: 30px; height: 30px; }
  .view-title { font-size: 19px; }
  .topbar { gap: 10px; }
  .auth-area { margin-left: 2px; padding-left: 10px; }

  .main-content { padding: var(--edge) var(--edge) calc(92px + env(safe-area-inset-bottom)); }

  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .quick-card-wrap, .daily-card, .ai-strip { grid-column: auto; }
  .mini-board-wrap { max-width: 420px; margin-left: auto; margin-right: auto; }

  .mp-layout, .lb-layout, .play-layout { grid-template-columns: minmax(0, 1fr); }
  .ai-settings { grid-template-columns: 1fr 1fr; }
  .ai-settings .span-2 { grid-column: span 2; }

  .toast-container { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); }

  .nav-mobile {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--ground);
    border-top: 1px solid var(--border);
  }

  .mob-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--faint);
    cursor: pointer;
    transition: color .15s;
  }
  .mob-link .ic { width: 22px; height: 22px; }
  .mob-link small { font-size: 11px; font-weight: 600; }
  .mob-link.active { color: var(--text); }
}

@media (max-width: 640px) {
  .status-chip { padding: 0 8px; margin-right: 0; }
  .status-chip-label { display: none; }
  .quick-grid { gap: 8px; }
  .quick-tile { min-height: 104px; padding: 14px; }
  .quick-time { font-size: 30px; }
  .tc-ring { width: 34px; height: 34px; right: 12px; bottom: 12px; }
  .quick-label { font-size: 13px; }
  .level-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .level-tile { flex-direction: row; align-items: center; justify-content: space-between; padding: 14px 16px; }
  .level-foot { width: auto; gap: 14px; }
  .player-name { font-size: 14px; }
  .clock { min-width: 80px; font-size: 19px; padding: 6px 10px; }
  .card-head { flex-wrap: wrap; }
  .pz-head-end { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .quick-tile:hover, .level-tile:hover { transform: none; }
}

/* ---------- Feinschliff ---------- */
.dot-online.is-zero { background: var(--control); }
.player-meta > div { min-width: 0; }
.row-item.active .tag-gold, .row-item.clickable:hover .tag-gold { background: var(--raised-2); }
.view-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

@media (max-width: 640px) {
  .view-title { font-size: 18px; }
  .topbar-end { gap: 2px; }
  .topbar .icon-btn { width: 34px; height: 34px; }
  .auth-area .btn { padding: 0 14px; }
}
@media (max-width: 420px) {
  .status-chip { display: none; }
}

/* ---------- Stellungen: Editor & Snapshots ---------- */
.segmented-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
.segmented-4 .pill { padding: 0 6px; }
.pill:disabled { opacity: .4; cursor: not-allowed; }

.ed-panel { margin-top: 16px; }
.ed-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ed-tools { display: flex; gap: 6px; }

.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
#ed-fen { font-size: 13px; font-variant-numeric: tabular-nums; }
textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

.ed-save { display: flex; gap: 8px; }
.ed-save input { flex: 1; min-width: 0; }
.side-h .meta { margin-left: 6px; }

.palette {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 4px;
  padding: 6px;
  border-radius: var(--radius-inner);
  background: var(--surface);
}
.pal-btn {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color .15s, transform .12s var(--ease);
}
.pal-btn svg { width: 100%; height: 100%; }
.pal-btn:hover { background: var(--raised); }
.pal-btn:active { transform: scale(.94); }
.pal-btn.active { background: var(--raised-2); box-shadow: inset 0 0 0 2px var(--accent); }
.pal-eraser .ic { width: 60%; height: 60%; }

.snap-list { max-height: 360px; overflow-y: auto; margin-right: -6px; padding-right: 6px; }
.snap-row { padding: 8px 6px 8px 8px; }
.snap-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.snap-text { min-width: 0; }
.snap-text strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snap-thumb { width: 52px; height: 52px; flex-shrink: 0; border-radius: 6px; overflow: hidden; pointer-events: none; }
.snap-thumb .coord-rank, .snap-thumb .coord-file { display: none; }
.snap-row .icon-btn .ic { color: var(--muted); }
.snap-row .icon-btn:hover .ic { color: var(--pill-negative-ink); }
.moves-box-sm { height: 150px; }

.snapshot-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 8px 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--pill-positive-bg);
  color: var(--pill-positive-ink);
  font-size: 14px;
}
.snapshot-note span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snapshot-note .btn { color: var(--text); }

.ai-elo { color: var(--faint); font-weight: 500; }

/* Tablet: Tagesrätsel als zwei Spalten statt eines schmalen Bretts in der Mitte */
@media (min-width: 641px) and (max-width: 960px) {
  .daily-card {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas: "board head" "board title" "board ." "board btn";
    column-gap: 22px;
  }
  .daily-card .card-head { grid-area: head; }
  .daily-card .daily-title { grid-area: title; margin: 0; font-family: var(--font-brand); font-size: 26px; letter-spacing: -0.02em; line-height: 1.15; }
  .daily-card .mini-board-wrap { grid-area: board; max-width: none; margin: 0; }
  .daily-card .btn { grid-area: btn; }
}

@media (max-width: 960px) {
  .nav-mobile { grid-template-columns: repeat(6, 1fr); }
  .mob-link small { font-size: 10.5px; letter-spacing: -0.01em; }
}

@media (max-width: 640px) {
  .ai-prefix { display: none; }
  .palette { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .segmented-4 .pill { font-size: 12px; padding: 0 2px; }
}
.pal-btn[data-tool^="w"] { order: 1; }
.pal-eraser { order: 2; }
.pal-btn[data-tool^="b"] { order: 3; }
.pal-btn { background: var(--sq-light); }
.pal-btn:hover { background: var(--sq-light); filter: brightness(.94); }
.pal-btn.active { background: var(--sq-light); box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 0 4px var(--ground); }
.pal-eraser { color: var(--ground); }
.level-foot { flex-wrap: wrap; gap: 6px 10px; }
@media (max-width: 640px) { .level-foot { flex-wrap: nowrap; } }
@media (max-width: 960px) { .nav-mobile { padding-left: 12px; padding-right: 12px; } }

/* Toast mit Aktion */
.toast { display: flex; align-items: center; gap: 14px; }
.toast-action {
  margin: -4px -8px -4px 0;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--ground);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.toast-action:hover { background: #fff; }
#ed-valid { margin-top: 14px; }

/* Spielerleiste: Name mittig, solange noch nichts geschlagen wurde */
.captured-row:empty { display: none; }
.player-bar { min-height: 60px; }
.player-name { line-height: 1.3; }
.captured-row { margin-top: 3px; }

/* Zugliste: geschlagene Figur neben der Notation */
.move-san { display: flex; align-items: center; gap: 6px; min-height: 26px; }
.move-cap { display: inline-flex; width: 20px; height: 20px; flex-shrink: 0; }
.move-cap svg { width: 100%; height: 100%; }
.move-cap-dark svg { filter: drop-shadow(0 0 1px rgba(243, 242, 239, 0.85)) drop-shadow(0 0 0.5px rgba(243, 242, 239, 0.85)); }
