/* Robot Coder - program a robot through a maze with instruction tiles.
   Shared shell, buttons and colours come from kids-common.css. */

.level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 360px;
}

.level-btn {
  aspect-ratio: 1;
  border: 3px solid var(--kids-border);
  border-radius: 16px;
  background: var(--kids-card);
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--kids-ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
}

.level-btn small {
  font-size: 0.7rem;
  letter-spacing: 1px;
  min-height: 1em;
}

.level-btn.loop {
  border-color: #b9e3d3;
}

.level-btn.locked {
  opacity: 0.45;
  cursor: default;
}

.level-btn:not(.locked):active {
  transform: scale(0.95);
}

.tip {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--kids-ink-soft);
  min-height: 1.3em;
  margin-bottom: 8px;
}

/* ===================== The board ===================== */

.board-wrap {
  display: flex;
  justify-content: center;
}

#board {
  display: block;
  width: 100%;
  max-height: 42vh;
  border-radius: 16px;
  background: #e8e4fb;
}

.robot {
  transition: transform 0.38s ease-in-out;
}

.robot-turn {
  transition: transform 0.3s ease-in-out;
}

.robot.bump .robot-body {
  animation: rc-bump 0.45s;
}

@keyframes rc-bump {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-8px, 0); }
  50% { transform: translate(8px, 0); }
  75% { transform: translate(-5px, 0); }
}

.robot.win .robot-body {
  animation: rc-win 0.6s ease-in-out 2;
}

@keyframes rc-win {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(0, -18px); }
}

.gone {
  opacity: 0;
  transition: opacity 0.3s;
}

/* ===================== Program rows ===================== */

.prog-row {
  margin-top: 10px;
  border: 3px solid var(--kids-border);
  border-radius: 16px;
  padding: 6px 8px 8px;
  background: var(--kids-card);
  cursor: pointer;
}

.prog-row.active {
  border-color: var(--kids-lilac);
  box-shadow: 0 0 0 3px #d9d5fa;
}

.prog-row.loop-row.active {
  border-color: var(--kids-green);
  box-shadow: 0 0 0 3px #c4ecdd;
}

.prog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--kids-ink-soft);
  margin-bottom: 6px;
}

.prog-head .count {
  margin-left: auto;
  color: var(--kids-muted);
}

.times {
  display: flex;
  align-items: center;
  gap: 4px;
}

.times button {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 2px solid var(--kids-border);
  background: var(--kids-lilac-pale);
  font-family: inherit;
  font-weight: 900;
  font-size: 1rem;
  color: var(--kids-ink-soft);
  cursor: pointer;
}

.times span {
  min-width: 34px;
  text-align: center;
  font-size: 1.05rem;
  color: var(--kids-green);
}

.slots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 46px;
}

.slots .hint {
  align-self: center;
  color: #a7a3c9;
  font-weight: 800;
  font-size: 0.85rem;
}

/* ===================== Tiles ===================== */

.tile {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: none;
  font-family: "Segoe UI Symbol", "Segoe UI", sans-serif;
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}

.tile.F { background: #3fa9f5; }
.tile.L { background: #f08a3c; }
.tile.R { background: #e0574b; }
.tile.P { background: var(--kids-green); }

.tile.running {
  outline: 4px solid #ffd23f;
  transform: scale(1.1);
}

.palette {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.palette .tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--kids-ink-soft);
  padding: 0;
}

.palette .tile {
  width: 58px;
  height: 58px;
  font-size: 2rem;
}

.palette .tool[disabled] {
  opacity: 0.35;
  cursor: default;
}

.play-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

.play-actions .big-btn {
  max-width: 200px;
}

.end-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

@media (max-width: 380px) {
  .tile {
    width: 40px;
    height: 40px;
    font-size: 1.35rem;
  }
  .palette .tile {
    width: 52px;
    height: 52px;
  }
}
