@import './blocks.css';

body.in-game,
.game-top-bar,
.game-layout,
.game-layout * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.in-game input,
body.in-game textarea,
.game-layout input,
.game-layout textarea {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

body.in-game ::selection,
.game-top-bar ::selection,
.game-layout ::selection {
  background: transparent !important;
}

body.in-game input::selection,
body.in-game textarea::selection,
.game-layout input::selection,
.game-layout textarea::selection {
  background: rgba(237, 193, 124, 0.45) !important;
  color: inherit !important;
}

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

.game-layout .world {
  position: relative;
  overflow: hidden;
  padding: 0;
}

.game-layout .scene {
  width: 100%;
  height: clamp(460px, 70vh, 760px);
  min-height: 460px;
}

.game-layout .world-heading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  padding: 24px 26px 12px;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(7, 16, 24, 0.7);
}

.game-layout .world-heading p {
  max-width: 460px;
}

.game-layout .world-bottom {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  padding: 14px 26px;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(7, 16, 24, 0.7);
}

.scene-tools {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
}

.scene-tools button {
  min-width: 38px;
  height: 38px;
  padding: 0;
  font-size: 20px;
}

.scene-tools #reset-view {
  font-size: 18px;
}

.scene-tools .primary {
  margin-left: 8px;
  font-size: 15px;
}

.scene-tools span {
  min-width: 42px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.program-panel .command-label,
.program-panel .block-head .command-label,
.program-panel .advanced-block>.block-head>.command-label {
  display: none !important;
}

.program-panel .command {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 9px;
  box-sizing: border-box;
}

.program-panel {
  padding: 16px 18px;
}

.program-panel .palette {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  overflow: visible;
}

.available-commands {
  margin-top: 14px;
}

.program-panel .section-label {
  justify-content: flex-end;
  gap: 8px;
  text-align: right;
  margin-bottom: 2px;
}

.program-panel #count {
  font-size: 12px;
  font-weight: 600;
  color: #c5d3dc;
  letter-spacing: 0.2px;
}

.program-panel .section-label.over-limit #count {
  color: #ff8c82 !important;
  font-weight: 700;
}

.trash-zone,
.controls button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  font-size: 20px;
}

.trash-zone {
  display: block;
}

.program-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.program-panel .program,
.program-panel .loop-body {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
}

.program-panel .program {
  gap: 6px;
  padding: 10px;
  min-height: calc(5 * 48px + 4 * 6px + 22px); /* 286px — мінімальна висота на 5 блоків команд */
  box-sizing: border-box;
}

.program-panel .block-head {
  min-height: 22px;
  position: relative;
  justify-content: flex-start;
}

.program-panel .block-head .icon {
  margin: 0;
}

.program-panel .block-head .block-number {
  position: absolute;
  left: 34px;
  margin-left: 0;
}

.program-panel .block-remove {
  width: 18px;
  min-width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: #e78682;
  font-size: 16px;
  line-height: 16px;
}

.program-panel .block-head .block-remove {
  position: absolute;
  right: 0;
  margin-left: 0;
}

