/* Dilema del Prisionero Iterado — Laboratorio Interactivo
   Dual Typography: Authentic LaTeX (Latin Modern Roman + KaTeX) & Modern UI */

@font-face {
  font-family: "Latin Modern Roman";
  src: url("fonts/lmroman12-regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Latin Modern Roman";
  src: url("fonts/lmroman12-bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Latin Modern Roman";
  src: url("fonts/lmroman12-italic.otf") format("opentype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Latin Modern Mono";
  src: url("fonts/lmmono10-regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --ink: #0f253c;
  --ink-secondary: #3f5266;
  --ink-muted: #64748b;
  --navy: #103760;
  --navy-soft: #ecf3fc;
  --blue: #1565c0;
  --green: #2e7d32;
  --green-soft: #e8f5e9;
  --red: #c62828;
  --red-soft: #ffebee;
  --amber: #d97706;
  --amber-soft: #fff7ed;
  --purple: #6d28d9;
  --purple-soft: #f5f3ff;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 37, 60, 0.04), 0 2px 8px rgba(15, 37, 60, 0.03);
  --shadow-md: 0 8px 24px rgba(15, 37, 60, 0.08);
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Authentic Academic LaTeX Typography Mode */
body.latex-theme {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-alt: #f7f6f2;
  --border: #e5e2d9;
  --border-strong: #cbc6b8;
  --ink: #161b22;
  --ink-secondary: #374151;
  --ink-muted: #666c75;
  --navy: #0e3358;
  --navy-soft: #f0f4f9;
  --font-body: "Latin Modern Roman", "Computer Modern Serif", "STIX Two Text", Georgia, serif;
  --font-heading: "Latin Modern Roman", "Computer Modern Serif", "STIX Two Text", Georgia, serif;
  --font-mono: "Latin Modern Mono", "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
}

body.latex-theme {
  font-size: 15.5px;
  letter-spacing: 0.005em;
}

body.latex-theme h1,
body.latex-theme h2,
body.latex-theme h3,
body.latex-theme h4 {
  font-family: var(--font-heading);
  letter-spacing: -0.01em;
}

body.latex-theme .card {
  box-shadow: 0 1px 3px rgba(22, 27, 34, 0.04);
}

/* KaTeX polish */
.katex { font-size: 1.04em; }
.katex-display { margin: 0.45em 0 !important; overflow-x: auto; overflow-y: hidden; }
.math-block {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  margin: 8px 0;
  overflow-x: auto;
}

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #0d1f33;
  color: #dbe6f2;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1b3450;
  overflow-y: auto;
  z-index: 20;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sidebar-brand {
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-eyebrow {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7cc4fa;
  font-weight: 700;
  margin-bottom: 5px;
}

.brand-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
}

body.latex-theme .brand-title {
  font-family: "Latin Modern Roman", Georgia, serif;
  font-size: 18px;
  font-weight: 700;
}

.brand-sub {
  margin: 5px 0 0;
  font-size: 11.5px;
  color: #93acc6;
  line-height: 1.35;
}

.nav-section-label {
  padding: 18px 18px 7px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6f8cab;
  font-weight: 700;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 10px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #c2d4e7;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.nav-btn:hover { background: rgba(255, 255, 255, 0.08); color: #ffffff; }
.nav-btn.active {
  background: linear-gradient(135deg, #1762b0, #124c8c);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
}

.nav-btn-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-icon { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }

.nav-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  color: #e2effd;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  color: #8ba6c2;
}

/* Main Area */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

body.latex-theme .topbar {
  background: rgba(250, 249, 246, 0.95);
}

.topbar-title-wrap h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.topbar-title-wrap p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Typography Switcher Pill */
.font-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  padding: 2px;
  gap: 2px;
}

.font-toggle button {
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.14s;
}

.font-toggle button.active {
  background: var(--navy);
  color: #ffffff;
}

.font-toggle button[data-font="latex"] {
  font-family: "Latin Modern Roman", Georgia, serif;
  font-size: 13px;
}

.font-toggle button[data-font="modern"] {
  font-family: "Inter", sans-serif;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 99px;
  background: var(--navy-soft);
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #2e7d32; }

/* Spacious Content Stage */
.content-stage {
  padding: 24px 30px 56px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.tab-section { display: none; animation: fadeIn 0.18s ease; }
.tab-section.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Subtabs (Clean Pill Bar) */
.subtabs {
  display: inline-flex;
  background: rgba(15, 37, 60, 0.06);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.subtab-btn {
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.14s;
}

.subtab-btn:hover { color: var(--ink); }
.subtab-btn.active {
  background: var(--surface);
  color: var(--navy);
  box-shadow: 0 1px 4px rgba(15, 37, 60, 0.11);
}

.subpanel { display: none; }
.subpanel.active { display: block; animation: fadeIn 0.16s ease; }

/* Cards & Panels with Generous Breathing Room */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.card-subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

/* Clean Academic Theorem Boxes */
.theorem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.theorem-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.theorem-box h4 {
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--navy);
}

.theorem-box p {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--ink-secondary);
}

/* KPI Strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--navy);
}

.kpi-card.green { border-top-color: var(--green); }
.kpi-card.purple { border-top-color: var(--purple); }
.kpi-card.blue { border-top-color: var(--blue); }
.kpi-card.amber { border-top-color: var(--amber); }
.kpi-card.red { border-top-color: var(--red); }

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 700;
  color: var(--ink);
  margin: 4px 0 2px;
}

.kpi-sub { font-size: 12.2px; color: var(--ink-secondary); }

/* Toolbars */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  flex: 1;
}

.field { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.field.wide { min-width: 220px; flex: 1; }
.field.compact { min-width: 92px; }

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.field label .val-mono {
  font-family: var(--font-mono);
  color: var(--navy);
  font-weight: 700;
}

input[type="text"],
input[type="number"],
select,
textarea {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

input[type="range"] { accent-color: var(--navy); cursor: pointer; }

/* Buttons */
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.52; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #ffffff; }
.btn-primary:hover:not(:disabled) { background: #164b82; }
.btn-success { background: var(--green); color: #ffffff; }
.btn-success:hover:not(:disabled) { background: #226026; }
.btn-purple { background: var(--purple); color: #ffffff; }
.btn-purple:hover:not(:disabled) { background: #5b21b6; }
.btn-secondary { background: var(--surface-alt); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: #eaeef4; }
.btn-danger { background: #fff5f5; color: var(--red); border-color: #f3c2c2; }
.btn-danger:hover:not(:disabled) { background: #ffe5e5; }
.btn-sm { padding: 5px 10px; font-size: 12.2px; }

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.grid-asymmetric {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 1180px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-asymmetric { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.chart-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.chart-card-head h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }
.chart-card-head .chart-note { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }

.canvas-wrap { position: relative; width: 100%; height: 340px; }
.canvas-wrap.tall { height: 440px; }
.canvas-wrap.xtall { height: 540px; }
.canvas-wrap.short { height: 265px; }
.canvas-wrap.compact-bar { height: 365px; }
.canvas-wrap canvas { width: 100%; height: 100%; display: block; }

/* TURN WINDOW INSPECTOR (Expectimax & Duelo 1v1) */
.window-strip {
  display: flex;
  align-items: stretch;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
}

.win-slot {
  flex: 1;
  min-width: 118px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  position: relative;
}

.win-slot.is-prev {
  border-color: #93c5fd;
  background: #f5f9ff;
}

.win-slot.is-current {
  border: 2px solid var(--navy);
  background: #eef5fd;
  box-shadow: 0 3px 12px rgba(16, 55, 96, 0.1);
}

.win-slot .w-turn {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.win-slot.is-current .w-turn { color: var(--navy); }

.win-slot .w-moves {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  margin: 4px 0 3px;
}

.win-slot .w-pts {
  font-size: 12px;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
}

.win-arrow {
  display: flex;
  align-items: center;
  font-size: 18px;
  color: var(--ink-muted);
  font-weight: 700;
  padding: 0 2px;
}

/* Step-by-step live decision cards */
.calc-steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

@media (max-width: 1180px) {
  .calc-steps-grid { grid-template-columns: 1fr; }
}

.calc-step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 17px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--navy);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.decision-verdict {
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13.5px;
  text-align: center;
}

.decision-verdict.choose-c {
  background: var(--green-soft);
  color: #166534;
  border: 1px solid #a7d7ab;
}

.decision-verdict.choose-d {
  background: var(--red-soft);
  color: #991b1b;
  border: 1px solid #f2b4b4;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table th {
  background: var(--surface-alt);
  color: var(--ink-secondary);
  font-weight: 700;
  text-align: left;
  padding: 9px 11px;
  border-bottom: 1.5px solid var(--border-strong);
  white-space: nowrap;
}

table.data-table td {
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}

table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: #f5f9fe; }
table.data-table tr.highlight-row { background: #edf7ed; font-weight: 600; }
table.data-table tr.highlight-gary { background: #f5effb; font-weight: 600; }

.mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.badge-c { background: var(--green-soft); color: var(--green); }
.badge-d { background: var(--red-soft); color: var(--red); }
.badge-blue { background: #e3f2fd; color: var(--blue); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-gray { background: #eef2f6; color: #475569; }

/* Interactive 200-turn Move Ribbon */
.ribbon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10px, 1fr));
  gap: 2px;
  padding: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.ribbon-cell {
  height: 20px;
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.08s;
}

.ribbon-cell:hover { transform: scale(1.28); z-index: 4; }
.ribbon-cell.active-turn { outline: 2px solid #0f253c; transform: scale(1.3); z-index: 5; }
.ribbon-cell.st-CC { background: #2e7d32; }
.ribbon-cell.st-DC { background: #1976d2; }
.ribbon-cell.st-DD { background: #ef6c00; }
.ribbon-cell.st-CD { background: #d32f2f; }

.legend-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-secondary);
  align-items: center;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

/* Playback bar */
.playback-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--navy-soft);
  border: 1px solid #cdddf0;
  border-radius: 10px;
  margin-bottom: 14px;
}

.playback-bar input[type="range"] { flex: 1; min-width: 160px; }

/* Sliders in MDP lab */
.prob-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.prob-slider-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.prob-slider-card .top {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 5px;
}

.prob-slider-card input[type="range"] { width: 100%; }

/* Strategy Chips */
.chip-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 195px;
  overflow-y: auto;
  padding: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.strategy-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  font-size: 12.2px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.12s;
}

.strategy-chip.selected { background: var(--navy); color: #ffffff; border-color: var(--navy); }
.strategy-chip .dot { width: 8px; height: 8px; border-radius: 50%; }

/* Progress Bar */
.progress-box {
  background: var(--navy-soft);
  border: 1px solid #c5daf2;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.progress-track { height: 10px; background: #dbe8f8; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #1565c0, #2e7d32); width: 0%; transition: width 0.2s ease; }

/* Code Viewer & Editor */
.code-editor-textarea {
  width: 100%;
  min-height: 330px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  background: #0d1b2a;
  color: #e6edf3;
  border: 1px solid #243b55;
  border-radius: 10px;
  padding: 14px;
  tab-size: 4;
  resize: vertical;
}

.code-viewer-pre {
  margin: 0;
  padding: 16px;
  background: #0d1b2a;
  color: #e2ecf7;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  border-radius: 10px;
  overflow: auto;
  max-height: 560px;
}

.code-viewer-pre .kw { color: #ff7b72; font-weight: 600; }
.code-viewer-pre .cmt { color: #7d92a8; font-style: italic; }
.code-viewer-pre .num { color: #79c0ff; }

.custom-list { display: flex; flex-direction: column; gap: 10px; }

.custom-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface-alt);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Floating Chart Tooltip */
#chart-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  background: rgba(12, 31, 53, 0.96);
  color: #f4f8fc;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.2px;
  font-family: "Inter", sans-serif;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  max-width: 320px;
  display: none;
}

#chart-tooltip .tt-title {
  font-weight: 700;
  color: #7cc4fa;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 3px;
}

#chart-tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0f253c;
  color: #ffffff;
  padding: 10px 15px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  border-left: 4px solid #38bdf8;
  max-width: 390px;
}
.toast.success { border-left-color: #4ade80; }
.toast.error { border-left-color: #f87171; }

.svg-diagram-box {
  width: 100%;
  overflow-x: auto;
  background: #fbfcfd;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.hidden { display: none !important; }
.muted { color: var(--ink-muted); font-size: 12.5px; }

/* =========================================================================
   VOXEL GAME STAGE, DIAMOND PAYOFF MATRIX, TOKEN TRACK & AXELROD RING
   Harmonized with both LaTeX academic & Modern UI themes
   ========================================================================= */

.voxel-stage {
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(90deg, #e7f5fb 0%, #e7f5fb 48%, #fbeaf2 52%, #fbeaf2 100%);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.voxel-arena-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 20px 22px 16px;
}

.voxel-stage.is-compact .voxel-arena-row {
  padding: 12px 16px 10px;
}

.voxel-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.voxel-name-tag {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 2px;
}

.voxel-trait-tag {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(15, 37, 60, 0.12);
  color: var(--ink-secondary);
  margin-bottom: 8px;
}

.voxel-sprite-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.voxel-char-svg {
  filter: drop-shadow(0 4px 8px rgba(15, 37, 60, 0.14));
}

.voxel-arm-pop {
  animation: armPop 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes armPop {
  from { opacity: 0.4; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.score-pop {
  position: absolute;
  top: -8px;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 99px;
  background: #0f253c;
  color: #facc15;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  animation: scorePopAnim 0.28s ease;
}

.score-pop.pop-left { left: -12px; }
.score-pop.pop-right { right: -12px; }

@keyframes scorePopAnim {
  0% { opacity: 0; transform: translateY(8px) scale(0.8); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.voxel-center-diamond {
  display: flex;
  justify-content: center;
  align-items: center;
}

.voxel-stage.is-compact .diamond-matrix-svg {
  width: 154px;
  height: 160px;
}

/* Glowing Full-History Token Board (grows left -> right, history scrolls left) */
.token-board {
  background: linear-gradient(180deg, #33220d 0%, #241708 100%);
  border-top: 3px solid #d97706;
  padding: 8px 16px 10px;
  color: #fef3c7;
}

.token-board-grid {
  display: grid;
  grid-template-columns: 42px 1fr 68px;
  align-items: stretch;
  gap: 10px;
}

.tok-avatars-col,
.tok-scores-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tok-scores-col {
  border-left: 2px solid rgba(251, 191, 36, 0.45);
  padding-left: 10px;
}

.tok-head-spacer {
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.tok-avatar {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 2px;
}

.tok-scroll-track {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(251, 191, 36, 0.5) rgba(0, 0, 0, 0.2);
  padding-bottom: 3px;
}

.tok-col {
  flex: 0 0 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid rgba(251, 191, 36, 0.22);
}

.tok-col:last-child { border-right: none; }

.tok-col-head {
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.tok-num {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: rgba(254, 243, 199, 0.65);
  line-height: 1;
}

.tok-col.tok-active .tok-num {
  color: #facc15;
  font-weight: 700;
}

.tok-caret {
  font-size: 8.5px;
  color: #facc15;
  line-height: 1;
}

.tok-cell {
  height: 32px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tok-cell-sep {
  width: 100%;
  height: 1px;
  background: rgba(251, 191, 36, 0.32);
  margin: 3px 0;
}

.tok-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid #fef08a;
  transition: transform 0.12s;
}

.tok-col.tok-active .tok-dot {
  transform: scale(1.16);
  box-shadow: 0 0 10px #facc15;
}

.tok-dot.tok-c { background: radial-gradient(circle at 35% 35%, #4ade80, #16a34a); }
.tok-dot.tok-d { background: radial-gradient(circle at 35% 35%, #f87171, #dc2626); }
.tok-dot.tok-empty { background: rgba(255, 255, 255, 0.08); border-color: rgba(251, 191, 36, 0.25); }

.tok-score {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 18px;
  font-weight: 800;
  color: #fef08a;
}

/* Human Play Action Buttons */
.play-action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.btn-play-c {
  background: linear-gradient(135deg, #22c55e, #15803d);
  color: #ffffff;
  font-size: 15px;
  padding: 12px 28px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(21, 128, 61, 0.25);
}
.btn-play-c:hover:not(:disabled) { transform: translateY(-1px); background: linear-gradient(135deg, #16a34a, #166534); }

.btn-play-d {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #ffffff;
  font-size: 15px;
  padding: 12px 28px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(185, 28, 28, 0.25);
}
.btn-play-d:hover:not(:disabled) { transform: translateY(-1px); background: linear-gradient(135deg, #dc2626, #991b1b); }

/* Character Picker Grid ("Elige tu rival") */
.char-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 8px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.14s ease;
}

.char-card:hover { border-color: var(--navy); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.char-card.active { border-color: var(--navy); background: var(--navy-soft); box-shadow: 0 0 0 2px rgba(16, 55, 96, 0.16); }
.char-card .c-name { font-weight: 700; font-size: 12.8px; margin-top: 4px; color: var(--ink); }
.char-card .c-trait { font-size: 11px; color: var(--ink-muted); margin-top: 2px; line-height: 1.25; }

/* Nice vs Nasty Axelrod 1980 Voxel Leaderboard */
.axelrod-lb-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.axelrod-lb-row {
  display: grid;
  grid-template-columns: 30px 30px 150px 52px 1fr;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.1s;
}

.axelrod-lb-row:hover { transform: translateX(3px); }
.axelrod-lb-row.is-nice { background: #f0fdf4; border-color: #bbf7d0; }
.axelrod-lb-row.is-nasty { background: #fef2f2; border-color: #fecaca; }
.axelrod-lb-row.is-ai { background: #f5f3ff; border-color: #c4b5fd; border-width: 2px; }

.axelrod-lb-bar-track {
  height: 16px;
  background: rgba(15, 37, 60, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.axelrod-lb-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.35s ease;
}

@media (max-width: 820px) {
  .voxel-arena-row { grid-template-columns: 1fr; }
  .axelrod-lb-row { grid-template-columns: 28px 28px 115px 46px 1fr; }
}
