/* ============ Tokens ============ */
:root {
  --bg: #eeede9;
  --bg-glow: #f7f6f3;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-solid: #fbfbfa;
  --surface-2: rgba(0, 0, 0, 0.035);
  --surface-3: rgba(0, 0, 0, 0.06);
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.12);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a3a3a8;
  --accent: #1d1d1f;
  --accent-text: #ffffff;
  --green: #30b35a;
  --red: #e5484d;
  --blue: #0a84ff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05), 0 24px 60px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.05), 0 24px 80px rgba(0, 0, 0, 0.16);

  --sq-light: #f2f0eb;
  --sq-dark: #d3d3d3;
  --frame: #f6f5f2;
  --coord: #9d9a93;
  --selected: rgba(29, 29, 31, 0.1);
  --dot: rgba(29, 29, 31, 0.16);
  --check: rgba(229, 72, 77, 0.55);
  --arrow-user: #3d8f5a;
  --arrow-hint: #3f6fb8;
  --arrow-o: 0.62;
  --arrow-blend: multiply;
  --piece-shadow: drop-shadow(0 0.5px 1.2px rgba(40, 32, 20, 0.08));
  /* dünne Kontur um die Figuren auf dem Brett (SVG-Filter aus pieces.js: hell weiß, dunkel #pc-outline-dark schwarz) */
  --piece-outline: url(#pc-outline);
  --sh-color: #2a2012;
  --avatar-a: #e2ded6; --avatar-b: #c9c3b8;
  --slot: rgba(60, 50, 35, 0.09);
  --veval-line: rgba(40, 32, 20, 0.12); --veval-mid: rgba(110, 102, 90, 0.75);
  --lm-blue: rgba(63, 111, 184, 0.12); --lm-blue-light: rgba(57, 80, 110, 0.2);
  /* Aktivitätsfeld (letzter Zug, Auswahl): neutrales, leicht kühles Grau – ergibt auf beiden Feldfarben #a1a2a7 */
  --sel-tint: rgba(29, 33, 51, 0.275); --sel-tint-light: rgba(29, 33, 51, 0.375);
  --trail-c: #1d2133;
  /* Platte der 3D-Ansicht: Rand, Vorderkante (Licht), Seitenkante (Schatten), Bodenschatten */
  --slab-edge: rgba(255, 255, 255, 0.5);
  --slab-l1: #d9d4cb; --slab-l2: #cbc5ba; --slab-r1: #beb7aa; --slab-r2: #aea698;
  --ground-c: #4a3d2e; --ground-o: 0.3;
 
  /* Schatten färben sich wie echte Schatten in den Ton des Steins: Multiplizieren mit warmen Tönen. Gilt in beiden
     Themes (Multiplizieren nimmt auf hellen wie dunklen Feldern denselben Anteil Licht weg) */
  --sh-blend: multiply;
  --shk-c: #58585a; --shs-c: #6e6d78; --sha-c: #7d7d80;
  --sh-sharp: 0.3;
  --sh-soft: 0.36;
  /* Schatten-Geometrie (Licht von oben links, 233°): Kern (nah, dichter) und weiche Lage (weit);
     Versatz in % der Feldgröße, Unschärfe als Anteil */
  --shk-x: 3.37%; --shk-y: 4.47%; --shk-b: 0.04;
  --shs-x: 12.7%; --shs-y: 16.85%; --shs-b: 0.072; --shs-s: 1.04;
  /* Kontaktschattierung direkt an der Kontur (hebt die Figur vom Brett ab) */
  --sh-ao: 0.21; --sha-b: 0.022; --sha-s: 1.03;
  /* Anteil der Beleuchtung von rechts in den Figuren (0 = Licht von links, 1 = von rechts) */
  --light-r: 0;

  --radius: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0e; --bg-glow: #17171b; --surface: rgba(255, 255, 255, 0.035); --surface-solid: #18181b;
    --surface-2: rgba(255, 255, 255, 0.04); --surface-3: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.07); --border-strong: rgba(255, 255, 255, 0.13);
    --text: #ededef; --text-2: #8a8f98; --text-3: #5b5f67; --accent: #ededef; --accent-text: #0c0c0e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 40px rgba(0, 0, 0, 0.35); --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.6);
    --sq-light: #8a909a; --sq-dark: #676d78; --frame: #17191d; --coord: #6f7582; --piece-outline: url(#pc-outline-dark);
    --selected: rgba(255, 255, 255, 0.12); --dot: rgba(0, 0, 0, 0.3);
    --avatar-a: #a8a39a; --avatar-b: #857f76; --slot: rgba(255, 255, 255, 0.07); --veval-line: rgba(255, 255, 255, 0.14); --veval-mid: rgba(200, 195, 186, 0.7); --lm-blue: rgba(70, 110, 180, 0.22); --lm-blue-light: rgba(17, 45, 96, 0.3); --sel-tint: rgba(70, 110, 180, 0.32); --sel-tint-light: rgba(30, 58, 110, 0.4); --arrow-hint: #7fa6e6; --arrow-user: #7cc494; --arrow-o: 0.75; --arrow-blend: normal; --trail-c: #000; --slab-edge: rgba(255, 255, 255, 0.07); --slab-l1: #232529; --slab-l2: #1e2024; --slab-r1: #14161a; --slab-r2: #101216; --ground-c: #000; --ground-o: 0.6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0c0e; --bg-glow: #17171b; --surface: rgba(255, 255, 255, 0.035); --surface-solid: #18181b;
  --surface-2: rgba(255, 255, 255, 0.04); --surface-3: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.07); --border-strong: rgba(255, 255, 255, 0.13);
  --text: #ededef; --text-2: #8a8f98; --text-3: #5b5f67; --accent: #ededef; --accent-text: #0c0c0e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 40px rgba(0, 0, 0, 0.35); --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.6);
  --sq-light: #8a909a; --sq-dark: #676d78; --frame: #17191d; --coord: #6f7582; --piece-outline: url(#pc-outline-dark);
  --selected: rgba(255, 255, 255, 0.12); --dot: rgba(0, 0, 0, 0.3);
  --avatar-a: #a8a39a; --avatar-b: #857f76; --slot: rgba(255, 255, 255, 0.07); --veval-line: rgba(255, 255, 255, 0.14); --veval-mid: rgba(200, 195, 186, 0.7); --lm-blue: rgba(70, 110, 180, 0.22); --lm-blue-light: rgba(17, 45, 96, 0.3); --sel-tint: rgba(70, 110, 180, 0.32); --sel-tint-light: rgba(30, 58, 110, 0.4); --arrow-hint: #7fa6e6; --arrow-user: #7cc494; --arrow-o: 0.75; --arrow-blend: normal; --trail-c: #000; --slab-edge: rgba(255, 255, 255, 0.07); --slab-l1: #232529; --slab-l2: #1e2024; --slab-r1: #14161a; --slab-r2: #101216; --ground-c: #000; --ground-o: 0.6;
  color-scheme: dark;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: -0.006em;
  color: var(--text);
  background: radial-gradient(1200px 700px at 50% 30%, var(--bg-glow), var(--bg) 70%) fixed, var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