.program-panel .loop-times {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  position: absolute;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.program-panel .loop-times>span {
  min-width: 28px;
  color: #e5d6ff;
  text-align: center;
}

.program-panel .loop-times button {
  width: 20px;
  min-width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid #6d6280;
  color: #d9c8f7;
  font-size: 14px;
  line-height: 18px;
}

.program-panel .block-remove:hover {
  color: #ffaaa3;
  background: #542d32;
}

.program-panel .block {
  width: 100%;
  padding: 8px;
}

.program-panel .program:not(:empty)::after {
  content: 'Поклади';
  display: flex;
  flex: 0 0 48px;
  align-items: center;
  justify-content: center;
  border: 1px dashed #4b6371;
  border-radius: 8px;
  color: #819bab;
  font-size: 12px;
}

.program-panel .loop-body {
  margin-left: 14px;
  min-width: 0;
  gap: 10px;
  padding: 8px;
}

.program-panel .loop-body:empty::before {
  display: block;
  width: 100%;
  padding: 12px 4px;
  color: #819bab;
  content: 'Поклади';
  text-align: center;
}

.program-panel .program:empty::before {
  content: 'Поклади';
}

.trash-zone {
  flex: 1;
  width: auto;
  margin-top: 0;
  border: 1px dashed #8b6262;
  background: #291f24;
  color: #e8b1a8;
}

.trash-zone.drop-target {
  border-color: #ef9b8e;
  background: #4a2930;
  box-shadow: 0 0 0 2px #ef9b8e44;
}

.win,
[data-theme="light"] .win {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 0 12px 0;
  display: flex;
  justify-content: center;
}

.win[hidden] {
  display: none !important;
}

@keyframes winSlideIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.win:not([hidden]) {
  animation: winSlideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes pulseNextStreet {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.45), 0 0 0 0 rgba(52, 211, 153, 0.65);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.025);
    box-shadow: 0 6px 26px rgba(16, 185, 129, 0.8), 0 0 18px 4px rgba(74, 222, 128, 0.55), 0 0 0 8px rgba(52, 211, 153, 0);
    filter: brightness(1.12);
  }
}

