:root {
    color-scheme: dark;
    --paper: #f4f2e9;
    --ink: #101218;
    --muted: rgba(242, 242, 235, 0.62);
    --line: rgba(255, 255, 255, 0.18);
    --accent: #dfff55;
    --accent-2: #ff7256;
    --panel: rgba(12, 14, 22, 0.68);
    --ease: cubic-bezier(0.22, 0.9, 0.32, 1);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    min-height: 100%;
    background: #080a11;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    color: var(--paper);
    background: #080a11;
    font-family: "Arial Narrow", "Inter", "SF Pro Display", "Segoe UI", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

body.is-grabbing,
body.is-grabbing * {
    cursor: grabbing !important;
    user-select: none !important;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
a,
[tabindex] {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
    font: inherit;
}

::selection {
    color: #0a0c12;
    background: var(--accent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 300;
    padding: 10px 15px;
    border-radius: 999px;
    color: #080a10;
    background: #fff;
    font-size: 0.76rem;
    font-weight: 850;
    transform: translateY(-170%);
    transition: transform 180ms ease;
}

.skip-link:focus {
    transform: none;
}

.field-nav {
    position: fixed;
    top: max(15px, env(safe-area-inset-top));
    left: 50%;
    z-index: 200;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    width: min(1180px, calc(100% - 28px));
    min-height: 54px;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(8, 10, 17, 0.58);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 20px 48px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(16px) saturate(1.18);
    -webkit-backdrop-filter: blur(16px) saturate(1.18);
    transform: translateX(-50%);
}

.field-nav > a {
    display: inline-flex;
    width: fit-content;
    min-height: 40px;
    align-items: center;
    gap: 8px;
    padding: 0 13px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    transition: color 180ms ease, background 180ms ease, transform 180ms var(--ease);
}

.field-nav > a:hover,
.field-nav > a:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-2px);
}

.field-nav p,
.field-nav b {
    margin: 0;
    color: var(--muted);
    font-size: 0.62rem;
    font-weight: 850;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.field-nav p {
    display: flex;
    align-items: center;
    gap: 9px;
}

.field-nav p i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 14px var(--accent);
}

.field-nav b {
    justify-self: end;
    padding-right: 13px;
}

.physics-lab {
    position: relative;
    display: grid;
    grid-template-columns: minmax(285px, 0.68fr) minmax(480px, 1.32fr);
    min-height: 100svh;
    padding: 104px max(28px, calc((100vw - 1320px) / 2)) 28px;
    gap: clamp(24px, 4vw, 72px);
    overflow: hidden;
}

.physics-copy {
    position: relative;
    z-index: 4;
    align-self: center;
    padding-bottom: 72px;
}

.physics-kicker {
    margin: 0 0 17px;
    color: var(--accent);
    font-size: 0.64rem;
    font-weight: 900;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.physics-copy h1 {
    max-width: 650px;
    margin: 0;
    font-size: clamp(3.5rem, 7.6vw, 8.2rem);
    font-weight: 950;
    line-height: 0.82;
    letter-spacing: -0.075em;
    text-transform: uppercase;
}

.physics-copy h1 em {
    color: var(--accent-2);
    font-style: normal;
}

.physics-description {
    max-width: 470px;
    margin: 23px 0 28px;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.78;
}

.physics-readout {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(100%, 490px);
    margin: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.physics-readout > div {
    min-width: 0;
    padding: 13px 10px 13px 0;
}

.physics-readout > div + div {
    padding-left: 12px;
    border-left: 1px solid var(--line);
}

.physics-readout dt {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.48rem;
    font-weight: 850;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.physics-readout dd {
    margin: 0;
    overflow: hidden;
    font-family: ui-monospace, "Cascadia Mono", monospace;
    font-size: clamp(0.78rem, 1.55vw, 1.12rem);
    font-weight: 850;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.physics-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
}

.reset-button {
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--paper);
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.64rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms var(--ease);
}

.reset-button:hover,
.reset-button:focus-visible {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
}

.key-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.57rem;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.physics-stage {
    position: relative;
    z-index: 3;
    min-height: min(76vh, 760px);
    align-self: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: clamp(22px, 3vw, 38px);
    background: var(--panel);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 38px 80px rgba(0, 0, 0, 0.22);
    isolation: isolate;
}

.physics-stage::before {
    position: absolute;
    inset: 0;
    z-index: -2;
    opacity: 0.34;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.09) 1px, transparent 1px);
    background-size: 48px 48px;
    content: "";
}

.physics-stage::after {
    position: absolute;
    inset: 0;
    z-index: -1;
    background: radial-gradient(circle at 70% 25%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 42%);
    content: "";
    pointer-events: none;
}

.physics-canvas {
    display: block;
    width: 100%;
    height: 100%;
    min-height: inherit;
    cursor: grab;
    touch-action: none;
}

.stage-tag,
.stage-status {
    position: absolute;
    z-index: 5;
    margin: 0;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(8, 10, 16, 0.48);
    font-family: ui-monospace, "Cascadia Mono", monospace;
    font-size: 0.52rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    pointer-events: none;
    backdrop-filter: blur(10px);
}

.stage-tag {
    top: 16px;
    left: 16px;
}

.stage-status {
    right: 16px;
    bottom: 16px;
    color: var(--accent);
}

.field-next {
    position: absolute;
    right: max(24px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 80;
    display: grid;
    grid-template-columns: 1fr 18px;
    min-width: 216px;
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(8, 10, 16, 0.58);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: border-color 180ms ease, background 180ms ease, transform 180ms var(--ease);
}

.field-next:hover,
.field-next:focus-visible {
    border-color: color-mix(in srgb, var(--accent) 65%, white);
    background: rgba(16, 19, 27, 0.9);
    transform: translateY(-3px);
}

.field-next small,
.field-next span {
    display: block;
}

.field-next small {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.54rem;
    font-weight: 850;
    letter-spacing: 0.15em;
}

.field-next span {
    font-size: 0.76rem;
    font-weight: 850;
}

.no-script {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 400;
    max-width: 360px;
    margin: 0;
    padding: 12px 16px;
    color: #101218;
    background: #fff;
    font-size: 0.8rem;
}

/* 40 — Rope constraint */

body[data-effect="rope-constraint"] {
    --accent: #dfff55;
    --accent-2: #7ef2ff;
    --panel: rgba(10, 14, 28, 0.78);
    background:
        radial-gradient(circle at 22% 15%, rgba(126, 242, 255, 0.14), transparent 33rem),
        #070914;
}

.rope-lab {
    background:
        linear-gradient(115deg, transparent 48%, rgba(223, 255, 85, 0.045) 48.1%, transparent 48.3%),
        radial-gradient(circle at 78% 42%, rgba(90, 105, 255, 0.16), transparent 31rem);
}

.rope-stage {
    border-color: rgba(126, 242, 255, 0.22);
}

/* 41 — Collision drag */

body[data-effect="collision-drag"] {
    color-scheme: light;
    --paper: #111218;
    --muted: rgba(15, 16, 20, 0.6);
    --line: rgba(15, 16, 20, 0.2);
    --accent: #ff4f35;
    --accent-2: #4261ff;
    --panel: rgba(255, 252, 240, 0.68);
    color: var(--paper);
    background: #f0eddf;
}

body[data-effect="collision-drag"] .field-nav {
    background: rgba(247, 244, 233, 0.72);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.72), 0 20px 44px rgba(49, 45, 34, 0.1);
}

body[data-effect="collision-drag"] .field-nav > a:hover,
body[data-effect="collision-drag"] .field-nav > a:focus-visible,
body[data-effect="collision-drag"] .reset-button:hover,
body[data-effect="collision-drag"] .reset-button:focus-visible {
    color: #0e1015;
    background: rgba(0, 0, 0, 0.07);
}

body[data-effect="collision-drag"] .reset-button {
    color: #111218;
    background: rgba(255, 255, 255, 0.36);
}

body[data-effect="collision-drag"] .stage-tag,
body[data-effect="collision-drag"] .stage-status {
    background: rgba(255, 252, 240, 0.74);
}

body[data-effect="collision-drag"] .field-next {
    color: #fff;
    background: rgba(14, 16, 22, 0.86);
}

body[data-effect="collision-drag"] .field-next small {
    color: rgba(255, 255, 255, 0.6);
}

.collision-lab {
    background:
        linear-gradient(90deg, rgba(17, 18, 24, 0.055) 1px, transparent 1px),
        #f0eddf;
    background-size: 8.333vw 100%;
}

.collision-stage {
    box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.34), 0 38px 80px rgba(42, 37, 23, 0.15);
}

