/* ════════ SchachPfad – Design ════════ */
:root {
  --bg: #12121f;
  --bg-soft: #1a1a2e;
  --card: #222238;
  --card-hover: #2a2a44;
  --border: #32324e;
  --text: #eceaf4;
  --text-dim: #9b98b3;
  --accent: #7ec46f;
  --accent-deep: #4e9442;
  --gold: #e8b54d;
  --red: #e06c6c;
  --blue: #6ca7e0;
  --sq-light: #ecdab9;
  --sq-dark: #ae8a68;
  --sq-sel: rgba(126, 196, 111, 0.55);
  --sq-last: rgba(232, 181, 77, 0.42);
  --sq-check: rgba(224, 108, 108, 0.75);
  --hl-green: rgba(126, 196, 111, 0.55);
  --hl-red: rgba(224, 108, 108, 0.55);
  --hl-yellow: rgba(232, 181, 77, 0.45);
  --arrow-green: #5fae50;
  --arrow-red: #d05c5c;
  --arrow-blue: #5c93d0;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

/* ───── Topbar ───── */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; }
.brand-icon { font-size: 1.5rem; color: var(--accent); }
#elo-badge { text-align: right; min-width: 110px; }
.elo-label { font-size: 0.62rem; letter-spacing: 2px; color: var(--text-dim); font-weight: 700; }
.elo-value { font-size: 1.35rem; font-weight: 800; color: var(--gold); line-height: 1.1; transition: transform 0.3s; }
.elo-value.bump { transform: scale(1.25); }
.elo-goal { height: 4px; background: var(--border); border-radius: 2px; margin-top: 3px; overflow: hidden; }
#elo-goal-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 2px; transition: width 0.6s ease; }

/* ───── Layout ───── */
#screen { flex: 1; overflow-y: auto; padding: 16px; max-width: 980px; width: 100%; margin: 0 auto; padding-bottom: 90px; }
#tabbar {
  display: flex; justify-content: space-around;
  background: var(--bg-soft); border-top: 1px solid var(--border);
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; color: var(--text-dim);
  font-family: inherit; font-size: 0.7rem; font-weight: 600;
  padding: 8px 0 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab-icon { font-size: 1.3rem; }
.tab.active { color: var(--accent); }

h1.screen-title { font-size: 1.4rem; margin-bottom: 4px; }
p.screen-sub { color: var(--text-dim); font-size: 0.92rem; margin-bottom: 18px; }

