:root {
  --panel: rgba(255,255,255,.90);
  --ink: #19140f;
  --muted: #6d6458;
  --gold: #f0c45f;
  --green: #68b879;
  --red: #e16e57;
  --blue: #5d7cff;
  --dark: #111827;
  --line: rgba(39,31,19,.16);
  --shadow: 0 22px 70px rgba(0,0,0,.26);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100svh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(240,196,95,.28), transparent 32rem),
    radial-gradient(circle at 88% 10%, rgba(107,139,255,.20), transparent 30rem),
    linear-gradient(135deg, #171d29, #0d1018 58%, #15100d);
}
.app {
  width: min(1440px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 30px;
  display: grid;
  gap: 14px;
}
.hero, .panel {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 26px;
  box-shadow: var(--shadow);
}
.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: clamp(16px, 2.4vw, 28px);
}
.hero-actions, .control-row { display: flex; gap: 9px; flex-wrap: wrap; }
.kicker {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: .11em;
  color: var(--gold);
  font-weight: 1000;
  font-size: .78rem;
}
h1 { margin: 0; font-size: clamp(2.0rem, 5vw, 4.2rem); line-height: .9; letter-spacing: -0.07em; }
h2 { margin: 0 0 8px; font-size: 1.15rem; }
.lead { margin: 10px 0 0; color: rgba(255,255,255,.80); max-width: 62ch; line-height: 1.45; }
.layout {
  display: grid;
  grid-template-columns: minmax(255px, 320px) minmax(520px, 1fr) minmax(230px, 300px);
  gap: 14px;
  align-items: start;
}
.panel { padding: clamp(13px, 1.8vw, 20px); }
.controls { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 900; color: var(--muted); }
select {
  width: 100%;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,.82);
  color: var(--ink);
  font-weight: 900;
}
button {
  border: 0;
  border-radius: 999px;
  padding: 10px 13px;
  font-weight: 950;
  cursor: pointer;
  background: var(--gold);
  color: #221908;
  box-shadow: 0 10px 24px rgba(0,0,0,.13);
}
button.secondary { background: rgba(255,255,255,.86); }
button:disabled { opacity: .5; cursor: not-allowed; }
.status { margin: 0; color: var(--muted); line-height: 1.4; font-weight: 800; }
.ai-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 11px;
  background: rgba(255,255,255,.54);
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.35;
}
.rules {
  display: grid;
  gap: 6px;
  font-size: .92rem;
  color: var(--muted);
  line-height: 1.35;
}
.rules p { margin: 0; }
.board-panel { display: grid; gap: 12px; }
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: var(--dark);
  color: #fff;
  padding: 9px 13px;
  font-weight: 1000;
}
#turnDot { width: 18px; height: 18px; border-radius: 999px; border: 2px solid rgba(255,255,255,.7); background: #fff; }
#turnDot.black { background: #111; }
.hilbert-board {
  position: relative;
  width: min(84vw, 780px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 24px;
  overflow: hidden;
  border: 6px solid #2a2419;
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,.14), transparent 28%),
    linear-gradient(135deg, #d6c08b, #9f7c44 46%, #5f482b);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 24px 70px rgba(0,0,0,.26);
}
.hilbert-board.flipped { transform: rotate(180deg); }
.hilbert-board.flipped .cell-content,
.hilbert-board.flipped .num,
.hilbert-board.flipped .result-banner { transform: rotate(180deg); }
.path-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}
.path-under {
  fill: none;
  stroke: rgba(34, 23, 9, .55);
  stroke-width: 24;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.path-main {
  fill: none;
  stroke: rgba(255, 243, 184, .88);
  stroke-width: 13;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.28));
}
.cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  z-index: 2;
}
.cell {
  position: relative;
  appearance: none;
  border: 1px solid rgba(255,255,255,.13);
  background: rgba(255,255,255,.025);
  cursor: pointer;
  padding: 0;
  overflow: visible;
}
.cell:nth-child(even) { background: rgba(0,0,0,.035); }
.cell.goal-white { background: rgba(20,20,20,.16); }
.cell.goal-black { background: rgba(255,255,255,.12); }
.cell.selected { background: rgba(93,124,255,.28); box-shadow: inset 0 0 0 4px rgba(93,124,255,.75); }
.cell.legal { background: rgba(104,184,121,.25); box-shadow: inset 0 0 0 4px rgba(104,184,121,.70); }
.cell.capture { background: rgba(225,110,87,.30); box-shadow: inset 0 0 0 4px rgba(225,110,87,.82); }
.cell-content {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.num {
  position: absolute;
  left: 5px;
  top: 4px;
  font-size: clamp(8px, 1vw, 12px);
  font-weight: 1000;
  color: rgba(36, 24, 9, .55);
  z-index: 5;
  pointer-events: none;
}
.piece {
  width: 88%;
  height: 88%;
  position: relative;
  z-index: 4;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 8px 8px rgba(0,0,0,.32));
  transition: transform .12s ease, filter .12s ease;
}
.piece img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.piece.white img { filter: drop-shadow(0 0 1px rgba(0,0,0,.9)); }
.piece.black img { filter: drop-shadow(0 0 1px rgba(255,255,255,.55)); }
.cell.selected .piece { transform: translateY(-2px) scale(1.06); }
.result-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  z-index: 9;
  display: none;
  max-width: 92%;
  padding: clamp(18px, 4vw, 34px) clamp(22px, 5vw, 46px);
  border-radius: 28px;
  border: 5px solid rgba(255,255,255,.9);
  color: white;
  text-align: center;
  font-weight: 1100;
  font-size: clamp(2rem, 7vw, 5.8rem);
  line-height: .9;
  letter-spacing: -0.06em;
  text-shadow: 0 4px 18px rgba(0,0,0,.35);
  box-shadow: 0 24px 80px rgba(0,0,0,.40);
}
.result-banner.show { display: block; }
.result-banner.win { background: linear-gradient(135deg, #2dae61, #78ca45); }
.result-banner.loss { background: linear-gradient(135deg, #a31f1f, #e16e57); }
.result-banner.draw { background: linear-gradient(135deg, #465169, #8290a8); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; color: var(--muted); font-size: .88rem; font-weight: 850; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 15px; height: 15px; border-radius: 5px; border: 1px solid rgba(0,0,0,.2); }
.swatch.goalW { background: rgba(20,20,20,.24); }
.swatch.goalB { background: rgba(255,255,255,.54); }
.swatch.selected { background: rgba(93,124,255,.35); }
.swatch.legal { background: rgba(104,184,121,.35); }
.swatch.capture { background: rgba(225,110,87,.35); }
.log-panel { display: grid; gap: 8px; }
.log {
  max-height: 680px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 7px;
  color: var(--muted);
  font-size: .92rem;
}
.log p {
  margin: 0;
  padding: 8px 10px;
  border-radius: 13px;
  background: rgba(255,255,255,.50);
  border: 1px solid rgba(0,0,0,.05);
}
@media (max-width: 1120px) {
  .layout { grid-template-columns: 1fr; }
  .hilbert-board { width: min(94vw, 760px); }
  .log { max-height: 220px; }
}
@media (max-width: 680px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .lead { color: var(--muted); }
  .hilbert-board { border-width: 4px; }
  .path-under { stroke-width: 20; }
  .path-main { stroke-width: 11; }
}

/* v6: Schach-Warnung */
.cell.check-king {
  background: rgba(225, 82, 63, .38) !important;
  box-shadow:
    inset 0 0 0 5px rgba(225, 82, 63, .92),
    inset 0 0 30px rgba(225, 82, 63, .35);
}
.cell.check-king .piece {
  animation: checkPulse 1.05s ease-in-out infinite;
}
@keyframes checkPulse {
  0%, 100% { transform: translateY(-2px) scale(1.04); filter: drop-shadow(0 8px 8px rgba(0,0,0,.34)); }
  50% { transform: translateY(-3px) scale(1.12); filter: drop-shadow(0 0 14px rgba(225,82,63,.92)); }
}

/* v7: Schwarz/Weiß-Feldmuster, damit Läuferfarben sofort sichtbar sind. */
.cell.light-square {
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.08), transparent 64%),
    rgba(238, 229, 202, .38);
}
.cell.dark-square {
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.04), transparent 64%),
    rgba(61, 50, 31, .24);
}
.cell.goal-white.light-square,
.cell.goal-white.dark-square {
  background:
    radial-gradient(circle at 50% 50%, rgba(0,0,0,.10), transparent 64%),
    rgba(40, 34, 25, .30);
}
.cell.goal-black.light-square,
.cell.goal-black.dark-square {
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.14), transparent 64%),
    rgba(255, 245, 211, .42);
}
.cell.selected { background: rgba(93,124,255,.32) !important; }
.cell.legal { background: rgba(104,184,121,.30) !important; }
.cell.capture { background: rgba(225,110,87,.34) !important; }
.swatch.lightfield { background: rgba(238,229,202,.75); }
.swatch.darkfield { background: rgba(61,50,31,.55); }