.collision-stage::before {
    background-image:
        linear-gradient(rgba(17, 18, 24, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(17, 18, 24, 0.1) 1px, transparent 1px);
}

/* 42 — Orbital drag */

body[data-effect="orbital-drag"] {
    --accent: #ffda5b;
    --accent-2: #c5a0ff;
    --panel: rgba(18, 10, 36, 0.74);
    background:
        radial-gradient(circle at 78% 16%, rgba(197, 160, 255, 0.18), transparent 31rem),
        #0c0718;
}

.orbit-lab {
    background:
        radial-gradient(circle at 72% 48%, rgba(255, 218, 91, 0.08), transparent 27rem),
        repeating-radial-gradient(circle at 20% 70%, transparent 0 38px, rgba(197, 160, 255, 0.04) 39px 40px);
}

.orbit-stage {
    border-radius: 50% 50% 34px 34px / 22% 22% 34px 34px;
    border-color: rgba(197, 160, 255, 0.3);
}

/* 43 — Rubber band drag */

body[data-effect="rubber-band-drag"] {
    color-scheme: light;
    --paper: #231013;
    --muted: rgba(58, 25, 31, 0.62);
    --line: rgba(80, 27, 37, 0.2);
    --accent: #d91546;
    --accent-2: #ff6a44;
    --panel: rgba(255, 233, 226, 0.68);
    color: var(--paper);
    background: #ffd9cf;
}

body[data-effect="rubber-band-drag"] .field-nav {
    background: rgba(255, 240, 234, 0.72);
}

body[data-effect="rubber-band-drag"] .field-nav > a:hover,
body[data-effect="rubber-band-drag"] .field-nav > a:focus-visible {
    color: #2b1015;
    background: rgba(97, 20, 37, 0.08);
}

body[data-effect="rubber-band-drag"] .reset-button {
    color: #39131a;
    background: rgba(255, 255, 255, 0.3);
}

body[data-effect="rubber-band-drag"] .stage-tag,
body[data-effect="rubber-band-drag"] .stage-status {
    background: rgba(255, 239, 233, 0.72);
}

body[data-effect="rubber-band-drag"] .field-next {
    color: #fff;
    background: rgba(55, 12, 22, 0.86);
}

body[data-effect="rubber-band-drag"] .field-next small {
    color: rgba(255, 255, 255, 0.62);
}

.rubber-lab {
    background:
        linear-gradient(125deg, rgba(255, 255, 255, 0.22) 0 19%, transparent 19.1%),
        radial-gradient(circle at 80% 50%, rgba(217, 21, 70, 0.12), transparent 29rem),
        #ffd9cf;
}

.rubber-stage {
    border-radius: 38px 38px 38px 120px;
    box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.24), 0 38px 80px rgba(95, 23, 41, 0.16);
}