.win .next-street {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 24px;
  border: 1px solid #34d399;
  border-radius: 10px;
  background: linear-gradient(135deg, #22c55e, #10b981, #059669);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-decoration: none;
  text-shadow: 0 1px 3px rgba(0, 40, 20, 0.5);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.45);
  animation: pulseNextStreet 1.6s ease-in-out infinite;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.win .next-street:hover {
  background: linear-gradient(135deg, #4ade80, #22c55e, #10b981);
  border-color: #6ee7b7;
  color: #ffffff;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 30px rgba(16, 185, 129, 0.85), 0 0 20px 6px rgba(74, 222, 128, 0.6);
  animation: pulseNextStreet 1.2s ease-in-out infinite;
}

.confetti-ribbon {
  position: absolute;
  top: -48px;
  left: var(--x);
  z-index: 4;
  width: var(--width);
  height: var(--height);
  border-radius: 2px;
  pointer-events: none;
  transform-origin: center center;
  perspective: 520px;
  transform-style: preserve-3d;
  will-change: top, transform, opacity;
  animation: ribbon-fall var(--duration) linear var(--delay) forwards;
}

@keyframes ribbon-fall {
  0% {
    top: -48px;
    opacity: 0;
    transform: translate3d(0, 0, 0) rotateZ(0deg) rotateX(0deg) rotateY(0deg);
  }

  8% {
    opacity: 1;
  }

  45% {
    transform: translate3d(calc(var(--sway) * -.35), 0, 0) rotateZ(calc(var(--spin) * .35)) rotateX(calc(var(--flip) * .35)) rotateY(calc(var(--flip) * -.2));
  }

  90% {
    top: calc(100% - 20px);
    opacity: 1;
    transform: translate3d(var(--sway), 0, 0) rotateZ(calc(var(--spin) * .8)) rotateX(calc(var(--flip) * .8)) rotateY(calc(var(--flip) * -.6));
  }

  100% {
    top: calc(100% + var(--height) + 48px);
    opacity: 0;
    transform: translate3d(calc(var(--sway) * 1.2), 0, 0) rotateZ(var(--spin)) rotateX(var(--flip)) rotateY(var(--flip));
  }
}

.program-actions .controls {
  margin-top: 0;
}

.program-panel .command .icon,
.program-panel .block-head .icon {
  color: var(--gold);
  font-size: 19px;
}

.program-panel .icon svg,
.program-panel .command svg,
.program-panel .block svg,
.program-panel .block-head svg,
.drag-floating svg,
.insertion-preview svg {
  display: block;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.program-panel .command {
  border-color: color-mix(in srgb, var(--command-color) 52%, #263944);
  background: color-mix(in srgb, var(--command-color) 16%, #1b2b35);
}

.program-panel .command:hover {
  background: color-mix(in srgb, var(--command-color) 25%, #1b2b35);
}

.program-panel .command-forward,
.program-panel .block.command-forward {
  --command-color: #73c6bb;
}

.program-panel .command-left,
.program-panel .block.command-left {
  --command-color: #91b9ef;
}

.program-panel .command-right,
.program-panel .block.command-right {
  --command-color: #e69a9a;
}

.program-panel .command-jump,
.program-panel .block.command-jump {
  --command-color: #e7b36b;
}

.program-panel .command-light,
.program-panel .block.command-light {
  --command-color: #f0cf78;
}

.program-panel .command-loop,
.program-panel .block.command-loop {
  --command-color: #c5a2e8;
}

.program-panel .command-if,
.program-panel .block.command-if {
  --command-color: #e5ba77;
}

.program-panel .command-while,
.program-panel .block.command-while {
  --command-color: #c5a2e8;
}

.program-panel .command-call,
.program-panel .block.command-call {
  --command-color: #8abfee;
}

.program-panel .command-take,
.program-panel .block.command-take {
  --command-color: #ffd043;
}

.program-panel .command-fix,
.program-panel .block.command-fix {
  --command-color: #e09653;
}

.program-panel .command-grip {
  display: none;
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Advanced level styles & block components */
.advanced-level {
  grid-template-columns: minmax(0, 1fr) 460px;
}

.advanced-level .program-panel {
  min-width: 0;
}

.program-panel .command-if {
  --command-color: #e5ba77;
}

.program-panel .command-while {
  --command-color: #c5a2e8;
}

.program-panel .command-call {
  --command-color: #8abfee;
}

.program-panel .command-take {
  --command-color: #ffd043;
}

.program-panel .command-fix {
  --command-color: #e09653;
}

.program-panel .advanced-block {
  min-width: 0 !important;
  max-width: 100%;
  background: linear-gradient(145deg, color-mix(in srgb, var(--command-color) 12%, #1b2832), #142028);
  border-color: color-mix(in srgb, var(--command-color) 38%, #364a59);
  border-left: 4.5px solid var(--command-color);
  border-radius: 10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  padding: 10px;
}

.program-panel .advanced-block>.block-head {
  padding-right: 24px;
}

.program-panel .advanced-block>.block-head>.icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--command-color) 22%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--command-color);
}

.program-panel .advanced-block select,
.program-panel .advanced-block input {
  width: auto;
  min-width: 0;
  max-width: 100%;
  font-size: 11px;
  padding: 6px;
}

.program-panel .advanced-block>select {
  margin: 10px 0 0;
  width: 100%;
}

.program-panel .advanced-block .code-body {
  min-width: 0;
  margin: 8px 0 0;
  padding: 8px;
}

.if-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 7px 0 3px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(14, 22, 29, 0.7);
  border: 1px solid #334755;
}

.if-header .condition-editor {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 0;
}

.add-else-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  min-height: 26px;
  background: #1d2c38;
  border: 1px solid #3a5062;
  color: #e5ba77;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.add-else-btn:hover {
  background: #2a3e4e;
  border-color: #e5ba77;
  box-shadow: 0 0 8px rgba(229, 186, 119, 0.3);
}

.else-section {
  margin-top: 9px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(22, 28, 36, 0.4);
  border-top: 1.5px dashed #523f4c;
}

.else-section .code-body {
  border-left-color: #e69a9a;
}

.else-title {
  font-size: 11px;
  font-weight: 600;
  color: #e69a9a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.remove-else-btn {
  font-size: 9.5px;
  padding: 2px 8px;
  min-height: 22px;
  background: #362024;
  border: 1px solid #5d333a;
  color: #ffaaa3;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.remove-else-btn:hover {
  background: #4d242a;
  border-color: #ff7e72;
}

.condition-editor {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid #4a5c6b;
  border-radius: 6px;
  background: #14232d;
  margin: 6px 0;
}

.condition-editor select {
  font-size: 11.5px;
  font-weight: 550;
  padding: 4px 8px;
  border-radius: 6px;
  background: #111e27;
  border: 1px solid #3c5466;
  color: #f5e2be;
  cursor: pointer;
}

.not-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  min-height: 26px;
  border-radius: 6px;
  background: #1b2833;
  border: 1px solid #3d5161;
  color: #8ea2b0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.not-btn.selected {
  background: #785426;
  border-color: #e5ba77;
  color: #ffe5b8;
  box-shadow: 0 0 8px rgba(229, 186, 119, 0.35);
}

.condition-editor .value-editor {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.value-editor>select {
  flex: 1;
}

.value-editor input {
  width: 75px !important;
}

.branch {
  margin-top: 8px;
}

.branch-title {
  font-size: 10px;
  color: #d7ba85;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}

.branch-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.program-panel .body-caption {
  display: none !important;
}

.program-panel .code-body.selected {
  outline: 2px solid #ad98cf;
  outline-offset: 1px;
}

.program-panel .code-body:empty:before {
  font-size: 10.5px;
  content: 'Перетягни команду сюди';
  white-space: normal;
  text-align: center;
  display: block;
  padding: 8px 4px;
}

.code-library:empty {
  display: none;
}

.code-library {
  margin-top: 14px;
}

.library-section {
  border-top: 1px solid #3f535e;
  padding-top: 12px;
  margin-top: 12px;
}

.library-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: #abc3d1;
}

.library-heading button {
  font-size: 10px;
  padding: 6px 9px;
}

.function-card {
  background: #15232d;
  border: 1px solid #3e5462;
  border-radius: 8px;
  padding: 10px;
  margin-top: 9px;
}

.function-card>input {
  width: 65%;
  font-size: 11px;
}

.function-card>button {
  font-size: 9px;
  padding: 5px;
  margin: 4px 0;
}

.function-card .code-body {
  margin-left: 0 !important;
  min-width: 0 !important;
}

@media (max-width: 1100px) {
  .advanced-level {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Premium game-top-bar */
.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 16px;
  padding: 8px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(22, 35, 45, 0.9), rgba(16, 25, 33, 0.95));
  border: 1px solid #293d4c;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
}

.game-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 8px;
  background: #1d2c38;
  border: 1px solid #364e5f;
  color: #c5d7e4;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.game-back-btn:hover {
  background: #273c4d;
  border-color: var(--gold);
  color: #ffffff;
  transform: translateX(-2px);
  box-shadow: 0 0 10px rgba(237, 193, 124, 0.2);
}

.game-level-name {
  font-size: 15px;
  font-weight: 650;
  color: #f0f4f8;
  letter-spacing: -0.2px;
  padding-right: 4px;
}

@media (max-width: 740px) {
  .game-top-bar {
    gap: 8px;
    padding: 8px 12px;
  }

  .game-level-name {
    font-size: 13.5px;
  }
}

.speed-btn {
  flex: none;
  padding: 5px 12px;
  border-radius: 20px;
  background: #1d2c38;
  border: 1px solid #364e5f;
  color: #8db4cc;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  min-width: 42px;
  text-align: center;
}

.speed-btn:hover {
  background: #273c4d;
  border-color: var(--gold);
  color: var(--gold);
}

.speed-btn:active {
  transform: scale(0.95);
}

/* Run button above program */
.program-run-bar {
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.program-panel #run {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f5cb7b, #e0ad58);
  border: 1px solid var(--gold);
  color: #211c10;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  box-shadow: 0 3px 14px rgba(237, 193, 124, 0.28);
  transition: all 0.18s ease;
  cursor: pointer;
}

.program-panel #run:hover:not(:disabled) {
  background: linear-gradient(135deg, #fae0a2, #e8b663);
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(237, 193, 124, 0.42);
}

.program-panel #run:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(237, 193, 124, 0.2);
}

.program-panel #run:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.run-icon {
  font-size: 14px;
}

.program-run-bar #reset {
  flex: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s ease;
}

.program-run-bar #reset:hover {
  color: var(--text);
  background: var(--hover);
  border-color: var(--accent);
}

