:root {
  --bg: #161d27;
  --panel: #1f2937;
  --panel2: #273244;
  --text: #eef0f3;
  --muted: #9aa8bc;
  --accent: #81b64c;      /* chess.com-Grün */
  --accent-dark: #5d8f33;
  --accent2: #f7b32b;     /* freundliches Amber */
  --info: #4aa8ff;
  --sq-light: #ecd9b9;
  --sq-dark: #b08662;
  --danger: #e05d5d;
  --radius: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: radial-gradient(1100px 500px at 75% -80px, #21304a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a.inline-link { color: var(--accent2); text-decoration: underline; text-underline-offset: 3px; }
a.inline-link:hover { color: #ffd069; }

/* ---------- Header & Navigation ---------- */
header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 3px solid var(--accent);
  flex-wrap: wrap;
}
.logo { font-size: 1.25rem; font-weight: 800; cursor: pointer; color: var(--text); display: flex; align-items: center; gap: 8px; }
.logo-icon { width: 30px; height: 30px; border-radius: 6px; }
.logo-posi { color: #14b8a6; }
.logo .beta { font-size: .65rem; color: var(--accent2); vertical-align: super; }
#main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.nav-btn:hover { color: var(--text); background: var(--panel2); }
.nav-btn.active { color: #fff; background: var(--accent-dark); }
.header-stats { margin-left: auto; }
.header-stats span { margin-left: 14px; font-weight: 700; }

/* ---------- Seiten & Screens ---------- */
main { flex: 1; display: flex; justify-content: center; padding: 26px 16px; }
.page { display: none; max-width: 860px; width: 100%; }
.page.active { display: block; }
.screen { display: none; text-align: center; max-width: 720px; margin: 0 auto; }
.screen.active { display: block; }
.content-page { max-width: 760px; margin: 0 auto; }
.content-page h1 { margin-bottom: 10px; }
.lead { color: var(--muted); margin-bottom: 20px; font-size: 1.05rem; }

h1 { font-size: 1.9rem; margin-bottom: 12px; }
h1 small { color: var(--accent); font-size: 1.2rem; }
h2 { margin-bottom: 14px; }
h3 { margin: 16px 0 8px; }
h3.left { text-align: left; }

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  text-align: left;
}
.card.narrow { max-width: 420px; }
.card ol, .card ul { margin: 8px 0 0 20px; line-height: 1.7; }
.card p { line-height: 1.65; color: #d5dbe4; }
.card h3 { margin-top: 0; }

.science-note {
  background: var(--panel);
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  margin: 14px 0 18px;
  text-align: left;
  color: var(--muted);
  font-size: .93rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  line-height: 1.6;
}
.science-note.small { font-size: .86rem; margin: 12px 0; }
.science-note a { color: var(--accent2); }

.daily-line { color: var(--accent2); font-weight: 600; margin-bottom: 10px; min-height: 1.2em; }

/* ---------- Levelraster ---------- */
#level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.level-btn {
  padding: 10px 4px;
  background: var(--panel);
  border: 2px solid var(--panel2);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: transform .1s, border-color .15s;
}
.level-btn:hover:not(.locked) { transform: translateY(-2px); }
.level-btn small { display: block; color: var(--muted); font-size: .7rem; margin-top: 2px; font-weight: 400; }
.level-btn.selected { border-color: var(--accent); background: #2b3a24; }
.level-btn.locked { opacity: .35; cursor: not-allowed; }

.mode-row { margin: 8px 0 16px; color: var(--muted); font-size: .9rem; text-align: left; }

/* ---------- Buttons ---------- */
button.primary {
  background: var(--accent);
  color: #14210b;
  font-weight: 800;
  border: none;
  border-bottom: 4px solid var(--accent-dark);
  padding: 12px 30px;
  font-size: 1rem;
  border-radius: 14px;
  cursor: pointer;
  margin: 6px 4px;
  transition: filter .1s, transform .05s;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.primary:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
button.primary:disabled { opacity: .45; cursor: not-allowed; }
button.primary.big { font-size: 1.12rem; padding: 14px 38px; }
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 2px solid var(--panel2);
  padding: 10px 20px;
  border-radius: 14px;
  cursor: pointer;
  margin: 6px 4px;
  font-weight: 600;
}
button.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
button.ghost.small { padding: 7px 14px; font-size: .85rem; }
button.ghost.small.active { border-color: var(--danger); color: var(--danger); }

/* ---------- Timer ---------- */
.timer-bar {
  height: 12px;
  background: var(--panel2);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 14px;
}
#timer-fill, #timer-fill-recall {
  height: 100%;
  width: 100%;
  background: var(--accent2);
  transition: width .1s linear;
}
#timer-fill-recall { background: var(--danger); }

/* ---------- Brett ---------- */
.board-wrap { position: relative; display: inline-block; max-width: 100%; }
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(88vw, 460px);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 6px solid #52412d;
  border-radius: 10px;
  overflow: hidden;
  user-select: none;
  box-shadow: 0 14px 34px #000a, 0 0 0 1px #6b5638 inset;
}
.sq {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(20px, 4.8vw, 36px);
  line-height: 0;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
/* SVG-Figuren: gestochen scharf in jeder Größe */
.pc-img {
  width: 88%;
  height: 88%;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 2px 2px #0007);
}
.pc-img.ghost-pc { opacity: .38; filter: none; }
.sq.correct::after, .sq.wrong::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.sq.correct::after { box-shadow: inset 0 0 0 3px #52b788; }
.sq.wrong::after { box-shadow: inset 0 0 0 3px var(--danger); }
.sq .ghost-pc { opacity: .38; }
.sq.drag-over { outline: 3px solid var(--accent2); outline-offset: -3px; }

/* ---------- Figuren-Picker (Klick aufs Feld) ---------- */
.picker {
  position: absolute;
  z-index: 20;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 8px 24px #000a;
  display: grid;
  grid-template-columns: repeat(6, 44px);
  gap: 4px;
}
.picker button {
  width: 44px; height: 44px;
  font-size: 28px;
  background: var(--panel2);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 0;
}
.picker button:hover { background: var(--accent-dark); }
.picker button.pick-remove { font-size: 18px; grid-column: span 6; width: auto; height: 34px; color: var(--danger); }
.picker button .pc-img { width: 82%; height: 82%; }

.hint { color: var(--muted); margin-top: 10px; font-size: .88rem; line-height: 1.5; }

/* ---------- Recall-Layout: Palette KLEBT neben dem Brett ---------- */
.recall-layout {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: flex-start;
}
.palette-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: sticky;
  top: 10px;
}
.palette { display: grid; grid-template-columns: repeat(2, 50px); gap: 5px; margin-bottom: 10px; }
.pal-btn {
  width: 50px; height: 50px;
  font-size: 32px;
  background: var(--panel);
  border: 2px solid var(--panel2);
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 0;
}
.pal-btn.selected { border-color: var(--accent2); background: #3a3423; }
.pal-btn .pc-img { width: 80%; height: 80%; }

/* Mobil: Palette bleibt im Seitenfluss und haftet beim Scrollen unten. */
@media (max-width: 700px) {
  .recall-layout { flex-direction: column; align-items: center; }
  .palette-wrap {
    position: sticky;
    bottom: 0;
    width: 100%;
    background: var(--panel);
    border-top: 3px solid var(--accent);
    padding: 8px 6px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    z-index: 30;
  }
  .palette { grid-template-columns: repeat(12, 34px); gap: 3px; margin: 0; }
  .pal-btn { width: 34px; height: 34px; font-size: 22px; }
  .palette-wrap .hint { display: none; }
  #screen-recall { padding-bottom: 24px; }
}

/* ---------- Ergebnis & Stats ---------- */
.result-grid { display: flex; gap: 12px; justify-content: center; margin: 16px 0; flex-wrap: wrap; }
.stat-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px 20px;
  min-width: 116px;
  border-bottom: 4px solid var(--accent-dark);
}
.stat-num { font-size: 1.7rem; font-weight: 800; color: var(--accent); }
.stat-label { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.legend { color: var(--muted); font-size: .85rem; margin: 10px 0 14px; }

#history { text-align: left; max-width: 560px; margin: 0 auto 14px; }
.hist-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel);
  padding: 9px 14px;
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: .88rem;
  flex-wrap: wrap;
}
.hist-row .acc { font-weight: 800; color: var(--accent); }

/* Performance-Balken */
.perf-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: .85rem; }
.perf-row .pl { width: 64px; color: var(--muted); text-align: right; }
.perf-bar { flex: 1; height: 18px; background: var(--panel2); border-radius: 9px; overflow: hidden; }
.perf-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent-dark), var(--accent)); border-radius: 9px; }
.perf-row .pv { width: 48px; font-weight: 700; }