.rubber-stage::before {
    background-image:
        radial-gradient(circle, rgba(107, 24, 43, 0.16) 1px, transparent 1.5px);
    background-size: 25px 25px;
}

/* 44 — Physics reorder */

body[data-effect="physics-reorder"] {
    color-scheme: light;
    --paper: #111521;
    --muted: rgba(17, 21, 33, 0.6);
    --line: rgba(17, 21, 33, 0.18);
    --accent: #315cff;
    --accent-2: #ff4d4d;
    --panel: rgba(232, 237, 255, 0.72);
    color: var(--paper);
    background: #e4e9ff;
}

body[data-effect="physics-reorder"] .field-nav {
    background: rgba(245, 247, 255, 0.74);
}

body[data-effect="physics-reorder"] .field-nav > a:hover,
body[data-effect="physics-reorder"] .field-nav > a:focus-visible {
    color: #101522;
    background: rgba(49, 92, 255, 0.08);
}

body[data-effect="physics-reorder"] .reset-button {
    color: #111521;
    background: rgba(255, 255, 255, 0.48);
}

body[data-effect="physics-reorder"] .field-next {
    color: #fff;
    background: rgba(18, 24, 43, 0.9);
}

body[data-effect="physics-reorder"] .field-next small {
    color: rgba(255, 255, 255, 0.62);
}

.reorder-lab {
    background:
        linear-gradient(90deg, rgba(49, 92, 255, 0.055) 1px, transparent 1px),
        linear-gradient(rgba(49, 92, 255, 0.04) 1px, transparent 1px),
        #e4e9ff;
    background-size: 8.333vw 100%, 100% 64px;
}

.reorder-stage {
    display: grid;
    min-height: min(76vh, 760px);
    place-items: center;
    padding: 62px clamp(14px, 3vw, 38px) 42px;
    border-radius: 18px;
    box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.34), 0 38px 80px rgba(39, 53, 111, 0.16);
}

.reorder-stage::before {
    background-image: linear-gradient(90deg, rgba(49, 92, 255, 0.09) 1px, transparent 1px);
    background-size: 72px 100%;
}

.reorder-board {
    --row-height: clamp(57px, 8.1vh, 72px);
    position: relative;
    width: min(100%, 610px);
    height: calc(var(--row-height) + var(--row-height) + var(--row-height) + var(--row-height) + var(--row-height) + var(--row-height) + 78px);
    border: 1px solid rgba(17, 21, 33, 0.19);
    border-radius: 24px;
    background: rgba(250, 251, 255, 0.46);
    box-shadow: inset 0 1px #fff;
    touch-action: none;
}

