/* Farkle – Design & Animationen */

:root {
  color-scheme: dark;
  --bg-1: #1b2240;
  --bg-2: #2d3a6b;
  --accent: #ffd23f;
  --accent-2: #ff7b54;
  --green: #3ddc84;
  --green-dark: #1f9c5c;
  --card: rgba(255, 255, 255, 0.07);
  --card-solid: #232b4e;
  --text: #f5f7ff;
  --muted: #aab2d5;
  --die-face: #fdfdfd;
  --die-pip: #2a2a3a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 0%, var(--bg-2), var(--bg-1) 60%);
  min-height: 100vh;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.topbar { text-align: center; margin-bottom: 20px; position: relative; }
.back-link {
  position: absolute; left: 0; top: 6px;
  color: var(--muted); font-size: 0.9rem; text-decoration: none;
}
.back-link:hover { color: var(--text); }

/* --- Spielauswahl (Landing) --- */
.game-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .game-picker { grid-template-columns: 1fr; } }
.pick-card {
  display: block; text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px; padding: 24px; box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.pick-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.pick-emoji { font-size: 3rem; }
.pick-card h2 { margin: 10px 0 6px; }
.pick-card p { color: var(--muted); font-size: 0.92rem; line-height: 1.5; margin: 0 0 14px; }
.pick-go { color: var(--accent); font-weight: 600; }
.pick-card.teaser { border-style: dashed; border-color: rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.02); }

/* Mehr-Mathe-Spiele-Seite */
.math-list { list-style: none; padding: 0; margin: 0; }
.math-list li { padding: 12px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07); color: var(--muted); line-height: 1.5; }
.math-list li:last-child { border-bottom: none; }
.math-list strong { color: var(--text); }
.math-list .playable { color: var(--green); font-weight: 600; text-decoration: none; font-size: 0.85rem; }
.math-list .playable:hover { text-decoration: underline; }
.formula {
  display: block; margin-top: 5px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.82rem;
  color: var(--accent); background: rgba(255, 210, 63, 0.06);
  border-left: 2px solid rgba(255, 210, 63, 0.4);
  padding: 5px 9px; border-radius: 4px;
}
.teaser-note { color: var(--muted); font-size: 0.92rem; line-height: 1.55; margin: 0; }
.topbar h1 { font-size: 2.6rem; margin: 0; letter-spacing: 1px; }
@media (max-width: 480px) {
  .topbar h1 { font-size: 1.9rem; }
  .topbar-action { font-size: 0.76rem; padding: 6px 10px; }
}
.tagline { color: var(--muted); margin: 6px 0 0; }

.card, .game {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.hidden { display: none !important; }

/* --- Setup --- */
.setup h2 { margin-top: 0; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label { color: var(--muted); font-size: 0.9rem; }
.field input, .field select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 1rem;
}
.field select { cursor: pointer; }

/* --- Buttons --- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #2a1d00; }
.btn-secondary { background: #41507f; color: var(--text); }
.btn-success { background: linear-gradient(135deg, var(--green), var(--green-dark)); color: #04150c; }
.btn-ghost { background: transparent; border: 1px solid rgba(255, 255, 255, 0.25); color: var(--text); }

/* --- Scoreboard --- */
.btn-small { padding: 8px 14px; font-size: 0.85rem; white-space: nowrap; }
.topbar-action { position: absolute; right: 0; top: 0; }

.speed-control {
  display: flex; align-items: center; gap: 10px;
  margin: -4px 0 14px; padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--muted); font-size: 0.9rem;
}
.speed-control select {
  background: var(--card-solid); color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px; padding: 5px 8px; cursor: pointer;
}
.scoreboard { display: flex; gap: 14px; margin-bottom: 18px; }
.player-card {
  flex: 1;
  background: var(--card-solid);
  border-radius: 14px;
  padding: 14px 16px;
  border: 2px solid transparent;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.player-card.active {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(255, 210, 63, 0.25);
}
.player-card .name { color: var(--muted); font-size: 0.9rem; }
.player-card .total { font-size: 2rem; font-weight: 700; }
.player-card .bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.12); margin-top: 8px; overflow: hidden; }
.player-card .bar > span { display: block; height: 100%; background: var(--accent); transition: width 0.5s ease; }

/* --- Turn info --- */
.turninfo {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  color: var(--muted); margin-bottom: 16px; font-size: 0.95rem;
}
.turninfo strong { color: var(--text); }

/* --- Dice --- */
.dice-tray {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin: 10px 0 18px;
}
@media (max-width: 560px) { .dice-tray { grid-template-columns: repeat(3, 1fr); } }

