:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --board: #157f43;
  --board-line: #0d5e30;
  --legal: rgba(255, 255, 255, 0.28);
  --last: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.app {
  width: 100%;
  max-width: 560px;
  padding: 24px 16px 48px;
}

header { text-align: center; margin-bottom: 20px; }
h1 { margin: 0; font-size: 2rem; letter-spacing: 1px; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--panel);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 16px;
}
.control { display: flex; flex-direction: column; gap: 4px; }
.control label { font-size: 0.8rem; color: var(--muted); }

/* Presets */
.presets { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.presets-label { font-size: 0.8rem; color: var(--muted); }
.preset-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.preset-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.preset-btn:hover { background: #3f4d63; }
.preset-btn.active { background: var(--accent); color: #082f49; border-color: var(--accent); font-weight: 600; }
.preset-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.preset-btn:disabled:hover { background: var(--panel-2); }

/* Slider */
.sliders { display: flex; flex-direction: column; gap: 14px; }
.slider-row { display: flex; flex-direction: column; gap: 6px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; }
.slider-head label { font-size: 0.85rem; color: var(--text); cursor: help; }
.slider-warn { margin: 0; font-size: 0.8rem; color: var(--last); }
.slider-val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
  font-size: 1rem;
}
.info {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: help;
}
.info:hover { background: var(--accent); color: #082f49; }

/* Eigener Tooltip (statt native title-Verzögerung) – sofort beim Hovern. */
.info:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  transform: translateX(-8px);
  width: 230px;
  max-width: 60vw;
  background: #0b1220;
  color: var(--text);
  border: 1px solid #475569;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.info:hover::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 4px;
  border: 6px solid transparent;
  border-top-color: #475569;
  z-index: 20;
  pointer-events: none;
}

/* Das "?" der Siegchance steht mittig: Tooltip zentrieren, sonst ragt er auf
   schmalen Bildschirmen rechts aus dem Fenster. */
.eval-caption .info:hover::after { left: 50%; transform: translateX(-50%); }
.eval-caption .info:hover::before { left: 50%; transform: translateX(-50%); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--panel-2);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
input[type="range"]:disabled { opacity: 0.4; cursor: not-allowed; }
select:disabled { opacity: 0.5; cursor: not-allowed; }

.bottom-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.bottom-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  background: var(--panel-2);
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:hover { background: #3f4d63; }
.icon-btn.muted { opacity: 0.55; }

select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.95rem;
}

button.primary {
  background: var(--accent);
  color: #082f49;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary.danger { background: #f87171; color: #450a0a; }

.scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.score { display: flex; align-items: center; gap: 8px; }
.count { font-size: 1.5rem; font-weight: 700; min-width: 1.4ch; text-align: center; }
.status {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.disc {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-block;
}
.disc-black { background: #0f172a; border: 2px solid #64748b; }
.disc-white { background: #f8fafc; border: 2px solid #cbd5e1; }

/* KI-Bewertungsleiste (Schwarz <-> Weiß, wie beim Schachcomputer). */
.eval { margin-bottom: 14px; }
.eval-caption {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 5px;
}
.eval-bar {
  position: relative;
  width: 100%;
  height: 20px;
  border-radius: 10px;
  overflow: hidden;
  background: #f1f5f9;                 /* Weiß-Seite */
  /* Rahmen als Ring außen, damit die Innengeometrie exakt bleibt (Mitte = 50%). */
  box-shadow: 0 0 0 1px #475569;
}
.eval-black {
  height: 100%;
  width: 50%;
  background: #0f172a;                 /* Schwarz-Seite, wächst von links */
  transition: width 0.45s ease;
}
/* Mittelmarkierung (ausgeglichen). */
.eval-bar::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 1px;
  background: rgba(100, 116, 139, 0.6);
  transform: translateX(-0.5px);
}
/* Prozentzahlen im Balken. mix-blend-mode: difference invertiert die (weiße)
   Schrift gegen den Untergrund – dadurch immer sichtbar, egal ob gerade der
   schwarze oder der weiße Teil des Balkens dahinterliegt. */
.eval-num {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
}
.eval-num-left { left: 9px; }
.eval-num-right { right: 9px; }

.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.board {
  display: grid;
  gap: 3px;
  background: var(--board-line);
  padding: 3px;
  border-radius: 8px;
  width: 100%;
  aspect-ratio: 1 / 1;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.cell {
  background: var(--board);
  border-radius: 4px;
  position: relative;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cell.playable { cursor: pointer; }
.cell.playable:hover { background: #1a9350; }

.stone {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  transform-origin: center;
}
.stone.black { background: radial-gradient(circle at 35% 30%, #475569, #0f172a 70%); }
.stone.white { background: radial-gradient(circle at 35% 30%, #ffffff, #cbd5e1 75%); }

/* Neu gesetzter Stein: kurzes Aufploppen. */
.stone.pop { animation: pop var(--pop-dur, 150ms) ease-out; }
@keyframes pop {
  0%   { transform: scale(0.1); opacity: 0.2; }
  70%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

/* Umgedrehter Stein: um die vertikale Achse klappen (Farbwechsel bei 50%). */
.stone.flip { animation: flip var(--flip-dur, 220ms) ease-in-out; }
@keyframes flip {
  0%   { transform: scaleX(1); }
  50%  { transform: scaleX(0.05); }
  100% { transform: scaleX(1); }
}

.hint {
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--legal);
}

.cell.last-ai::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid var(--last);
  border-radius: 4px;
  pointer-events: none;
}

footer { text-align: center; margin-top: 16px; min-height: 1.4em; }
.thinking { color: var(--accent); font-size: 0.9rem; }

.hidden { display: none !important; }
/* Unsichtbar, aber Platz behalten (z. B. Passen-Button: sonst springt das Layout). */
.invisible { visibility: hidden; }

.status.win { color: #4ade80; font-weight: 600; }
.status.lose { color: #f87171; font-weight: 600; }
.status.draw { color: #fbbf24; font-weight: 600; }