/* Gezogene Figur über der Topbar (z-index 5) und über den Pfeilen halten (.pieces ist ein eigener Stapelkontext) */
body.is-dragging #board { z-index: 6; }
body.is-dragging .pieces { z-index: 3; }

/* ============ Buttons & Inputs ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  font-weight: 500; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, transform .12s var(--ease), box-shadow .15s, opacity .15s;
}
.btn svg { font-size: 16px; }
.btn:active { transform: scale(0.98); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.lg { height: 44px; padding: 0 18px; font-size: 14.5px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.1); }
.btn.primary:hover { opacity: .9; }
.btn.secondary { background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { background: var(--surface-3); }
.btn:disabled { opacity: .45; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn svg { font-size: 18px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.linkish { color: var(--text-2); font-size: 13px; padding: 6px; border-radius: 6px; }
.linkish:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.input {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text);
  font: inherit; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent); }
.input::placeholder { color: var(--text-3); }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }

/* Segmented control (Apple-Style) */
.seg {
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 3px; border-radius: 12px; background: var(--surface-3);
}
.seg > button {
  position: relative; z-index: 1; height: 32px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: color .2s;
}
.seg > button.active { color: var(--text); }
.seg > button svg { font-size: 15px; }
.seg-pill {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 3px; border-radius: 9px;
  background: var(--surface-solid); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.05);
  transition: transform .28s var(--ease), width .28s var(--ease);
}
:root[data-theme="dark"] .seg-pill { background: #2a2a2f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg-pill { background: #2a2a2f; } }

/* ============ Layout ============ */
.app { min-height: 100%; display: flex; flex-direction: column; }
:root { --topbar-h: 60px; }
@media (max-width: 780px) { :root { --topbar-h: 54px; } }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 60px; padding: 0 22px; position: relative; z-index: 5;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.brand-mark { width: 26px; height: 26px; }
.bm-bg { fill: var(--accent); stroke: none; }
.bm-fg { stroke: var(--accent-text); stroke-width: 1.8; }
.topbar-center { position: absolute; left: 50%; transform: translateX(-50%); font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.top-actions { display: flex; align-items: center; gap: 6px; }

.stage {
  --board: min(calc(100vh - 150px), calc(100vw - 732px), 780px);
  flex: 1;
  display: grid;
  grid-template-columns: 224px var(--board) 10px 320px;
  grid-template-rows: auto auto auto;
  grid-template-areas: "top board eval panel" "actions board eval panel" "bottom board eval panel";
  column-gap: 34px;
  justify-content: center;
  align-content: center;
  padding: 8px 24px 40px;
}
.board-area { grid-area: board; }
.player.top { grid-area: top; align-self: start; }
.player.bottom { grid-area: bottom; align-self: end; }
.panel { grid-area: panel; }
.actions { grid-area: actions; align-self: center; }

/* ============ Board ============ */
.board-frame {
  display: grid; position: relative;
  grid-template-columns: 22px 1fr;
  grid-template-rows: 1fr 24px;
  padding: 14px 16px 6px 6px;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  width: var(--board);
}
/* Card-Fläche als eigene Ebene: blendet in 3D nur per Deckkraft aus (billig während der Animation) */
.board-frame::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  background: var(--frame); border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: opacity .5s; will-change: opacity;
}
.coords { position: relative; color: var(--coord); font-size: 11px; font-weight: 500; user-select: none; transition: opacity .4s; }
/* 3D-Ansicht: die Card tritt zurück, das Brett steht als Objekt frei auf der Fläche */
:root[data-view="iso"] .board-frame { margin-inline: auto; }
:root[data-view="iso"] .board-frame::before { opacity: 0; }
:root[data-view="iso"] .coords { opacity: 0; }
/* Fläche um das 3D-Brett: greifen und ziehen dreht/kippt es */
:root[data-view="iso"] .board-area { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
:root[data-view="iso"] .stage { overflow-x: clip; }
body.is-orbiting, body.is-orbiting * { cursor: grabbing !important; }
.coords.ranks { grid-column: 1; grid-row: 1; display: grid; grid-template-rows: repeat(8, 1fr); align-items: center; justify-items: center; }
.coords.files { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(8, 1fr); align-items: center; justify-items: center; }
#board { grid-column: 2; grid-row: 1; }

/* Bewertungs-Card: schlanke Card im Stil der anderen, volle Brett-Höhe, an das Panel gedockt.
   Darin eine flache Kapsel in den Figurenfarben; der Elfenbein-Anteil wächst von Weiß' Brettseite aus.
   Die Mittellinie ragt minimal über den Balken hinaus und markiert den Nullpunkt. */
.veval {
  /* schmale Grid-Spalte (10px) + 30px breite Card, nach rechts ans Panel gezogen:
     zum Brett gleicher Abstand wie überall, zum Panel eng angedockt */
  grid-area: eval; align-self: stretch; justify-self: end; width: 30px; margin-right: -20px;
  display: flex; justify-content: center; padding: 16px 0;
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border); border-radius: 15px; box-shadow: var(--shadow);
}
.veval-inner { position: relative; width: 6px; height: 100%; transition: opacity .3s; }
.veval-track {
  position: absolute; inset: 0; overflow: hidden; border-radius: 99px;
  background: #3a3a3f;
}
.veval-track::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
  box-shadow: inset 0 0 0 1px var(--veval-line);
}
.veval-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 50%;
  background: #efeeeb;
  transition: height .7s var(--ease);
}
.veval.flipped .veval-fill { bottom: auto; top: 0; }
.veval-mid {
  position: absolute; left: -4px; right: -4px; top: 50%; height: 1px; margin-top: -0.5px; z-index: 3;
  background: var(--veval-mid); border-radius: 1px;
}
.veval.muted .veval-inner { opacity: .3; }

