.math-game-shell {
  display: grid;
  gap: 16px;
}

.math-game-hero,
.math-game-card,
.math-game-progress-card,
.math-game-question-card {
  border: 1px solid #f0d3ad;
  border-radius: 20px;
  background: linear-gradient(135deg, #fffaf2, #fff3df);
  box-shadow: 0 18px 40px rgba(74, 47, 29, 0.12);
}

.math-game-hero {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 520px);
  gap: 16px;
  align-items: center;
  padding: 22px;
}

.math-game-hero span,
.math-game-progress-card span,
.math-game-card p {
  color: #7c5f46;
  font-weight: 800;
}

.math-game-hero h3 {
  margin: 6px 0;
  color: #4a2f1d;
  font-size: 30px;
  line-height: 1.05;
}

.math-game-scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.math-game-scoreboard article {
  border-radius: 18px;
  background: #fffefd;
  padding: 14px;
  box-shadow: inset 0 0 0 1px #f0d3ad;
}

.math-game-scoreboard strong {
  display: block;
  margin-top: 4px;
  color: #d97706;
  font-size: 26px;
  font-weight: 900;
}

.math-game-progress-card {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
}

.math-game-progress-card > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.math-game-progress-card strong {
  color: #365c3b;
  font-size: 16px;
}

.math-game-progress {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #eadcc9;
}

.math-game-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #365c3b, #f6c453, #d97706);
}

.math-game-card {
  padding: 18px;
}

.math-game-card strong {
  color: #4a2f1d;
  font-size: 18px;
}

.math-game-card.error {
  border-color: #fecaca;
  background: #fff1f2;
}

.math-game-card.warn {
  border-color: #fed7aa;
  background: #fff7ed;
}

.math-game-question-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.math-game-question-body {
  min-height: 160px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #fffefd;
  color: #17324a;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.22;
  text-align: center;
  overflow: hidden;
  padding: 16px;
  box-shadow: inset 0 0 0 1px #efd7b4;
}

.math-game-question-body p {
  margin: 6px 0;
}

.math-game-question-body svg,
.math-game-question-body img,
.math-game-question-body table {
  max-width: 100%;
}

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

.math-game-options button {
  min-height: 96px;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-start;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, #365c3b, #2f6f49);
  color: white;
  padding: 14px 16px;
  font-size: 19px;
  text-align: left;
  box-shadow: 0 10px 0 rgba(54, 92, 59, 0.22);
  transition: transform 0.18s ease, filter 0.18s ease;
}

.math-game-options button:nth-child(2) {
  background: linear-gradient(135deg, #d97706, #f59e0b);
}

.math-game-options button:nth-child(3) {
  background: linear-gradient(135deg, #0f5a8a, #0284c7);
}

.math-game-options button:nth-child(4) {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
}

.math-game-options button:hover {
  transform: translateY(-2px) scale(1.01);
  filter: brightness(1.04);
}

.math-game-options button span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.22);
  font-weight: 900;
}

.math-game-options button strong {
  color: inherit;
  font-size: inherit;
  line-height: 1.15;
}

.math-game-options button.correct,
.math-game-options button.correct-answer {
  outline: 5px solid #22c55e;
}

.math-game-options button.incorrect {
  outline: 5px solid #ef4444;
}

.math-game-feedback {
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 900;
}

.math-game-feedback.correct {
  background: #dcfce7;
  color: #166534;
}

.math-game-feedback.incorrect {
  background: #fee2e2;
  color: #991b1b;
}

.math-game-insights {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 14px;
}

.math-game-stats-card,
.math-game-ranking-card {
  border: 1px solid #f0d3ad;
  border-radius: 20px;
  background: linear-gradient(135deg, #fffaf2, #fffefd);
  box-shadow: 0 18px 40px rgba(74, 47, 29, 0.1);
  padding: 16px;
}

.math-game-stats-card header span,
.math-game-ranking-card header span {
  display: block;
  color: #d97706;
  font-size: 11px;
  font-weight: 1000;
  text-transform: uppercase;
}

.math-game-stats-card h4,
.math-game-ranking-card h4 {
  margin: 4px 0 12px;
  color: #4a2f1d;
  font-size: 20px;
}

.math-game-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.math-game-stats-grid div {
  border-radius: 16px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #f0d3ad;
  padding: 12px;
}

.math-game-stats-grid span,
.math-game-ranking-list small {
  display: block;
  color: #7c5f46;
  font-size: 11px;
  font-weight: 850;
}

.math-game-stats-grid strong {
  display: block;
  margin-top: 3px;
  color: #d97706;
  font-size: 24px;
}

.math-game-ranking-list {
  display: grid;
  gap: 8px;
}

.math-game-ranking-list article {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-radius: 16px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #f0d3ad;
  padding: 10px;
}

.math-game-ranking-list article > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 12px;
  background: #365c3b;
  color: #fff;
  font-weight: 1000;
}

.math-game-ranking-list strong {
  display: block;
  color: #4a2f1d;
}

.math-game-ranking-list b {
  color: #d97706;
  font-size: 20px;
}

.math-game-empty {
  border-radius: 16px;
  background: #fff;
  color: #7c5f46;
  box-shadow: inset 0 0 0 1px #f0d3ad;
  padding: 14px;
  font-weight: 850;
}

.math-game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.math-game-actions button,
.math-game-launch {
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #d97706, #f6c453);
  color: #4a2f1d;
  padding: 12px 16px;
  font-weight: 900;
}

body.math-game-window-mode {
  min-height: 100dvh;
  overflow: auto;
  background:
    radial-gradient(circle at 16% 10%, rgba(246, 196, 83, .22), transparent 30%),
    linear-gradient(135deg, #f5e6d3, #fff8ef 48%, #f1dcc0);
}

.math-game-window-view {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  padding: 20px;
}

.math-game-window-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border: 1px solid #f0d3ad;
  border-radius: 22px;
  background: linear-gradient(135deg, #fffaf2, #fff0dc);
  box-shadow: 0 18px 40px rgba(74, 47, 29, .12);
  padding: 18px 20px;
}

.math-game-window-head span {
  color: #d97706;
  font-size: 12px;
  font-weight: 1000;
  text-transform: uppercase;
}

.math-game-window-head h1 {
  margin: 4px 0;
  color: #4a2f1d;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}

.math-game-window-head p {
  margin: 0;
  color: #7c5f46;
  font-weight: 850;
}

.math-game-window-head button {
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #4a2f1d, #7c4a22);
  color: #fff8ef;
  padding: 12px 16px;
  font-weight: 1000;
}

.math-game-window-mount {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

html.math-game-window-boot body {
  background: #f5e6d3;
}

html.math-game-window-boot body::before {
  content: "Cargando juego...";
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  color: #4a2f1d;
  font-weight: 1000;
  background:
    radial-gradient(circle at 22% 18%, rgba(246, 196, 83, .3), transparent 30%),
    linear-gradient(135deg, #fffaf2, #f5e6d3);
}

@media (max-width: 900px) {
  .math-game-hero,
  .math-game-options,
  .math-game-insights,
  .math-game-stats-grid {
    grid-template-columns: 1fr;
  }

  .math-game-window-view {
    padding: 12px;
  }

  .math-game-window-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
