.tower-lesson {
  --purple: #654acb;
  --cyan: #66e4bc;
}

.tower-lesson .cover-slide {
  background: radial-gradient(ellipse at 18% 28%, #eee4ff, transparent 70%),
    linear-gradient(135deg, #f8f7ff, #e9f8f4);
}

.tower-lesson .cover-grid { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
.tower-lesson .cover-copy h1 { font-size: clamp(2.35rem, 5vw, 4.5rem); }
.td-preview { width: 100%; }
#defenseGame, #mapBoard { display: block; width: 100%; height: auto; }
.td-preview .game-overlay { background: #05131ed9; padding: 1rem; }
.td-preview .game-overlay strong { font-size: clamp(1.45rem, 4vw, 3.2rem); }
.td-preview .game-overlay p { margin: .55rem 0 1rem; }
.td-preview .game-foot { font-size: .75rem; }
.td-game-note { margin: 0; padding: .55rem 1rem .75rem; min-height: 3rem; color: #b6cadd; font-size: .84rem; }

.td-pads { position: absolute; inset: 0; }
.td-pads[hidden] { display: none; }
.td-pads button {
  position: absolute;
  translate: -50% -50%;
  width: 8%;
  min-width: 24px;
  min-height: 24px;
  aspect-ratio: 1;
  border: 2px solid #6be4bf;
  border-radius: 50%;
  color: #d7ffee;
  background: #102b30;
  cursor: pointer;
  font-size: clamp(.65rem, 1.6vw, 1rem);
  font-weight: 900;
}
.td-pads button:hover, .td-pads button:focus-visible { background: #22625a; outline: 2px solid #fff; outline-offset: 3px; }
.td-pads button[aria-pressed=true] { border-color: transparent; background: transparent; color: transparent; }

.tower-lesson .td-workbench { grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr); align-items: start; }
.tower-lesson .mission-list { line-height: 1.6; }
.tower-lesson .mission-list li + li { margin-top: .55rem; }
.td-test { margin-top: 1.25rem; padding: .75rem 1rem; border-left: 3px solid var(--cyan); background: #ffffff10; }
.td-test h3, .td-test p { margin: .15rem 0; }
.td-test p { color: #d5e0ed; font-size: .94rem; line-height: 1.45; }
.td-data { margin: 0 0 .4rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; line-height: 1.55; }
.tower-lesson .hint-ladder { min-width: 0; }
.tower-lesson .hint-ladder summary { line-height: 1.35; }
.tower-lesson .hint-ladder h3 { margin: 1.25rem 0 .35rem; font-size: .92rem; }
.tower-lesson .hint-ladder h3:first-child { margin-top: .35rem; }
.tower-lesson .sb-board { max-width: 100%; }
.tower-lesson .sb-stack { width: max-content; min-width: 0; max-width: none; padding-right: .4rem; }
.tower-lesson .sb-block, .tower-lesson .sb-c-head { white-space: nowrap; font-size: .78rem; }
.tower-lesson .sb-c { width: max-content; min-width: max-content; }
.tower-lesson .sb-event, .tower-lesson .sb-control-flat, .tower-lesson .sb-c-head { color: #272007; text-shadow: none; }
.tower-lesson .sb-list, .tower-lesson .td-list-value { background: #cf5214; }
.tower-lesson .sb-my { background: #ce3f65; }
.tower-lesson .td-variable { background: #b25b00; }
.tower-lesson .td-motion-value { background: #2764b7; }
.tower-lesson .sb-operator, .tower-lesson .sb-sense { color: #142a21; text-shadow: none; }
.tower-lesson .td-else { border-radius: 0; }

.td-map { display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 250px); gap: 1rem; margin-top: 1rem; align-items: start; }
.td-map figure { margin: 0; padding: .7rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
#mapBoard { border-radius: 10px; }
.td-map figcaption { margin-top: .65rem; }
.td-map a { color: #5138a2; font-weight: 750; }
.td-coordinates { margin-top: 1rem; max-width: 33rem; }
.td-table { width: 100%; border-spacing: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.td-table caption { text-align: left; font-weight: 850; padding: 0 0 .4rem; }
.td-table th, .td-table td { text-align: left; padding: .55rem .65rem; border-bottom: 1px solid var(--line); }
.td-table thead { background: #ede8fd; }
.td-table tr:last-child > * { border-bottom: 0; }

@media (max-width: 980px) {
  .tower-lesson .cover-grid, .tower-lesson .td-workbench { grid-template-columns: 1fr; }
  .td-preview { max-width: 640px; }
}

@media (max-width: 600px) {
  .td-map { grid-template-columns: 1fr; }
  .tower-lesson .cover-copy h1 { font-size: clamp(1.7rem, 7vw, 2.45rem); overflow-wrap: anywhere; }
  .tower-lesson .scratch-rail { width: 62px; }
  .tower-lesson .scratch-stage, .tower-lesson .scratch-topbar { right: 62px; }
  .tower-lesson .next-arrow { right: 72px; }
  .td-preview .game-foot, .td-preview .game-head { gap: .35rem; padding-inline: .5rem; font-size: .61rem; }
  .td-preview .game-overlay p, .td-game-note { font-size: .75rem; }
  .td-table th, .td-table td { padding-inline: .4rem; }
}

.tower-lesson .td-menu { background: #0003; color: inherit; border-radius: 5px; }
.tower-lesson .td-menu::after { content: " ▾"; }
.tower-lesson .td-argument { background: #bf335b; }
.tower-lesson .td-bool { clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 50%, calc(100% - 7px) 100%, 7px 100%, 0 50%); padding-inline: .62rem; }
.tower-lesson .sb-var { color: #281500; text-shadow: none; }
