:root {
  --bg: #eef7f2;
  --ink: #19323c;
  --muted: #5c6f76;
  --panel: #ffffff;
  --line: #c9ddd8;
  --accent: #2c9c7b;
  --accent-dark: #14725a;
  --accent-soft: #d9f4ea;
  --warning: #f3b63e;
  --danger: #d65353;
  --success: #248f5a;
  --shadow: 0 12px 0 rgba(25, 50, 60, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(44, 156, 123, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(44, 156, 123, 0.08) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: #f4fbf8;
  box-shadow: inset 0 -3px 0 rgba(25, 50, 60, 0.12);
  cursor: pointer;
  min-height: 2.7rem;
  padding: 0.7rem 0.85rem;
  touch-action: manipulation;
}

button:hover:not(:disabled),
button:focus-visible:not(:disabled) {
  background: #e5f7f0;
  outline: 3px solid rgba(44, 156, 123, 0.24);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

a {
  color: var(--accent-dark);
  font-weight: 700;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 1rem;
}

.hero {
  display: grid;
  gap: 1rem;
  align-items: center;
  padding: 1rem 0 1.25rem;
}

.brand-mark {
  width: min(12rem, 55vw);
  padding: 0.35rem;
  border: 3px solid #bde8dc;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: auto;
}

.hero-copy {
  max-width: 820px;
  min-width: 0;
}

.eyebrow,
.level-indicator {
  margin: 0 0 0.25rem;
  color: var(--accent-dark);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.45rem;
  font-size: clamp(1.85rem, 7.5vw, 4.4rem);
  line-height: 0.95;
  overflow-wrap: break-word;
}

h2 {
  margin-bottom: 0.25rem;
  font-size: 1.2rem;
}

.hero p,
.level-consigna,
.panel-heading p {
  color: var(--muted);
  line-height: 1.5;
}

.game-layout {
  display: grid;
  gap: 1rem;
}

.play-panel,
.panel-block {
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.play-panel {
  padding: 0.85rem;
  min-width: 0;
}

.level-header {
  display: grid;
  gap: 0.75rem;
}

.progress-chip {
  justify-self: start;
  align-self: start;
  padding: 0.45rem 0.7rem;
  border: 2px solid #bde8dc;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 800;
}

.message {
  margin: 0.75rem 0;
  padding: 0.7rem;
  border: 2px solid #bde8dc;
  border-radius: 8px;
  background: #f5fffb;
  font-weight: 700;
}

.message.success {
  border-color: #8fd5ab;
  color: #135b38;
  background: #e7f9ee;
}

.message.error {
  border-color: #efb0a9;
  color: #852f2f;
  background: #fff0ee;
}

.message.info {
  border-color: #bedaea;
  color: #245368;
  background: #eef8fc;
}

.scene-frame {
  overflow: hidden;
  border: 4px solid #8fbfb3;
  border-radius: 8px;
  background: #dff3e9;
}

.scene-topline {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem;
  color: #103b31;
  background: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.legend {
  color: var(--muted);
  font-weight: 700;
}

.board {
  --columns: 5;
  --rows: 5;
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: 0.25rem;
  width: min(100%, 31rem);
  aspect-ratio: var(--columns) / var(--rows);
  margin: 0 auto;
  padding: 0.75rem;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(25, 50, 60, 0.22);
  border-radius: 6px;
  background: #f7fff7;
  box-shadow:
    inset 0 -8px 0 rgba(25, 50, 60, 0.07),
    inset 8px 0 0 rgba(255, 255, 255, 0.35);
}

.cell::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 4px;
  border: 1px dashed rgba(25, 50, 60, 0.15);
  pointer-events: none;
}

.cell.start {
  background: #e9fbff;
}

.cell.start::before {
  content: "INICIO";
  position: absolute;
  left: 0.25rem;
  bottom: 0.2rem;
  z-index: 1;
  color: #337084;
  font-size: 0.5rem;
  font-weight: 900;
}

.goal-star {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 64%;
  aspect-ratio: 1;
  border-radius: 6px;
  color: #7d5300;
  background: #ffd966;
  box-shadow: inset 0 -8px 0 rgba(125, 83, 0, 0.18);
  font-size: clamp(1.35rem, 7vw, 2.4rem);
  font-weight: 900;
}

.obstacle {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 72%;
  min-height: 58%;
  border-radius: 6px;
  text-align: center;
  font-size: clamp(0.52rem, 2vw, 0.75rem);
  font-weight: 900;
  text-transform: uppercase;
}

.obstacle-muro {
  color: #f8fbfb;
  background:
    linear-gradient(90deg, transparent 48%, rgba(255, 255, 255, 0.2) 48% 54%, transparent 54%),
    linear-gradient(#71868c 0 48%, #60777d 48% 54%, #71868c 54%);
  box-shadow: inset 0 -8px 0 rgba(25, 50, 60, 0.28);
}

.obstacle-charco,
.obstacle-pozo {
  color: #0d5771;
  background: #8fe5ff;
  box-shadow: inset 0 -7px 0 rgba(13, 87, 113, 0.2);
}

.obstacle-pozo {
  color: #f0fbff;
  background: #3f5a67;
}

.obstacle-bajo {
  color: #6b4100;
  background: #ffc86b;
  min-height: 38%;
  align-self: end;
  margin-bottom: 15%;
}

.robot {
  --turn: 90deg;
  position: relative;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 62%;
  aspect-ratio: 1;
  border: 3px solid #15566b;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.55), transparent 35%),
    #52c6e8;
  box-shadow:
    inset 0 -9px 0 rgba(21, 86, 107, 0.24),
    0 6px 0 rgba(25, 50, 60, 0.15);
  transform: rotate(var(--turn));
  transition: transform 220ms ease;
}

.robot::before,
.robot::after {
  content: "";
  position: absolute;
  top: 28%;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #103a48;
}

.robot::before {
  left: 27%;
}

.robot::after {
  right: 27%;
}

.robot .face-line {
  width: 38%;
  height: 9%;
  margin-top: 24%;
  border-radius: 999px;
  background: #103a48;
}

.robot .antenna {
  position: absolute;
  top: -20%;
  width: 12%;
  height: 20%;
  border-radius: 6px 6px 0 0;
  background: #15566b;
}

.robot .antenna::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -0.45rem;
  width: 0.45rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffd966;
  transform: translateX(-50%);
}

.robot.direction-norte {
  --turn: 0deg;
}

.robot.direction-este {
  --turn: 90deg;
}

.robot.direction-sur {
  --turn: 180deg;
}

.robot.direction-oeste {
  --turn: 270deg;
}

.robot.action-move {
  animation: robot-step 480ms ease;
}

.robot.action-turn {
  animation: robot-turn 480ms ease;
}

.robot.action-jump {
  animation: robot-jump 500ms ease;
}

.robot.action-crouch {
  animation: robot-crouch 500ms ease;
}

@keyframes robot-step {
  0% { transform: translateY(0) rotate(var(--turn)); }
  45% { transform: translateY(-8%) rotate(var(--turn)); }
  100% { transform: translateY(0) rotate(var(--turn)); }
}

@keyframes robot-turn {
  0% { transform: rotate(calc(var(--turn) - 18deg)); }
  100% { transform: rotate(var(--turn)); }
}

@keyframes robot-jump {
  0% { transform: translateY(0) scale(1) rotate(var(--turn)); }
  45% { transform: translateY(-45%) scale(0.94, 1.06) rotate(var(--turn)); }
  100% { transform: translateY(0) scale(1) rotate(var(--turn)); }
}

@keyframes robot-crouch {
  0% { transform: scale(1) rotate(var(--turn)); }
  45% { transform: scale(1.08, 0.62) rotate(var(--turn)); }
  100% { transform: scale(1) rotate(var(--turn)); }
}

.theme-escuela {
  background: #dff3ff;
  border-color: #86bad4;
}

.theme-plaza {
  background: #e8f8d8;
  border-color: #95c87a;
}

.theme-cancha {
  background: #d8f3ce;
  border-color: #62a869;
}

.theme-laguna {
  background: #dff7fb;
  border-color: #79bfd2;
}

.theme-pozos {
  background: #eff0e8;
  border-color: #b4b68f;
}

.theme-deportiva {
  background: #ecf9d7;
  border-color: #83c273;
}

.theme-pasillo {
  background: #f1f5fa;
  border-color: #9ab0c9;
}

.theme-patio {
  background: #fff4d8;
  border-color: #e0b85a;
}

.theme-aula {
  background: #f2ece2;
  border-color: #c7a982;
}

.theme-rumbos {
  background: #e7f6ee;
  border-color: #52a882;
}

.control-panel {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.panel-block {
  padding: 0.85rem;
}

.panel-heading {
  margin-bottom: 0.7rem;
}

.panel-heading p {
  margin-bottom: 0;
  font-size: 0.92rem;
}

.row-heading {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.program-count {
  flex: 0 0 auto;
  align-self: start;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.85rem;
  font-weight: 800;
}

.command-grid,
.level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.command-button {
  --block: var(--accent);
  display: grid;
  min-height: clamp(7.5rem, 31vw, 10rem);
  align-content: stretch;
  place-items: center;
  justify-items: center;
  gap: 0;
  padding: 0.65rem;
  border: 3px solid #acdcd0;
  border: 3px solid color-mix(in srgb, var(--block), #19323c 18%);
  color: var(--ink);
  color: color-mix(in srgb, var(--block), #19323c 42%);
  background: #f4fbf8;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.24)),
    color-mix(in srgb, var(--block), #ffffff 82%);
  text-align: center;
  box-shadow:
    inset 0 -8px 0 color-mix(in srgb, var(--block), #19323c 18%),
    0 6px 0 rgba(25, 50, 60, 0.12);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.command-button:hover:not(:disabled),
.command-button:focus-visible:not(:disabled) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.32)),
    color-mix(in srgb, var(--block), #ffffff 76%);
  transform: translateY(-2px);
}

.command-button:active:not(:disabled) {
  box-shadow:
    inset 0 -4px 0 color-mix(in srgb, var(--block), #19323c 18%),
    0 3px 0 rgba(25, 50, 60, 0.12);
  transform: translateY(2px);
}

.command-art {
  display: grid;
  place-items: center;
  width: min(7rem, 34vw);
  aspect-ratio: 1;
  border: 3px solid color-mix(in srgb, var(--block), #19323c 16%);
  border-radius: 16px;
  color: var(--block);
  background:
    linear-gradient(135deg, #ffffff, rgba(255, 255, 255, 0.35)),
    color-mix(in srgb, var(--block), #ffffff 86%);
  box-shadow:
    inset 0 -9px 0 rgba(25, 50, 60, 0.11),
    0 4px 0 rgba(25, 50, 60, 0.1);
}

.command-svg {
  display: block;
  width: 86%;
  height: 86%;
}

.command-svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.command-svg rect {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
}

.command-svg circle {
  fill: #ffffff;
}

.command-button.command-avanza,
.program-step.command-avanza {
  --block: #26b8a0;
}

.command-button.command-izquierda,
.program-step.command-izquierda {
  --block: #6f8df6;
}

.command-button.command-derecha,
.program-step.command-derecha {
  --block: #8b72e8;
}

.command-button.command-saltar {
  --block: #1fa7d6;
}

.command-button.command-agacharse {
  --block: #e89b2f;
}

.program-step.command-saltar {
  --block: #1fa7d6;
}

.program-step.command-agacharse {
  --block: #e89b2f;
}

.program-board {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.6rem;
  min-height: 9.7rem;
  overflow-x: hidden;
  padding: 0.75rem;
  border: 3px solid #b8d8d0;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(44, 156, 123, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(44, 156, 123, 0.12) 1px, transparent 1px),
    #f7fffb;
  background-size: 22px 22px;
  scroll-snap-type: x proximity;
}

.program-board::before {
  content: none;
}

.program-start,
.program-finish {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 4.2rem;
  min-height: 4.2rem;
  border: 3px solid #acdcd0;
  border-radius: 12px;
  color: var(--accent-dark);
  background: #ffffff;
  box-shadow: inset 0 -6px 0 rgba(25, 50, 60, 0.1);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.program-start {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.program-finish {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  color: #7d5300;
  border-color: #f0ce62;
  background: #fff6cf;
}

.program-list {
  position: relative;
  z-index: 1;
  display: grid;
  grid-column: 1 / -1;
  grid-row: 2;
  grid-template-columns: repeat(auto-fit, minmax(6.7rem, 7.4rem));
  justify-content: start;
  align-items: stretch;
  gap: 0.6rem;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.program-empty {
  position: relative;
  z-index: 1;
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0;
  padding: 1rem;
  border: 3px dashed #b8d8d0;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.8);
  text-align: center;
  font-weight: 800;
}

.program-step {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  gap: 0.35rem;
  width: 100%;
  min-height: 7.8rem;
  padding: 0.75rem 0.45rem 0.5rem;
  border: 3px solid #b8d8d0;
  border: 3px solid color-mix(in srgb, var(--block), #19323c 18%);
  border-radius: 12px;
  color: var(--ink);
  color: color-mix(in srgb, var(--block), #19323c 42%);
  background: #f7fffb;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.25)),
    color-mix(in srgb, var(--block), #ffffff 80%);
  box-shadow:
    inset 0 -8px 0 color-mix(in srgb, var(--block), #19323c 17%),
    0 5px 0 rgba(25, 50, 60, 0.12);
  scroll-snap-align: start;
}

.step-number {
  position: absolute;
  left: -0.45rem;
  top: -0.45rem;
  display: grid;
  place-items: center;
  width: 1.8rem;
  aspect-ratio: 1;
  border: 2px solid #ffffff;
  border-radius: 999px;
  color: #ffffff;
  background: color-mix(in srgb, var(--block), #19323c 30%);
  box-shadow: 0 3px 0 rgba(25, 50, 60, 0.18);
  font-weight: 900;
  font-size: 0.82rem;
}

.step-icon {
  display: grid;
  place-items: center;
  width: 4.45rem;
  aspect-ratio: 1;
  border: 2px solid color-mix(in srgb, var(--block), #19323c 14%);
  border-radius: 10px;
  color: var(--block);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 -5px 0 rgba(25, 50, 60, 0.09);
}

.step-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.2rem;
  width: 100%;
}

.step-actions button {
  min-width: 0;
  min-height: 2.15rem;
  padding: 0.25rem;
  border: 2px solid rgba(25, 50, 60, 0.12);
  background: rgba(255, 255, 255, 0.75);
  font-weight: 900;
  line-height: 1;
}

.mini-svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  margin: auto;
}

.mini-svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-row {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.icon-action {
  display: grid;
  place-items: center;
  min-height: 4rem;
  border: 3px solid #b8d8d0;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
  font-weight: 900;
}

.primary-button:hover:not(:disabled),
.primary-button:focus-visible:not(:disabled) {
  background: var(--accent-dark);
}

.button-svg {
  display: block;
  width: 2.25rem;
  height: 2.25rem;
}

.button-svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button .button-svg path {
  fill: currentColor;
  stroke: currentColor;
}

.level-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.level-button {
  min-height: 2.35rem;
  padding: 0.35rem;
  border: 2px solid #b8d8d0;
  font-weight: 900;
}

.level-button.active {
  color: #ffffff;
  background: var(--accent);
}

.level-button.locked {
  color: #718087;
  background: #edf1f1;
}

@media (min-width: 640px) {
  .hero {
    grid-template-columns: 12rem 1fr;
  }

  .level-header {
    grid-template-columns: 1fr auto;
  }

  .action-row {
    grid-template-columns: 1fr 1fr;
  }

  .action-row .primary-button {
    grid-column: 1 / -1;
  }
}

@media (min-width: 960px) {
  .app-shell {
    padding: 1.25rem;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    align-items: start;
  }

  .play-panel,
  .panel-block {
    padding: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