/* Brett (flach, Draufsicht). Die 3D-Ansicht zeichnet board3d.js per WebGL. */
.board {
  position: relative; aspect-ratio: 1; width: 100%;
  border-radius: 6px; overflow: visible;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
/* Ebenen, die auf dem Brett liegen: Felder, Markierungen, Schatten, Schweif; darüber die Pfeile */
.plane { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.plane-top { z-index: 2; mix-blend-mode: var(--arrow-blend); }
/* Abrunden/Abschneiden nur in den Flächen-Ebenen – die gezogene Figur darf über den Brettrand hinaus */
.squares, .marks, .shadows, .promo, .board-overlay { border-radius: inherit; overflow: hidden; }
.squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.marks, .pieces { position: absolute; inset: 0; pointer-events: none; }
.pieces { z-index: 1; }

.mark { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; }
/* Letzter Zug: gleiches Blaugrau wie die Auswahl – auf hellen Feldern kräftiger, damit es überall gleich wirkt */
.mark.last.to { background: var(--sel-tint); }
.mark.last.to.on-light { background: var(--sel-tint-light); }
/* Ursprungsfeld: nur ein Punkt in der klassischen Punktfarbe */
.mark.last.from::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 18%; height: 18%;
  transform: translate(-50%, -50%); border-radius: 50%; background: var(--dot);
}
/* Ausgewähltes Feld: satteres Blaugrau (ohne Rahmen) – auf hellen und dunklen Feldern gleicher Farbton */
.mark.selected { background: var(--sel-tint); }
.mark.selected.on-light { background: var(--sel-tint-light); }
.mark.hover { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--text) 22%, transparent); }
.mark.check { background: radial-gradient(circle, var(--check) 0%, color-mix(in srgb, var(--check) 40%, transparent) 42%, transparent 70%); }
.mark.dest::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 18%; height: 18%;
  transform: translate(-50%, -50%); border-radius: 50%; background: var(--dot);
}
.mark.dest.capture::after { content: none; } /* Schlagbar: keine Feldmarkierung – die Figur zittert (.piece.threat) */
.mark.circle { box-shadow: inset 0 0 0 calc(var(--sq, 80px) * 0.045) color-mix(in srgb, var(--arrow-user) 62%, transparent); border-radius: 50%; }

/* Figur: --x/--y = Feld (linke obere Ecke, in Feldern), mittig im Feld */
.piece {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%;
  display: grid; place-items: center; will-change: transform;
  transform: translate(calc(var(--x, 0) * 100%), calc(var(--y, 0) * 100%)) scale(var(--ds, 1));
  transition: transform var(--move-ms, 340ms) var(--ease), opacity .2s;
}
.piece svg { width: 92%; height: 92%; display: block; filter: var(--piece-outline) var(--piece-shadow); overflow: visible; }
/* Dark Mode: feine Lichtkante hält die Graphit-Figuren vom Brett abgesetzt */
:root[data-theme="dark"] .piece.b svg { filter: var(--piece-outline) var(--piece-shadow); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .piece.b svg { filter: var(--piece-outline) var(--piece-shadow); } }
.piece.noanim, .piece.dragging { transition: none; }

/* Schatten: Figuren liegen flach auf dem Brett (Draufsicht), Licht von oben links.
   Zwei versetzte, unscharfe Silhouetten ergeben einen weichen, tiefen, organischen Schatten:
   eine nahe, dichtere Kernschatten-Lage und eine weite, sehr weiche Umgebungs-Lage. */
