:root {
    color-scheme: dark;
    --or-text: #fff0da;
    --or-muted: #ceb7a4;
    --or-line: #a36945;
    --or-cyan: #81fff5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
.or-body {
    color: var(--or-text);
    background: #15110f url("station.webp") center center / cover fixed;
    font: 15px/1.5 system-ui, "Segoe UI", Tahoma, sans-serif;
    -webkit-tap-highlight-color: transparent;
}
.or-body:has(.hp-hud:not([hidden])) { --or-hearts-height: var(--hp-height, 38px); }
.or-body .hp-hud { position: relative; top: auto; }
button, a { touch-action: manipulation; }
button { color: inherit; font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--or-cyan); outline-offset: 3px; }
a { color: inherit; }
.or-sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }
.or-shell { width: min(100% - 40px, 1050px); margin: auto; }

.or-top, .or-title, .or-top-actions {
    display: flex;
    align-items: center;
    gap: 11px;
}
.or-top { justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #e7a26945; }
.or-title img { width: 32px; height: 38px; object-fit: contain; filter: drop-shadow(0 2px 6px #000); }
.or-title h1 { margin: 0; font-size: clamp(1.1rem, 2.1vw, 1.65rem); line-height: 1.2; }
.or-wallet { padding: 5px 10px; border-radius: 8px; border: 1px solid #805634; background: #271b15; }
.or-wallet span:first-child { color: #ffce79; margin-inline-end: 4px; }
.or-icon {
    inline-size: 42px;
    block-size: 42px;
    border: 1px solid #966641;
    border-radius: 10px;
    background: linear-gradient(#483121, #281b14);
    color: #ffdfb5;
    font-size: 1.2rem;
    line-height: 1;
}

.or-layout {
    display: grid;
    grid-template-columns: minmax(240px, .58fr) minmax(360px, 1fr);
    align-items: center;
    gap: clamp(26px, 6vw, 94px);
    padding: clamp(12px, 3vh, 44px) 0 24px;
}
.or-mission { padding: clamp(20px, 3vw, 36px); border: 1px solid #97634370; border-radius: 20px; background: linear-gradient(140deg, #37271eea, #1b1715ed); box-shadow: 0 18px 42px #0006; }
.or-section { display: flex; gap: 8px; align-items: center; margin: 0 0 13px; color: #ffcb91; font-weight: 700; }
.or-led { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--or-cyan); box-shadow: 0 0 11px #5effec; }
.or-mission h2 { margin: 0; font-size: clamp(1.2rem, 2.3vw, 1.82rem); line-height: 1.42; }
.or-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 20px 0; }
.or-metrics div { display: grid; gap: 4px; padding: 8px; border-radius: 8px; background: #110d0c6b; }
.or-metrics dt { color: var(--or-muted); font-size: .82rem; }
.or-metrics dd { margin: 0; color: #ffd491; font-size: 1.13rem; font-weight: 800; }
.or-legend { list-style: none; display: grid; gap: 8px; padding: 0; margin: 0 0 17px; }
.or-legend li { display: flex; align-items: center; gap: 8px; color: var(--or-muted); font-size: .89rem; }
.or-legend-arrows, .or-legend-pad { width: 24px; text-align: center; color: #ffc783; font-weight: 900; }
.or-legend-track { margin-inline: 4px; width: 16px; height: 3px; border-radius: 2px; background: var(--or-cyan); box-shadow: 0 0 8px #40fff0; }
.or-about { color: #ffd2a3; text-underline-offset: 4px; }

.or-console { width: min(100%, clamp(350px, calc(100dvh - var(--game-guest-height, 0px) - var(--or-hearts-height, 0px) - 270px), 560px)); margin-inline: auto; }
.or-console-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 12px 8px; margin: 0 8px 9px; border: 1px solid #9d643e; border-radius: 9px; background: linear-gradient(#58351e, #2e2018); color: #f2c09b; box-shadow: inset 0 1px #e4aa6a66, 0 3px 9px #0009; }
.or-stage, .or-moves { display: flex; align-items: baseline; gap: 6px; font-size: .78rem; font-weight: 600; }
button.or-stage { padding: 1px 6px; border: 1px solid #d095655c; border-radius: 6px; color: inherit; background: #21130e45; }
button.or-stage:hover { border-color: #f5c79f; }
.or-phase { padding: 1px 6px; border-radius: 6px; border: 1px solid #8ee9db50; background: #153f3b9e; color: #b6f4e8; font-size: .73rem; font-weight: 650; white-space: nowrap; }
.or-stage strong, .or-moves strong { color: #fff0d6; font-size: 1.26rem; font-variant-numeric: tabular-nums; }
#or-total { direction: ltr; }
.or-console-head progress { position: absolute; inset-inline: 4%; bottom: 0; width: 92%; height: 3px; border: 0; appearance: none; background: #110d0b; border-radius: 2px; }
.or-console-head progress::-webkit-progress-bar { background: #110d0b; }
.or-console-head progress::-webkit-progress-value { background: #65ddd4; }
.or-console-head progress::-moz-progress-bar { background: #65ddd4; }
.or-frame {
    position: relative;
    padding: clamp(6px, 1.15vw, 13px);
    border: 1px solid #d59866;
    border-radius: 17px;
    background: radial-gradient(circle at 5px 5px, #ffcf99, #6a4029 2px, transparent 3px) 1px 1px / 46px 46px, linear-gradient(145deg, #ba7749, #5f3520 12%, #8d5133 53%, #3c231b 74%, #a76d43);
    box-shadow: inset 0 0 0 3px #ffd1a640, inset 0 -5px 4px #31180b99, 0 16px 32px #0009;
}
.or-board { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; isolation: isolate; touch-action: none; user-select: none; border: 1px solid #0e0b0a; border-radius: 8px; background: #17191b; }
.or-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
#or-tiles, #or-track { pointer-events: none; }
.or-tile, .or-wall, .or-crate, .or-pad, .or-gate, .or-marker, .or-exit, .or-robot { position: absolute; }
.or-tile {
    border: 1px solid #101313;
    border-radius: 4px;
    background: radial-gradient(circle at 6px 6px, #7d83823d 1px, transparent 2px), radial-gradient(circle at calc(100% - 6px) calc(100% - 6px), #7d83823d 1px, transparent 2px), linear-gradient(145deg, #33383a, #202425);
    box-shadow: inset 0 1px #ffffff17, inset -1px -2px #0005;
}
.or-wall { background: linear-gradient(#10131a44, #0009), url("steel.webp") center / 100% 100%; }
.or-exit { background: url("door.webp") center / 91% 91% no-repeat; filter: drop-shadow(0 0 7px #41e8e2a8); }
.or-crate {
    z-index: 3;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: var(--or-crate) center / 100% 100% no-repeat;
    color: #fff0c3;
    filter: drop-shadow(0 4px 3px #000b);
    transition: left .16s ease-out, top .16s ease-out, filter .14s;
    text-shadow: 0 2px 3px #2c1709, 0 0 4px #000;
    font-size: clamp(1.15rem, 5.8vmin, 2.3rem);
    font-weight: 950;
    line-height: 1;
    cursor: grab;
}
.or-crate[data-picked] { z-index: 5; filter: drop-shadow(0 0 5px #75fff2); }
.or-crate[data-hint] { z-index: 5; filter: drop-shadow(0 0 6px #ffdc65); }
.or-crate:active { cursor: grabbing; }
.or-crate[data-circuit]::after {
    content: attr(data-circuit);
    position: absolute;
    top: -2px;
    right: -2px;
    display: grid;
    place-items: center;
    min-width: 1.35em;
    height: 1.35em;
    border: 1px solid #ffcd83;
    border-radius: 50%;
    color: #ffedbe;
    background: #703816;
    font-size: .68rem;
    text-shadow: none;
}
.or-marker { z-index: 2; border: 1px dashed #88e8df; border-radius: 17%; background: #3bdfca2b; box-shadow: inset 0 0 8px #63ffee70; pointer-events: none; }
.or-marker.or-hint { z-index: 6; border: 2px dashed #ffe291; background: #ffc54a33; box-shadow: 0 0 8px #ffbf71; }
.or-pad { z-index: 1; display: grid; place-items: center; color: #ffc86f; border: 2px solid #e7a94f; border-radius: 11px; background: repeating-linear-gradient(135deg, #684a27 0 4px, #3e2c1b 4px 8px); font-size: 1.35rem; }
.or-pad[data-open] { border-color: #aaffde; color: #aaffde; }
.or-gate { z-index: 2; display: grid; place-items: center; border-radius: 9px; border: 2px solid #ff9c57; background: repeating-linear-gradient(45deg, #932f14 0 4px, #3a1d17 4px 8px); color: #fff1c6; box-shadow: 0 0 7px #ff733055; font-size: 1.4rem; }
.or-gate[data-open] { color: #adffde; border-color: #7be7ca; background: #14474266; }
.or-gate[data-circuit]::after { content: '×'; position: absolute; top: -2px; right: 2px; color: #ffc3a1; font: 800 .62rem/1 system-ui, sans-serif; }
.or-gate[data-circuit][data-open]::after { content: '✓'; color: var(--or-cyan); }
.or-pad, .or-gate[data-circuit] { font: 800 clamp(.72rem, 3.5vmin, 1.3rem)/1 system-ui, sans-serif; }
.or-robot { z-index: 7; object-fit: contain; object-position: center; pointer-events: none; filter: drop-shadow(0 4px 4px #050505) drop-shadow(0 0 8px #35dcd06e); }

.or-status { display: flex; align-items: center; justify-content: center; min-height: 2.6em; margin: 2px 0; padding: 2px 4px; color: #f2d4b9; text-align: center; font-size: .84rem; line-height: 1.26; }
.or-toolbar { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 7px; }
.or-button {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 6px 8px;
    border: 1px solid #9e6b49;
    border-radius: 9px;
    background: linear-gradient(#483227, #2c211c);
    box-shadow: inset 0 1px #ffffff24, 0 3px 1px #0006;
    color: #fff0d8;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}
.or-button > span { font-size: 1.05rem; }
.or-button > small { font-size: .72rem; white-space: nowrap; }
.or-button:disabled { opacity: .55; }
.or-primary { border-color: #edb075; background: linear-gradient(#f0b476, #b66437); color: #261811; }
.or-next { width: 100%; }

.or-dialog {
    width: min(450px, calc(100vw - 24px));
    max-height: min(76dvh, 620px);
    padding: 0;
    color: var(--or-text);
    border: 1px solid #ca8d5f;
    border-radius: 16px;
    background: linear-gradient(135deg, #3a291e, #211713);
    box-shadow: 0 24px 70px #000c;
}
.or-dialog::backdrop { background: #0c0807b3; }
.or-dialog-inner { padding: 15px; }
.or-dialog header { display: flex; justify-content: space-between; align-items: center; gap: 9px; margin-bottom: 12px; }
.or-dialog h2 { margin: 0; font-size: 1.25rem; }
.or-menu-links { display: grid; gap: 9px; }
.or-chapters { display: grid; gap: 8px; }
.or-chapter { border: 1px solid #9e6b496b; border-radius: 9px; background: #2b1e18; }
.or-chapter-heading { cursor: pointer; padding: 8px 10px; font-size: .84rem; }
.or-chapter-heading::marker { color: #ffc88a; }
.or-chapter-heading:focus-visible { outline: 2px solid var(--or-cyan); outline-offset: 2px; }
.or-chapter-name { margin-inline: 5px 8px; font-weight: 700; }
.or-chapter-heading bdi { color: #f1c9a2; font-variant-numeric: tabular-nums; }
.or-chapter-meta { display: block; padding-inline-start: 18px; color: #83e2d2; font-size: .72rem; }
.or-level-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.or-chapter .or-level-list { padding: 0 9px 9px; }
.or-level-list [aria-current] { border-color: var(--or-cyan); }
.or-level-list .or-button { flex-direction: column; gap: 1px; }
.or-level-list small { color: #ffd082; line-height: 1; }
.or-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (max-width: 767px), (max-height: 540px) and (orientation: landscape) and (pointer: coarse) {
    html:has(.or-body), .or-body { height: 100%; overflow: hidden; overscroll-behavior: none; }
    .or-body { height: 100dvh; background-position: 83% center; }
    .or-shell { height: calc(100dvh - var(--game-guest-height, 0px) - var(--or-hearts-height, 0px)); width: 100%; padding: 0 max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); display: grid; grid-template-rows: auto minmax(0, 1fr); }
    .or-top { padding: 4px max(4px, env(safe-area-inset-left)); }
    .or-title img { height: 28px; width: 24px; }
    .or-top .or-icon { width: 36px; height: 34px; }
    .or-layout { padding: 0; display: grid; grid-template-columns: 1fr; align-content: center; min-height: 0; }
    .or-mission { display: none; }
    .or-console { width: min(100%, max(144px, calc(100dvh - var(--game-guest-height, 0px) - var(--or-hearts-height, 0px) - 198px))); }
    .or-console-head { margin-bottom: 5px; }
    .or-frame { border-radius: 12px; }
}
@media (max-height: 540px) and (orientation: landscape) {
    .or-layout { padding: 4px 0 0; grid-template-columns: minmax(156px, 0.65fr) minmax(160px, 1fr); gap: 10px; }
    .or-mission { display: block; padding: 9px; margin: 0 auto; }
    .or-mission h2 { font-size: 1rem; }
    .or-mission :is(.or-metrics, .or-legend, .or-about) { display: none; }
    .or-console { width: min(100%, max(100px, calc(100dvh - var(--game-guest-height, 0px) - var(--or-hearts-height, 0px) - 133px))); position: relative; }
    .or-console-head { margin: 0 0 3px; padding: 0 6px 3px; }
    .or-console-head strong { font-size: .93rem; }
    .or-status { display: none; }
    .or-toolbar, .or-next { margin-top: 4px; }
    .or-toolbar { gap: 3px; grid-template-columns: repeat(3, 1fr); }
    .or-toolbar button, .or-next { min-height: 29px; gap: 3px; padding: 2px; font-size: .67rem; }
    .or-toolbar small { display: none; }
    .or-top { padding-block: 2px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0s !important; }
}