/* ---------- Freies Training ---------- */
.free-panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-top: 20px;
  text-align: left;
}
.free-panel h3 { margin-top: 0; }
.free-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; }
.free-row label { color: var(--muted); font-size: .85rem; display: flex; flex-direction: column; gap: 4px; }
.free-row input, .form-label input {
  width: 130px;
  padding: 9px;
  background: var(--bg);
  border: 2px solid var(--panel2);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
}
.form-label { display: block; color: var(--muted); font-size: .88rem; margin-bottom: 12px; }
.form-label input { width: 100%; margin-top: 4px; }

/* ---------- Preise ---------- */
.pricing-grid { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.price-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  width: 230px;
  text-align: center;
  position: relative;
  border: 2px solid var(--panel2);
}
.price-card.featured { border-color: var(--accent2); transform: scale(1.04); }
.price-card .badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--accent2); color: #201a05; font-weight: 800; font-size: .75rem;
  padding: 3px 12px; border-radius: 10px;
}
.price-card .price { font-size: 2rem; font-weight: 800; color: var(--accent); margin: 8px 0 2px; }
.price-card .price span { font-size: .9rem; color: var(--muted); font-weight: 400; }
.price-alt { color: var(--accent2); font-size: .85rem; margin-bottom: 6px; }
.price-card ul { list-style: none; margin: 12px 0; text-align: left; }
.price-card li { padding: 5px 0; border-bottom: 1px solid var(--panel2); font-size: .9rem; }
.price-card li::before { content: "✓ "; color: var(--accent); font-weight: 800; }