.shadows { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: var(--sh-blend); }
.shadow {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; color: var(--sh-color);
  transform: translate(calc(var(--x, 0) * 100%), calc(var(--y, 0) * 100%)) scale(var(--ds, 1));
  transition: transform var(--move-ms, 340ms) var(--ease), opacity .2s;
}
/* Hülle der Schattenlagen (kippt beim Umstoßen mit der Figur, board.js knock2D) */
.sh-proj { position: absolute; inset: 0; }
.shadow.noanim, .shadow.dragging { transition: none; }
.shadow.captured { opacity: 0; transition: opacity .18s; }
.shadow.appear { animation: appear .25s var(--ease); }
.sh-cast {
  position: absolute; inset: 4%;
  transition: transform .28s var(--ease), opacity .28s, filter .28s;
}
.sh-cast svg { width: 100%; height: 100%; display: block; overflow: visible; fill: currentColor; stroke: none; }
/* Lage-Variablen der Figur nicht in die SVGs vererben (dort unbenutzt, jede Änderung rechnete sonst alle Knoten neu) */
.piece > svg, .sh-cast > svg { --x: initial; --y: initial; --ds: initial; --move-ms: initial; }
.sh-cast.sharp {
  color: var(--shk-c);
  opacity: var(--sh-sharp);
  transform: translate(var(--shk-x), var(--shk-y));
  filter: blur(calc(var(--sq, 80px) * var(--shk-b)));
}
.sh-cast.soft {
  color: var(--shs-c);
  opacity: var(--sh-soft);
  transform: translate(var(--shs-x), var(--shs-y)) scale(var(--shs-s));
  filter: blur(calc(var(--sq, 80px) * var(--shs-b)));
}
.sh-cast.ao {
  color: var(--sha-c);
  opacity: var(--sh-ao);
  transform: scale(var(--sha-s));
  filter: blur(calc(var(--sq, 80px) * var(--sha-b)));
}
.shadow.lifted .sh-cast.ao { opacity: 0; }
/* Angehoben: Abstand zum Brett wächst → Schatten wandert weiter nach unten-rechts, wird weicher und heller */
.shadow.lifted .sh-cast.sharp { opacity: calc(var(--sh-sharp) * 0.35); transform: translate(calc(var(--shk-x) * 2.4), calc(var(--shk-y) * 2.4)); filter: blur(calc(var(--sq, 80px) * var(--shk-b) * 1.5)); }
.shadow.lifted .sh-cast.soft { opacity: calc(var(--sh-soft) * 0.85); transform: translate(calc(var(--shs-x) * 1.6), calc(var(--shs-y) * 1.6)) scale(calc(var(--shs-s) + 0.02)); filter: blur(calc(var(--sq, 80px) * var(--shs-b) * 1.4)); }
.piece.dragging, .shadow.dragging { --ds: 1.08; }
.piece.dragging { z-index: 400; }
.piece.dragging svg { filter: var(--piece-outline) drop-shadow(0 10px 12px rgba(0,0,0,.28)); }
.piece.moving { z-index: 300; }
/* 3D per WebGL (board3d.js): der Canvas liegt unter der ganzen Bühne (über dem Seitenhintergrund, unter Karten und
   Panel – das Brett liegt auf dem Tisch, die Oberfläche schwebt darüber); gerahmt wird das Brett in der Brettfläche,
   dort kommen auch die Zeiger an. Die DOM-Ebenen des Bretts treten zurück; die Brett-Card liegt darüber
   (Umwandlung, Einladungskarte), lässt Zeiger aber durch. */
.stage { position: relative; }
/* reicht nach oben unter die (durchsichtige) Topbar: gezoomt endet das Brett sonst an einer harten Kante */
.board3d { position: absolute; left: 0; top: calc(-1 * var(--topbar-h)); width: 100%; height: calc(100% + var(--topbar-h)); display: block; z-index: -1; pointer-events: none; }
.board3d[hidden] { display: none; }
.board-area.gl .board-frame { z-index: 2; pointer-events: none; }
.board > .plane, .board > .pieces { transition: opacity .3s, visibility 0s; }
/* Umschalten: in 3D tritt das flache Brett sofort zurück (sein Abbild blendet an alter Stelle aus, app.js);
   zurück in 2D bleibt es verborgen, bis das 3D-Brett auf ihm landet (gl-land), und blendet dann ein */
.board.gl > .plane, .board.gl > .pieces, .board.gl-land > .plane, .board.gl-land > .pieces { opacity: 0; visibility: hidden; transition: none; }
.board-area.gl .board-frame::before, .board-area.gl .coords,
.board-area.gl-land .board-frame::before, .board-area.gl-land .coords { opacity: 0; transition: none; }
:root .board-frame.ghost::before, :root .board-frame.ghost .coords { opacity: 1; transition: none; }
.board-frame.ghost > div:not(.coords) { grid-column: 2; grid-row: 1; }
/* Abbild ohne eigenen Schatten: darunter liegt schon der Bodenschatten des 3D-Bretts (sonst kurz doppelt so dunkel) */
:root .board-frame.ghost::before { box-shadow: none; }
/* Landung des 3D-Bretts: das flache Brett erscheint sofort (es gleicht dem letzten 3D-Bild; überblendet wären die
   Schatten kurz doppelt), Brett-Card und Koordinaten blenden ein, während der 3D-Rand ausblendet (LAND_MS) */
.board.gl-landed > .plane, .board.gl-landed > .pieces { transition: none; }
.board-area.gl-landed .board-frame::before, .board-area.gl-landed .coords { transition-duration: .26s; }
/* Umwandlung: nur die Auswahlspalte fängt Zeiger (die Ebene selbst deckt das unsichtbare 2D-Brett ab) */
.board.gl .promo-col, .board.gl .board-overlay { pointer-events: auto; }
.board.gl .promo { background: transparent; backdrop-filter: none; overflow: visible; }
.board.gl .board-overlay { background: transparent; backdrop-filter: none; }
#viewBtn.busy { opacity: .5; cursor: progress; }
/* Schatten der angehobenen/bewegten Figur über den übrigen Figuren, knapp unter ihr selbst */
.shadow.dragging { z-index: 19; }
.shadow.moving { z-index: 9; }
.piece.captured { opacity: 0; transition: opacity .18s; }
/* Bedrohte Figur (schlagbar mit der gewählten Figur): zittert gleich beim Auswählen kurz, dann alle 2,4 s */
.piece.threat:not(.captured) svg { transform-origin: 50% 86%; animation: pc-shiver 2.4s ease-in-out infinite; }
@keyframes pc-shiver {
  0%, 22%, 100% { transform: none; }
  4% { transform: rotate(-4deg); } 8% { transform: rotate(3.5deg); } 12% { transform: rotate(-2.5deg); }
  16% { transform: rotate(1.5deg); } 20% { transform: rotate(-0.5deg); }
}
.piece.appear { animation: appear .25s var(--ease); }
@keyframes appear { from { opacity: 0; } }

