/* Mini gra: uruchom obwod */
.circuit-lab {
  background: linear-gradient(180deg, #fff 0%, #f4ecde 100%);
  padding: 64px 24px;
  position: relative;
  overflow: hidden;
}

.circuit-lab::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(232, 160, 32, 0.12), transparent 28%),
    radial-gradient(circle at 85% 18%, rgba(30, 136, 229, 0.08), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(26, 45, 79, 0.03) 100%);
  pointer-events: none;
}

.circuit-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;
}

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

.circuit-copy h2 span {
  color: var(--gold);
}

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

.circuit-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;
}

.circuit-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);
}

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

.circuit-help-toggle::after {
  content: '+';
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(232, 160, 32, 0.14);
  color: #a56609;
  font-size: 1rem;
  line-height: 1;
}

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

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

.circuit-description {
  display: grid;
  gap: 10px;
  max-width: 540px;
}

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

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

.circuit-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);
}

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

.circuit-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;
}

.circuit-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;
}

.circuit-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);
}

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

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

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

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

.circuit-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-chip,
.board-reset {
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, color 0.2s;
}

.mode-chip {
  background: rgba(26, 45, 79, 0.08);
  color: var(--navy);
}

.mode-chip.is-active {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 10px 24px rgba(26, 45, 79, 0.24);
}

.board-reset {
  background: var(--gold);
  color: var(--navy);
  box-shadow: 0 8px 20px rgba(232, 160, 32, 0.24);
}

.mode-chip:hover,
.board-reset:hover {
  transform: translateY(-2px);
}

.circuit-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);
}

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

.circuit-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);
}

