/* Mini gra: programowanie robota */
.coding-lab {
  background: linear-gradient(180deg, #f6fbff 0%, #eef7f1 100%);
  padding: 64px 24px;
  position: relative;
  overflow: hidden;
}

.coding-lab::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 16%, rgba(30, 136, 229, 0.12), transparent 28%),
    radial-gradient(circle at 88% 14%, rgba(60, 184, 90, 0.10), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(26, 45, 79, 0.04) 100%);
  pointer-events: none;
}

.coding-shell {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 32px;
  align-items: start;
  position: relative;
  z-index: 1;
}

.coding-copy h2 {
  font-size: clamp(2rem, 4.8vw, 3.2rem);
  font-weight: 900;
  color: var(--navy);
  line-height: 1.12;
  margin-bottom: 12px;
}

.coding-copy h2 span {
  color: var(--blue);
}

.coding-description {
  display: grid;
  gap: 10px;
  max-width: 560px;
}

.coding-description p {
  font-size: 1rem;
  color: #5a6478;
  line-height: 1.72;
  margin: 0;
}

.coding-subtitle {
  font-size: 1.12rem;
  font-weight: 900;
  color: var(--navy);
  margin: 20px 0 14px;
}

.coding-help-panel {
  margin-bottom: 18px;
  border: 1px solid rgba(26, 45, 79, 0.08);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 12px 28px rgba(26, 45, 79, 0.08);
  overflow: hidden;
}

.coding-help-toggle {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--navy);
}

.coding-help-toggle::-webkit-details-marker {
  display: none;
}

.coding-help-toggle::after {
  content: '+';
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 136, 229, 0.12);
  color: var(--blue);
  font-size: 1rem;
  line-height: 1;
}

.coding-help-panel[open] .coding-help-toggle::after {
  content: '-';
}

.coding-help-body {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
}

.coding-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}

.coding-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(26, 45, 79, 0.08);
  box-shadow: 0 10px 24px rgba(26, 45, 79, 0.06);
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--navy);
}

.coding-step-list {
  list-style: none;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.coding-step-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(26, 45, 79, 0.08);
  color: #5a6478;
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1.55;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s;
}

.coding-step-item::before {
  content: attr(data-step-number);
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 45, 79, 0.08);
  color: var(--navy);
  font-size: 0.85rem;
  font-weight: 900;
}

.coding-step-item.is-done {
  background: rgba(60, 184, 90, 0.10);
  border-color: rgba(60, 184, 90, 0.3);
  box-shadow: 0 12px 24px rgba(60, 184, 90, 0.12);
  color: #244832;
  transform: translateX(4px);
}

.coding-step-item.is-done::before {
  content: '\2713';
  background: var(--green);
  color: #fff;
}

.coding-board-column {
  display: grid;
  gap: 18px;
  align-content: start;
}

.coding-board-card {
  background: rgba(255, 255, 255, 0.84);
  border-radius: 32px;
  padding: 22px;
  border: 1px solid rgba(26, 45, 79, 0.08);
  box-shadow: 0 18px 40px rgba(26, 45, 79, 0.12);
  backdrop-filter: blur(12px);
}

.coding-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.coding-mission-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(30, 136, 229, 0.10);
  border: 1px solid rgba(30, 136, 229, 0.18);
  color: var(--navy);
  font-size: 0.86rem;
  font-weight: 900;
}

.coding-mission-chip::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(180deg, #6fdc8c 0%, #3cb85a 100%);
  box-shadow: 0 0 0 8px rgba(60, 184, 90, 0.10);
}

.coding-reset {
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 900;
  cursor: pointer;
  background: var(--gold);
  color: var(--navy);
  box-shadow: 0 8px 20px rgba(232, 160, 32, 0.24);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.coding-reset:hover {
  transform: translateY(-2px);
}

.coding-stage {
  --pad-button-size: 62px;
  --pad-gap: 8px;
  --pad-shell-padding: 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}

.coding-console {
  display: grid;
  gap: 12px;
  align-content: start;
  width: calc((var(--pad-button-size) * 3) + (var(--pad-gap) * 2) + (var(--pad-shell-padding) * 2));
  flex: 0 0 auto;
}

.coding-pad {
  display: grid;
  grid-template-columns: repeat(3, var(--pad-button-size));
  grid-template-rows: repeat(3, var(--pad-button-size));
  grid-template-areas:
    ". forward ."
    "left play right"
    ". backward .";
  gap: var(--pad-gap);
  padding: var(--pad-shell-padding);
  width: 100%;
  justify-self: start;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(26, 45, 79, 0.96) 0%, rgba(26, 45, 79, 0.88) 100%);
  box-shadow: 0 18px 30px rgba(26, 45, 79, 0.18);
}