.program-run-bar #reset:active {
  transform: translateY(1px);
}

/* Light Theme game overrides */
[data-theme="light"] .game-top-bar {
  background: linear-gradient(135deg, #ffffff, #f7f8fa);
  border-color: #dfe3e7;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .game-back-btn {
  background: #f1f3f5;
  border-color: #dce0e5;
  color: #1e242b;
}

[data-theme="light"] .game-back-btn:hover {
  background: #e7ebef;
  border-color: #df9825;
  color: #111a22;
  box-shadow: 0 0 10px rgba(223, 152, 37, 0.18);
}

[data-theme="light"] .game-level-name {
  color: #162633;
}

[data-theme="light"] .scene-tools button {
  background: rgba(255, 255, 255, 0.95);
  border-color: #dce0e5;
  color: #172733;
}

[data-theme="light"] .scene-tools button:hover {
  background: #ffffff;
  border-color: #df9825;
}

[data-theme="light"] #zoom-value {
  color: #172733;
  background: rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .trash-zone {
  background: #fdf2f0;
  border-color: #eecbc6;
  color: #c94432;
}

[data-theme="light"] .trash-zone:hover {
  background: #fae4e0;
}

[data-theme="light"] .if-header {
  background: #f4f5f7;
  border-color: #dce0e5;
}

[data-theme="light"] .condition-editor {
  background: #ffffff;
  border-color: #dce0e5;
}

[data-theme="light"] .condition-editor select {
  background: #f4f5f7;
  border-color: #dce0e5;
  color: #172733;
}

[data-theme="light"] .not-btn {
  background: #f4f5f7;
  border-color: #dce0e5;
  color: #556e80;
}

[data-theme="light"] .not-btn.selected {
  background: #e8a93a;
  border-color: #df9825;
  color: #1b1608;
}

[data-theme="light"] .program-panel .command {
  background: #ffffff;
  border-color: #dce0e5;
  color: #162633;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .program-panel .command:hover {
  background: #f5f6f8;
  border-color: #c7cbd1;
}

[data-theme="light"] .program-panel .block {
  background: #ffffff;
  border-color: #dce0e5;
  color: #162633;
}

[data-theme="light"] .program-panel .block-head button {
  color: #677d8e;
}

[data-theme="light"] .program-panel .block-head button:hover {
  color: #c94432;
}

/* Light Theme scene text styling - clean, crisp, pleasant */
[data-theme="light"] .game-layout .world-heading {
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.95), 0 0 14px rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .game-layout .world-heading .eyebrow {
  color: #a05a00;
  font-weight: 750;
  letter-spacing: 2px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .game-layout .world-heading p {
  color: #172c3d;
  font-weight: 550;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.95), 0 0 10px rgba(255, 255, 255, 0.6);
}

[data-theme="light"] .game-layout .world-bottom {
  color: #1c3547;
  font-weight: 550;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.95), 0 0 14px rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .game-layout .world-bottom .lamp-count {
  color: #a05a00;
  font-weight: 750;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .program-panel #count {
  color: #4b6375;
}

[data-theme="light"] .program-panel .section-label.over-limit #count {
  color: #dc2626 !important;
}

