:root {
  --bg: #f8fafc;
  --paper: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #d9e1ea;
  --line-strong: #b9c5d3;
  --teal: #0e9384;
  --teal-dark: #0b6f63;
  --coral: #f05d4f;
  --yellow: #f7c948;
  --green: #16a34a;
  --blue: #2563eb;
  --danger: #dc2626;
  --shadow: 0 14px 45px rgba(17, 24, 39, 0.1);
  --edge: 2px solid var(--ink);
  --edge-soft: 1px solid var(--line);
  --iso-sm: 5px 5px 0 var(--iso-side);
  --iso-md: 5px 5px 0 var(--iso-side);
  --iso-lg: 5px 5px 0 var(--iso-side);
  --focus-ring: 0 0 0 4px rgba(14, 147, 132, 0.16);
  --iso-side: #f7c948;
  --pop-a: #00bcd4;
  --pop-b: #ff5a5f;
  --pop-c: #f7c948;
  --radius: 8px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  position: relative;
  isolation: isolate;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(48, 111, 174, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(48, 111, 174, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(48, 111, 174, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(48, 111, 174, 0.055) 1px, transparent 1px),
    #fbfdff;
  background-size: 140px 140px, 140px 140px, 28px 28px, 28px 28px, auto;
  color: var(--ink);
}

.math-scribbles {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  color: #174eaa;
  font-family: "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
  font-weight: 600;
}

.math-scribbles span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-size: var(--size);
  line-height: 1;
  opacity: var(--alpha);
  white-space: nowrap;
  transform: rotate(var(--turn));
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100svh;
}

.arcade-start {
  position: relative;
  display: grid;
  place-items: start center;
}

.pixel-burst {
  display: none;
}

.arcade-card {
  width: min(860px, 100%);
  display: grid;
  gap: 18px;
  padding: clamp(18px, 4vw, 32px);
  border: var(--edge);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--iso-lg), var(--shadow);
}

.arcade-title {
  display: flex;
  gap: 16px;
  align-items: center;
}

.pixel-title {
  font-weight: 950;
  color: var(--ink);
  text-transform: uppercase;
  text-shadow:
    4px 4px 0 var(--iso-side),
    7px 7px 0 rgba(17, 24, 39, 0.18);
}

.arcade-title p {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 800;
}

.app-version {
  display: inline-block;
  margin-top: 7px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.player-entry {
  display: grid;
  gap: 8px;
}

.quick-start-grid,
.advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.advanced-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 8px;
}

.quick-start-grid label,
.advanced-grid label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.advanced-grid > label {
  padding-bottom: 5px;
}

.play-button {
  min-height: 68px;
  border: var(--edge);
  border-radius: var(--radius);
  background: var(--teal);
  color: #fff;
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: var(--iso-lg);
}

.play-button:active {
  transform: translate(3px, 3px);
  box-shadow: var(--iso-sm);
}

.arcade-records {
  box-shadow: var(--iso-md);
}

.arcade-records h2 {
  text-transform: uppercase;
}

.advanced-panel {
  min-width: 0;
  max-width: 100%;
  border: var(--edge);
  border-radius: var(--radius);
  background: #fff;
  padding: 0;
  box-shadow: var(--iso-md);
}

.advanced-panel > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--ink);
  font-weight: 950;
  text-transform: uppercase;
  cursor: pointer;
}

.advanced-panel[open] {
  padding-bottom: 14px;
}

.advanced-panel[open] > summary {
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.advanced-panel > *:not(summary) {
  margin-left: 14px;
  margin-right: 14px;
}

/* Estadisticas educativas: resumen, selector de metrica y heatmap 12 x 12. */
.adult-panel {
  min-width: 0;
  max-width: 100%;
  margin-top: 18px;
  margin-bottom: 5px;
  border: 2px solid rgba(17, 24, 39, 0.38);
  border-radius: var(--radius);
  background: rgba(244, 247, 250, 0.94);
  padding: 0;
  box-shadow: 5px 5px 0 rgba(185, 197, 211, 0.78);
}

.adult-panel summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #485467;
  font-weight: 950;
  text-transform: uppercase;
  cursor: pointer;
}