/* Schweif hinter ziehenden Figuren (board.js): flach auf dem Brett, weich, multipliziert wie die Schatten */
.trails { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; mix-blend-mode: var(--sh-blend); }
.trail-layer path { stroke: none; }

svg.pc { stroke: none; }
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.arrow { opacity: var(--arrow-o); animation: fade .25s var(--ease); }
.arrow-shaft { fill: none; stroke: currentColor; stroke-width: 0.12; stroke-linecap: round; stroke-linejoin: round; }
.arrow-head { fill: currentColor; stroke: currentColor; stroke-width: 0.05; stroke-linejoin: round; }
.arrow.user { color: var(--arrow-user); }
.arrow.hint { color: var(--arrow-hint); }

.promo { position: absolute; inset: 0; background: rgba(20, 20, 22, 0.28); backdrop-filter: blur(2px); z-index: 30; animation: fade .15s; }
.promo-col {
  position: absolute; width: 12.5%; display: flex; background: var(--surface-solid); border-radius: 10px;
  box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .2s var(--ease);
}
.promo-btn { aspect-ratio: 1; width: 100%; padding: 8%; transition: background .12s; }
.promo-btn:hover { background: var(--surface-3); }
.promo-btn svg { width: 100%; height: 100%; filter: var(--piece-shadow); stroke-width: 1.4; }

.board-overlay {
  position: absolute; inset: 0; z-index: 25; display: grid; place-items: center;
  background: color-mix(in srgb, var(--frame) 55%, transparent); backdrop-filter: blur(6px) saturate(1.1); animation: fade .25s;
}
.invite-card {
  width: min(360px, 86%); padding: 26px; border-radius: var(--radius-lg); text-align: center;
  background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.invite-card h3 { margin: 12px 0 4px; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.invite-card p { margin: 0 0 18px; color: var(--text-2); font-size: 13px; }
.invite-code { font-size: 28px; font-weight: 500; letter-spacing: 0.18em; margin: 6px 0 16px; font-variant-numeric: tabular-nums; }
.invite-card .btn + .btn { margin-top: 8px; }

/* ============ Player cards ============ */
/* Spieler: zwei Cards im Stil des Panels untereinander – Spieler-Card (König als Hauptmotiv) und Vitrine */
.player { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pc-card, .pc-tray {
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.pc-card {
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
  position: relative; overflow: hidden; min-height: 150px; padding: 16px 18px;
}
.pc-tray { padding: 14px 18px; }
.pc-body { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
/* Aktionen der laufenden Partie: Card im Stil der Spieler-Cards, zwei ruhige Schaltflächen (Radius innen = außen −
   Innenabstand − Rahmen). Aufgeben fragt mit dem ersten Klick nach (.confirm), erst der zweite gibt auf. */
.actions {
  display: flex; align-items: center; gap: 4px; padding: 5px;
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.actions[hidden], .act[hidden] { display: none; }
.act {
  flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 10px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500; color: var(--text-2); white-space: nowrap;
  transition: background .15s, color .15s, transform .12s var(--ease);
}
.act svg { font-size: 16px; }
.act:hover { background: var(--surface-3); color: var(--text); }
.act:active { transform: scale(0.98); }
.act:disabled { opacity: .45; pointer-events: none; }
.act.danger:hover, .act.confirm { color: var(--red); }
.act.confirm { background: color-mix(in srgb, var(--red) 12%, transparent); }
/* König als angeschnittenes Motiv: gut zwei Drittel sichtbar, rechts von der Card-Kante angeschnitten.
   Beide Könige identisch in Größe, Position und Schatten. */
.pc-king {
  position: absolute; right: -53px; top: 50%; width: 152px; height: 152px; margin-top: -76px; pointer-events: auto; z-index: 2;
}
.pc-king svg {
  position: relative; width: 100%; height: 100%; display: block; overflow: visible;
  filter: none;
}
/* Elfenbein: etwas mehr Modellierung, damit er auf der hellen Card gleich präsent wirkt wie Graphit */
.pc-king.w svg {
  filter: contrast(1.14) brightness(0.97);
}
.pc-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.1), 0 6px 16px rgba(0,0,0,.08);
}
/* Avatar: König in der eigenen Figurenfarbe auf einer Scheibe im Ton der Brettfelder */
.avatar {
  background: radial-gradient(circle at 35% 28%, var(--avatar-a), var(--avatar-b));
  border: 1px solid var(--border);
}
.avatar svg { width: 74%; height: 74%; filter: var(--piece-shadow) drop-shadow(0.5px 1px 1px rgba(42, 32, 20, 0.18)); }
.pc-meta { min-width: 0; }
.pc-color { font-size: 11px; color: var(--text-3); line-height: 1.2; }
.pc-name { font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.015em; }
.pc-rating { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.status-dot.off { background: var(--text-3); box-shadow: none; }
.thinking { display: inline-flex; gap: 3px; margin-left: 2px; }
.thinking i { width: 4px; height: 4px; border-radius: 50%; background: var(--text-2); animation: blink 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

.clock-wrap { display: flex; flex-direction: column; gap: 2px; }
.clock {
  font-size: 38px; font-weight: 300; letter-spacing: -0.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--text-3); transition: color .2s;
}
.player.active .clock { color: var(--text); }
.clock.low { color: var(--red) !important; }
.clock-sub { font-size: 11.5px; color: var(--text-3); }
/* Vitrine: Leerplätze als eingeprägte Silhouetten, geschlagene Figuren in voller Farbe */
.tray-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.tray-title { font-size: 11.5px; color: var(--text-3); letter-spacing: .01em; }
.tray-title b { font-weight: 500; color: var(--text-2); margin-left: 3px; font-variant-numeric: tabular-nums; }
.tray-adv { font-size: 13px; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tray-adv.up { color: var(--text); }
.tray-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px 0; justify-items: center; }
.slot { width: 22px; height: 22px; display: grid; place-items: center; color: var(--slot); }
.slot svg { width: 100%; height: 100%; display: block; }
.slot svg.sil { fill: currentColor; }
.slot.on svg { filter: drop-shadow(0 0 0.6px rgba(40, 32, 20, 0.45)) drop-shadow(0.5px 1px 1px rgba(40, 32, 20, 0.2)); }
.slot.pop { animation: slot-pop .45s var(--ease); }
@keyframes slot-pop { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); } }

/* ============ Panel ============ */
.panel {
  display: flex; flex-direction: column; min-height: 0; position: relative;
  /* exakt so hoch wie das Brett-Element (gleiche Grid-Zeilen) → bündige Ober- und Unterkante */
  align-self: stretch;
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 18px;
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 2px 2px 16px; }
.game-title { font-weight: 500; font-size: 14px; letter-spacing: -0.015em; }
.game-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); padding-top: 1px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent); }
.live.idle .live-dot { background: var(--text-3); box-shadow: none; }
.live.pulse .live-dot { animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 6%, transparent); } }