.die {
  aspect-ratio: 1 / 1;
  background: var(--die-face);
  border-radius: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 14%;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.12), 0 6px 12px rgba(0,0,0,0.3);
  cursor: default;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.die .pip { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.die .pip::after {
  content: "";
  width: 64%; height: 64%;
  background: var(--die-pip);
  border-radius: 50%;
}
.die.selectable { cursor: pointer; }
.die.selectable:hover { transform: translateY(-3px); }
.die.scoring { box-shadow: 0 0 0 3px var(--accent), 0 6px 12px rgba(0,0,0,0.3); }
.die.selected {
  transform: translateY(-6px);
  box-shadow: 0 0 0 4px var(--green), 0 10px 18px rgba(0,0,0,0.4);
}
.die.locked { opacity: 0.45; transform: scale(0.92); cursor: default; }
.die.rolling { animation: roll 0.5s ease; }

@keyframes roll {
  0%   { transform: rotate(0deg) scale(1); }
  25%  { transform: rotate(-18deg) scale(1.08); }
  50%  { transform: rotate(15deg) scale(0.95); }
  75%  { transform: rotate(-8deg) scale(1.05); }
  100% { transform: rotate(0deg) scale(1); }
}

/* Pip-Positionen je Augenzahl (3x3 Raster) */
.die[data-v="1"] .pip:nth-child(1) { grid-area: 2 / 2; }
.die[data-v="2"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-v="2"] .pip:nth-child(2) { grid-area: 3 / 3; }
.die[data-v="3"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-v="3"] .pip:nth-child(2) { grid-area: 2 / 2; }
.die[data-v="3"] .pip:nth-child(3) { grid-area: 3 / 3; }
.die[data-v="4"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-v="4"] .pip:nth-child(2) { grid-area: 1 / 3; }
.die[data-v="4"] .pip:nth-child(3) { grid-area: 3 / 1; }
.die[data-v="4"] .pip:nth-child(4) { grid-area: 3 / 3; }
.die[data-v="5"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-v="5"] .pip:nth-child(2) { grid-area: 1 / 3; }
.die[data-v="5"] .pip:nth-child(3) { grid-area: 2 / 2; }
.die[data-v="5"] .pip:nth-child(4) { grid-area: 3 / 1; }
.die[data-v="5"] .pip:nth-child(5) { grid-area: 3 / 3; }
.die[data-v="6"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-v="6"] .pip:nth-child(2) { grid-area: 1 / 3; }
.die[data-v="6"] .pip:nth-child(3) { grid-area: 2 / 1; }
.die[data-v="6"] .pip:nth-child(4) { grid-area: 2 / 3; }
.die[data-v="6"] .pip:nth-child(5) { grid-area: 3 / 1; }
.die[data-v="6"] .pip:nth-child(6) { grid-area: 3 / 3; }

/* --- Suggestion --- */
.suggestion {
  background: rgba(255, 210, 63, 0.1);
  border: 1px solid rgba(255, 210, 63, 0.3);
  border-radius: 14px;
  padding: 14px 16px;
  margin-top: 20px;
  margin-bottom: 16px;
}
.suggestion-text { font-weight: 600; }
.suggestion-advice { color: var(--muted); font-size: 0.9rem; margin-top: 4px; min-height: 1.2em; }
.suggestion .btn { margin-top: 12px; }

/* --- EV-Untermenü --- */
.ev-toggle {
  display: block;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.ev-toggle:hover { filter: brightness(1.15); }
.ev-section {
  margin-bottom: 18px;
  padding: 14px;
  background: rgba(255, 210, 63, 0.06);
  border: 1px solid rgba(255, 210, 63, 0.28);
  border-radius: 14px;
}
.stats-box .ev-section h4 {
  margin: 0; color: var(--accent); font-size: 1rem;
  border: none; padding: 0;
}

/* --- Nim --- */
.ev-section > h4 { margin: 0 0 8px; color: var(--accent); font-size: 1rem; }
.nim-board { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 18px; }
.nim-heap { display: flex; align-items: center; gap: 12px; }
.nim-label { width: 1.4em; font-weight: 700; color: var(--muted); text-align: center; }
.nim-row { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-height: 34px; align-items: center; }
.nim-token {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; cursor: pointer; padding: 0;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.nim-token:not(:disabled):hover { transform: translateY(-3px) scale(1.08); }
.nim-token:disabled { cursor: default; }
.nim-token.take { background: linear-gradient(135deg, #ff6b6b, #c0392b); opacity: 0.9; transform: scale(0.9); }
.nim-empty { color: var(--muted); font-size: 0.85rem; font-style: italic; }
.nim-count { width: 1.6em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.nim-bin { width: auto; min-width: 220px; }
.nim-bin .bits { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 2px; }
.nim-bin tfoot td { border-top: 2px solid rgba(255, 255, 255, 0.25); padding-top: 8px; }
.nim-verdict { margin: 10px 0 0; }
.card-sub { color: var(--muted); font-size: 0.72rem; margin-top: 2px; }
.log-reason { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }

/* --- Farkle Strategie-Tafel --- */
.strat-card { margin: 14px 0; padding: 12px 14px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; }
.strat-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.strat-head > strong { color: var(--text); }
.strat-toggle { display: flex; gap: 6px; }
.strat-btn { background: transparent; border: 1px solid rgba(255, 255, 255, 0.2); color: var(--muted); border-radius: 8px; padding: 4px 12px; cursor: pointer; font-size: 0.8rem; }
.strat-btn.active { background: var(--accent); color: #2a1d00; border-color: var(--accent); font-weight: 600; }
.strat-legend { color: var(--muted); font-size: 0.82rem; margin: 6px 0; line-height: 1.45; }
.strat-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.strat-grid { border-collapse: collapse; width: 100%; font-size: 0.82rem; text-align: center; }
.strat-grid th, .strat-grid td { border: 1px solid rgba(255, 255, 255, 0.08); padding: 6px 8px; }
.strat-grid thead th { color: var(--muted); font-weight: 600; font-size: 0.74rem; white-space: nowrap; }
.strat-grid tbody th { color: var(--muted); white-space: nowrap; }
.strat-grid td.go { background: rgba(61, 220, 132, 0.18); color: #7ef0ad; font-weight: 700; }
.strat-grid td.stop { background: rgba(255, 75, 75, 0.16); color: #ff9b9b; font-weight: 700; }
.strat-grid td.risk { background: none; color: var(--muted); font-weight: 600; }
.strat-grid.detail td.go, .strat-grid.detail td.stop { font-weight: 600; }
.sw { display: inline-block; min-width: 1.3em; text-align: center; border-radius: 4px; font-weight: 700; padding: 0 2px; }
.sw.go { background: rgba(61, 220, 132, 0.25); color: #7ef0ad; }
.sw.stop { background: rgba(255, 75, 75, 0.22); color: #ff9b9b; }
.strat-rule { color: var(--muted); font-size: 0.82rem; margin: 12px 0 4px; }
.strat-thresh { margin-top: 4px; }
.strat-thresh td, .strat-thresh th { font-size: 0.85rem; }
.strat-note { color: var(--muted); font-size: 0.8rem; line-height: 1.5; margin-top: 8px; }
.strat-princ th, .strat-princ td { text-align: left; vertical-align: top; }
.strat-princ td.sit { color: var(--text); font-weight: 600; }
.strat-princ tfoot td { text-align: right; color: var(--text); }
.strat-eval { margin: 6px 0; padding-left: 20px; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }

/* --- Cabo --- */
.cabo-status { color: var(--muted); font-size: 0.95rem; margin: 4px 0 12px; min-height: 1.4em; line-height: 1.4; }
.cabo-scores { flex-wrap: wrap; }
.cabo-scores .player-card { flex: 1 1 90px; min-width: 84px; padding: 10px 12px; }
.cabo-scores .total { font-size: 1.6rem; }
.player-card.caboed { border-color: var(--accent); }
.cabo-center { display: flex; gap: 16px; justify-content: center; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; }
.cabo-pile { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; padding: 0; }
.cabo-pile.stock { cursor: pointer; }
.cabo-pile.discard { cursor: pointer; }
.pile-label { font-size: 0.72rem; color: var(--muted); }
.pile-count { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.cabo-face { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 74px; height: 100px; border-radius: 12px; background: var(--die-face); color: #15152a; font-weight: 800; font-size: 2rem; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35); }
.cabo-face small { font-size: 0.9rem; font-weight: 700; opacity: 0.65; }
.cabo-face.empty { color: #888; background: rgba(255, 255, 255, 0.08); box-shadow: none; }
.cabo-face.cv-low { color: #1a8f53; } .cabo-face.cv-high { color: #c0392b; }
.cabo-pile .pw { color: var(--accent); font-size: 0.7rem; margin-top: 2px; }

.cabo-table { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.cabo-hand { padding: 10px 12px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(255, 255, 255, 0.02); }
.cabo-hand.active { border-color: var(--accent); background: rgba(255, 210, 63, 0.05); }
.cabo-hand-name { font-size: 0.9rem; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.cabo-cards { display: flex; gap: 10px; }
.cabo-card { width: 72px; height: 98px; border-radius: 12px; border: 3px solid transparent; background: var(--die-face); color: #15152a; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: default; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); transition: transform 0.12s ease; padding: 0; }
.cabo-card .cv { font-size: 2.4rem; line-height: 1; }
.cabo-card small { font-size: 0.82rem; font-weight: 700; opacity: 0.65; margin-top: 2px; }
.cabo-card.back { background: repeating-linear-gradient(45deg, #3a3f6b, #3a3f6b 6px, #2e335a 6px, #2e335a 12px); color: rgba(255, 255, 255, 0.5); border-color: rgba(255, 255, 255, 0.1); }
.cabo-card.clickable { cursor: pointer; border-color: var(--accent); }
.cabo-card.clickable:hover { transform: translateY(-4px); }
.cabo-card.selswap { border-color: #ff6b6b; transform: translateY(-4px); }
.cabo-card.cv-low { color: #1a8f53; } .cabo-card.cv-high { color: #c0392b; }
.cabo-hand-total { margin-top: 8px; font-size: 0.85rem; color: var(--text); font-weight: 600; }

.player-config .pc-line { display: flex; gap: 8px; }
.player-config .pc-line select { flex: 1; min-width: 0; }
.player-config .pc-line input { width: 38%; }
.msg-sub { color: var(--muted); font-size: 0.85rem; }

/* --- Pig --- */
.pig-board { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 12px 0 14px; }
.pig-die-wrap { flex: 0 0 auto; }
.pig-die { width: 92px; }
.pig-die.empty { opacity: 0.3; }
.pig-die.bust { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 0 0 3px #ff5555, 0 6px 12px rgba(0, 0, 0, 0.35); }
.pig-die.bust .pip::after { background: #c0392b; }
.pig-turn { color: var(--muted); font-size: 0.95rem; text-align: center; line-height: 1.3; }
.pig-turn strong { display: block; font-size: 2.4rem; color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 430px) {
  .cabo-card { width: 60px; height: 82px; border-width: 2px; }
  .cabo-card .cv { font-size: 2rem; }
  .cabo-card small { font-size: 0.72rem; }
  .cabo-cards { gap: 7px; }
  .cabo-hand { padding: 8px 9px; }
  .cabo-face { width: 64px; height: 88px; font-size: 1.7rem; }
}
.ev-panel {
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  padding: 12px;
  overflow-x: auto;
}
.ev-hint { color: var(--muted); font-size: 0.8rem; margin: 0 0 10px; }
.ev-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.ev-table th, .ev-table td { padding: 7px 8px; text-align: center; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.ev-table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.ev-sub { display: block; color: var(--muted); font-size: 0.68rem; margin-top: 2px; white-space: nowrap; }
.ev-row { cursor: pointer; transition: background 0.12s ease; }
.ev-row:hover { background: rgba(255, 255, 255, 0.07); }
.ev-row.best { background: rgba(255, 210, 63, 0.14); }
.ev-row.best td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.mini-die {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin: 0 2px;
  background: var(--die-face); color: var(--die-pip);
  border-radius: 6px; font-weight: 700; font-size: 0.8rem;
}
.rec { padding: 2px 8px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; }
.rec.roll { background: rgba(61, 220, 132, 0.2); color: var(--green); }
.rec.bank { background: rgba(255, 210, 63, 0.2); color: var(--accent); }

/* --- Messages --- */
.message {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 16px;
  border-radius: 14px;
  margin-bottom: 16px;
}
.message.farkle { background: rgba(255, 75, 75, 0.18); color: #ff9b9b; animation: shake 0.5s; }
.message.win { background: rgba(61, 220, 132, 0.18); color: var(--green); animation: pop 0.5s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
@keyframes pop {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* --- Actions --- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 auto; }

/* --- Statistik-Box --- */
.stats-box {
  margin-top: 18px;
  background: var(--card-solid);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px;
}
/* Boxen, die breiter sein dürfen als die schmale Spielspalte */
.wide-box {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: min(1040px, calc(100vw - 24px));
}
.chart-row { display: flex; gap: 18px; }
.chart-col { flex: 1; min-width: 0; }
@media (max-width: 640px) { .chart-row { flex-direction: column; gap: 4px; } }

.stats-box h3 { margin: 0 0 12px; font-size: 1.1rem; }
.ev-breakdown {
  color: var(--muted); font-size: 0.86rem; line-height: 1.55;
  margin: 10px 0 0; padding: 10px 12px;
  background: rgba(0, 0, 0, 0.18); border-radius: 10px;
}
.ev-breakdown strong { color: var(--text); }
.stats-box h4 { margin: 16px 0 8px; font-size: 0.95rem; color: var(--muted); }
.chart-title { color: var(--muted); font-size: 0.82rem; font-weight: 600; margin: 10px 0 2px; }
.chart-empty { color: var(--muted); font-size: 0.9rem; margin: 6px 0; }
.score-chart .chart-svg { width: 100%; height: 150px; display: block; }
.chart-svg .grid { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; }
.chart-svg .axis { fill: var(--muted); font-size: 8px; }
.legend { display: flex; align-items: center; gap: 14px; margin-top: 6px; font-size: 0.82rem; color: var(--muted); }
.legend .leg { display: inline-flex; align-items: center; gap: 5px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .axis-x { margin-left: auto; }

.kpi { border-collapse: collapse; width: 100%; margin-top: 12px; font-size: 0.88rem; }
.kpi th, .kpi td { padding: 6px 10px; text-align: right; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.kpi thead th { color: var(--muted); font-weight: 600; }
.kpi tbody th { text-align: left; color: var(--muted); font-weight: 500; }
.kpi td { font-weight: 600; }

/* --- Dame --- */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mode-grid .btn { padding: 22px 12px; font-size: 1.05rem; line-height: 1.4; }
.mode-grid .btn small { font-weight: 400; opacity: 0.8; font-size: 0.8rem; }

.dame-status {
  text-align: center; margin: 4px 0 12px; font-size: 1.05rem; min-height: 1.4em;
}
.dame-status .must { color: var(--accent-2); font-weight: 700; }
.dame-status .cnt { color: var(--muted); margin-left: 8px; font-size: 0.9rem; }
.dame-status .ok { color: var(--green); font-weight: 700; }
.dame-status .bad { color: #ff8585; font-weight: 700; }

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 100%; max-width: 440px; margin: 0 auto;
  aspect-ratio: 1 / 1;
  border: 4px solid #2a1c10; border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow);
}
.square { position: relative; display: flex; align-items: center; justify-content: center; }
.square.light { background: #e9d3b0; }
.square.dark { background: #8a5a3b; cursor: pointer; }
.square.sel { box-shadow: inset 0 0 0 3px var(--accent); }
.square.lastmove { background: #a8773f; }
.square.hintsq { box-shadow: inset 0 0 0 3px var(--green); }
.square.target::after {
  content: ''; width: 30%; height: 30%; border-radius: 50%;
  background: rgba(61, 220, 132, 0.7);
}
.square.target-cap { box-shadow: inset 0 0 0 4px rgba(255, 80, 80, 0.85); }

.piece {
  width: 76%; height: 76%; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.45), inset 0 -3px 4px rgba(0, 0, 0, 0.25);
}
.piece.white { background: radial-gradient(circle at 35% 30%, #ffffff, #d2d2d2); color: #7a5a2a; border: 2px solid #2a2a3a; }
.piece.black { background: radial-gradient(circle at 35% 30%, #4a4f5c, #14161c); color: var(--accent); border: 2px solid #e9d3b0; }
.piece.king { box-shadow: 0 3px 5px rgba(0,0,0,0.45), inset 0 -3px 4px rgba(0,0,0,0.25), 0 0 0 3px var(--accent); }

/* Puzzle-Liste */
.puzzle-list .muted { color: var(--muted); font-size: 0.9rem; }
.puzzle-list .grp { margin: 16px 0 8px; font-size: 1rem; }
.puzzle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.puzzle-card {
  position: relative; text-align: left; cursor: pointer;
  background: var(--card-solid); border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text); border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px; transition: transform 0.12s ease, border-color 0.12s ease;
}
.puzzle-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.puzzle-card.solved { border-color: var(--green); }
.puzzle-card .pz-num { color: var(--muted); font-size: 0.78rem; }
.puzzle-card .pz-title { font-weight: 600; }
.puzzle-card .pz-check { position: absolute; top: 10px; right: 12px; color: var(--green); font-weight: 700; }
.puzzle-info h3 { margin: 0 0 4px; }
.puzzle-info .diff { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.puzzle-info p { color: var(--muted); font-size: 0.9rem; margin: 0 0 10px; }

/* --- Computer-Log --- */
.ailog-box {
  margin-top: 18px;
  background: var(--card-solid);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px;
}
.ailog-box h3 { margin: 0 0 10px; font-size: 1.1rem; }
.ailog { max-height: 220px; overflow-y: auto; font-size: 0.86rem; line-height: 1.45; }
.ailog-entry { padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); color: var(--muted); }
.ailog-entry:last-child { border-bottom: none; }
.ailog-who { color: var(--accent); font-weight: 600; margin-right: 4px; }

/* --- Regel-Box (am Seitenende) --- */
.rules-box {
  margin-top: 22px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 4px 18px;
}
.rules-box summary {
  cursor: pointer;
  font-weight: 600;
  padding: 12px 0;
  list-style: none;
}
.rules-box summary::-webkit-details-marker { display: none; }
.rules-box[open] summary { border-bottom: 1px solid rgba(255, 255, 255, 0.08); margin-bottom: 10px; }
.rules-content { color: var(--muted); font-size: 0.92rem; line-height: 1.5; padding-bottom: 12px; }
.rules-content strong { color: var(--text); }
.rules-content ul { margin: 6px 0; padding-left: 20px; }
.rules-content h4 {
  color: var(--accent); font-size: 1rem; margin: 18px 0 6px;
  padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Footer --- */
.footer { text-align: center; margin-top: 22px; }
.footer a { color: var(--muted); font-size: 0.85rem; }
.build-info { color: var(--muted); font-size: 0.75rem; opacity: 0.7; margin-top: 6px; }
.credit { color: var(--muted); font-size: 0.8rem; margin-top: 10px; }

/* --- Passwort-Schutz (protect.js) --- */
html.protect-locked, html.protect-locked body { overflow: hidden; }
.protect-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(10, 12, 18, 0.96);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.protect-card {
  background: var(--card, #1b1f2a); border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px; padding: 24px; max-width: 360px; width: 100%; text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.protect-card h2 { margin: 0 0 6px; }
.protect-card p { color: var(--muted, #9aa3b2); margin: 0 0 12px; }
.protect-input {
  width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: 1.1rem;
  border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.25); color: var(--text, #eef); margin-bottom: 10px; text-align: center;
}
.protect-card .btn { width: 100%; }
.protect-msg { color: #ff8a8a; min-height: 1.2em; margin: 10px 0 0; font-size: 0.9rem; }

/* --- Ergebnisse abschicken (results.js) --- */
.submit-box {
  background: var(--card, #1b1f2a); border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 4px solid var(--accent, #ffd23f); border-radius: 14px;
  padding: 16px 18px; margin: 22px 0 8px;
}
.submit-box h3 { margin: 0 0 8px; }
.submit-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.submit-chip {
  background: rgba(255, 255, 255, 0.07); border-radius: 999px; padding: 3px 10px;
  font-size: 0.82rem; color: var(--text, #eef);
}
.submit-hint { color: var(--muted, #9aa3b2); font-size: 0.86rem; margin: 0 0 10px; }
.submit-row { display: flex; flex-wrap: wrap; gap: 8px; }
.submit-name {
  flex: 1 1 180px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.25);
  color: var(--text, #eef); font-size: 1rem;
}
.submit-done { min-height: 1.2em; margin: 10px 0 0; font-weight: 600; }
.submit-done.ok { color: #5bd68a; }
.submit-done.err { color: #ff8a8a; }

/* --- Admin-Bereich --- */
.admin-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.admin-tab {
  background: var(--card, #1b1f2a); border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px; padding: 8px 14px; cursor: pointer; color: var(--text, #eef);
}
.admin-tab.active { border-color: var(--accent, #ffd23f); color: var(--accent, #ffd23f); }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.admin-table th, .admin-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); font-size: 0.92rem;
}
.admin-table th { color: var(--muted, #9aa3b2); font-weight: 600; }
.admin-table tr.clickable { cursor: pointer; }
.admin-table tr.clickable:hover { background: rgba(255, 255, 255, 0.04); }
.admin-bar { background: rgba(255, 255, 255, 0.08); border-radius: 6px; height: 14px; overflow: hidden; min-width: 80px; display: inline-block; width: 120px; vertical-align: middle; }
.admin-bar > span { display: block; height: 100%; background: var(--accent, #ffd23f); }
.admin-empty { color: var(--muted, #9aa3b2); margin: 16px 0; }
.admin-detail { background: var(--card, #1b1f2a); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px; padding: 14px 16px; margin-top: 12px; }
.admin-actions { margin-top: 16px; }
.mat-form { display: grid; gap: 10px; max-width: 480px; }
.mat-form label { font-size: 0.88rem; color: var(--muted, #9aa3b2); }
.mat-form input, .mat-form select {
  width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.25); color: var(--text, #eef);
}

/* --- PDF-Materialien (Anzeige) --- */
.materials { margin-top: 18px; }
.materials-hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 10px; }
.materials-list { display: grid; gap: 10px; }
.materials-item {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
  background: var(--card-solid); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
}
.materials-item:hover { border-color: var(--accent); }
.materials-icon { font-size: 1.6rem; }
.materials-text { display: flex; flex-direction: column; flex: 1; }
.materials-title { font-weight: 700; }
.materials-meta { color: var(--muted); font-size: 0.82rem; }
.materials-go { color: var(--accent); font-weight: 600; font-size: 0.9rem; }

/* --- Stil-Auswahl (Theme-Switcher) --- */
.theme-switch {
  max-width: 760px; margin: 8px auto 26px; padding: 10px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: center;
  color: var(--muted); font-size: 0.85rem;
}
.theme-btn {
  cursor: pointer; border-radius: 999px; padding: 6px 12px; font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.18); background: var(--card-solid); color: var(--text);
}
.theme-btn.active { border-color: var(--accent); color: var(--accent); }

/* ===== Theme: Clean Girl (hell, cremig) ===== */
html.theme-clean {
  --bg-1: #e7ddcd; --bg-2: #f6f0e6;
  --accent: #b08968; --accent-2: #c8a48a;
  --green: #7d9b76; --green-dark: #5f7d59;
  --card: #fffdf9; --card-solid: #fffaf2;
  --text: #4a423a; --muted: #9a8f80;
  --shadow: 0 10px 28px rgba(120, 100, 70, 0.14);
}
/* ===== Theme: Pastell (rosé/lavendel) ===== */
html.theme-pastel {
  --bg-1: #ecdff0; --bg-2: #fbeef4;
  --accent: #d2789f; --accent-2: #b29ce0;
  --green: #6fb3a2; --green-dark: #4f9183;
  --card: #fffafd; --card-solid: #fff4fa;
  --text: #5b3f55; --muted: #a98fa6;
  --shadow: 0 10px 28px rgba(180, 120, 160, 0.16);
}
/* ===== Theme: Ozean (hell, blau) ===== */
html.theme-ocean {
  --bg-1: #d3e8f2; --bg-2: #eef7fb;
  --accent: #2e8bbf; --accent-2: #54b0c8;
  --green: #2fa39a; --green-dark: #1f7d76;
  --card: #ffffff; --card-solid: #f2fafd;
  --text: #21495a; --muted: #6f93a0;
  --shadow: 0 10px 28px rgba(40, 90, 120, 0.14);
}
/* ===== Theme: Salbei (hell, grün) ===== */
html.theme-mint {
  --bg-1: #dcebe0; --bg-2: #f0f7f1;
  --accent: #3f9d6b; --accent-2: #69b98c;
  --green: #3f9d6b; --green-dark: #2f7d52;
  --card: #ffffff; --card-solid: #f3faf5;
  --text: #2f4a3a; --muted: #7d9587;
  --shadow: 0 10px 28px rgba(60, 120, 90, 0.14);
}
/* ===== Theme: Sepia (hell, Papier) ===== */
html.theme-sepia {
  --bg-1: #e7dcc4; --bg-2: #f5edda;
  --accent: #a87b46; --accent-2: #c2a06a;
  --green: #7d8a4f; --green-dark: #5f6b3a;
  --card: #fffaf0; --card-solid: #fbf3e2;
  --text: #4d4030; --muted: #998a72;
  --shadow: 0 10px 28px rgba(120, 95, 55, 0.14);
}
/* ===== Theme: Pfirsich (hell, warm) ===== */
html.theme-peach {
  --bg-1: #f6ddd0; --bg-2: #fdeee6;
  --accent: #e07a55; --accent-2: #f0a17e;
  --green: #6fae8c; --green-dark: #4f8e6c;
  --card: #fffaf7; --card-solid: #fff2ec;
  --text: #5b3a2c; --muted: #ab8576;
  --shadow: 0 10px 28px rgba(190, 110, 80, 0.16);
}
/* ===== Theme: Mitternacht (sehr dunkel) ===== */
html.theme-midnight {
  --bg-1: #090c12; --bg-2: #141a26;
  --accent: #6ea8fe; --accent-2: #9b8cff;
  --green: #3ddc84; --green-dark: #1f9c5c;
  --card: rgba(255, 255, 255, 0.05); --card-solid: #161c28;
  --text: #e6ebf5; --muted: #8b96ad;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
/* ===== Theme: Beere (dunkel, lila) ===== */
html.theme-grape {
  --bg-1: #190f2e; --bg-2: #2c1a4d;
  --accent: #c79bff; --accent-2: #ff9bd2;
  --green: #5fe0b0; --green-dark: #2f9c78;
  --card: rgba(255, 255, 255, 0.06); --card-solid: #241640;
  --text: #f0e9ff; --muted: #b3a4d0;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
/* ===== Theme: Wald (dunkel, grün) ===== */
html.theme-forest {
  --bg-1: #0c1a12; --bg-2: #16301f;
  --accent: #7fd49b; --accent-2: #c9d97f;
  --green: #5fc98a; --green-dark: #2f9c5c;
  --card: rgba(255, 255, 255, 0.05); --card-solid: #15281c;
  --text: #e6f2e9; --muted: #93b3a0;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* jedes aktive Theme färbt den Seitenhintergrund (auch auf Übungsseiten) */
html.theme-on body, html.theme-on body.eng {
  background: radial-gradient(circle at 80% 0%, var(--bg-2), var(--bg-1) 60%);
}
/* gemeinsame Anpassungen für die hellen Themes */
html.theme-light { color-scheme: light; }
html.theme-light .pick-card, html.theme-light .rule-section, html.theme-light .exercise-intro,
html.theme-light .scorebar, html.theme-light .writebox, html.theme-light .role-card,
html.theme-light .submit-box, html.theme-light .tippbox, html.theme-light .cloze-card,
html.theme-light .kw-item, html.theme-light .ef-card, html.theme-light .admin-detail,
html.theme-light .materials-item, html.theme-light .hear-row, html.theme-light .life-wrap,
html.theme-light .protect-card, html.theme-light .theme-btn, html.theme-light .mhd-fig svg,
html.theme-light .staende-svg {
  background: var(--card-solid); border-color: rgba(0, 0, 0, 0.12);
}
html.theme-light input, html.theme-light textarea, html.theme-light select,
html.theme-light .type-input, html.theme-light .cloze-input, html.theme-light .ef-fix,
html.theme-light .submit-name, html.theme-light .protect-input, html.theme-light .mat-form input,
html.theme-light .mat-form select {
  background: #ffffff; color: var(--text); border-color: rgba(0, 0, 0, 0.2);
}
html.theme-light .admin-table th, html.theme-light .admin-table td { border-bottom-color: rgba(0, 0, 0, 0.1); }

/* --- Admin: Leistungs-Ampel (rot < 50 %, gelb < 70 %, grün ≥ 70 %) --- */
.grade {
  display: inline-block; min-width: 3.4em; text-align: center;
  padding: 2px 9px; border-radius: 999px; font-weight: 700; font-size: 0.85rem;
}
.grade.g-red    { background: rgba(229, 72, 77, 0.18);  color: #ff9396; }
.grade.g-yellow { background: rgba(240, 179, 35, 0.20); color: #ffce5a; }
.grade.g-green  { background: rgba(63, 185, 80, 0.18);  color: #74d488; }

/* --- Admin: Sichtbarkeit der Übungen --- */
.vis-group { margin: 14px 0; }
.vis-group > h3 { margin: 0 0 6px; font-size: 1rem; }
.vis-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03); margin-bottom: 6px;
}
.vis-row input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; cursor: pointer; }
.vis-row label { cursor: pointer; flex: 1; }
.vis-row.is-hidden { opacity: 0.55; }
.vis-row .vis-state { font-size: 0.8rem; color: var(--muted); }
.vis-row.is-section label { font-weight: 600; }
.vis-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
html.theme-light .vis-row { border-color: rgba(0, 0, 0, 0.1); background: rgba(0, 0, 0, 0.02); }

/* --- Freitext-Prüfung (writecheck) --- */
.wc-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.wc-feedback { margin-top: 12px; }
.wc-feedback:empty { display: none; }
.wc-head { font-weight: 700; margin: 0 0 6px; }
.wc-head.good { color: #74d488; }
.wc-head.partial { color: #ffce5a; }
.wc-list { list-style: none; padding-left: 0; margin: 0; line-height: 1.7; }
.wc-list .wc-ok { color: #74d488; }
.wc-list .wc-no { color: #ff9396; }
.wc-sol { margin-top: 10px; }
.wc-sol summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.wc-sol p { color: var(--muted); line-height: 1.55; margin: 6px 0 0; }
.wc-ai {
  border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 0 12px 12px 0;
  background: rgba(255, 255, 255, 0.04);
}
.wc-ai-head { font-weight: 700; margin: 0 0 6px; }
.wc-ai-body { line-height: 1.6; color: var(--text); }
html.theme-light .wc-ai { background: rgba(0, 0, 0, 0.03); }

/* --- Lösungswort-Buchstaben (Present Perfect / California) --- */
.sol-letter { margin: -6px 0 18px; padding: 10px 14px; border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.03);
  font-weight: 600; }
.sol-letter.locked { color: var(--muted); }
.sol-letter.done { border-style: solid; border-color: var(--accent);
  background: rgba(124, 92, 255, 0.10); color: var(--text); }
.sol-letter .sol-big { font-size: 1.6rem; font-weight: 800; letter-spacing: 3px; color: var(--accent); }
html.theme-light .sol-letter { border-color: rgba(0, 0, 0, 0.15); background: rgba(0, 0, 0, 0.02); }

/* --- US-Karten-Bonus (Present Perfect) --- */
.map-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; }
.map-score { color: var(--muted); font-weight: 600; }
.us-outline { fill: rgba(255, 255, 255, 0.05); stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 3; stroke-linejoin: round; pointer-events: none; }
html.theme-light .us-outline { fill: rgba(0, 0, 0, 0.04); stroke: rgba(0, 0, 0, 0.55); }
.map-abbrs { display: none; }
.map-abbrs.show { display: block; }
.map-tiprow { margin: 8px 0 2px; }

/* --- Buchstaben-Notizfeld (Present Perfect) --- */
.notes-box .notes-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.notes-grid label { display: flex; flex-direction: column; align-items: center;
  font-size: 0.72rem; color: var(--muted); gap: 3px; }
.notes-grid input { width: 38px; height: 44px; text-align: center; font-size: 1.3rem;
  font-weight: 800; text-transform: uppercase; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.25); color: var(--text); }
.notes-grid input:focus { outline: none; border-color: var(--accent); }
html.theme-light .notes-grid input { background: #ffffff; border-color: rgba(0, 0, 0, 0.2); }
.map-abbr { font-size: 15px; font-weight: 800; fill: rgba(255, 255, 255, 0.55);
  text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.map-placed { font-size: 12px; font-weight: 700; fill: var(--text);
  text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
html.theme-light .map-abbr { fill: rgba(0, 0, 0, 0.45); }
