/* Maze-only styles; shared layout lives in game.css. */

/* ---------- Tablero ---------- */
.board {
  --label: 28px;
  display: grid;
  grid-template-columns: var(--label) 1fr;
  grid-template-rows: var(--label) auto;
  width: min(100%, 680px, var(--stage-h));
  margin: 0 auto;
  background: var(--card);
  padding: 8px 12px 12px 4px;
  border-radius: var(--radius);
  box-shadow: 0 4px 0 var(--line);
}
.col-labels, .row-labels { display: grid; font-weight: 700; color: var(--muted); font-size: clamp(.7rem, 1.8vw, .95rem); }
.col-labels { grid-template-columns: repeat(var(--n), 1fr); }
.row-labels { grid-template-rows: repeat(var(--n), 1fr); }
.col-labels span, .row-labels span {
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.col-labels span.hl, .row-labels span.hl { background: var(--yellow); color: var(--ink); }

.grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  aspect-ratio: 1;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--wall);
  container-type: inline-size;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(100cqw / var(--n) * .5);
  user-select: none;
  cursor: pointer;
}
.cell.open { background: #fff; box-shadow: inset 0 0 0 .5px #e6ebf5; }
.cell.wall { background: var(--wall); }
@media (hover: hover) { .cell.open:hover { background: #fff6cc; } }
.cell.open:active { background: #fff6cc; }
.cell.start { background: #dbeafe; }
.cell.exit { background: #dcfce7; }
.cell.visited.open:not(.start):not(.exit) { background: #fef9c3; }
.cell.exit.locked::after { content: '🔒'; position: absolute; right: 4%; bottom: 2%; font-size: .45em; }

.cell .item { transition: transform .3s, opacity .3s; }
.cell .item.collected { transform: scale(2) translateY(-40%); opacity: 0; }

.cell .badge {
  position: absolute;
  top: 5%; left: 5%;
  min-width: 1.6em;
  height: 1.6em;
  padding: 0 .3em;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-weight: 700;
  font-size: max(9px, .32em);
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
  pointer-events: none;
}
.cell.wall .badge { background: var(--red); }
.cell.fail { animation: failFlash .5s ease 3; }
@keyframes failFlash { 50% { box-shadow: inset 0 0 0 999px rgba(239, 68, 68, .6); } }

.robot {
  position: absolute;
  top: 0; left: 0;
  width: calc(100% / var(--n));
  height: calc(100% / var(--n));
  display: flex; align-items: center; justify-content: center;
  font-size: calc(100cqw / var(--n) * .66);
  transition: transform var(--step-ms, 380ms) ease-in-out;
  z-index: 5;
  pointer-events: none;
}
.robot .face { display: inline-block; }
.robot.left .face { transform: scaleX(-1); }
.robot.walking .face { animation: hop var(--step-ms, 380ms) ease-in-out infinite; }
.robot.left.walking .face { animation-name: hopLeft; }
.robot.shake .face { animation: shake .45s ease; }
.robot.happy .face { animation: party .6s ease infinite; }
@keyframes hop { 50% { transform: translateY(-18%); } }
@keyframes hopLeft { 0%, 100% { transform: scaleX(-1); } 50% { transform: scaleX(-1) translateY(-18%); } }
@keyframes shake { 20%, 60% { transform: translateX(-12%) rotate(-10deg); } 40%, 80% { transform: translateX(12%) rotate(10deg); } }
@keyframes party { 25% { transform: rotate(-15deg) scale(1.15); } 75% { transform: rotate(15deg) scale(1.15); } }

/* ---------- Programa ---------- */
.program-head, .program-list li {
  display: grid;
  grid-template-columns: 40px 1fr 1fr 44px;
  gap: 8px;
  align-items: center;
}
.program-head { font-size: .85rem; font-weight: 600; color: var(--muted); padding: 0 6px; text-align: center; }
.start-line { font-weight: 600; color: var(--blue); padding: 6px; background: #eff5ff; border-radius: 10px; }

.program-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 96px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.program-list li { padding: 4px 6px; border-radius: 12px; transition: background .15s; }
.program-list .num {
  justify-self: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
}
.program-list li.empty-line .num { background: #e3e8f4; color: var(--muted); }
.program-list .fld {
  width: 100%;
  height: 44px;
  font: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}
.program-list .fld.sel { border-color: var(--blue); background: #eff5ff; box-shadow: 0 0 0 3px rgba(59, 130, 246, .25); }
.program-list .fld.sel:empty::after { content: '|'; color: var(--blue); animation: caret 1s steps(1) infinite; }
.program-list .fld.invalid { border-color: var(--red); background: #fee2e2; }
.program-list .fld:disabled { background: #f6f8fc; cursor: default; }
@keyframes caret { 50% { opacity: 0; } }

/* On-screen number pad: on an iPad the system keyboard would cover half the board. */
.keypad {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 6px;
}
.key {
  font: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: #e8eefc;
  color: var(--ink);
  box-shadow: 0 3px 0 #cdd6ee;
  cursor: pointer;
}
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 #cdd6ee; background: var(--blue); color: #fff; }
.key.back { background: #fde2e2; box-shadow: 0 3px 0 #f5b5b5; }
.key:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.program-list .del {
  border: none; background: transparent; color: #b4bdd3;
  cursor: pointer; font-size: 1.1rem; border-radius: 10px; height: 44px;
}
@media (hover: hover) { .program-list .del:hover { color: #fff; background: var(--red); } }
.program-list .del:active { color: #fff; background: var(--red); }
.program-list li.active { background: #fef9c3; }
.program-list li.done .num { background: var(--green); }
.program-list li.bad { background: #fee2e2; }
.program-list li.bad .num { background: var(--red); }

/* The step list takes whatever height is left so Jugar is always visible. */
.program-list { flex-shrink: 1; }

@media (max-width: 880px) and (min-width: 600px) {
  .panel.program {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "t t" "tip tip" "head pad" "start pad" "list pad" "list ctl";
    grid-template-rows: auto auto auto auto 1fr auto;
    column-gap: 18px;
    max-height: none;
  }
  .program > h2 { grid-area: t; }
  .program > .tip { grid-area: tip; }
  .program-head { grid-area: head; }
  .start-line { grid-area: start; }
  .program-list { grid-area: list; max-height: 260px; }
  .keypad { grid-area: pad; align-self: start; }
  .program > .controls { grid-area: ctl; }
}