.reorder-item {
    position: absolute;
    top: 0;
    right: 14px;
    left: 14px;
    z-index: 1;
    display: grid;
    grid-template-columns: 26px 42px minmax(0, 1fr) auto;
    height: var(--row-height);
    align-items: center;
    gap: 12px;
    padding: 0 18px 0 14px;
    border: 1px solid color-mix(in srgb, var(--item-color) 30%, rgba(17, 21, 33, 0.14));
    border-radius: 14px;
    color: #111521;
    background: color-mix(in srgb, var(--item-color) 10%, #fff);
    box-shadow: 0 7px 18px rgba(34, 45, 91, 0.08);
    cursor: grab;
    touch-action: none;
    transform: translate3d(0, var(--item-y, 14px), 0) rotate(var(--item-rotate, 0deg)) scale(var(--item-scale, 1));
    transform-origin: 50% 50%;
    will-change: transform;
}

.reorder-item:hover {
    border-color: color-mix(in srgb, var(--item-color) 74%, #111521);
}

.reorder-item.is-dragging {
    z-index: 20;
    box-shadow: 0 22px 42px rgba(35, 47, 98, 0.25);
}

.drag-handle {
    color: color-mix(in srgb, var(--item-color) 75%, #111521);
    font-size: 1.05rem;
    letter-spacing: -0.22em;
}

.item-slot {
    font-family: ui-monospace, "Cascadia Mono", monospace;
    font-size: 0.72rem;
    font-weight: 900;
}

.item-title {
    overflow: hidden;
    font-size: clamp(0.82rem, 1.45vw, 1.06rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-code {
    padding: 6px 8px;
    border: 1px solid rgba(17, 21, 33, 0.14);
    border-radius: 999px;
    color: rgba(17, 21, 33, 0.62);
    font-size: 0.48rem;
    font-weight: 900;
    letter-spacing: 0.12em;
}

@media (max-width: 960px) {
    body {
        overflow: auto;
    }

    .physics-lab {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(420px, 1fr);
        min-height: 100svh;
        padding: 94px 18px 112px;
        gap: 20px;
        overflow: visible;
    }

    .physics-copy {
        align-self: end;
        padding: 0;
    }

    .physics-copy h1 {
        font-size: clamp(3.3rem, 13vw, 6.2rem);
    }

    .physics-description {
        max-width: 680px;
        margin: 17px 0 20px;
    }

    .physics-stage,
    .reorder-stage {
        min-height: max(52svh, 420px);
    }

    .field-next {
        position: fixed;
    }
}

@media (max-width: 620px) {
    .field-nav {
        top: max(9px, env(safe-area-inset-top));
        width: calc(100% - 18px);
        min-height: 48px;
    }

    .field-nav > a {
        min-height: 36px;
        padding: 0 9px;
    }

    .field-nav > a span,
    .field-nav p {
        display: none;
    }

    .field-nav b {
        grid-column: 3;
        padding-right: 8px;
    }

    .physics-lab {
        grid-template-rows: auto minmax(390px, 58svh);
        padding: 76px 10px 104px;
        gap: 14px;
    }

    .physics-kicker {
        margin-bottom: 11px;
    }

    .physics-copy h1 {
        font-size: clamp(2.85rem, 14vw, 4.8rem);
    }

    .physics-description {
        margin: 13px 0 16px;
        font-size: 0.82rem;
        line-height: 1.55;
    }

    .physics-readout > div {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .physics-actions {
        margin-top: 12px;
    }

    .key-hint {
        max-width: 210px;
        line-height: 1.4;
    }

    .physics-stage,
    .reorder-stage {
        min-height: 390px;
        border-radius: 20px;
    }

    .field-next {
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        min-width: 190px;
    }

    .reorder-stage {
        padding: 56px 8px 24px;
    }

    .reorder-board {
        --row-height: 56px;
    }

    .reorder-item {
        right: 8px;
        left: 8px;
        grid-template-columns: 19px 30px minmax(0, 1fr);
        gap: 8px;
        padding: 0 10px 0 8px;
    }

    .item-code {
        display: none;
    }
}

@media (max-height: 720px) and (min-width: 961px) {
    .physics-lab {
        padding-top: 82px;
    }

    .physics-stage,
    .reorder-stage {
        min-height: calc(100svh - 104px);
    }

    .physics-description {
        margin: 14px 0 17px;
        line-height: 1.5;
    }

    .physics-copy {
        padding-bottom: 58px;
    }
}

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