.adult-panel[open] {
  padding-bottom: 12px;
}

.adult-summary {
  display: grid;
  gap: 10px;
  margin: 0 12px 10px;
}

.stats-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-block: 1px solid var(--line);
}

.stats-metric {
  min-width: 0;
  padding: 10px 12px;
}

.stats-metric + .stats-metric {
  border-left: 1px solid var(--line);
}

.stats-metric strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.stats-metric span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  line-height: 1.2;
  text-transform: uppercase;
}

.stats-metric.is-faster strong {
  color: #087a4f;
}

.stats-metric.is-slower strong {
  color: #b33a2f;
}

.stats-coverage {
  display: grid;
  gap: 2px;
}

.stats-coverage strong {
  font-size: 18px;
}

.stats-coverage span,
.heatmap-legend,
.slow-items span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.heat-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 12px 10px;
}

.heat-toggle label {
  position: relative;
}

.heat-toggle input {
  position: absolute;
  opacity: 0;
}

.heat-toggle span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  font-weight: 950;
  text-transform: uppercase;
  cursor: pointer;
}

.heat-toggle input:checked + span {
  border-color: var(--ink);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--iso-side);
}

.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 12px 10px;
}

.heatmap-legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.heatmap-legend i {
  width: 16px;
  height: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}

.legend-empty {
  background: #eef2f7;
}

.legend-fast {
  background: hsl(145 78% 74%);
}

.legend-mid {
  background: hsl(62 78% 74%);
}

.legend-slow {
  background: hsl(0 78% 74%);
}

.heatmap-wrap {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  margin: 0 12px;
  padding-bottom: 4px;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: 30px repeat(12, minmax(48px, 1fr));
  gap: 4px;
  min-width: 680px;
}

.heat-axis,
.heat-corner {
  display: grid;
  min-height: 28px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.heat-cell {
  display: grid;
  min-height: 46px;
  place-items: center;
  border: 1px solid rgba(17, 24, 39, 0.18);
  border-radius: 6px;
  background: var(--cell-bg);
  color: var(--ink);
  text-align: center;
}

.heat-cell strong {
  font-size: 15px;
  line-height: 1;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.heat-cell span {
  color: rgba(17, 24, 39, 0.72);
  font-size: 10px;
  font-weight: 900;
}

.heat-cell.is-empty {
  color: rgba(102, 112, 133, 0.48);
}

.heat-cell.is-empty span {
  display: none;
}

.slow-items {
  display: grid;
  gap: 5px;
  margin: 10px 12px 0;
}

.slow-items strong {
  font-size: 15px;
  text-transform: uppercase;
}

.start-screen,
.results-screen {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.brand-row,
.results-header,
.game-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-row {
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: var(--edge);
  border-radius: var(--radius);
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
  font-size: 26px;
  box-shadow: var(--iso-md);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 6vw, 62px);
  line-height: 0.96;
  letter-spacing: 0;
}

.brand-row p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 18px;
}

.start-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) 380px;
  gap: 22px;
  align-items: start;
}

.start-panel,
.records-panel,
.summary-panel,
.analysis-panel,
.ranking-panel,
.score-panel {
  border: var(--edge);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--iso-md), var(--shadow);
}

.start-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.records-panel,
.summary-panel,
.analysis-panel,
.ranking-panel,
.score-panel {
  padding: 18px;
}

