:root {
  --bg: #1f1e1c;
  --panel: #2a2926;
  --panel-2: #33312e;
  --text: #ececea;
  --muted: #a7a6a2;
  --accent: #6aa84f;
  --accent-2: #5b9a42;
  --border: #3d3b37;
  --sq-light: #e8dfc8;
  --sq-dark: #9a7b5a;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; padding: 16px; max-width: 1200px; width: 100%; margin: 0 auto; }
a { color: #8fc46e; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; background: #191816; border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; font-size: 18px; display: flex; gap: 8px; align-items: center; }
.logo { font-size: 24px; }
.top-right { display: flex; gap: 12px; align-items: center; }
.engine-status { font-size: 13px; color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent-2); color: #fff; }
.btn.big { padding: 12px 22px; font-size: 16px; width: 100%; margin-top: 14px; }
.link { background: none; border: none; color: #8fc46e; cursor: pointer; margin-top: 14px; font-size: 14px; text-decoration: underline; }

/* carga */
.load-card { max-width: 620px; margin: 30px auto; }
.load-card h1 { margin-top: 0; }
.drop { display: flex; gap: 16px; align-items: center; justify-content: center; border: 2px dashed #5a5853; border-radius: var(--radius); padding: 30px; cursor: pointer; margin: 18px 0; text-align: left; }
.drop:hover, .drop.over { border-color: var(--accent); background: #2f352a; }
.drop-icon { font-size: 34px; color: var(--accent); }
.paste summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
textarea { width: 100%; background: #1b1a18; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-family: ui-monospace, monospace; font-size: 12px; margin-bottom: 8px; }
.error { background: #4a2523; border: 1px solid #8a3a36; color: #ffd8d5; padding: 10px 12px; border-radius: 8px; margin: 12px 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; flex: 1; }
.field label { font-size: 13px; color: var(--muted); }
.fields { display: flex; gap: 14px; flex-wrap: wrap; }
select { background: #1b1a18; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 14px; }
.game-info { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.info-players { font-size: 18px; font-weight: 700; margin-bottom: 4px; }

/* progreso */
.progress-card { max-width: 520px; margin: 60px auto; text-align: center; }
.progress { height: 14px; background: #1b1a18; border-radius: 7px; overflow: hidden; margin: 18px 0 10px; }
#progressFill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* revisión */
.review { display: grid; grid-template-columns: minmax(300px, 600px) minmax(300px, 1fr); gap: 18px; align-items: start; }
.board-col { display: flex; flex-direction: column; gap: 8px; }
.player { font-weight: 600; padding: 4px 2px; }
.board-wrap { display: flex; gap: 8px; }
.eval-bar { width: 26px; flex: 0 0 26px; background: #403e3a; border-radius: 4px; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.eval-bar.flipped { justify-content: flex-start; }
#evalFill { background: #f1f1ef; width: 100%; transition: height .3s; }
#evalText { position: absolute; left: 0; right: 0; font-size: 10px; font-weight: 700; text-align: center; top: 4px; color: #eee; }
#evalText.on-white { top: auto; bottom: 4px; color: #333; }
.eval-bar.flipped #evalText { top: auto; bottom: 4px; }
.eval-bar.flipped #evalText.on-white { top: 4px; bottom: auto; }
.nav { display: flex; gap: 6px; justify-content: center; }
.nav .btn { min-width: 54px; font-size: 16px; }

.board { position: relative; flex: 1; aspect-ratio: 1; user-select: none; container-type: inline-size; }
.board-grid { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%; border-radius: 4px; overflow: hidden; }
.sq { position: relative; display: flex; align-items: center; justify-content: center; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last.light { background: #f3e27a; }
.sq.last.dark { background: #c9a944; }
.sq.selected { box-shadow: inset 0 0 0 4px #4c8fd6; }
.sq.check { background: radial-gradient(circle, #ff4b4b 0%, #e33 40%, transparent 75%) !important; }
.sq.target::after { content: ""; width: 30%; height: 30%; border-radius: 50%; background: rgba(0,0,0,.25); position: absolute; }
.sq.target-capture::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(0,0,0,.25); }
.coord { position: absolute; font-size: 11px; font-weight: 700; opacity: .75; pointer-events: none; }
.coord.rank { top: 2px; left: 3px; }
.coord.file { bottom: 1px; right: 4px; }
.sq.light .coord { color: var(--sq-dark); }
.sq.dark .coord { color: var(--sq-light); }
.piece { font-size: 44px; font-size: 10.5cqw; line-height: 1; font-family: "Segoe UI Symbol", "DejaVu Sans", "Noto Sans Symbols2", "Apple Symbols", serif; pointer-events: none; font-variant-emoji: text; }
.piece.pw { color: #fff; text-shadow: 0 0 2px #000, 0 0 1px #000, 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.piece.pb { color: #1a1a1a; text-shadow: 0 0 1px #fff8; }
.badge { position: absolute; top: 3%; right: 3%; width: 42%; max-width: 28px; aspect-ratio: 1; border-radius: 50%; color: #fff; font-weight: 800; font-size: 12px; font-size: clamp(8px, 2.2cqw, 13px); display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px #0008; z-index: 3; border: 2px solid #fff; }
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.sq[data-sq] { cursor: default; }

.side-col { display: flex; flex-direction: column; gap: 12px; }
.coach-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.coach-title { font-size: 18px; font-weight: 700; }
.coach-sub { font-size: 13px; color: var(--muted); }
.coach-text { line-height: 1.5; }
.coach-engine { margin-top: 10px; font-family: ui-monospace, monospace; font-size: 13px; background: #1f2a1b; border-left: 3px solid var(--accent); padding: 8px 10px; border-radius: 4px; }
.coach-engine.threat { background: #2c1f1e; border-left-color: #ca3431; }
.coach-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.coach-line { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.line-mv { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; cursor: pointer; font-family: ui-monospace, monospace; }
.line-mv.active { background: var(--accent); color: #fff; }

.cls-badge { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 15px; flex: 0 0 auto; }
.cls-badge.small { width: 18px; height: 18px; font-size: 10px; line-height: 1; vertical-align: middle; }

.graph { padding: 0; height: 90px; cursor: crosshair; position: relative; }
.graph svg { border-radius: var(--radius); }
.graph-title { font-size: 12px; margin: 0 0 -6px 2px; }
.g-hover { stroke: #4c8fd6; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.g-tip { position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%); background: #111; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 12px; white-space: nowrap; pointer-events: none; z-index: 5; box-shadow: 0 2px 8px #0008; }
.g-tip-title { font-weight: 700; margin-bottom: 2px; }
.graph svg { width: 100%; height: 100%; display: block; }
.g-light { fill: #f1f1ef; }
.g-dark { fill: #403e3a; }
.g-mid { stroke: #888; stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.g-cur { stroke: #6aa84f; stroke-width: 2; vector-effect: non-scaling-stroke; }

.moves { padding: 8px; }
.move-list { max-height: 260px; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 14px; }
.mrow { display: grid; grid-template-columns: 40px 1fr 1fr; gap: 4px; padding: 1px 0; }
.mrow:nth-child(odd) { background: #2f2d2a; }
.mno { color: var(--muted); padding: 4px 6px; }
.mv { background: none; border: none; color: var(--text); text-align: left; padding: 4px 6px; border-radius: 4px; cursor: pointer; display: flex; gap: 6px; align-items: center; font: inherit; }
.mv:hover { background: #3b3935; }
.mv.active { background: #4b5a3f; }
.mv.empty { color: var(--muted); cursor: default; }

.sum-head { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.sum-player { text-align: center; background: var(--panel-2); border-radius: 8px; padding: 10px; }
.sum-player.me { outline: 2px solid var(--accent); }
.sum-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sum-acc { font-size: 28px; font-weight: 800; }
.sum-label { font-size: 12px; color: var(--muted); }
.sum-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sum-table td { padding: 4px; }
.sum-table td.num { width: 40px; text-align: center; font-weight: 700; }
.sum-table td.mid { text-align: left; }
.key-moments h3 { font-size: 15px; margin: 14px 0 8px; }
.km { display: flex; align-items: center; gap: 4px; width: 100%; text-align: left; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; cursor: pointer; font-size: 14px; }
.km:hover { filter: brightness(1.15); }

.foot { text-align: center; font-size: 12px; padding: 14px; }

@media (max-width: 860px) {
  .review { grid-template-columns: 1fr; }
  main { padding: 8px; }
}
.sum-opening { font-size: 13px; color: var(--muted); margin-bottom: 10px; text-align: center; }
.sum-mode { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }

.acc-graph { height: 110px; background: #262522; }
.a-grid { stroke: #3d3b37; stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.a-me { fill: none; stroke: #6aa84f; stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.a-opp { fill: none; stroke: #9a9893; stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; opacity: .8; }
.acc-legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: -6px; }
.a-leg { display: flex; align-items: center; gap: 6px; }
.a-swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.a-me-bg { background: #6aa84f; }
.a-opp-bg { background: #9a9893; }
.a-axis { position: absolute; left: 4px; top: 0; bottom: 0; pointer-events: none; font-size: 9px; color: #77756f; }
.a-axis span { position: absolute; transform: translateY(-50%); }
.a-axis span:first-child { transform: none; }
.a-axis span:last-child { transform: translateY(-100%); }