/* ---------- Konto-Tabs ---------- */
.acct-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn {
  background: var(--panel);
  border: 2px solid var(--panel2);
  color: var(--muted);
  padding: 9px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
}
.tab-btn.active { color: #fff; border-color: var(--accent); background: #2b3a24; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

footer {
  text-align: center;
  color: #6b7789;
  font-size: .8rem;
  padding: 14px;
  border-top: 1px solid var(--panel2);
}
footer a { margin: 0 4px; }

/* ---------- Modus-Karten (Tages-Challenge, Wissenschafts-Check, Schwächen) ---------- */
.mode-cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 18px 0; }
.mode-card {
  background: var(--panel);
  border: 2px solid var(--panel2);
  border-radius: var(--radius);
  padding: 16px 14px 12px;
  width: 218px;
  text-align: center;
  transition: transform .12s, border-color .15s;
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.mc-icon { font-size: 2rem; }
.mode-card h3 { margin: 6px 0 4px; font-size: 1.02rem; }
.mode-card p { color: var(--muted); font-size: .82rem; line-height: 1.45; min-height: 3.4em; }
.mode-card .primary { padding: 9px 18px; font-size: .9rem; }
.mc-status { color: var(--accent2); font-size: .8rem; min-height: 1.1em; margin-top: 4px; font-weight: 600; }

/* ---------- Brett-Koordinaten ---------- */
.sq .coord {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  opacity: .75;
}
.sq .coord.file { right: 3px; bottom: 2px; }
.sq .coord.rank { left: 3px; top: 2px; }
.sq.light .coord { color: var(--sq-dark); }
.sq.dark .coord { color: var(--sq-light); }

/* ---------- 3-2-1 Countdown ---------- */
.countdown-overlay {
  position: absolute;
  inset: 0;
  background: #161d27ee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5.5rem;
  font-weight: 800;
  color: var(--accent2);
  border-radius: 8px;
  z-index: 15;
}

/* ---------- Wissenschafts-Check ---------- */
.sci-bars { max-width: 520px; margin: 18px auto; }
.sci-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sci-label { width: 140px; text-align: right; color: var(--muted); font-size: .9rem; }
.sci-bar { flex: 1; height: 26px; background: var(--panel2); border-radius: 13px; overflow: hidden; }
.sci-bar > div { height: 100%; border-radius: 13px; width: 0; transition: width .8s ease; }
.sci-bar .real { background: linear-gradient(90deg, var(--accent-dark), var(--accent)); }
.sci-bar .random { background: linear-gradient(90deg, #7a6a35, var(--accent2)); }
.sci-val { width: 52px; font-weight: 800; text-align: left; }

/* ---------- Onboarding & Toast ---------- */
.overlay {
  position: fixed; inset: 0;
  background: #0009;
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.overlay-card {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 18px;
  padding: 26px 24px;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 20px 60px #000c;
}
.ob-steps { text-align: left; margin: 18px 0; }
.ob-step { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.ob-num {
  background: var(--accent); color: #14210b;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; flex-shrink: 0;
}
.ob-step p { color: #d5dbe4; line-height: 1.5; font-size: .93rem; }

.toast {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel);
  border: 2px solid var(--accent2);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 14px;
  font-weight: 700;
  z-index: 120;
  box-shadow: 0 8px 30px #000a;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Abzeichen ---------- */
#badge-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.badge-card {
  background: var(--panel);
  border: 2px solid var(--panel2);
  border-radius: var(--radius);
  padding: 12px;
  width: 150px;
  text-align: center;
}
.badge-card.earned { border-color: var(--accent2); }
.badge-card .b-icon { font-size: 1.9rem; }
.badge-card.locked { opacity: .38; filter: grayscale(1); }
.badge-card h4 { font-size: .85rem; margin: 6px 0 2px; }
.badge-card p { font-size: .72rem; color: var(--muted); line-height: 1.35; }

/* ---------- Sparkline & Auswahl ---------- */
#perf-spark svg { width: 100%; height: 70px; }
.free-row select {
  width: 170px;
  padding: 9px;
  background: var(--bg);
  border: 2px solid var(--panel2);
  border-radius: 10px;
  color: var(--text);
  font-size: .95rem;
}

/* ---------- Blitz-Quiz ---------- */
.tagline {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.02rem;
  margin-bottom: 4px;
}
.quiz-card { max-width: 520px; margin: 0 auto 14px; text-align: center; }
.quiz-card h3 { font-size: 1.15rem; margin-bottom: 14px; }
.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.quiz-opt {
  padding: 14px 10px;
  background: var(--panel2);
  border: 2px solid transparent;
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .12s, transform .08s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
.quiz-opt.right { background: #2b4a2b; border-color: #52b788; }
.quiz-opt.wrong { background: #4a2626; border-color: var(--danger); }
.quiz-opt:disabled { cursor: default; }
@media (max-width: 480px) { .quiz-options { grid-template-columns: 1fr; } }

/* ---------- Wissenstest ---------- */
.kn-feedback { margin-top: 12px; text-align: left; }
.kn-feedback p { margin: 8px 0; line-height: 1.55; }
.kn-feedback .kn-wrong { color: var(--danger); }
.kn-feedback details { margin: 8px 0; color: var(--muted); }
.kn-feedback summary { cursor: pointer; color: var(--accent2); font-weight: 600; }
.kn-feedback .primary { margin-top: 8px; }

/* ---------- Meine Partien ---------- */
#inp-pgn {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--panel2);
  border-radius: 10px;
  color: var(--text);
  font-family: monospace;
  font-size: .85rem;
  padding: 10px;
}
.tag-far {
  background: var(--accent2);
  color: #201a05;
  font-weight: 700;
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 8px;
}
.small-btn { padding: 6px 12px !important; font-size: .82rem !important; }
#inp-pgn-file { color: var(--muted); }

/* ---------- Punkte-Animation (Quiz-Session) ---------- */
.pts-pop {
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent2);
  text-align: center;
  margin: 8px 0 2px;
  animation: pts-pop .6s cubic-bezier(.2, 1.6, .4, 1);
  text-shadow: 0 3px 12px #f7b32b55;
}
@keyframes pts-pop {
  0% { transform: scale(.3); opacity: 0; }
  60% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); }
}
.pts-today { text-align: center; color: var(--text); margin-bottom: 10px; }
.pts-bar {
  height: 12px;
  max-width: 320px;
  margin: 6px auto 0;
  background: var(--panel2);
  border-radius: 6px;
  overflow: hidden;
}
.pts-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent2));
  transition: width .8s ease;
}

/* ---------- Mini-Plakette: richtige Figur bei falsch belegtem Feld ---------- */
.mini-correct {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 46%;
  height: 46%;
  background: #fffef2;
  border: 2px solid var(--danger);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px #0008;
  z-index: 2;
}
.mini-correct .pc-img { width: 88%; height: 88%; filter: none; }

/* ---------- Kontrast: schwarze Figuren in Palette & Picker ---------- */
.pal-btn, .picker button:not(.pick-remove) {
  background: linear-gradient(135deg, var(--sq-light) 50%, #d9c6a5 50%);
}
.pal-btn:hover, .picker button:not(.pick-remove):hover { filter: brightness(1.08); }
.pal-btn.selected { outline: 3px solid var(--accent2); background: linear-gradient(135deg, #f4e6c8 50%, #e2cfa9 50%); }

/* ---------- Heller Modus (Einstellungen → Design) ---------- */
body.light {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel2: #dde4ec;
  --text: #1d2634;
  --muted: #55647a;
  --accent-dark: #4e7d2b;
  background: radial-gradient(1100px 500px at 75% -80px, #dfe7f2 0%, var(--bg) 55%) fixed;
}
body.light .card p { color: #33404f; }
body.light .ob-step p { color: #33404f; }
body.light .stat-card { border-bottom-color: var(--accent); }
body.light .toast { box-shadow: 0 8px 30px #0003; }
body.light .overlay-card { box-shadow: 0 20px 60px #0004; }
body.light .board { box-shadow: 0 14px 34px #0004, 0 0 0 1px #6b5638 inset; }
.form-label select {
  width: 100%;
  margin-top: 4px;
  padding: 9px;
  background: var(--bg);
  border: 2px solid var(--panel2);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
}
#kn-board { width: min(80vw, 380px); }
#kn-turn { margin: 8px 0 4px; font-weight: 700; color: var(--accent2); }