.field-label,
.settings-grid label,
.tables-picker legend {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.initials-input {
  width: 100%;
  height: 92px;
  border: var(--edge);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-size: clamp(42px, 10vw, 72px);
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0;
  outline: none;
  box-shadow: var(--iso-md);
}

.initials-input:focus,
.answer-input:focus,
select:focus,
.event-code-row input:focus {
  border-color: var(--teal);
  box-shadow: var(--focus-ring), var(--iso-sm);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mode-card {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 14px;
  border: var(--edge-soft);
  border-radius: var(--radius);
  background: var(--paper);
}

.mode-card input {
  position: absolute;
  opacity: 0;
}

.mode-card:has(input:checked) {
  border-color: var(--ink);
  box-shadow: var(--iso-sm);
}

.mode-card span {
  font-weight: 900;
  font-size: 18px;
}

.mode-card small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

select,
.event-code-row input {
  width: 100%;
  height: 44px;
  margin-top: 7px;
  border: var(--edge);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
  font-weight: 900;
  box-shadow: var(--iso-sm);
}

select:disabled {
  color: var(--muted);
  background: #f8fafc;
  opacity: 1;
  cursor: default;
}

.event-code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: stretch;
  margin-top: 7px;
}

.event-code-row input {
  margin-top: 0;
}

.event-code-row .ghost-button {
  height: 44px;
}

.tables-picker {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.quick-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.table-checks {
  display: grid;
  grid-template-columns: repeat(12, minmax(34px, 1fr));
  gap: 7px;
}

.table-checks label {
  display: grid;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  font-weight: 900;
}

.table-checks input {
  position: absolute;
  opacity: 0;
}

.table-checks label:has(input:checked) {
  border-color: var(--ink);
  background: #dff7f3;
  box-shadow: inset 0 0 0 2px var(--teal);
}

.toggle-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--muted);
  line-height: 1.35;
}

.primary-button,
.ghost-button,
.submit-button,
.help-button,
.icon-button,
.finish-round-button {
  min-height: 44px;
  border-radius: var(--radius);
  border: var(--edge);
  font-weight: 900;
}

.primary-button {
  background: var(--ink);
  color: #fff;
  padding: 0 18px;
  box-shadow: var(--iso-sm);
}

.ghost-button,
.icon-button {
  background: var(--paper);
  color: var(--ink);
  padding: 0 14px;
  box-shadow: var(--iso-sm);
}

.records-panel {
  display: grid;
  gap: 14px;
}

.records-panel h2,
.results-screen h2 {
  font-size: 28px;
  line-height: 1.05;
}

.record-hero,
.note-block {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: var(--radius);
  background: #ecfeff;
  border: var(--edge);
  box-shadow: var(--iso-sm);
}

.record-hero strong {
  font-size: 24px;
}

.record-hero span,
.note-block span,
.compact-list small {
  color: var(--muted);
  line-height: 1.35;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.record-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: var(--edge);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--iso-sm);
}

.rank-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--yellow);
  font-weight: 900;
}

.record-row strong {
  display: block;
  font-size: 17px;
}

.record-row em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.game-screen {
  display: none;
  min-height: 100svh;
  padding: 14px;
  overflow-x: hidden;
}

.app[data-screen="game"] .game-screen {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
}

.app[data-screen="game"] .start-screen,
.app[data-screen="game"] .results-screen,
.app[data-screen="results"] .start-screen,
.app[data-screen="results"] .game-screen,
.app[data-screen="start"] .game-screen,
.app[data-screen="start"] .results-screen {
  display: none;
}

.app[data-screen="results"] .results-screen {
  display: block;
}

.game-topbar {
  justify-content: center;
  flex-wrap: wrap;
  padding: 8px;
}

.top-stat,
.guard-pill {
  display: grid;
  min-width: 98px;
  min-height: 48px;
  justify-items: center;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 5px 10px;
}

.top-stat span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.top-stat strong,
.guard-pill {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.guard-pill {
  color: var(--green);
}

.guard-pill.is-warning {
  color: #a16207;
  border-color: #facc15;
  background: #fffbeb;
}

.guard-pill.is-danger {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}

.progress-track {
  overflow: hidden;
  height: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
}

.progress-track div {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--yellow), var(--coral));
  transition: width 180ms ease;
}