.coding-pad-button {
  width: var(--pad-button-size);
  min-height: var(--pad-button-size);
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 18px;
  padding: 0;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.14), 0 12px 20px rgba(0, 0, 0, 0.16);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.coding-pad-button:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
}

.coding-pad-button:disabled {
  cursor: default;
  opacity: 0.55;
  transform: none;
}

.coding-pad-button--forward {
  grid-area: forward;
  background: linear-gradient(180deg, #69cf80 0%, #3cb85a 100%);
}

.coding-pad-button--backward {
  grid-area: backward;
  background: linear-gradient(180deg, #ff847c 0%, #e45755 100%);
}

.coding-pad-button--left {
  grid-area: left;
  background: linear-gradient(180deg, #ffd76a 0%, #f5c842 100%);
  color: var(--navy);
}

.coding-pad-button--right {
  grid-area: right;
  background: linear-gradient(180deg, #55a9ff 0%, #1e88e5 100%);
}

.coding-pad-button--play {
  grid-area: play;
  background: linear-gradient(180deg, #ffb553 0%, #fb8c00 100%);
}

.coding-pad-icon {
  font-size: 1.18rem;
  line-height: 1;
}

.coding-pad-button--play .coding-pad-icon {
  font-size: 1.02rem;
}

.coding-pad-label {
  display: none;
}

.coding-sequence-panel {
  border-radius: 28px;
  padding: 14px 14px 12px;
  background: rgba(245, 249, 255, 0.92);
  border: 1px solid rgba(26, 45, 79, 0.08);
  box-shadow: 0 14px 28px rgba(26, 45, 79, 0.08);
  display: grid;
  align-content: start;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.coding-sequence-title {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: #8b96a8;
}

.coding-sequence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
  width: 100%;
}

.coding-sequence-empty {
  font-size: 0.8rem;
  font-weight: 700;
  color: #7a869a;
  line-height: 1.6;
}

.coding-sequence-empty.is-hidden {
  display: none;
}

.coding-sequence-meta {
  font-size: 0.78rem;
  font-weight: 800;
  color: #607089;
}

.coding-sequence-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 0.82rem;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 10px 18px rgba(26, 45, 79, 0.12);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.coding-sequence-chip.is-active {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 14px 24px rgba(26, 45, 79, 0.20);
}

.coding-sequence-chip--forward {
  background: linear-gradient(180deg, #69cf80 0%, #3cb85a 100%);
}

.coding-sequence-chip--backward {
  background: linear-gradient(180deg, #ff847c 0%, #e45755 100%);
}

.coding-sequence-chip--left {
  background: linear-gradient(180deg, #ffd76a 0%, #f5c842 100%);
  color: var(--navy);
}

.coding-sequence-chip--right {
  background: linear-gradient(180deg, #55a9ff 0%, #1e88e5 100%);
}

.coding-sequence-chip-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.coding-board-panel {
  min-width: 0;
  width: min(100%, 430px);
  justify-self: stretch;
}

.coding-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 30px;
  overflow: hidden;
  background: linear-gradient(180deg, #fafdff 0%, #edf5ff 100%);
  border: 1px solid rgba(26, 45, 79, 0.08);
  --code-cols: 4;
  --code-rows: 4;
}

.coding-board::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(26, 45, 79, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 45, 79, 0.06) 1px, transparent 1px);
  background-size: calc(100% / var(--code-cols)) calc(100% / var(--code-rows));
  pointer-events: none;
}

.coding-board::after {
  content: none;
}

.coding-grid {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.66) 0%, rgba(255, 255, 255, 0) 68%);
  pointer-events: none;
}

.coding-marker {
  position: absolute;
  left: calc(var(--col) * (100% / var(--code-cols)));
  top: calc(var(--row) * (100% / var(--code-rows)));
  width: calc(100% / var(--code-cols));
  height: calc(100% / var(--code-rows));
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  pointer-events: none;
}

.coding-marker-start {
  background:
    linear-gradient(180deg, rgba(60, 184, 90, 0.14) 0%, rgba(60, 184, 90, 0.07) 100%);
  color: #2a6a3e;
  border-bottom-left-radius: 30px;
  box-shadow: inset 0 0 0 1px rgba(60, 184, 90, 0.14);
}

.coding-marker-goal {
  background:
    linear-gradient(180deg, rgba(245, 200, 66, 0.22) 0%, rgba(245, 200, 66, 0.10) 100%);
  color: #755500;
  border-top-right-radius: 30px;
  box-shadow: inset 0 0 0 1px rgba(232, 160, 32, 0.16);
}

.coding-obstacles {
  position: absolute;
  inset: 0;
}

.coding-obstacle,
.coding-robot {
  position: absolute;
  left: calc((var(--col) + 0.5) * (100% / var(--code-cols)));
  top: calc((var(--row) + 0.5) * (100% / var(--code-rows)));
  transform: translate(-50%, -50%);
}

.coding-obstacle {
  width: min(64px, calc(100% / var(--code-cols) - 22px));
  aspect-ratio: 1;
  border-radius: 18px;
  background: linear-gradient(180deg, #60718b 0%, #42546f 100%);
  box-shadow: inset 0 -10px 16px rgba(0, 0, 0, 0.16), 0 14px 20px rgba(26, 45, 79, 0.12);
  z-index: 1;
}

.coding-obstacle::before {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 12px;
  border: 3px solid rgba(255, 255, 255, 0.18);
}

.coding-obstacle::after {
  content: none;
}

.coding-robot {
  width: min(58px, calc(100% / var(--code-cols) - 28px));
  aspect-ratio: 1;
  display: flex;
  gap: 6px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #edf3fb 100%);
  border: 4px solid var(--navy);
  box-shadow: 0 16px 26px rgba(26, 45, 79, 0.16);
  z-index: 2;
  overflow: hidden;
  transition:
    left 0.58s ease,
    top 0.58s ease,
    transform 0.58s ease,
    box-shadow 0.24s ease,
    border-color 0.24s ease;
}

.coding-robot::before {
  content: '';
  position: absolute;
  background: rgba(30, 136, 229, 0.16);
  border-radius: 999px;
}

.coding-robot[data-dir] {
  transform: translate(-50%, -50%);
}

.coding-robot[data-dir="north"]::before,
.coding-robot[data-dir="south"]::before {
  left: 12px;
  right: 12px;
  height: 10px;
}

.coding-robot[data-dir="east"]::before,
.coding-robot[data-dir="west"]::before {
  top: 12px;
  bottom: 12px;
  width: 10px;
}

.coding-robot[data-dir="north"]::before {
  top: 10px;
}

.coding-robot[data-dir="south"]::before {
  bottom: 10px;
}

.coding-robot[data-dir="east"]::before {
  right: 10px;
}

.coding-robot[data-dir="west"]::before {
  left: 10px;
}

.coding-robot-eye {
  width: 7px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--navy);
  animation: codingRobotBlinkVertical 4.8s infinite;
  transform-origin: 50% 50%;
  position: relative;
  z-index: 1;
}

.coding-robot-eye-right {
  animation-delay: 0.08s;
}

.coding-robot[data-dir="north"] {
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  padding-top: 13px;
}

.coding-robot[data-dir="south"] {
  flex-direction: row;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 13px;
}

.coding-robot[data-dir="east"] {
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  padding-right: 13px;
}

.coding-robot[data-dir="west"] {
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding-left: 13px;
}

.coding-robot[data-dir="east"] .coding-robot-eye,
.coding-robot[data-dir="west"] .coding-robot-eye {
  animation-name: codingRobotBlinkHorizontal;
}

.coding-robot.is-bumped {
  animation: codingRobotBump 0.35s ease;
  border-color: #e45755;
  box-shadow: 0 16px 26px rgba(228, 87, 85, 0.20);
}

.coding-robot.is-success {
  box-shadow: 0 18px 28px rgba(60, 184, 90, 0.24);
  border-color: var(--green);
}

.coding-board-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
  color: #66758a;
}

.coding-status-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(26, 45, 79, 0.08);
}

.coding-status-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 1.7px;
  text-transform: uppercase;
  color: #8b96a8;
}

.coding-status-message {
  margin: 0;
  flex: 1 1 220px;
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--navy);
}

@keyframes codingRobotBlinkVertical {
  0%,
  88%,
  100% {
    transform: scaleY(1);
  }

  90%,
  94% {
    transform: scaleY(0.14);
  }
}

@keyframes codingRobotBlinkHorizontal {
  0%,
  88%,
  100% {
    transform: scaleX(1);
  }

  90%,
  94% {
    transform: scaleX(0.14);
  }
}

@keyframes codingRobotBump {
  0% {
    transform: translate(-50%, -50%);
  }

  25% {
    transform: translate(calc(-50% - 5px), -50%);
  }

  50% {
    transform: translate(calc(-50% + 4px), -50%);
  }

  75% {
    transform: translate(calc(-50% - 3px), -50%);
  }

  100% {
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 960px) {
  .coding-shell {
    grid-template-columns: 1fr;
  }

  .coding-copy p,
  .coding-copy h2 {
    max-width: none;
  }
}

@media (max-width: 720px) {
  .coding-lab {
    padding: 52px 16px;
  }

  .coding-board-card {
    padding: 18px;
  }

  .coding-stage {
    --pad-button-size: clamp(48px, 10vw, 58px);
    grid-template-columns: 1fr;
  }

  .coding-console {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: stretch;
    gap: 12px;
    width: 100%;
    max-width: 430px;
    justify-self: center;
  }

  .coding-sequence-panel {
    min-height: 100%;
  }

  .coding-board-panel {
    width: min(100%, 430px);
    justify-self: center;
  }

  .coding-obstacle {
    width: min(58px, calc(100% / var(--code-cols) - 18px));
  }
}

@media (max-width: 540px) {
  .coding-toolbar {
    align-items: stretch;
  }

  .coding-mission-chip,
  .coding-reset {
    width: 100%;
    justify-content: center;
  }

  .coding-help-toggle {
    padding: 13px 14px;
    font-size: 0.76rem;
    letter-spacing: 1.4px;
  }

  .coding-help-body {
    padding: 0 14px 14px;
  }

  .coding-tag {
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  .coding-status-panel {
    gap: 2px 8px;
    margin-top: 8px;
    padding-top: 10px;
  }

  .coding-status-message {
    font-size: 0.84rem;
  }

  .coding-pad {
    width: 100%;
  }

  .coding-pad-button {
    min-height: var(--pad-button-size);
    border-radius: 16px;
  }

  .coding-stage {
    --pad-button-size: clamp(40px, 11vw, 50px);
    --pad-gap: 6px;
    --pad-shell-padding: 8px;
  }

  .coding-console {
    gap: 10px;
  }

  .coding-sequence-panel {
    padding: 12px 12px 10px;
    border-radius: 22px;
    gap: 8px;
  }

  .coding-sequence-title {
    font-size: 0.66rem;
    letter-spacing: 1.4px;
  }

  .coding-sequence-empty {
    font-size: 0.75rem;
    line-height: 1.45;
  }

  .coding-sequence-meta {
    font-size: 0.74rem;
  }

  .coding-sequence-chip {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .coding-marker {
    font-size: 0.74rem;
  }

  .coding-robot {
    width: min(52px, calc(100% / var(--code-cols) - 20px));
  }
}

@media (max-width: 420px) {
  .coding-stage {
    --pad-button-size: clamp(36px, 10.6vw, 44px);
    --pad-gap: 5px;
    --pad-shell-padding: 7px;
  }

  .coding-help-panel {
    border-radius: 22px;
  }

  .coding-console {
    gap: 8px;
  }

  .coding-sequence-panel {
    padding: 10px;
  }

  .coding-sequence-chip {
    width: 34px;
    height: 34px;
  }

  .coding-board-hint {
    font-size: 0.76rem;
  }

  .coding-robot {
    width: min(46px, calc(100% / var(--code-cols) - 18px));
  }
}