.circuit-board {
  --circuit-board-scale: 1;
  --circuit-scene-height: 500px;
  position: relative;
  min-height: 500px;
  border-radius: 30px;
  overflow: hidden;
  background: linear-gradient(180deg, #fafdff 0%, #eef4fb 100%);
  border: 1px solid rgba(26, 45, 79, 0.08);
}

.circuit-board-scene {
  position: relative;
  width: 100%;
  min-height: inherit;
  height: 100%;
  z-index: 1;
}

.circuit-board,
.circuit-board .module-label,
.circuit-board .module-note,
.circuit-board .board-hint,
.circuit-board .terminal {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.circuit-board::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(26, 45, 79, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 45, 79, 0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.65;
  pointer-events: none;
}

.circuit-board::after {
  content: '';
  position: absolute;
  inset: 12px;
  z-index: 0;
  border-radius: 24px;
  border: 1px dashed rgba(26, 45, 79, 0.08);
  pointer-events: none;
}

.circuit-wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.wire-path,
.wire-preview {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wire-path {
  stroke-width: 4.4;
  filter: drop-shadow(0 5px 12px rgba(26, 45, 79, 0.2));
}

.wire-preview {
  stroke: rgba(26, 45, 79, 0.36);
  stroke-width: 3.4;
  stroke-dasharray: 5 6;
  opacity: 0;
}

.circuit-module {
  position: absolute;
  border-radius: 24px;
  padding: 20px 18px 22px;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}

.circuit-module::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(26, 45, 79, 0.08);
  box-shadow: 0 16px 32px rgba(26, 45, 79, 0.09);
  pointer-events: none;
}

.circuit-module > * {
  position: relative;
  z-index: 2;
}

.module-label {
  position: absolute;
  top: 20px;
  left: 18px;
  right: 18px;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  line-height: 1.18;
  color: #8692a6;
  overflow-wrap: anywhere;
}

.module-note {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 22px;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.24;
  color: #5e6b7e;
  margin: 0;
  overflow-wrap: anywhere;
}

.battery-module {
  left: 34px;
  top: 214px;
  width: 156px;
  height: 214px;
}

.battery-visual {
  position: absolute;
  top: 58px;
  left: 50%;
  width: 82px;
  height: 120px;
  margin: 0;
  transform: translateX(-50%);
  border-radius: 24px;
  background: linear-gradient(180deg, #ff8f70 0%, #ff6b57 100%);
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.12), 0 12px 24px rgba(255, 107, 87, 0.18);
}

.battery-cap {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 34px;
  height: 16px;
  transform: translateX(-50%);
  border-radius: 8px 8px 0 0;
  background: #cfd8e4;
}

.battery-band {
  position: absolute;
  inset: 18px 12px;
  border-radius: 16px;
  border: 3px solid rgba(255, 255, 255, 0.28);
}

.switch-module {
  left: 50%;
  top: 34px;
  width: 248px;
  height: 176px;
  transform: translateX(-50%);
  text-align: center;
}

.switch-toggle {
  position: absolute;
  top: 46px;
  left: 50%;
  display: block;
  width: 124px;
  height: 74px;
  margin: 0;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #1d3153 0%, #152743 100%);
  border: none;
  border-radius: 22px;
  cursor: pointer;
  box-shadow: inset 0 -8px 12px rgba(0, 0, 0, 0.16), 0 12px 24px rgba(26, 45, 79, 0.22);
}

.switch-contact {
  position: absolute;
  top: 34px;
  width: 22px;
  height: 8px;
  border-radius: 999px;
  background: #b2c0d4;
}

.switch-contact-left {
  left: 14px;
}

.switch-contact-right {
  right: 14px;
}

.switch-arm {
  position: absolute;
  left: 32px;
  top: 34px;
  width: 52px;
  height: 8px;
  border-radius: 999px;
  background: #d7dfeb;
  transform-origin: 8px 50%;
  transform: rotate(-32deg);
  transition: transform 0.24s ease, background 0.24s ease, box-shadow 0.24s ease;
}

.switch-pivot {
  position: absolute;
  left: 26px;
  top: 28px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid #c8d2df;
}

.switch-toggle.is-on .switch-arm {
  transform: rotate(0deg);
  background: var(--green);
  box-shadow: 0 0 18px rgba(60, 184, 90, 0.4);
}

.device-module {
  right: 34px;
  top: 206px;
  width: 184px;
  height: 220px;
}

.device-showcase {
  position: absolute;
  top: 56px;
  left: 18px;
  right: 18px;
  height: 124px;
  margin: 0;
}

.device-visual {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

.device-module[data-mode="lamp"] [data-visual="lamp"],
.device-module[data-mode="fan"] [data-visual="fan"] {
  display: flex;
}

.lamp-device {
  position: relative;
  width: 102px;
  height: 128px;
}

.lamp-glow {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 92px;
  height: 92px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 229, 130, 0.6) 0%, rgba(245, 200, 66, 0.18) 58%, rgba(245, 200, 66, 0) 78%);
  filter: blur(12px);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}

.lamp-glass {
  position: absolute;
  top: 10px;
  left: 50%;
  width: 70px;
  height: 82px;
  transform: translateX(-50%);
  border-radius: 50% 50% 46% 46%;
  background: linear-gradient(180deg, #edf3fb 0%, #dae3ef 100%);
  border: 5px solid #c4cfde;
  box-shadow: inset -8px -10px 18px rgba(150, 168, 193, 0.22);
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}

.lamp-highlight {
  position: absolute;
  top: 22px;
  left: 24px;
  width: 16px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  transform: rotate(10deg);
  opacity: 0.92;
}

.lamp-filament {
  position: absolute;
  left: 50%;
  top: 56px;
  width: 30px;
  height: 12px;
  transform: translateX(-50%);
  border-bottom: 4px solid #a8b5c8;
  border-radius: 0 0 999px 999px;
  transition: border-color 0.25s, transform 0.25s;
}

.lamp-filament-support {
  position: absolute;
  top: 50px;
  width: 4px;
  height: 14px;
  border-radius: 999px;
  background: #afbccf;
  transition: background 0.25s, box-shadow 0.25s;
}

.lamp-filament-support-left {
  left: 39px;
  transform: rotate(18deg);
}

.lamp-filament-support-right {
  right: 39px;
  transform: rotate(-18deg);
}

.lamp-neck {
  position: absolute;
  top: 84px;
  left: 50%;
  width: 24px;
  height: 16px;
  transform: translateX(-50%);
  border-radius: 0 0 10px 10px;
  background: linear-gradient(180deg, #c8d2de 0%, #adb9ca 100%);
}

.lamp-socket {
  position: absolute;
  top: 96px;
  left: 50%;
  width: 34px;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 0 0 12px 12px;
  background: linear-gradient(180deg, #9eafc4 0%, #8597ae 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.lamp-socket::before,
.lamp-socket::after {
  content: '';
  position: absolute;
  left: 5px;
  right: 5px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
}

.lamp-socket::before {
  top: 7px;
}

.lamp-socket::after {
  top: 13px;
}

.lamp-tip {
  position: absolute;
  top: 118px;
  left: 50%;
  width: 8px;
  height: 10px;
  transform: translateX(-50%);
  border-radius: 0 0 999px 999px;
  background: #96a8bf;
}

.fan-device {
  position: relative;
  width: 96px;
  height: 112px;
}

.fan-ring {
  position: absolute;
  top: 14px;
  left: 50%;
  width: 72px;
  height: 72px;
  transform: translateX(-50%);
  border-radius: 50%;
  border: 6px solid #cad4e3;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.fan-blades {
  position: absolute;
  top: 15px;
  left: 50%;
  width: 70px;
  height: 70px;
  transform: translateX(-50%);
  transform-origin: 50% 50%;
}

.fan-blade {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 30px;
  margin-left: -9px;
  margin-top: -28px;
  border-radius: 18px 18px 8px 8px;
  background: linear-gradient(180deg, #9fb0c9 0%, #d7dfeb 100%);
  transform-origin: 50% 28px;
}

.fan-blade:nth-child(2) {
  transform: rotate(120deg);
}

.fan-blade:nth-child(3) {
  transform: rotate(240deg);
}

.fan-hub {
  position: absolute;
  top: 50px;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border-radius: 50%;
  background: #8ea0b8;
  z-index: 2;
}

.fan-stand {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 12px;
  height: 26px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #8ea0b8;
}

.fan-base {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 56px;
  height: 12px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #8ea0b8;
}

.device-module.is-active .lamp-glow {
  opacity: 1;
  transform: translateX(-50%) scale(1.08);
  animation: pulseGlow 1.6s ease-in-out infinite;
}

.device-module.is-active .lamp-glass {
  background: linear-gradient(180deg, #fff4ba 0%, #ffe07d 100%);
  border-color: #f5c842;
  box-shadow: inset -8px -10px 18px rgba(255, 196, 35, 0.22), 0 0 28px rgba(245, 200, 66, 0.45);
  transform: translateX(-50%) scale(1.03);
}

.device-module.is-active .lamp-filament {
  border-color: #d98d00;
  transform: translateX(-50%) scale(1.06);
}

.device-module.is-active .lamp-filament-support {
  background: #d7a641;
  box-shadow: 0 0 10px rgba(245, 200, 66, 0.26);
}

.device-module.is-active .fan-blades {
  animation: spin 1s linear infinite;
}

.device-module.is-active .fan-ring {
  border-color: rgba(60, 184, 90, 0.5);
  box-shadow: 0 0 0 10px rgba(60, 184, 90, 0.08);
}

.terminal {
  position: absolute;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 3px solid var(--navy);
  background: #fff;
  color: var(--navy);
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 900;
  cursor: pointer;
  z-index: 3;
  box-shadow: 0 12px 24px rgba(26, 45, 79, 0.14);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background 0.2s, color 0.2s;
}

.terminal:hover {
  transform: scale(1.08);
}

.terminal.is-selected {
  background: var(--gold);
  border-color: var(--gold2);
  color: var(--navy);
  box-shadow: 0 0 0 10px rgba(232, 160, 32, 0.18);
}

.terminal.is-connected {
  border-color: var(--green);
  background: #fff;
}

.terminal-positive {
  right: -19px;
  top: 48px;
}

.terminal-negative {
  right: -19px;
  bottom: 48px;
}

.switch-module .terminal[data-terminal="switch_left"] {
  left: -19px;
  top: 78px;
}

.switch-module .terminal[data-terminal="switch_right"] {
  right: -19px;
  top: 78px;
}

.device-module .terminal:first-of-type {
  left: -19px;
  top: 50px;
}

.device-module .terminal:last-of-type {
  left: -19px;
  bottom: 50px;
}

.terminal-neutral {
  color: transparent;
}

.board-hint {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 12px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: #66758a;
  z-index: 2;
}

@keyframes spin {
  from {
    transform: translateX(-50%) rotate(0deg);
  }

  to {
    transform: translateX(-50%) rotate(360deg);
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    opacity: 0.82;
  }

  50% {
    opacity: 1;
  }
}

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

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

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

  .circuit-board-card {
    padding: 16px;
  }

  .circuit-board {
    --circuit-scene-height: 560px;
    min-height: 0;
    height: calc(var(--circuit-scene-height) * var(--circuit-board-scale));
  }

  .circuit-board-scene {
    width: 324px;
    min-height: 0;
    height: var(--circuit-scene-height);
    margin: 0 auto;
    transform: scale(var(--circuit-board-scale));
    transform-origin: top center;
  }

  .battery-module {
    left: 18px;
    top: 280px;
    width: 132px;
    height: 198px;
  }

  .switch-module {
    top: 40px;
    width: 210px;
    height: 166px;
  }

  .device-module {
    right: 18px;
    top: 272px;
    width: 144px;
    height: 204px;
  }

  .board-hint {
    left: 16px;
    right: 16px;
  }

  .board-hint {
    bottom: 10px;
  }
}

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

  .circuit-mode-switch {
    width: 100%;
  }

  .mode-chip {
    flex: 1 1 0;
  }

  .board-reset {
    width: 100%;
  }

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

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

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

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

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

  .circuit-board {
    --circuit-scene-height: 570px;
  }

  .circuit-board-scene {
    width: 324px;
  }

  .module-label {
    font-size: 0.72rem;
    letter-spacing: 1.3px;
  }

  .module-note {
    font-size: 0.74rem;
    line-height: 1.18;
  }

  .terminal {
    width: 34px;
    height: 34px;
    border-width: 2px;
    font-size: 0.86rem;
  }

  .terminal-positive {
    right: -17px;
  }

  .terminal-negative {
    right: -17px;
  }

  .switch-module .terminal[data-terminal="switch_left"] {
    left: -17px;
  }

  .switch-module .terminal[data-terminal="switch_right"] {
    right: -17px;
  }

  .device-module .terminal:first-of-type,
  .device-module .terminal:last-of-type {
    left: -17px;
  }

  .battery-module .module-note,
  .device-module .module-note {
    text-align: center;
  }

  .battery-module {
    left: 12px;
    top: 292px;
    width: 122px;
  }

  .device-module {
    right: 12px;
    top: 300px;
    width: 128px;
  }

  .switch-module {
    top: 48px;
    width: 194px;
  }

}

@media (max-width: 420px) {
  .circuit-help-panel {
    border-radius: 22px;
  }

  .module-label {
    font-size: 0.68rem;
    letter-spacing: 1.1px;
  }

  .module-note {
    font-size: 0.7rem;
  }
}