/* ───── Lernpfad ───── */
.chapter { margin-bottom: 22px; }
.chapter-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px;
}
.chapter-num {
  background: var(--accent-deep); color: white; font-weight: 800; font-size: 0.8rem;
  border-radius: 8px; padding: 2px 9px; flex-shrink: 0;
}
.chapter.locked .chapter-num { background: var(--border); color: var(--text-dim); }
.chapter-title { font-size: 1.08rem; font-weight: 700; }
.chapter-motto { color: var(--text-dim); font-size: 0.84rem; margin: 2px 0 10px; font-style: italic; }
.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson-card, .boss-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  text-align: left; color: inherit; font-family: inherit; width: 100%;
}
.lesson-card:hover, .boss-card:hover { background: var(--card-hover); }
.lesson-card:active, .boss-card:active { transform: scale(0.985); }
.lesson-card.locked, .boss-card.locked { opacity: 0.45; cursor: not-allowed; }
.lesson-icon {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft); border: 2px solid var(--border); font-size: 1.05rem;
}
.lesson-card.done .lesson-icon { background: var(--accent-deep); border-color: var(--accent); }
.lesson-info { flex: 1; min-width: 0; }
.lesson-title { font-weight: 700; font-size: 0.95rem; }
.lesson-sub { color: var(--text-dim); font-size: 0.8rem; }
.boss-card { border-color: var(--gold); background: linear-gradient(135deg, var(--card), #2e2616); }
.boss-card.beaten { border-color: var(--accent); background: linear-gradient(135deg, var(--card), #1d2e1a); }
.boss-emoji { font-size: 1.7rem; }
.badge { font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; flex-shrink: 0; }
.badge.gold { background: rgba(232, 181, 77, 0.18); color: var(--gold); }
.badge.green { background: rgba(126, 196, 111, 0.18); color: var(--accent); }
.badge.dim { background: var(--bg-soft); color: var(--text-dim); }

/* ───── Brett ───── */
.board {
  display: grid; grid-template-columns: repeat(8, 1fr);
  width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  position: relative; box-shadow: var(--shadow); user-select: none; touch-action: manipulation;
}
.sq { position: relative; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq .coord { position: absolute; font-size: 0.6rem; font-weight: 700; opacity: 0.65; pointer-events: none; }
.sq.light .coord { color: var(--sq-dark); }
.sq.dark .coord { color: var(--sq-light); }
.coord.rank { top: 2px; left: 3px; }
.coord.file { bottom: 1px; right: 4px; }
.piece { width: 100%; height: 100%; position: relative; z-index: 3; pointer-events: none; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; opacity: 0.9; }
.sq.sel::before, .sq.hl-last::before, .sq.hl-check::before,
.sq.hl-green::before, .sq.hl-red::before, .sq.hl-yellow::before {
  content: ''; position: absolute; inset: 0; z-index: 1;
}
.sq.sel::before { background: var(--sq-sel); }
.sq.hl-last::before { background: var(--sq-last); }
.sq.hl-check::before { background: var(--sq-check); border-radius: 50%; filter: blur(4px); }
.sq.hl-green::before { background: var(--hl-green); }
.sq.hl-red::before { background: var(--hl-red); }
.sq.hl-yellow::before { background: var(--hl-yellow); }
.dot { position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(20, 40, 15, 0.35); z-index: 2; }
.ring { position: absolute; inset: 4%; border: 4px solid rgba(20, 40, 15, 0.35); border-radius: 50%; z-index: 2; }
.board-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
.sq.found::after {
  content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 900; color: var(--accent-deep); z-index: 5;
  text-shadow: 0 1px 3px rgba(255,255,255,0.5);
}
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.board.shake { animation: shake 0.25s; }

/* ───── Lektions-Player & Spiel-Layout ───── */
.player { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 760px) {
  .player { flex-direction: row; align-items: flex-start; }
  .player .board-wrap { flex: 0 0 54%; max-width: 480px; }
  .player .side-panel { flex: 1; }
}
.board-wrap { width: 100%; max-width: 480px; margin: 0 auto; }
.side-panel { display: flex; flex-direction: column; gap: 12px; }
.panel-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.panel-card h3 { font-size: 1.02rem; margin-bottom: 8px; }
.step-text { font-size: 0.94rem; line-height: 1.55; color: var(--text); white-space: pre-wrap; }
.step-text strong { color: var(--gold); }
.feedback { border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; line-height: 1.5; margin-top: 10px; white-space: pre-wrap; }
.feedback.good { background: rgba(126, 196, 111, 0.14); border: 1px solid var(--accent-deep); }
.feedback.bad { background: rgba(224, 108, 108, 0.12); border: 1px solid var(--red); }
.feedback.hint { background: rgba(108, 167, 224, 0.12); border: 1px solid var(--blue); }

.btn {
  background: var(--accent-deep); color: white; border: none; border-radius: 10px;
  font-family: inherit; font-size: 0.95rem; font-weight: 700;
  padding: 11px 20px; cursor: pointer; transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.secondary { background: var(--card-hover); color: var(--text); border: 1px solid var(--border); }
.btn.gold { background: var(--gold); color: #2a2105; }
.btn.danger { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.progress-dots { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.pdot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.pdot.done { background: var(--accent); }
.pdot.now { background: var(--gold); transform: scale(1.3); }

.quiz-choice {
  display: block; width: 100%; text-align: left;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 11px 14px; margin-top: 8px;
  font-family: inherit; font-size: 0.9rem; cursor: pointer; transition: border-color 0.15s;
}
.quiz-choice:hover { border-color: var(--accent); }
.quiz-choice.correct { border-color: var(--accent); background: rgba(126, 196, 111, 0.14); }
.quiz-choice.wrong { border-color: var(--red); background: rgba(224, 108, 108, 0.12); }
.quiz-choice:disabled { cursor: default; }

.player-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.player-topline .title { font-weight: 800; font-size: 1.05rem; }
.player-topline .sub { color: var(--text-dim); font-size: 0.8rem; }
.icon-btn { background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 0.9rem; font-family: inherit; }

/* ───── Bots / Spielen ───── */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.bot-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: background 0.15s, transform 0.1s;
  display: flex; gap: 14px; align-items: center; text-align: left; color: inherit; font-family: inherit;
}
.bot-card:hover { background: var(--card-hover); }
.bot-card.locked { opacity: 0.45; cursor: not-allowed; }
.bot-avatar { font-size: 2.3rem; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; background: var(--bg-soft); border-radius: 50%; flex-shrink: 0; }
.bot-name { font-weight: 800; }
.bot-rating { color: var(--gold); font-weight: 700; font-size: 0.85rem; }
.bot-tagline { color: var(--text-dim); font-size: 0.8rem; margin-top: 3px; line-height: 1.35; }
.winchance { font-size: 0.75rem; color: var(--blue); margin-top: 4px; }

.game-status { display: flex; align-items: center; gap: 10px; }
.game-status .bot-avatar { width: 44px; height: 44px; font-size: 1.7rem; }
.thinking { color: var(--text-dim); font-size: 0.82rem; font-style: italic; }
.movelist { font-size: 0.84rem; color: var(--text-dim); line-height: 1.7; max-height: 130px; overflow-y: auto; font-variant-numeric: tabular-nums; }
.movelist b { color: var(--text); font-weight: 600; }

/* ───── Overlay / Modal ───── */
#overlay {
  position: fixed; inset: 0; background: rgba(10, 10, 18, 0.78);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 20px; backdrop-filter: blur(3px);
}
#overlay.hidden { display: none; }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 28px 24px; max-width: 420px; width: 100%; text-align: center;
  box-shadow: var(--shadow); animation: pop 0.25s ease;
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal .big-emoji { font-size: 3.2rem; margin-bottom: 8px; }
.modal h2 { margin-bottom: 8px; }
.modal p { color: var(--text-dim); font-size: 0.92rem; line-height: 1.5; margin-bottom: 6px; }
.elo-delta { font-size: 1.6rem; font-weight: 800; margin: 10px 0; }
.elo-delta.up { color: var(--accent); }
.elo-delta.down { color: var(--red); }

/* ───── Fortschritt ───── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--gold); }
.stat-label { font-size: 0.74rem; color: var(--text-dim); font-weight: 600; margin-top: 2px; }
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.chart-card svg { width: 100%; height: auto; }
.game-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
.game-row:last-child { border-bottom: none; }
.result-pill { font-weight: 800; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; margin-right: 8px; }
.result-pill.w { background: rgba(126,196,111,0.2); color: var(--accent); }
.result-pill.l { background: rgba(224,108,108,0.18); color: var(--red); }
.result-pill.d { background: rgba(155,152,179,0.18); color: var(--text-dim); }

.empty-note { color: var(--text-dim); text-align: center; padding: 30px 10px; font-size: 0.9rem; line-height: 1.6; }

/* Konfetti-Ersatz: pulsierendes Glühen */
@keyframes glow { 0%,100% { box-shadow: 0 0 0 rgba(232,181,77,0); } 50% { box-shadow: 0 0 38px rgba(232,181,77,0.55); } }
.glow { animation: glow 1.2s ease 2; }