.tabs { margin-bottom: 12px; }
.tab-body { flex: 1; min-height: 0; position: relative; }
.tab-pane { position: absolute; inset: 0; overflow-y: auto; display: none; scrollbar-width: thin; }
.tab-pane.active { display: block; animation: fade .2s; }

.moves { display: flex; flex-direction: column; gap: 2px; font-size: 13px; font-variant-numeric: tabular-nums; }
/* Eine Zugzeile ist ein durchgehendes Band; der aktive Zug ist eine weiße Pille wie der aktive Tab */
.mv-row {
  display: grid; grid-template-columns: 30px 1fr 1fr; align-items: center; gap: 2px;
  padding: 2px; border-radius: 11px; transition: background .15s;
}
.mv-row.current { background: var(--surface-3); }
.mv-num { color: var(--text-3); padding-left: 8px; }
.mv {
  text-align: left; padding: 6px 8px; border-radius: 9px; color: var(--text); font-weight: 400;
  transition: background .12s; display: inline-flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap;
}
.mv-pc { width: 18px; height: 18px; flex: none; display: inline-grid; place-items: center; }
.mv-pc svg { width: 100%; height: 100%; }
/* Kleine Figuren-Icons in der Zugliste: feine Kontur, damit Weiß auf hellem Grund sichtbar bleibt */
.mv-pc svg { filter: drop-shadow(0 0 0.6px rgba(40, 32, 20, 0.6)) drop-shadow(0 0.5px 0.6px rgba(40, 32, 20, 0.25)); }
:root[data-theme="dark"] .mv-pc svg { filter: drop-shadow(0 0 0.6px rgba(255, 255, 255, 0.45)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mv-pc svg { filter: drop-shadow(0 0 0.6px rgba(255, 255, 255, 0.45)); } }
.mv-path { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.mv-path i { font-style: normal; color: var(--text-3); margin: 0 3px; font-size: 11px; }
.mv-suf { color: var(--text-2); font-weight: 500; }
.pv-mv { display: inline-flex; align-items: center; gap: 4px; margin: 0 10px 4px 0; white-space: nowrap; }
.pv-mv.first .mv-path { font-weight: 600; }
.mv:hover { background: var(--surface-2); }
.mv-row.current .mv:hover { background: color-mix(in srgb, var(--surface-solid) 55%, transparent); }
.mv.active, .mv.active:hover, .mv-row.current .mv.active:hover {
  background: var(--surface-solid);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.05);
}
:root[data-theme="dark"] .mv.active { background: #2a2a2f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mv.active { background: #2a2a2f; } }
.mv.active .mv-path { font-weight: 600; }
.moves-empty { color: var(--text-3); font-size: 13px; padding: 28px 10px; text-align: center; }
.result-line { text-align: center; color: var(--text-2); font-size: 12.5px; padding: 12px 0 4px; font-weight: 500; }

.banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-top: 10px;
  border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border-strong); font-size: 13px;
  animation: pop .25s var(--ease);
}
.banner .grow { flex: 1; }
.banner .btn { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }

.eval { padding: 16px 2px 4px; border-top: 1px solid var(--border); margin-top: 12px; }
.eval-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text); margin-bottom: 6px; }
.eval-num { font-variant-numeric: tabular-nums; font-weight: 500; }
.eval-text { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); min-height: 18px; }
.eval-dot { width: 10px; height: 10px; border-radius: 50%; background: #f2f0eb; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); flex: none; }
.eval-dot.b { background: #2d2d31; }
.eval.muted .eval-num { opacity: .35; }

.controls {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 12px; padding: 5px;
  border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border);
}
.ctrl { height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2); transition: background .15s, color .15s; }
.ctrl svg { font-size: 17px; }
.ctrl:hover { background: var(--surface-3); color: var(--text); }
.ctrl.main { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.ctrl:disabled { opacity: .35; pointer-events: none; }
.menu-wrap { position: relative; display: grid; }
.menu {
  position: absolute; right: 0; bottom: calc(100% + 10px); min-width: 230px; padding: 6px; z-index: 40;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: pop .18s var(--ease); transform-origin: bottom right;
}
.menu button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; font-size: 13px; text-align: left;
}
.menu button svg { font-size: 16px; color: var(--text-2); }
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--red); }
.menu button.danger svg { color: var(--red); }
.menu kbd { margin-left: auto; font: inherit; font-size: 11px; color: var(--text-3); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 4px; }

