:root {
    --ink: #17223b;
    --muted: #768198;
    --line: #e8ebf2;
    --panel: #ffffff;
    --page: #f5f7fb;
    --purple: #7657e8;
    --purple-dark: #5f43d3;
    --orange: #f08a38;
    --teal: #21a89d;
    --cell-size: min(6.25vw, 68px);
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 4% 4%, rgba(118, 87, 232, 0.08), transparent 25rem),
        var(--page);
    font-family: "Nunito", system-ui, sans-serif;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

.app-shell {
    width: min(1540px, calc(100% - 48px));
    margin: 0 auto;
    padding-bottom: 40px;
}

.topbar {
    width: min(1540px, calc(100% - 48px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 82px;
    border-bottom: 1px solid var(--line);
}

.topbar__note {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.brand {
    display: inline-flex;
    gap: 12px;
    align-items: center;
    color: var(--ink);
    font-size: 22px;
    font-weight: 900;
    text-decoration: none;
}

.brand__mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: white;
    border-radius: 13px 13px 13px 5px;
    background: linear-gradient(145deg, #8d70f1, #6144d7);
    box-shadow: 0 7px 16px rgba(97, 68, 215, 0.26);
}

.topbar__actions {
    display: flex;
    gap: 10px;
}

.button {
    display: inline-flex;
    min-height: 44px;
    padding: 0 18px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 0;
    border-radius: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

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

.button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.button--ghost {
    border: 1px solid #e1e5ee;
    background: white;
}

.button--run {
    min-width: 145px;
    color: white;
    background: linear-gradient(145deg, #8769ef, #6446db);
    box-shadow: 0 8px 19px rgba(100, 70, 219, 0.25);
}

.play-icon {
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 9px solid currentColor;
}

.robot-footer {
    width: min(1200px, calc(100% - 48px));
    min-height: 120px;
    margin: 70px auto 0;
    padding: 28px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-size: 13px;
    font-weight: 700;
}

.robot-footer p {
    margin: 0;
}

.robot-footer a {
    color: var(--purple-dark);
    text-decoration: none;
}

.robot-hero,
.course-note,
.robot-levels {
    width: min(1200px, calc(100% - 48px));
    margin-inline: auto;
}

.robot-hero {
    min-height: 650px;
    padding: 72px 0 88px;
    display: grid;
    grid-template-columns: 1fr .92fr;
    align-items: center;
    gap: 80px;
}

.robot-hero h1,
.robot-section-heading h2,
.course-note h2,
.robot-rules h2 {
    margin-bottom: 0;
    font-size: clamp(44px, 5vw, 70px);
    line-height: .98;
    letter-spacing: -.055em;
}

.robot-hero h1 em {
    color: var(--purple);
    font-style: normal;
}

.robot-hero__lead {
    max-width: 620px;
    margin: 28px 0 34px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.72;
}

.robot-hero__button {
    width: fit-content;
    min-height: 52px;
    padding-inline: 23px;
    color: white;
    text-decoration: none;
}

.robot-scene {
    position: relative;
    min-height: 490px;
    overflow: hidden;
    border: 1px solid #e3def7;
    border-radius: 44% 44% 30px 30px;
    background:
        linear-gradient(rgba(118, 87, 232, .055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(118, 87, 232, .055) 1px, transparent 1px),
        #f0edfb;
    background-size: 54px 54px;
}

.robot-scene__orbit {
    position: absolute;
    inset: 66px;
    border: 1px dashed rgba(118, 87, 232, .27);
    border-radius: 50%;
}

.scene-command {
    position: absolute;
    z-index: 3;
    min-height: 66px;
    padding: 11px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    border-radius: 15px;
    box-shadow: 0 16px 32px rgba(43, 39, 79, .19), inset 0 -3px 0 rgba(0, 0, 0, .09);
    font-size: 13px;
    font-weight: 900;
}

.scene-command i {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, .17);
    font-size: 24px;
    font-style: normal;
}

.scene-command b {
    width: 32px;
    height: 31px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--purple-dark);
    background: white;
}

.scene-command--move {
    top: 80px;
    left: 35px;
    background: linear-gradient(135deg, #8668ec, #6648db);
    transform: rotate(-5deg);
}

.scene-command--turn {
    right: 30px;
    bottom: 92px;
    background: linear-gradient(135deg, #36b9ae, #16968e);
    transform: rotate(6deg);
}

.scene-robot {
    position: absolute;
    z-index: 2;
    top: 50%;
    left: 50%;
    width: 210px;
    height: 210px;
    padding: 18px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .72);
    box-shadow: 0 25px 55px rgba(64, 49, 125, .13);
    transform: translate(-50%, -45%);
}

.scene-robot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 9px 6px rgba(23, 34, 59, .2));
}

.scene-fragment,
.scene-finish {
    position: absolute;
    display: grid;
    place-items: center;
    color: #f4b51c;
    filter: drop-shadow(0 4px 2px rgba(150, 105, 0, .18));
}

.scene-fragment {
    z-index: 4;
    font-size: 27px;
}

.scene-fragment--one { top: -26px; left: 17px; transform: rotate(-17deg); }
.scene-fragment--two { top: 35px; right: -36px; transform: rotate(20deg); }
.scene-fragment--three { right: 2px; bottom: -25px; transform: rotate(-8deg); }

.scene-finish {
    right: 60px;
    top: 52px;
    width: 62px;
    height: 62px;
    border-radius: 18px;
    background: #fff1be;
    font-size: 35px;
    transform: rotate(7deg);
}

.course-note {
    padding: 55px 58px;
    display: grid;
    grid-template-columns: 150px 1fr .8fr;
    align-items: center;
    gap: 48px;
    border: 1px solid var(--line);
    border-radius: 27px;
    background: white;
    box-shadow: 0 15px 45px rgba(32, 43, 75, .05);
}

.course-note__label {
    align-self: start;
    color: var(--purple);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.course-note h2 {
    font-size: clamp(32px, 3.2vw, 46px);
}

.course-note div p {
    margin: 22px 0 0;
    color: var(--muted);
    line-height: 1.65;
}

.course-note ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.course-note li {
    padding: 15px 0;
    display: grid;
    gap: 4px;
    border-bottom: 1px solid var(--line);
}

.course-note li:last-child { border-bottom: 0; }
.course-note li strong { font-size: 14px; }
.course-note li span { color: var(--muted); font-size: 12px; }

.robot-levels {
    padding: 120px 0 130px;
}

.robot-section-heading {
    margin-bottom: 44px;
    display: grid;
    grid-template-columns: 1fr 390px;
    align-items: end;
    gap: 60px;
}

.robot-section-heading h2 {
    font-size: clamp(43px, 4.5vw, 62px);
}

.robot-section-heading > p {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.65;
}

.robot-level-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.robot-level-card {
    min-height: 495px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--ink);
    border: 1px solid #dad3f0;
    border-radius: 26px;
    background: linear-gradient(145deg, #ded7fb, #f0edfb);
    text-decoration: none;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.robot-level-card--teal { background: linear-gradient(145deg, #c9efeb, #e9f8f5); border-color: #b7ddd8; }
.robot-level-card--orange { background: linear-gradient(145deg, #fbd7b5, #fff0df); border-color: #ecc9a8; }
.robot-level-card--coral { background: linear-gradient(145deg, #f9c9bd, #ffebe6); border-color: #ebbbb0; }
.robot-level-card--blue { background: linear-gradient(145deg, #c9e4f4, #e9f5fb); border-color: #b9d7e7; }

.robot-level-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    min-height: 430px;
}

a.robot-level-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 26px 60px rgba(63, 45, 130, .14);
}

.robot-level-card__top,
.robot-level-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.robot-level-card__top span:last-child {
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .58);
}

.robot-level-card__route {
    height: 140px;
    padding: 25px 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.robot-level-card__route i {
    width: 57px;
    height: 4px;
    background: rgba(95, 67, 211, .28);
}

.robot-level-card__route i::after {
    display: block;
    width: 8px;
    height: 8px;
    margin: -2px auto 0;
    border-radius: 50%;
    background: #9b84eb;
    content: "";
}

.route-start,
.route-star {
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 16px;
    font-size: 24px;
    font-weight: 900;
}

.route-start { color: white; background: var(--purple); }
.route-star { color: #e9a514; background: #fff1b8; }

.robot-level-card__body > p {
    margin: 0 0 8px;
    color: var(--purple-dark);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.robot-level-card h3 {
    margin: 0;
    font-size: clamp(30px, 3vw, 42px);
    line-height: 1;
    letter-spacing: -.045em;
}

.robot-level-card__description {
    max-width: 490px;
    margin-top: 16px;
    display: block;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.robot-level-card__details {
    margin-top: 28px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

.robot-level-card__details > span {
    padding-right: 15px;
    display: grid;
    gap: 4px;
    border-right: 1px solid rgba(69, 48, 147, .16);
}

.robot-level-card__details > span:not(:first-child) { padding-left: 15px; }
.robot-level-card__details > span:last-child { border-right: 0; }
.robot-level-card__details small { color: var(--muted); font-size: 10px; font-weight: 800; }
.robot-level-card__details strong { font-size: 15px; }

.robot-level-card__footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(69, 48, 147, .16);
}

.robot-level-card__footer b {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: var(--purple-dark);
    font-size: 17px;
}

.robot-level-card--locked {
    color: #687188;
    border-color: var(--line);
    background: #eef0f5;
}

.locked-levels {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.locked-levels span {
    width: 75px;
    height: 75px;
    margin-left: -10px;
    display: grid;
    place-items: center;
    border: 1px solid #dce0e9;
    border-radius: 22px;
    background: rgba(255, 255, 255, .72);
    font-size: 20px;
    font-weight: 900;
    transform: rotate(-6deg);
}

.locked-levels span:nth-child(2) { z-index: 2; transform: translateY(-8px) rotate(4deg); }
.locked-levels span:nth-child(3) { transform: rotate(9deg); }
.locked-levels__text { display: block; margin-top: 25px; color: var(--muted); font-size: 14px; }

.robot-rules {
    width: min(1320px, calc(100% - 40px));
    margin: 0 auto 90px;
    padding: 75px max(60px, calc((100% - 1120px) / 2));
    display: grid;
    grid-template-columns: .85fr 1.15fr;
    gap: 90px;
    color: white;
    border-radius: 32px;
    background: #2d2750;
}

.eyebrow--light { color: #d8d0f8; }
.robot-rules h2 { font-size: clamp(38px, 4.2vw, 58px); }
.robot-rules ol { margin: 0; padding: 0; list-style: none; }
.robot-rules li { padding: 20px 0; display: grid; grid-template-columns: 50px 1fr; gap: 18px; border-bottom: 1px solid rgba(255, 255, 255, .14); }
.robot-rules li:last-child { border-bottom: 0; }
.robot-rules li > span { color: #d4c9ff; font-size: 14px; font-weight: 900; }
.robot-rules h3 { margin: 0 0 7px; font-size: 17px; }
.robot-rules li p { margin: 0; color: rgba(255, 255, 255, .62); font-size: 13px; line-height: 1.55; }

.intro {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    padding: 26px 2px 22px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--purple);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(25px, 2.4vw, 38px);
    line-height: 1.12;
}

.intro__hint {
    max-width: 440px;
    margin-bottom: 4px;
    color: var(--muted);
    text-align: right;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(230px, 0.78fr) minmax(270px, 0.95fr) minmax(520px, 1.8fr);
    gap: 16px;
    align-items: stretch;
}

.panel,
.game-column {
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--panel);
    box-shadow: 0 10px 35px rgba(32, 43, 75, 0.055);
}

.panel {
    min-height: 595px;
    padding: 20px;
}

.panel__heading,
.game-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    margin-bottom: 20px;
}

.panel__number {
    display: grid;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    place-items: center;
    color: var(--purple);
    border-radius: 11px;
    background: #f0ecff;
    font-weight: 900;
}

.panel h2,
.game-heading h2 {
    margin: 0;
    font-size: 17px;
    line-height: 1.2;
}

.panel__heading p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.palette {
    display: grid;
    gap: 13px;
}

.command {
    position: relative;
    display: flex;
    min-height: 58px;
    padding: 10px 12px;
    align-items: center;
    gap: 9px;
    color: white;
    border: 0;
    border-radius: 13px;
    font-size: 13px;
    font-weight: 800;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.1), 0 5px 11px rgba(35, 43, 78, 0.11);
    user-select: none;
}

.block-template {
    cursor: grab;
    transition: transform 150ms ease, filter 150ms ease;
}

.block-template:hover,
.block-template:focus-visible {
    z-index: 2;
    outline: none;
    filter: brightness(1.05);
    transform: translateY(-2px) rotate(-0.5deg);
}

.block-template:active {
    cursor: grabbing;
}

.command--move {
    background: linear-gradient(135deg, #8668ec, #6648db);
}

.command--left {
    background: linear-gradient(135deg, #f6a34f, #e57a2e);
}

.command--right {
    background: linear-gradient(135deg, #36b9ae, #16968e);
}

.command--wait {
    background: linear-gradient(135deg, #4d75d8, #3155b5);
}

.command--repeat {
    background: linear-gradient(135deg, #d65aa8, #b53f8e);
}

.command--end {
    color: #674369;
    border: 1px dashed #d9a9cf;
    background: #f7e8f3;
    box-shadow: none;
}

.command--end .command__grip { color: #b784ad; }
.command--end .command__icon { color: #a44587; background: #efd2e7; }

.command__grip {
    color: rgba(255, 255, 255, 0.64);
    font-size: 20px;
    line-height: 1;
}

.command__icon {
    display: grid;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.17);
    font-size: 21px;
    font-weight: 900;
}

.command__icon--turn {
    font-size: 24px;
}

.command__label {
    flex: 1;
    line-height: 1.14;
}

.command__value,
.steps-input {
    display: grid;
    width: 36px;
    height: 32px;
    place-items: center;
    color: #49359b;
    border: 0;
    border-radius: 8px;
    background: white;
    font-weight: 900;
    text-align: center;
}

.command__unit {
    color: rgba(255, 255, 255, 0.82);
    font-size: 11px;
}

.palette-tip {
    display: flex;
    gap: 9px;
    margin-top: 22px;
    padding: 13px;
    color: #657087;
    border-radius: 13px;
    background: #f7f8fc;
    font-size: 12px;
    line-height: 1.42;
}

.program-panel {
    display: flex;
    flex-direction: column;
}

.program-panel .panel__heading {
    align-items: flex-start;
}

.clear-button {
    margin-left: auto;
    padding: 6px;
    color: var(--muted);
    border: 0;
    background: transparent;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.clear-button:hover {
    color: #e05555;
}

.program-list {
    position: relative;
    display: flex;
    min-height: 475px;
    max-height: 475px;
    flex: 1;
    flex-direction: column;
    gap: 7px;
    padding: 14px;
    border: 2px dashed #dfe3ed;
    border-radius: 16px;
    background: #fafbfe;
    transition: border-color 150ms ease, background 150ms ease;
    overflow-y: auto;
    scrollbar-color: #c9c0e7 transparent;
    scrollbar-width: thin;
}

.program-list.is-over {
    border-color: #9d88ef;
    background: #f5f2ff;
}

.empty-program {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #a0a8b8;
    pointer-events: none;
    text-align: center;
}

.empty-program[hidden] {
    display: none !important;
}

.empty-program strong {
    color: #778197;
    font-size: 13px;
}

.empty-program span:last-child {
    margin-top: 3px;
    font-size: 11px;
}

.program-block {
    z-index: 1;
    flex: 0 0 auto;
    min-height: 54px;
    animation: block-in 180ms ease both;
}

.program-block:not(:last-of-type)::after {
    position: absolute;
    z-index: -1;
    bottom: -10px;
    left: 28px;
    width: 4px;
    height: 12px;
    border-radius: 4px;
    background: #c8c1e3;
    content: "";
}

.program-block.is-running {
    outline: 4px solid rgba(255, 210, 66, 0.44);
    transform: translateX(4px);
}

.program-block.command--repeat {
    margin-top: 5px;
    border-radius: 13px 13px 7px 7px;
}

.program-block.command--end {
    min-height: 44px;
    margin-bottom: 5px;
    border-radius: 7px 7px 13px 13px;
}

.program-block.is-dragging {
    opacity: 0.4;
}

.program-block .command__grip {
    cursor: grab;
}

.remove-command {
    display: grid;
    flex: 0 0 auto;
    width: 25px;
    height: 25px;
    padding: 0;
    place-items: center;
    color: white;
    border: 0;
    border-radius: 50%;
    background: rgba(29, 21, 61, 0.18);
    cursor: pointer;
    font-size: 16px;
}

.steps-input {
    appearance: textfield;
    outline: none;
}

.steps-input:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.steps-input::-webkit-inner-spin-button,
.steps-input::-webkit-outer-spin-button {
    appearance: none;
}

@keyframes block-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
}

.game-column {
    min-width: 0;
    padding: 20px;
}

.game-heading {
    justify-content: space-between;
}

.game-heading .eyebrow {
    margin-bottom: 2px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 11px;
    color: #667086;
    border: 1px solid #e6e9ef;
    border-radius: 999px;
    background: #fafbfc;
    font-size: 11px;
    font-weight: 800;
}

.status-pill__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #42bba8;
    box-shadow: 0 0 0 3px rgba(66, 187, 168, 0.13);
}

.status-pill.is-running .status-pill__dot {
    background: #f2a13b;
    box-shadow: 0 0 0 3px rgba(242, 161, 59, 0.16);
    animation: pulse 900ms ease infinite;
}

.status-pill.is-success {
    color: #167a70;
    border-color: #bfe6de;
    background: #edfaf7;
}

.status-pill.is-partial {
    color: #896316;
    border-color: #f0d994;
    background: #fff8df;
}

.status-pill.is-partial .status-pill__dot {
    background: #eebc36;
    box-shadow: 0 0 0 3px rgba(238, 188, 54, .16);
}

.game-heading__progress {
    display: flex;
    align-items: center;
    gap: 9px;
}

.fragment-score {
    min-height: 35px;
    padding: 5px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #f0dfac;
    border-radius: 999px;
    color: #8d6611;
    background: #fff9e4;
}

.fragment-score > span { color: #efb51f; font-size: 16px; }
.fragment-score small { color: #927a45; font-size: 9px; font-weight: 900; text-transform: uppercase; }
.fragment-score strong { font-size: 12px; }
.fragment-score b { font: inherit; }

@keyframes pulse {
    50% { transform: scale(1.55); }
}

.maze-wrap {
    overflow: hidden;
    padding: 9px;
    border-radius: 19px;
    background: #dfe3ed;
    box-shadow: inset 0 0 0 1px #d3d8e3;
}

.maze {
    position: relative;
    display: grid;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 10 / 8;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 1px;
    border-radius: 12px;
    background: #dfe3eb;
}

.maze__cell {
    position: relative;
    min-width: 0;
    background: #f9fafc;
}

.maze__cell::after {
    position: absolute;
    inset: 18%;
    border: 1px dashed #e2e6ee;
    border-radius: 5px;
    content: "";
}

.maze__cell--wall {
    background:
        linear-gradient(135deg, rgba(255,255,255,.075) 25%, transparent 25%) 0 0 / 14px 14px,
        linear-gradient(315deg, rgba(255,255,255,.055) 25%, transparent 25%) 0 0 / 14px 14px,
        #334159;
    box-shadow: inset 0 0 0 2px #2a364d;
}

.maze__cell--wall::after {
    display: none;
}

.maze__cell--void {
    background: #dfe3ed;
    box-shadow: none;
}

.maze__cell--void::after {
    display: none;
}

.maze__cell--start {
    background: #eaf8f5;
}

.maze__cell--start::before {
    position: absolute;
    inset: 10%;
    display: grid;
    place-items: center;
    color: #29a394;
    border: 2px dashed #8bd4ca;
    border-radius: 8px;
    content: "START";
    font-size: clamp(7px, .7vw, 10px);
    font-weight: 900;
}

.maze__cell--finish {
    background: #fff6d9;
}

.maze__cell--finish::before {
    position: absolute;
    z-index: 1;
    inset: 0;
    display: grid;
    place-items: center;
    color: #f5b720;
    content: "★";
    font-size: clamp(24px, 3vw, 42px);
    filter: drop-shadow(0 3px 2px rgba(150, 105, 0, .16));
}

.star-fragment {
    position: absolute;
    z-index: 2;
    inset: 17%;
    display: grid;
    place-items: center;
    color: #f1b51e;
    border: 1px solid #f2d36c;
    border-radius: 50% 35% 48% 40%;
    background: #fff4bf;
    box-shadow: 0 4px 9px rgba(150, 105, 0, .13);
    font-size: clamp(15px, 2vw, 26px);
    filter: drop-shadow(0 2px 1px rgba(150, 105, 0, .12));
    transform: rotate(13deg);
    transition: opacity 180ms ease, transform 180ms ease;
}

.star-fragment.is-collected {
    opacity: 0;
    transform: rotate(100deg) scale(1.8);
}

.maze__cell--laser {
    background: #f7f8fc;
}

.laser-gate {
    position: absolute;
    z-index: 3;
    inset: 8%;
    pointer-events: none;
}

.laser-gate i {
    position: absolute;
    z-index: 2;
    top: 50%;
    width: 20%;
    height: 34%;
    border: 2px solid #8e2930;
    border-radius: 4px;
    background: #d94e55;
    box-shadow: 0 2px 4px rgba(86, 15, 21, .25);
    transform: translateY(-50%);
    transition: border-color 180ms ease, background 180ms ease;
}

.laser-gate i:first-child { left: 0; }
.laser-gate i:nth-child(2) { right: 0; }

.laser-gate b {
    position: absolute;
    top: 50%;
    right: 12%;
    left: 12%;
    height: 3px;
    border-radius: 4px;
    background: #ff2635;
    box-shadow: 0 0 4px #ff2635, 0 0 10px #ff2635;
    transform: translateY(-50%);
    transition: opacity 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.laser-gate--vertical {
    transform: rotate(90deg);
}

.laser-gate.is-open i {
    border-color: #278578;
    background: #49bbaa;
}

.laser-gate.is-open b {
    opacity: .16;
    background: #3fc5b0;
    box-shadow: 0 0 4px #3fc5b0;
}

.robot {
    position: absolute;
    z-index: 4;
    top: 0;
    left: 0;
    width: calc(100% / var(--maze-columns, 10));
    height: calc(100% / var(--maze-rows, 8));
    padding: 5px;
    pointer-events: none;
    transition: left 520ms cubic-bezier(.36,.01,.25,1), top 520ms cubic-bezier(.36,.01,.25,1), transform 360ms ease;
}

.robot::after {
    position: absolute;
    right: 15%;
    bottom: 4%;
    left: 15%;
    height: 13%;
    border-radius: 50%;
    background: rgba(25, 35, 60, 0.18);
    filter: blur(3px);
    content: "";
}

.robot img {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 3px 2px rgba(23, 34, 59, 0.22));
}

.robot.is-bumped {
    animation: bump 340ms ease;
}

@keyframes bump {
    45% { filter: sepia(1) saturate(3); }
}

.robot.is-broken {
    animation: robot-break 540ms ease both;
    filter: grayscale(0.7);
}

.robot.is-zapped {
    animation: robot-zap 540ms ease both;
    filter: saturate(.4) brightness(1.3);
}

.robot.is-zapped::before {
    position: absolute;
    z-index: 3;
    inset: -12%;
    display: grid;
    place-items: center;
    color: #ffdf45;
    content: "ϟ";
    font-size: clamp(28px, 3vw, 46px);
    text-shadow: 0 0 5px #e72e3a, 0 0 12px #e72e3a;
}

@keyframes robot-zap {
    0%, 100% { transform: rotate(var(--robot-angle, 0deg)); }
    25% { transform: translateX(-4px) rotate(var(--robot-angle, 0deg)); }
    50% { transform: translateX(4px) rotate(var(--robot-angle, 0deg)); }
    75% { transform: translateX(-2px) rotate(var(--robot-angle, 0deg)); }
}

.robot.is-broken::before {
    position: absolute;
    z-index: 3;
    top: -8%;
    right: 0;
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    color: #9a3b22;
    border: 3px solid white;
    border-radius: 50%;
    background: #ffd64d;
    box-shadow: 0 3px 9px rgba(42, 27, 19, 0.25);
    content: "⚡";
    font-size: 17px;
}

@keyframes robot-break {
    0%, 100% { transform: rotate(var(--robot-angle, 0deg)); }
    20% { transform: translateX(-5px) rotate(var(--robot-angle, 0deg)); }
    40% { transform: translateX(5px) rotate(var(--robot-angle, 0deg)); }
    60% { transform: translateX(-3px) rotate(var(--robot-angle, 0deg)); }
    80% { transform: translateX(3px) rotate(var(--robot-angle, 0deg)); }
}

.legend {
    display: flex;
    justify-content: center;
    gap: 22px;
    padding-top: 14px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend__cell {
    display: grid;
    width: 15px;
    height: 15px;
    place-items: center;
    border-radius: 4px;
}

.legend__cell--start {
    border: 1px dashed #67c8bb;
    background: #eaf8f5;
}

.legend__cell--finish {
    color: #efa911;
    background: #fff3c9;
    font-size: 9px;
}

.legend__cell--fragment {
    color: #efa911;
    border: 1px solid #f0d576;
    background: #fff7d8;
    font-size: 10px;
}

.legend__cell--laser {
    position: relative;
    border: 2px solid #d94e55;
    background: #fff0f1;
}

.legend__cell--laser::after {
    position: absolute;
    right: 1px;
    left: 1px;
    top: 50%;
    height: 2px;
    background: #f02e3a;
    box-shadow: 0 0 3px #f02e3a;
    content: "";
}

.block-intro {
    width: min(760px, calc(100% - 28px));
    max-height: calc(100dvh - 28px);
    padding: 0;
    overflow: auto;
    color: var(--ink);
    border: 0;
    border-radius: 28px;
    background: white;
    box-shadow: 0 35px 100px rgba(23, 27, 56, .28);
}

.block-intro::backdrop {
    background: rgba(22, 26, 47, .58);
    backdrop-filter: blur(6px);
}

.block-intro__inner {
    position: relative;
    padding: 48px;
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 38px;
    align-items: start;
}

.block-intro__mark {
    min-height: 150px;
    padding: 18px;
    display: grid;
    place-items: center;
    color: white;
    border-radius: 28px 28px 28px 9px;
    background: linear-gradient(145deg, #8d70f1, #6144d7);
    box-shadow: 0 18px 36px rgba(97, 68, 215, .24);
    font-size: 31px;
    font-weight: 900;
    text-align: center;
}

.block-intro h2 {
    margin: 0;
    font-size: clamp(31px, 4vw, 44px);
    line-height: 1.02;
    letter-spacing: -.045em;
}

.block-intro__text {
    margin: 20px 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.65;
}

.block-intro__tip {
    padding: 13px 15px;
    display: flex;
    gap: 10px;
    border-radius: 13px;
    color: #685c40;
    background: #fff7d8;
    font-size: 13px;
    line-height: 1.5;
}

.block-intro__action {
    margin-top: 24px;
}

.block-intro__close {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 50%;
    background: white;
    cursor: pointer;
    font-size: 20px;
}

.legend__cell--wall {
    background: #334159;
}

@media (max-width: 1120px) {
    .robot-hero { gap: 38px; }
    .course-note { grid-template-columns: 1fr .8fr; }
    .course-note__label { grid-column: 1 / -1; }
    .robot-rules { gap: 45px; }

    .workspace {
        grid-template-columns: 1fr 1fr;
    }

    .game-column {
        grid-column: 1 / -1;
    }

    .panel {
        min-height: 480px;
    }

    .program-list {
        min-height: 350px;
    }
}

@media (max-width: 820px) {
    .robot-hero,
    .course-note,
    .robot-levels,
    .robot-footer {
        width: min(100% - 28px, 640px);
    }

    .robot-hero {
        min-height: 0;
        padding: 58px 0 75px;
        grid-template-columns: 1fr;
        gap: 54px;
    }

    .robot-hero h1 { font-size: clamp(47px, 12vw, 68px); }
    .robot-scene { min-height: 460px; }
    .course-note { padding: 38px 32px; grid-template-columns: 1fr; gap: 28px; }
    .course-note__label { grid-column: auto; }
    .robot-levels { padding: 90px 0; }
    .robot-section-heading { grid-template-columns: 1fr; gap: 20px; }
    .robot-level-grid { grid-template-columns: 1fr; }
    .robot-rules { width: calc(100% - 20px); padding: 55px 28px; grid-template-columns: 1fr; gap: 38px; }
}

@media (max-width: 680px) {
    .topbar {
        width: min(100% - 24px, 560px);
    }

    .app-shell {
        width: min(100% - 24px, 560px);
    }

    .topbar {
        min-height: 70px;
    }

    .brand {
        font-size: 18px;
    }

    .brand__mark {
        width: 36px;
        height: 36px;
    }

    .button {
        min-height: 40px;
        padding: 0 12px;
        font-size: 12px;
    }

    .button--run {
        min-width: 0;
    }

    .button--levels {
        width: 40px;
        padding: 0;
        font-size: 0;
    }

    .button--levels span { font-size: 16px; }

    .topbar__actions { gap: 6px; }

    .button--reset {
        width: 40px;
        padding: 0;
        font-size: 0;
    }

    .button--reset span { font-size: 16px; }

    .topbar__note { display: none; }

    .intro {
        display: block;
        padding-top: 20px;
    }

    .intro__hint {
        margin: 9px 0 0;
        text-align: left;
        font-size: 13px;
    }

    .workspace {
        display: flex;
        flex-direction: column;
    }

    .panel {
        min-height: 0;
        padding: 16px;
    }

    .program-list {
        min-height: 260px;
        max-height: 420px;
    }

    .game-column {
        order: -1;
        padding: 12px;
    }

    .game-heading {
        margin: 3px 3px 14px;
        align-items: flex-start;
    }

    .status-pill {
        max-width: 165px;
    }

    .game-heading__progress { align-items: flex-end; flex-direction: column; }

    .legend {
        gap: 12px;
        flex-wrap: wrap;
    }

    .robot-hero__lead { font-size: 16px; }
    .robot-scene { min-height: 400px; border-radius: 35% 35% 25px 25px; }
    .robot-scene__orbit { inset: 52px; }
    .scene-robot { width: 170px; height: 170px; }
    .scene-command { min-height: 57px; font-size: 11px; }
    .scene-command--move { top: 55px; left: 18px; }
    .scene-command--turn { right: 15px; bottom: 55px; }
    .scene-finish { top: 38px; right: 28px; }
    .robot-level-card { min-height: 465px; padding: 24px; }
    .robot-level-card__route { padding-inline: 5px; }
    .robot-level-card__route i { width: min(12vw, 57px); }
    .robot-footer { min-height: 150px; align-items: flex-start; flex-direction: column; justify-content: center; }

    .block-intro__inner {
        padding: 52px 24px 28px;
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .block-intro__mark {
        min-height: 96px;
        max-width: 190px;
        border-radius: 21px 21px 21px 7px;
        font-size: 26px;
    }

    .block-intro__text { font-size: 14px; }
    .block-intro__action { width: 100%; }
}

@media (max-width: 350px) {
    .topbar:has(.topbar__actions) .brand > span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