.playfield {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 12px;
  min-height: 0;
}

.problem-zone {
  --answer-stack-width: min(100%, 490px);
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 0;
  padding: clamp(16px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.app[data-answer-mode="choice"] .problem-zone {
  --answer-stack-width: min(100%, 590px);
}

.round-meta {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.problem {
  display: grid;
  grid-template-columns: 2ch 0.8ch 2ch;
  justify-content: center;
  align-items: baseline;
  margin: clamp(10px, 2.5vh, 28px) 0;
  font-size: clamp(104px, 20vw, 260px);
  line-height: 0.86;
  font-weight: 950;
  letter-spacing: 0;
  text-align: center;
  width: min(100%, 880px);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.problem-factor-left {
  text-align: right;
}

.problem-factor-right {
  text-align: left;
}

.problem-sign {
  text-align: center;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(140px, 380px) 88px;
  gap: 10px;
  width: var(--answer-stack-width);
}

.answer-input {
  width: 100%;
  height: clamp(88px, 12vh, 130px);
  border: var(--edge);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: clamp(56px, 11vw, 96px);
  font-weight: 950;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  outline: none;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.answer-input.is-correct {
  border-color: var(--green);
  background: #ecfdf3;
  color: #065f46;
  box-shadow: 0 0 0 5px rgba(22, 163, 74, 0.18);
}

.answer-input.is-wrong {
  border-color: var(--danger);
  background: #fef2f2;
  color: #991b1b;
  box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.16);
}

.submit-button {
  background: var(--teal);
  color: #fff;
  font-size: 28px;
  box-shadow: var(--iso-sm);
}

.choices {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: var(--answer-stack-width);
}

.choices:not([hidden]) {
  display: grid;
}

.choice-card {
  min-height: clamp(120px, 20vh, 210px);
  border: var(--edge);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 6px 6px 0 var(--yellow);
  color: var(--ink);
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.choice-card:first-child {
  box-shadow: 6px 6px 0 #b6edf0;
}

.choice-card span {
  font-size: clamp(60px, 12vw, 120px);
  font-weight: 950;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.choice-card.is-correct {
  border-color: var(--green);
  background: #ecfdf3;
  color: #065f46;
  box-shadow: 6px 6px 0 rgba(22, 163, 74, 0.35);
}

.choice-card.is-wrong {
  border-color: var(--danger);
  background: #fef2f2;
  color: #991b1b;
  box-shadow: 6px 6px 0 rgba(220, 38, 38, 0.28);
}

.feedback-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 38%);
  width: var(--answer-stack-width);
  min-height: 54px;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
}

.feedback {
  color: var(--muted);
  font-weight: 800;
  min-height: 22px;
  transition: color 160ms ease;
}

.feedback.is-correct {
  color: #047857;
}

.feedback.is-wrong {
  color: #b42318;
}

.help-button {
  width: 100%;
  background: #fff7ed;
  color: #9a3412;
  border-color: #fdba74;
  padding: 0 14px;
  box-shadow: var(--iso-sm);
}

.finish-round-button {
  width: var(--answer-stack-width);
  min-height: 60px;
  margin-top: 12px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--iso-md);
  font-size: 22px;
  letter-spacing: 0;
}

.finish-round-button[hidden] {
  display: none;
}

.hint-strip {
  width: var(--answer-stack-width);
  margin-top: 10px;
  min-height: 48px;
  padding: 12px;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  background: #fffbeb;
  color: #713f12;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2px);
  transition: opacity 180ms ease, visibility 180ms ease, transform 180ms ease;
}

.hint-strip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.game-side {
  display: grid;
  align-content: center;
  gap: 12px;
  min-width: 0;
}

.side-block {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 14px;
}

.side-block span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.side-block strong {
  font-size: 20px;
}

.target-meter {
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: #e5e7eb;
}

.target-meter div {
  width: 0%;
  height: 100%;
  background: var(--teal);
  transition: width 180ms ease;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px 8px;
  text-align: center;
}

.mini-grid strong {
  font-size: 28px;
}

.mini-grid label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.prize-block {
  border-color: #fde68a;
  background: #fffdf4;
}

.number-pad {
  display: none;
  grid-template-columns: repeat(12, minmax(54px, 1fr));
  gap: 8px;
}

.number-pad button {
  min-height: 58px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.number-pad button[data-key="enter"] {
  background: var(--ink);
  color: #fff;
}

.number-pad button[data-key="back"] {
  color: var(--coral);
}

.results-header {
  justify-content: space-between;
  margin-bottom: 18px;
}

.overline {
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}

.results-column {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.score-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.score-number {
  font-size: 78px;
  line-height: 0.9;
  font-weight: 950;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.status-banner {
  padding: 12px;
  border-radius: var(--radius);
  background: #ecfdf3;
  color: #027a48;
  font-weight: 900;
}

.status-banner.is-warning {
  background: #fffbeb;
  color: #92400e;
}

.status-banner.is-danger {
  background: #fef2f2;
  color: var(--danger);
}

.certificate {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.summary-panel,
.analysis-panel,
.ranking-panel {
  display: grid;
  gap: 13px;
  min-width: 0;
  align-content: start;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}

.summary-card {
  display: grid;
  gap: 4px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  min-width: 0;
}

.summary-card strong {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.table-analysis {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.table-row {
  display: grid;
  grid-template-columns: 50px minmax(120px, 1fr);
  gap: 5px 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius);
  min-width: 0;
}

.table-row strong {
  font-size: 18px;
}

.table-bar {
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: #e5e7eb;
}

.table-bar div {
  height: 100%;
  background: var(--coral);
}

.table-row.is-weak {
  background: #fff7ed;
}

.table-row.is-weak .table-bar div {
  background: var(--danger);
}

.table-row span {
  grid-column: 2;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ranking-panel .compact-list {
  align-content: start;
}

.ranking-panel .record-row {
  align-self: start;
}

@media (max-width: 900px) {
  .start-layout,
  .playfield,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .results-column {
    display: contents;
  }

  .score-panel {
    order: 1;
  }

  .summary-panel {
    order: 2;
  }

  .analysis-panel {
    order: 3;
  }

  .ranking-panel {
    order: 4;
  }

  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .game-side {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: stretch;
  }

}

@media (max-width: 760px), (pointer: coarse) and (max-width: 1024px) {
  .number-pad:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Telefono vertical: controles compactos sin permitir que el heatmap escale la pagina. */
@media (max-width: 620px) {
  .start-screen,
  .results-screen {
    width: min(100vw - 18px, 1180px);
    padding: 16px 0;
  }

  .brand-row {
    align-items: flex-start;
  }

  .mode-grid,
  .settings-grid,
  .quick-start-grid,
  .summary-stats,
  .game-side {
    grid-template-columns: 1fr;
  }

  .arcade-card {
    box-shadow: var(--iso-lg), var(--shadow);
  }

  .arcade-title {
    align-items: flex-start;
  }

  .pixel-title {
    font-size: clamp(34px, 12vw, 56px);
    text-shadow: 3px 3px 0 var(--iso-side), 5px 5px 0 rgba(17, 24, 39, 0.18);
  }

  .table-checks {
    grid-template-columns: repeat(6, minmax(34px, 1fr));
  }

  .table-row {
    grid-template-columns: 42px 1fr;
  }

  .table-row span {
    grid-column: 2;
  }

  .stats-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .advanced-panel > .adult-panel {
    margin-left: 6px;
    margin-right: 6px;
  }

  .advanced-panel,
  .adult-panel {
    overflow: hidden;
    contain: inline-size;
  }

  .adult-panel[open] {
    width: auto;
  }

  .adult-summary,
  .heat-toggle,
  .heatmap-legend,
  .heatmap-wrap {
    margin-left: 8px;
    margin-right: 8px;
  }

  .stats-metric:nth-child(3) {
    border-left: 0;
  }

  .stats-metric:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .stats-metric strong {
    font-size: 18px;
  }

  .stats-metric {
    padding: 9px 8px;
  }

  .stats-metric span {
    font-size: 9px;
  }

  .heatmap-wrap {
    width: calc(100% - 16px);
    overflow-x: auto;
    overflow-y: hidden;
    contain: inline-size;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .heatmap-grid {
    grid-template-columns: 16px repeat(12, minmax(0, 1fr));
    gap: 2px;
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  .heat-axis,
  .heat-corner {
    min-height: 18px;
    font-size: 9px;
  }

  .heat-cell {
    overflow: hidden;
    min-width: 0;
    min-height: 24px;
    border-radius: 3px;
  }

  .heat-cell strong {
    max-width: 100%;
    font-size: clamp(7px, 2.25vw, 9px);
    white-space: nowrap;
  }

  .heat-cell span {
    display: none;
  }

  .heatmap-legend {
    gap: 6px 9px;
    font-size: 10px;
  }

  .heatmap-legend i {
    width: 12px;
    height: 10px;
  }

  .slow-items {
    min-width: 0;
    max-width: calc(100% - 16px);
    margin-left: 8px;
    margin-right: 8px;
    overflow-wrap: anywhere;
  }

  .game-screen {
    padding: 6px;
  }

  .app[data-screen="game"][data-answer-mode="type"] .game-screen {
    height: 100svh;
    min-height: 100svh;
    grid-template-rows: auto 6px minmax(0, 1fr) auto;
    gap: 6px;
    overflow: hidden;
  }

  .game-topbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 0;
  }

  .icon-button {
    grid-column: auto;
  }

  .top-stat,
  .guard-pill {
    min-width: 0;
    min-height: 36px;
    padding: 2px 3px;
  }

  .game-topbar .icon-button {
    min-height: 36px;
    padding: 0 4px;
    font-size: 13px;
  }

  .top-stat span {
    font-size: 8px;
  }

  .top-stat strong,
  .guard-pill {
    font-size: 13px;
  }

  .progress-track {
    height: 6px;
  }

  .problem-zone {
    padding: 8px;
  }

  .game-side {
    display: none;
  }

  .problem {
    grid-template-columns: 2.1ch 1ch 2.1ch;
    margin-top: 6px;
    margin-bottom: 8px;
    font-size: clamp(58px, 19vw, 76px);
    font-weight: 900;
  }

  .round-meta {
    font-size: 10px;
    line-height: 1.1;
  }

  .app[data-answer-mode="choice"] .problem {
    margin-top: 18px;
    margin-bottom: 24px;
  }

  .answer-form {
    grid-template-columns: 1fr 62px;
    gap: 6px;
  }

  .answer-input {
    height: 56px;
    font-size: 40px;
    font-weight: 900;
  }

  .submit-button {
    min-height: 56px;
    font-size: 20px;
  }

  .feedback-row {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 5px;
    margin-top: 7px;
    justify-items: center;
  }

  .feedback {
    width: 100%;
    min-height: 18px;
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
  }

  .help-button {
    width: 74%;
    min-height: 40px;
    padding: 0 8px;
    font-size: 13px;
  }

  .choices {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .choice-card {
    min-height: 104px;
  }

  .choice-card span {
    font-size: clamp(42px, 14vw, 62px);
    font-weight: 900;
  }

  .app[data-answer-mode="choice"] .feedback-row {
    margin-top: 16px;
  }

  .hint-strip {
    min-height: 34px;
    margin-top: 4px;
    padding: 6px;
    font-size: 11px;
    line-height: 1.2;
  }

  .number-pad {
    gap: 4px;
  }

  .number-pad button {
    min-height: 42px;
    font-size: 19px;
  }

  .result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .result-actions button {
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 13px;
  }
}