/* Analyse & Details */
.analysis, .details { display: flex; flex-direction: column; gap: 14px; padding: 2px; }
.a-card { padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.a-label { font-size: 11.5px; color: var(--text-3); margin-bottom: 6px; display: flex; justify-content: space-between; }
.a-big { font-size: 26px; font-weight: 300; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.a-line { font-size: 13px; line-height: 1.7; font-variant-numeric: tabular-nums; display: flex; flex-wrap: wrap; }
.a-line .n { color: var(--text-3); margin-right: 3px; }
.a-line b { font-weight: 600; }
.a-muted { color: var(--text-3); font-size: 12.5px; }
.graph { width: 100%; height: 86px; display: block; cursor: pointer; }
.graph .g-area { fill: color-mix(in srgb, var(--text) 10%, transparent); stroke: none; }
.graph .g-line { stroke: var(--text-2); stroke-width: 1.4; fill: none; }
.graph .g-mid { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.graph .g-cur { stroke: var(--blue); stroke-width: 1.4; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-box {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11.5px; line-height: 1.55; color: var(--text-2);
  padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
  word-break: break-all; max-height: 120px; overflow: auto;
}
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ============ Dialogs ============ */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgba(15, 15, 18, 0.28); backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
  animation: fade .2s;
}
.dialog {
  position: relative; width: min(460px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-lg);
  padding: 28px; animation: pop .28s var(--ease);
}
.dlg-close { position: absolute; top: 16px; right: 16px; }
.dlg-head h2 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -0.025em; }
.dlg-head p { margin: 4px 0 22px; color: var(--text-2); font-size: 13.5px; }
.dlg-section { margin-top: 20px; }
.field-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; }
.dlg-actions { margin-top: 24px; display: flex; flex-direction: column; gap: 8px; }
.dlg-actions.row { flex-direction: row; }
.dlg-actions.row .btn { flex: 1; }

.mode-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; border-radius: 14px;
  border: 1px solid var(--border-strong); background: var(--surface-solid); text-align: left;
  transition: border-color .15s, box-shadow .15s, background .15s, transform .12s var(--ease);
}
.mode-card:hover { background: var(--surface-2); }
.mode-card:active { transform: scale(0.985); }
.mode-card svg { font-size: 20px; margin-bottom: 10px; color: var(--text-2); }
.mode-card.active { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.mode-card.active svg { color: var(--text); }
.mc-title { font-weight: 500; font-size: 13.5px; }
.mc-sub { font-size: 11.5px; color: var(--text-3); }

.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.level {
  padding: 10px 4px 9px; border-radius: 11px; border: 1px solid var(--border-strong); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px; transition: all .15s;
}
.level:hover { background: var(--surface-2); }
.level .bars { display: flex; gap: 2px; align-items: flex-end; height: 14px; }
.level .bars i { width: 3px; border-radius: 2px; background: var(--border-strong); }
.level .bars i.on { background: var(--text); }
.level .lv-elo { font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.level.active { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.level-desc { margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.level-desc b { color: var(--text); font-weight: 500; }

.colors .swatch { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.swatch.w { background: #fff; }
.swatch.b { background: #1d1d1f; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; transition: all .15s;
}
.chip small { color: var(--text-3); font-size: 11px; }
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip.active small { color: inherit; opacity: .6; }

.join-row { display: flex; gap: 8px; margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.join-row .input { height: 40px; text-transform: uppercase; }
.join-row .input::placeholder { text-transform: none; letter-spacing: 0; }
.join-row .btn { height: 40px; }

.seeking { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 30px 0 4px; gap: 6px; }
.seeking-title { font-size: 16px; font-weight: 500; margin-top: 14px; }
.seeking-sub { font-size: 12.5px; color: var(--text-2); margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.radar { position: relative; width: 64px; height: 64px; }
.radar span { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--text); opacity: 0; animation: ripple 2.4s infinite var(--ease); }
.radar span:nth-child(2) { animation-delay: .8s; } .radar span:nth-child(3) { animation-delay: 1.6s; }
.radar::after { content: ''; position: absolute; inset: 26px; border-radius: 50%; background: var(--text); }
@keyframes ripple { 0% { transform: scale(.3); opacity: .7; } 100% { transform: scale(1.3); opacity: 0; } }

.dialog.result { text-align: center; width: min(380px, 100%); padding-top: 34px; }
.result-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); }
.result-icon svg { width: 60%; height: 60%; stroke-width: 1.4; filter: var(--piece-shadow); }
.result h2 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.03em; }
.result p { margin: 4px 0 0; color: var(--text-2); font-size: 13.5px; }
.result-score { font-size: 15px; font-weight: 500; margin-top: 18px; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.result-rating { font-size: 12.5px; color: var(--text-2); margin-top: 4px; min-height: 18px; font-variant-numeric: tabular-nums; }
.result-rating .up { color: var(--green); font-weight: 500; }
.result-rating .down { color: var(--red); font-weight: 500; }
.result .linkish { margin-top: 12px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 200; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 500;
  background: var(--accent); color: var(--accent-text); box-shadow: var(--shadow-lg);
  transition: opacity .25s, transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }

/* ============ 3D-Layout ============ */
/* Desktop: Das 3D-Brett bekommt die ganze linke Fläche; die Spieler rücken kompakt über und unter das Panel.
   .iso-ghost: ausblendende Kopie einer Spieler-Card beim Umschalten zu 2D (app.js) behält das kompakte Aussehen. */
@media (min-width: 1181px) {
  :root[data-view="iso"] .stage {
    grid-template-columns: minmax(0, 1fr) 10px 320px;
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "board eval panel";
    justify-content: stretch;
  }
  /* Das Panel hat die ganze rechte Spalte; über der Brettfläche schweben die Aktionen (oben links), die eigene Karte
     (unten links) und der Gegner (unten rechts). Absolut im Grid-Bereich des Bretts: die Ecken der Brettfläche */
  /* (nur in der Bühne: die ausblendenden Kopien beim Umschalten behalten Breite und Lage) */
  :root[data-view="iso"] .stage > :is(.actions, .player) { position: absolute; grid-area: board; z-index: 3; }
  :root[data-view="iso"] .stage > .actions { left: 0; top: 0; width: 224px; }
  :root[data-view="iso"] .stage > .player { width: 320px; bottom: 0; }
  :root[data-view="iso"] .stage > .player.bottom { left: 0; }
  :root[data-view="iso"] .stage > .player.top { right: 0; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .player { gap: 8px; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .pc-card { flex-direction: row; align-items: center; justify-content: space-between; padding: 10px 14px; gap: 12px; border-radius: 16px; min-height: 0; overflow: visible; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .pc-body { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; flex: 1; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .pc-king { position: relative; right: auto; top: auto; margin-top: 0; width: 46px; height: 46px; flex: none; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .player .clock-wrap { align-items: flex-end; order: 3; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .clock { font-size: 28px; padding: 2px 12px; border-radius: 10px; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .player.active .clock { background: var(--surface-solid); box-shadow: var(--shadow-sm); }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .clock-sub { display: none; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .pc-tray { padding: 10px 14px; border-radius: 16px; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .tray-head { display: none; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .tray-grid { grid-template-columns: repeat(16, 1fr); gap: 0; }
  :is(:root[data-view="iso"] .stage, .iso-ghost) .slot { width: 16px; height: 16px; }
}
/* Tablet: in 3D nimmt das Brett die ganze Spaltenbreite */
@media (max-width: 1180px) and (min-width: 781px) {
  :root[data-view="iso"] .stage { grid-template-columns: minmax(0, 1fr) 10px 300px; justify-content: stretch; }
}
/* Handy: das schräg liegende 3D-Brett braucht weniger Höhe als das quadratische 2D-Brett */
@media (max-width: 780px) {
  :root[data-view="iso"] .board-frame { margin-block: calc(var(--board) * -0.14); }
}

/* ============ Responsive ============ */
@media (max-width: 1180px) {
  .stage {
    --board: min(calc(100vh - 150px), calc(100vw - 484px), 760px);
    grid-template-columns: var(--board) 10px 300px;
    grid-template-rows: auto auto auto;
    grid-template-areas: "top eval panel" "board eval panel" "bottom eval actions";
    column-gap: 24px; row-gap: 10px;
  }
  .panel { height: auto; align-self: stretch; }
  .player { flex-direction: row; align-items: stretch; gap: 10px; }
  .pc-card { flex: 1; flex-direction: row; align-items: center; justify-content: space-between; padding: 10px 14px; gap: 12px; border-radius: 16px; min-height: 0; overflow: visible; }
  .pc-tray { display: flex; align-items: center; padding: 8px 14px; border-radius: 16px; }
  .pc-body { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; flex: 1; }
  .pc-king { position: relative; right: auto; top: auto; margin-top: 0; width: 46px; height: 46px; flex: none; }
  .player.top, .player.bottom { align-self: center; }
  .player .clock-wrap { align-items: flex-end; order: 3; }
  .tray-head { display: none; }
  .tray-grid { gap: 2px 0; }
  .slot { width: 16px; height: 16px; }
  .clock { font-size: 28px; padding: 2px 12px; border-radius: 10px; }
  .player.active .clock { background: var(--surface-solid); box-shadow: var(--shadow-sm); }
  .clock-sub { display: none; }
  .stage { --board-extra: 0; }
  .panel { min-height: 0; max-height: calc(var(--board) + 150px); }
}
@media (max-width: 1180px) and (min-width: 781px) {
  .stage { --board: min(calc(100vh - 264px), calc(100vw - 484px), 760px); } /* inkl. unterem Innenabstand: kein Scrollen */
  .actions { align-self: stretch; } /* gleiche Höhe wie die eigene Spieler-Card daneben */
  .veval { margin-right: -12px; }
}
@media (max-width: 780px) {
  .pc-tray { display: none; }
  .topbar { height: 54px; padding: 0 14px; }
  .topbar-center { display: none; }
  .stage {
    --board: calc(100vw - 16px);
    grid-template-columns: 1fr; grid-template-areas: "top" "board" "bottom" "actions" "panel";
    padding: 0 8px 24px; row-gap: 8px; align-content: start;
  }
  .board-frame { padding: 8px 8px 2px 2px; grid-template-columns: 16px 1fr; grid-template-rows: 1fr 18px; border-radius: 16px; }
  .veval { display: none; }
  .coords { font-size: 9.5px; }
  .avatar { width: 32px; height: 32px; }
  .pc-color { display: none; }
  .clock { font-size: 24px; }
  .panel { height: 420px; max-height: none; padding: 14px; border-radius: 18px; }
  .dialog { padding: 22px; border-radius: 20px; }
  .mode-card { padding: 12px 10px; }
  .level .lv-elo { font-size: 11px; }
}
@media (max-width: 359px) { .topbar { gap: 8px; } .top-actions { gap: 2px; } .top-actions .icon-btn { width: 30px; } }
/* Hell ↔ Dunkel: kurze Überblendung der ganzen Seite (View Transition, app.js switchTheme) */
:root.theme-fade::view-transition-old(root),
:root.theme-fade::view-transition-new(root) { animation-duration: .32s; animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