@keyframes pulseNextStreetLight {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 16px rgba(22, 163, 74, 0.4), 0 0 0 0 rgba(34, 197, 94, 0.55);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.025);
    box-shadow: 0 6px 24px rgba(22, 163, 74, 0.7), 0 0 16px 3px rgba(34, 197, 94, 0.5), 0 0 0 8px rgba(34, 197, 94, 0);
    filter: brightness(1.08);
  }
}

[data-theme="light"] .win .next-street {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border: 1px solid #22c55e;
  color: #ffffff;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.4);
  animation: pulseNextStreetLight 1.6s ease-in-out infinite;
}

[data-theme="light"] .win .next-street:hover {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-color: #4ade80;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 28px rgba(22, 163, 74, 0.75), 0 0 18px 4px rgba(34, 197, 94, 0.55);
  animation: pulseNextStreetLight 1.2s ease-in-out infinite;
}

@media (max-width: 900px) {
  .game-layout,
  .game-layout.advanced-level {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 740px) {
  .game-top-bar {
    min-width: 0;
    flex-wrap: wrap;
    margin: 0 0 10px;
  }

  .game-back-btn { min-height: 44px; }
  .game-level-name { min-width: 0; overflow-wrap: anywhere; }
  .game-layout { gap: 12px; }

  .game-layout .scene {
    height: clamp(330px, 50svh, 480px);
    min-height: 330px;
  }

  .game-layout .world-heading { padding: 12px 14px 8px; }
  .game-layout .world-heading p { max-width: 90%; font-size: 12px; line-height: 1.35; }
  .game-layout .world-bottom { padding: 10px 14px; font-size: 11px; }

  .scene-tools {
    top: auto;
    right: 10px;
    bottom: 46px;
    gap: 5px;
  }

  .scene-tools button { min-width: 40px; height: 40px; }
  .program-panel { padding: 14px; min-width: 0; }
  .program-panel .palette { gap: 8px; }
  .program-panel .command { width: 48px; height: 48px; min-width: 48px; min-height: 48px; }
  .program-panel .program { min-height: calc(5 * 48px + 4 * 6px + 22px); }
  .program-panel .program:not(:empty)::after { flex-basis: 48px; }
  .program-panel .advanced-block { min-width: 0; max-width: 100%; }
  .program-panel .condition-editor select { max-width: 100%; }
}

@media (max-width: 380px) {
  .game-level-name { flex: 1 1 100%; }
  .scene-tools { right: 6px; gap: 3px; }
  .scene-tools button { min-width: 38px; height: 38px; }
  .program-panel { padding: 12px; }
}

.game-help-open { flex: none; min-height: 40px; padding: 7px 12px; color: var(--gold); }
.game-help-card {
  position: sticky;
  top: 8px;
  z-index: 8;
  max-width: 640px;
  width: min(640px, calc(100% - 24px));
  margin: 0 auto 14px;
  padding: 16px 18px;
  border: 1px solid #49d985;
  border-radius: 14px;
  background: #17242e;
  box-shadow: 0 14px 34px #00000080;
  box-sizing: border-box;
  max-height: min(520px, calc(100vh - 100px));
  overflow-y: auto;
}
.game-help-heading, .game-help-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-help-heading { font-size: 14.5px; font-weight: 700; color: var(--gold); }
.game-help-heading span { font-size: 12px; color: var(--muted); }
.game-help-card p {
  margin: 10px 0 14px;
  color: #e5edf0;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}
.game-help-actions { justify-content: flex-end; }
.game-help-actions button { min-height: 38px; }
.help-focus {
  position: relative;
  z-index: 6;
  outline: 3px solid #36dd78 !important;
  outline-offset: 4px;
  border-radius: 8px;
  animation: help-pulse 1.3s ease-in-out infinite;
}
@keyframes help-pulse {
  0%, 100% { outline-color: #22c765; box-shadow: 0 0 0 2px #22c76555, 0 0 10px #22c76566; }
  50% { outline-color: #a3ffd0; box-shadow: 0 0 0 7px #31e47b77, 0 0 24px #31e47baa; }
}
@media (prefers-reduced-motion: reduce) {
  .help-focus { animation: none; box-shadow: 0 0 0 4px #31e47b77; }
}
[data-theme="light"] .game-help-card { background: #fffdf7; border-color: #dca34d; box-shadow: 0 10px 25px #24354124; }
[data-theme="light"] .game-help-card p { color: #223440; }
[data-theme="light"] .game-help-heading { color: #985a08; }

@media (max-width: 740px) {
  .game-help-card { top: 4px; margin: 0 0 10px; padding: 12px 14px; max-height: calc(100vh - 70px); }
  .game-help-card p { font-size: 13px; line-height: 1.5; }
  .game-help-open { min-height: 44px; }
}
