/* ============ Chess MVP — estilos ============ */
:root {
  --bg: #f4f1ea;
  --bg-dark: #1e1e24;
  --card: #ffffff;
  --ink: #2b2b33;
  --muted: #6b6b76;
  --accent: #2e7d32;
  --accent-dark: #1b5e20;
  --light: #f0d9b5;
  --dark: #b58863;
  --sel: rgba(255, 235, 59, 0.55);
  --legal: rgba(46, 125, 50, 0.35);
  --lastmove: rgba(255, 213, 79, 0.5);
  --ok: #2e7d32;
  --fail: #c62828;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.screen { display: none; max-width: 560px; margin: 0 auto; padding: 16px; }
.screen.active { display: block; }

/* --- Home --- */
.hero { text-align: center; padding: 28px 0 12px; }
.hero .logo { font-size: 56px; line-height: 1; }
.hero h1 { font-size: 40px; letter-spacing: 2px; margin: 6px 0 4px; }
.tagline { color: var(--muted); font-size: 15px; }

.streak-card {
  background: linear-gradient(135deg, #ffb300, #ff8f00);
  color: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  text-align: center;
  font-size: 17px;
  margin: 16px 0;
  box-shadow: 0 4px 12px rgba(255, 143, 0, 0.3);
}
.streak-sub { display: block; font-size: 12px; opacity: 0.9; margin-top: 2px; }

.menu-group {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.menu-group h2 { font-size: 18px; margin-bottom: 6px; }
.menu-hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  background: #e8e4da;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s;
  margin: 4px;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn.disabled { opacity: 0.5; cursor: not-allowed; }
.btn.back-btn { width: 42px; padding: 8px 0; font-size: 16px; }

.level-btn { min-width: 100px; }
.level-btn.sel { outline: 3px solid var(--accent); background: #d8ecd8; }
.level-lock { color: var(--fail); font-size: 12px; min-height: 16px; margin-top: 6px; }

.footer { text-align: center; color: var(--muted); font-size: 11px; padding: 18px 0 30px; }
.footer a { color: var(--muted); }

/* --- Topbar / stats --- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.topbar-title { flex: 1; font-weight: 700; font-size: 16px; }
.topbar-right { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; }

.puzzle-stats {
  display: flex; justify-content: space-around;
  background: var(--card);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* --- Tablero --- */
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  user-select: none;
  touch-action: manipulation;
}
.cell { position: relative; display: flex; align-items: center; justify-content: center; }
.cell.light { background: var(--light); }
.cell.dark  { background: var(--dark); }
.cell.sel { background: var(--sel) !important; }
.cell.legal::after {
  content: "";
  position: absolute;
  width: 30%; height: 30%;
  border-radius: 50%;
  background: var(--legal);
}
.cell.legal.capture::after {
  width: 88%; height: 88%;
  border: 4px solid var(--legal);
  background: transparent;
  border-radius: 50%;
}
.cell.lastmove { background: var(--lastmove) !important; }
.cell.piece { cursor: pointer; }
.cell img { width: 88%; height: 88%; pointer-events: none; }

/* --- Feedback --- */
.feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
}
.feedback.ok { background: #e3f2e3; color: var(--ok); border: 1px solid #b9dcb9; }
.feedback.fail { background: #fdecea; color: var(--fail); border: 1px solid #f2c4c2; }
.feedback.hidden { display: none; }

.next-btn, #btn-end-session { width: 100%; margin-top: 10px; }

/* --- Resumen --- */
.summary-card {
  background: var(--card);
  border-radius: 16px;
  text-align: center;
  padding: 34px 20px;
  margin-top: 40px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.summary-big { font-size: 64px; font-weight: 800; margin: 14px 0; }
.summary-sub { color: var(--muted); margin-bottom: 22px; }
#btn-summary-home { background: transparent; border: 1px solid #ccc; }

/* --- Tutorial --- */
.tutorial-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.lesson-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  cursor: pointer;
}
.lesson-card .num {
  background: var(--accent); color: #fff;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.lesson-card.done .num { background: #7cb87c; }
.lesson-card h3 { font-size: 15px; }
.lesson-card p { font-size: 12px; color: var(--muted); }

.tutorial-lesson { margin-top: 12px; }
.tutorial-lesson h2 { margin-bottom: 10px; }
#lesson-body { line-height: 1.6; font-size: 15px; }
#lesson-body .piece-demo { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
#lesson-body .piece-demo img { width: 44px; }
#lesson-body table { border-collapse: collapse; margin: 10px 0; width: 100%; }
#lesson-body td, #lesson-body th { border: 1px solid #ddd; padding: 6px 8px; font-size: 13px; }
#lesson-body .tip {
  background: #fff8e1; border-left: 4px solid #ffb300;
  padding: 10px 12px; border-radius: 0 8px 8px 0; margin: 10px 0; font-size: 13px;
}
.lesson-nav { display: flex; justify-content: space-between; margin-top: 18px; }
#lesson-body .mini-board {
  display: grid; grid-template-columns: repeat(8, 1fr);
  width: min(280px, 90%); aspect-ratio: 1; margin: 10px auto;
  border-radius: 6px; overflow: hidden; border: 1px solid #bbb;
}
#lesson-body .mini-board .cell { font-size: 18px; }
#lesson-body .mini-board img { width: 82%; height: 82%; }

/* --- Dark mode básico --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161c;
    --card: #23232c;
    --ink: #e8e6e0;
    --muted: #9a9aa6;
    --light: #b7a16e;
    --dark: #7d6848;
  }
  .btn { background: #33333e; color: #e8e6e0; }
  .btn.primary { background: var(--accent); color: #fff; }
  .lesson-card.done .num { background: #5c8a5c; }
}
