:root {
    --pencil-paper: #f7f5ef;
    --pencil-panel: #fdfbf7;
    --pencil-ink: #292620;
    --pencil-muted: #62594c;
    --pencil-rule: #bdb3a3;
    --pencil-accent: #924d40;
}

body.pencil-orbit,
body.pencil-expedition { background: var(--pencil-paper); }

html.pencil-edition,
.pencil-edition body.pencil-orbit { background-color: #41362e; }

/* The start screen reads like the cover and first page of a sketchbook. */
.pencil-orbit #center-screen-overlay.menu-bg {
    background: var(--pencil-paper);
    color: var(--pencil-ink);
}

.pencil-orbit #center-screen-overlay.menu-bg > div {
    background: var(--pencil-panel);
    color: var(--pencil-ink);
    border: 1px solid var(--pencil-rule);
    border-radius: 5px 2px 6px 3px;
    box-shadow: 7px 9px 0 #3e32200d;
}

.pencil-orbit #center-screen-overlay.menu-bg #start-content {
    width: min(820px, calc(100vw - 28px)) !important;
    padding: clamp(12px, 3vw, 28px);
}

.pencil-cover {
    position: relative;
    min-height: clamp(150px, 25vh, 242px);
    display: grid;
    align-items: center;
    text-align: left;
    border-bottom: 1px solid var(--pencil-rule);
    margin-bottom: clamp(10px, 2vh, 19px);
    isolation: isolate;
}

.pencil-cover::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0 0 4px 42%;
    background: url("../assets/pencil-cover.png") center / contain no-repeat;
    mix-blend-mode: multiply;
}

.pencil-title {
    box-sizing: border-box;
    width: 53%;
    padding: 0 0 5px 2.5%;
}

.pencil-orbit #start-content .pencil-title h1 {
    width: fit-content;
    max-width: 100%;
    margin: 0 !important;
    font-family: var(--crew-title);
    font-size: clamp(38px, 5.6vw, 62px) !important;
    font-weight: 600;
    line-height: .98;
    text-align: left;
    text-transform: none;
    letter-spacing: -.045em;
    color: var(--pencil-ink);
    -webkit-text-fill-color: currentColor;
    background: none;
    text-shadow: none;
    filter: none;
}

.pencil-orbit #start-content .menu-ship-card,
.pencil-orbit #start-content .menu-ship-card.is-locked {
    background: #f9f6f0;
    color: var(--pencil-ink);
    border: 1px solid #c9bead;
    border-radius: 4px 3px 5px 2px;
    box-shadow: none;
    opacity: 1;
}

.pencil-orbit #start-content .menu-ship-card.is-selected {
    background: #eee7da;
    border-color: #6b5d4e;
    outline: 1px solid #6b5d4e;
    outline-offset: -3px;
    box-shadow: none;
}

.pencil-orbit .menu-ship-imgwrap img,
.pencil-orbit .ship-card-imgwrap img,
.pencil-orbit #start-content .menu-ship-card.is-locked img { filter: none; }
.space-prototype .pencil-orbit #start-content .menu-ship-card.is-locked img { opacity: .79; }

.pencil-orbit :is(.menu-ship-name, .menu-ship-strength, .menu-career-badge) {
    color: var(--pencil-ink);
    text-shadow: none;
}

.pencil-orbit :is(.menu-ship-locked, .menu-ship-unlocked) {
    color: #51483c;
    background: #ebe4d8;
}

.pencil-orbit #center-screen-overlay.menu-bg button,
.pencil-orbit #center-screen-overlay.menu-bg #start-content .menu-util-btn,
.pencil-orbit #pause-overlay button {
    background: #f7f3eb;
    color: var(--pencil-ink);
    border: 1px solid #a89a89;
    border-radius: 4px;
    box-shadow: none;
    text-shadow: none;
}

.pencil-orbit #center-screen-overlay.menu-bg #start-content .menu-util-btn:hover,
.pencil-orbit #center-screen-overlay.menu-bg button:hover {
    background: #ede6d8;
    color: var(--pencil-ink);
    border-color: #6b5d4e;
    box-shadow: none;
}

.pencil-orbit #center-screen-overlay.menu-bg #start-content .menu-play-btn,
.pencil-orbit #center-screen-overlay.menu-bg .diff-seg-btn.is-active {
    background: #36302a;
    color: #fffaf1;
    border-color: #36302a;
    border-radius: 4px 2px 5px 3px;
    box-shadow: 2px 3px 0 #8c7a6333;
}

.pencil-orbit :is(.diff-seg, .planetary-score-filters) {
    background: #f7f3eb;
    border-color: #c2b7a7;
}

.pencil-orbit button:focus-visible,
.pencil-expedition button:focus-visible {
    outline: 2px solid var(--pencil-accent);
    outline-offset: 3px;
}

.pencil-orbit #center-screen-overlay.menu-bg :is(#leaderboard-view, #settings-view, #hangar-view) {
    /* Keep the inherited detail layouts, including their scroll behavior. */
    color: var(--pencil-ink);
}

.pencil-orbit .leaderboard-container {
    background: #fdfbf7;
    border-color: var(--pencil-rule);
    box-shadow: none;
}
.pencil-orbit #leaderboard-view :is(h1, p, a, .loading-text, .score-name, .score-value, .score-rank) {
    color: var(--pencil-ink) !important;
    text-shadow: none;
}

.pencil-orbit #center-screen-overlay.menu-bg #leaderboard-view .diff-seg-btn[aria-pressed="true"] {
    color: var(--pencil-ink) !important;
    background: var(--selected-strokes, var(--drawn-hatch, none) 0 0 / 18px 14px repeat),
        var(--selected-paper, #f4e1bd) !important;
    background-blend-mode: multiply;
    border-image: var(--sketch-border) !important;
    font-weight: 700;
}

.pencil-orbit .scoreboard-footer {
    margin-top: 14px;
    max-width: 400px;
    color: var(--pencil-muted);
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
}
.pencil-orbit .scoreboard-footer a { text-decoration: underline; }

.pencil-orbit #start-content #menu-player-stats { color: var(--pencil-muted) !important; }

.pencil-orbit { --sector-chroma: 0; }
.pencil-orbit #launch-cutscene video { filter: grayscale(1) sepia(.12); }

.pencil-expedition { color: var(--pencil-ink); color-scheme: light; }
.pencil-expedition :is(header, .screen) { background: var(--pencil-paper); }
.pencil-expedition header { border-bottom: 1px solid var(--pencil-rule); }
.pencil-expedition .identity :is(b, .mark) { color: var(--pencil-accent); }
.pencil-expedition .overlay {
    background: linear-gradient(90deg, #f7f4ebee, #f7f4eb9c 51%, #f7f4eb24 85%);
}

.pencil-expedition .brief :is(h1, #title) {
    color: var(--pencil-ink);
    font-family: Georgia, serif;
    font-style: italic;
    font-weight: 500;
    letter-spacing: -.065em;
    text-shadow: none;
}
.pencil-expedition .brief p { color: var(--pencil-ink); }
.pencil-expedition :is(.hud-pill, #objective, .radar, #final-score, #volume-controls summary) {
    background: #f9f5ebef;
    color: var(--pencil-ink);
    border-color: #a99e8e;
    box-shadow: none;
}
.pencil-expedition :is(.hud-label, .hud-main, .hud-best .hud-label, #score-total, #score-caption, #score-breakdown dd) {
    color: var(--pencil-ink);
    text-shadow: none;
}
.pencil-expedition .hud-hearts { color: var(--pencil-accent); }
.pencil-expedition button {
    background: #f7f3eb;
    color: var(--pencil-ink);
    border-color: #a89a89;
    text-shadow: none;
}
.pencil-expedition .launch {
    background: #36302a;
    color: #fffaf1;
}
.pencil-expedition #flight-stores { filter: saturate(.25); }

.pencil-expedition {
    --mission-paper: #f6ead7;
    --mission-accent: #875535;
}
.pencil-expedition.pencil-triton {
    --mission-paper: #edf0ec;
    --mission-accent: #46616e;
}
.pencil-expedition :is(button, .hud-label, .hud-main, #objective, #score-caption, #campaign-credit) {
    font-family: var(--hand);
    letter-spacing: .035em;
}
.pencil-expedition .brief :is(h1, #title),
.pencil-expedition .overlay.is-paused h1 {
    color: var(--lead);
    font-family: var(--hand-title);
    font-style: normal;
    font-weight: 650;
    letter-spacing: -.035em;
    text-shadow: none;
}
.pencil-expedition .overlay.is-paused {
    background: var(--mission-paper) url("../assets/pencil-pause-paper.webp") center / cover no-repeat;
}
.pencil-expedition .overlay.is-result {
    background: #41362e url("../assets/pencil-score-desk.webp") center / cover no-repeat;
}
.pencil-expedition .overlay.is-result .brief {
    background: #f8efdf url("../assets/pencil-expedition-grain.webp") repeat;
    color: var(--lead);
    border: 1px solid #978674;
    border-radius: 2px 3px 2px 3px;
    box-shadow: 2px 4px 8px #21171080;
}
.pencil-expedition :is(#score-total, #campaign-credit) { color: var(--mission-accent); text-shadow: none; }
.pencil-expedition .overlay.is-result #score-total {
    -webkit-text-stroke: clamp(2px, .06em, 4px) #000;
    paint-order: stroke fill;
}
.pencil-expedition .overlay.is-result #score-caption::before,
.pencil-expedition .overlay.is-result #score-caption::after {
    background: linear-gradient(90deg, transparent, var(--mission-accent));
    opacity: .5;
}
.pencil-expedition .overlay.is-paused :is(.mission-actions button, #pause-sound),
.pencil-expedition :is(.pause-mix, .volume-panel, #radio) {
    background: var(--mission-paper);
    color: var(--lead);
    border: 1px solid #9c8b77;
    border-radius: 3px;
    box-shadow: none;
}
.pencil-expedition .overlay.is-paused :is(.mission-actions button, #pause-sound) {
    font-family: var(--hand);
}
.pencil-expedition #radio b,
.pencil-expedition .in-mission #surface-hud strong { color: var(--mission-accent); }
.pencil-expedition .in-mission #surface-hud {
    background: var(--mission-paper);
    color: var(--lead);
    border-color: #9c8b77;
}
.pencil-expedition .launch.mission-accomplished,
.pencil-expedition .launch.mission-accomplished:hover {
    background: #e8d1a6;
    color: var(--lead);
}
.pencil-expedition #flight-stores { filter: none; }
.pencil-expedition #flight-stores button {
    --rim: #7c6754;
    background: var(--mission-paper);
    color: var(--lead);
    border-width: 1px;
    box-shadow: none;
}
.pencil-expedition #flight-stores b { color: var(--lead); text-shadow: none; }
.pencil-expedition :is(#surface-fire, #surface-jump, #stick-prompt) {
    background: #f8f0e1ef;
    color: var(--pencil-ink);
    border: 1px solid var(--pencil-muted);
    border-radius: 4px 3px 5px 3px;
    box-shadow: 1px 1px 0 #5a4b3b4d;
    font-family: var(--hand);
    text-shadow: none;
}
.pencil-expedition #surface-fire { color: var(--mission-accent); }
.pencil-expedition #stick-prompt { border-style: dashed; box-shadow: none; }
.pencil-expedition #joystick-base {
    background: #f6eed735;
    border: 1px solid #776b5eb3;
    box-shadow: inset 0 0 0 2px #f4eee336;
}
.pencil-expedition #joystick-stick {
    background: #e2d5bd;
    border: 1px solid #75634f;
    box-shadow: none;
}
@media (max-width: 700px) {
    .pencil-expedition .overlay.is-result { background-image: url("../assets/pencil-score-desk-small.webp"); }
}
@media (forced-colors: active) {
    .pencil-expedition .overlay:is(.is-paused, .is-result),
    .pencil-expedition .overlay.is-result .brief { background: Canvas; }
}

@media (max-width: 560px) {
    .pencil-cover::before { inset-inline-start: 40%; }
    .pencil-title { padding-left: 1%; }
}

@media (max-height: 550px) and (orientation: landscape) {
    .pencil-cover { min-height: 86px; margin-bottom: 7px; }
    .pencil-orbit #start-content .pencil-title h1 { font-size: clamp(30px, 7vh, 43px) !important; }
    .pencil-orbit #center-screen-overlay.menu-bg #start-content { padding: 8px 14px; }
}

.pencil-orbit #start-content > .pencil-cover { width: 100%; margin-inline: 0; }

.pencil-orbit #center-screen-overlay .diff-seg .diff-seg-btn {
    color: #564d41 !important;
    border-radius: 4px !important;
}

.pencil-orbit #center-screen-overlay .diff-seg .diff-seg-btn.is-active,
.pencil-orbit #center-screen-overlay .planetary-mission-filters .diff-seg-btn.is-active {
    background: #3b332b !important;
    color: #fffaf1 !important;
    box-shadow: none !important;
}

body.pencil-orbit.desktop #ui-layer-desktop {
    background: #f7f3eb;
    border-color: var(--pencil-rule);
    box-shadow: none;
}

body.pencil-orbit.desktop .hud-pill,
body.pencil-orbit.desktop #pause-btn-desktop.hud-pause,
.pencil-orbit .hud-panel,
.pencil-orbit #shield-btn,
.pencil-orbit #pause-btn,
.pencil-expedition #pause {
    background: #f8f4ec !important;
    color: var(--pencil-ink) !important;
    border-color: var(--pencil-rule) !important;
    border-radius: 5px;
    box-shadow: none !important;
    text-shadow: none;
}

body.pencil-orbit :is(.hud-label,.hud-main,.hud-text,.hud-value) {
    color: var(--pencil-ink) !important;
    text-shadow: none !important;
}

.pencil-orbit #sector-progress {
    color: #3d352b !important;
    background: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

.pencil-orbit #controls-tutorial { background: #80705742; filter: none; }
.pencil-orbit .controls-tutorial-inner {
    background: var(--pencil-panel);
    border: 1px solid var(--pencil-rule);
    border-radius: 5px;
    box-shadow: 7px 9px 0 #3e322018;
    color: var(--pencil-ink);
}
.pencil-orbit .controls-tutorial-inner :is(div,span,p,strong,kbd) {
    color: var(--pencil-ink);
    text-shadow: none;
}
.pencil-orbit .controls-tutorial-title { background: #ebe4d8; }
.pencil-orbit .controls-tutorial-inner .controls-tutorial-hint { color: var(--pencil-accent); }
.pencil-orbit .controls-tutorial-inner img { filter: grayscale(1); }

.pencil-orbit #center-screen-overlay.menu-bg h1 {
    -webkit-text-fill-color: currentColor;
    background: none;
    color: var(--pencil-ink);
    filter: none;
}
.pencil-orbit #center-screen-overlay.menu-bg h2:not(.ship-card-title) {
    color: var(--pencil-ink);
    text-shadow: none;
}

@media (max-width: 560px) {
    .pencil-cover { min-height: clamp(125px, 21vh, 177px); }
    .pencil-cover::before { inset-inline-start: 43%; background-position: right center; }
}

.pencil-orbit .vignette { opacity: .12; }
.pencil-orbit #shield-btn :is(span,div) { color: var(--pencil-ink); text-shadow: none; }
.pencil-orbit .controls-tutorial-inner :is(.control-alt,small) { color: var(--pencil-muted); }
.pencil-orbit #settings-view :is(label,p,h2,#settings-version) { color: var(--pencil-ink) !important; text-shadow: none; }
.pencil-orbit #settings-view input { accent-color: var(--pencil-muted); }
.pencil-orbit #start-content .menu-ship-lock {
    width: 16px;
    height: 12px;
    margin-top: 3px;
    border: 2px solid currentColor;
    border-radius: 2px 2px 3px 2px;
    background: #f2e5cd;
    color: var(--pencil-ink);
    filter: none;
}
.pencil-orbit #start-content .menu-ship-lock::before {
    content: "";
    position: absolute;
    inset: -9px 2px auto;
    height: 9px;
    border: 1.5px solid currentColor;
    border-bottom: 0;
    border-radius: 7px 6px 0 0;
}
.pencil-orbit #start-content .menu-ship-lock::after {
    content: "";
    position: absolute;
    inset: 2px auto auto 50%;
    width: 2px;
    height: 4px;
    transform: translateX(-50%);
    background: currentColor;
}

.pencil-orbit .mars-chapter-loading {
    color: var(--pencil-ink);
    background: #f3e9d7 url("../assets/pencil-pause-paper.webp") center / cover no-repeat;
    font: 600 20px/1.4 var(--hand, cursive);
}
.pencil-orbit .mars-chapter-loading button {
    color: inherit;
    background: #f8efdd;
    border: 1px solid var(--pencil-muted);
    border-radius: 3px 2px;
    font: inherit;
    padding: .55em 1em;
}
@media (forced-colors: active) {
    .pencil-orbit .mars-chapter-loading { background: Canvas; }
}

.pencil-orbit #shield-label-mobile { color: var(--pencil-ink) !important; }
.pencil-expedition #surface-hud {
    background: #f9f5ebef;
    color: var(--pencil-ink);
    border-color: var(--pencil-rule);
}
.pencil-expedition #surface-hud :is(.pilot-vitals,span) { color: var(--pencil-ink); }
.pencil-expedition #surface-hud #pilot-hearts { color: var(--pencil-accent); }
@media (max-width: 560px) {
    .pencil-orbit #start-content .pencil-title h1 {
        font-size: clamp(32px, 8.6vw, 47px) !important;
    }
}

/* A short playtest uses the same flight controls and its own results. */
.space-prototype :is(#menu-top-bar, #menu-player-stats, #hangar-btn,
    #leaderboard-btn, #menu-ship-warlock, #menu-ship-ghost, #best-panel-desktop, .hud-panel.highscore) {
    display: none !important;
}

.space-prototype #start-content #menu-ship-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.space-prototype #space-objective {
    margin: 0 0 12px;
    color: var(--pencil-muted);
    font: 600 14px/1.35 system-ui, sans-serif;
}

.space-prototype #space-result {
    box-sizing: border-box;
    width: min(490px, calc(100vw - 28px));
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(18px, 5vw, 38px);
}

.space-prototype #space-result h1 {
    margin: 0;
    text-transform: none;
    font: italic clamp(34px, 7vw, 59px)/1 Georgia, serif;
    letter-spacing: -.04em;
}

.space-prototype #space-result p {
    margin: 16px 0 22px;
    font: 600 16px system-ui, sans-serif;
}

.space-result-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

#center-screen-overlay.menu-bg .space-result-actions button {
    margin: 0;
    padding: 9px 15px;
    min-height: 44px;
    letter-spacing: .06em;
    font-size: 13px;
}

#center-screen-overlay.menu-bg .space-result-actions #space-replay {
    background: #36302a;
    color: #fffaf1;
}

/* The cover, instrument strip and controls share the flight drawing's paper. */
.pencil-edition {
    --hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", cursive;
    --hand-title: "Ink Free", "Bradley Hand", "Segoe Print", var(--hand);
    --lead: #3e352d;
    --ochre: #9a5d2c;
    --sketch-border: var(--drawn-frame, none) 39 / 8px / 0 round;
    --ship-picker-width: 584px;
}
.pencil-edition.space-prototype { --ship-picker-width: 420px; }
.pencil-edition #start-content #menu-ship-grid { max-width: var(--ship-picker-width); }
.pencil-edition .pencil-orbit .vignette { opacity: 0; }
.pencil-edition .pencil-cover::before {
    background-image: url("../assets/one-sector-sketch.webp");
    background-size: cover;
    background-position: center;
    mask-image: linear-gradient(to right, transparent, #000 13%);
}
.pencil-edition .pencil-orbit #center-screen-overlay.menu-bg {
    background: #efe5d3 var(--drawn-paper, none) repeat;
    background-blend-mode: multiply;
}
.pencil-edition .pencil-orbit #center-screen-overlay.menu-bg > div,
.pencil-edition .controls-tutorial-inner,
.pencil-edition :is(#comeback-contract-ui,#comeback-complete-ui) > div {
    color: var(--lead) !important;
    background: #fbf4e8 var(--drawn-paper, none) repeat !important;
    border-color: transparent !important;
    border-image: var(--drawn-frame, none) 39 / 13px / 0 round;
    border-radius: 0 !important;
    box-shadow: 2px 3px 0 #74645024 !important;
}
.pencil-edition #start-content .pencil-cover {
    justify-content: stretch;
    border-color: transparent;
    background: var(--drawn-rule, none) left bottom / 158px 4px repeat-x;
}
.pencil-edition .pencil-orbit #start-content .pencil-title h1,
.pencil-edition :is(#pause-text,#space-result-title,.controls-tutorial-title,#settings-view h1) {
    font-family: var(--hand-title) !important;
    font-style: normal;
    letter-spacing: -.045em;
    color: var(--lead) !important;
    text-shadow: none !important;
}
.pencil-edition :is(.menu-ship-name,.menu-ship-strength,.menu-ship-badge,
    .pause-menu-btn,.diff-seg-btn,.hud-label,.hud-text,.hud-main,.hud-value,
    .controls-note,.flight-keys,.flight-controls strong,.flight-controls small,.flight-tip,.orbit-touch-help,
    .key-label,.controls-tutorial-hint,.settings-label,
    .settings-val,.settings-check-label,#shield-label-mobile,#shield-count-mobile,
    #pause-difficulty,#sector-progress,#space-result p,#space-objective,
    #center-screen-overlay button,#pause-btn,#pause-btn-desktop) {
    font-family: var(--hand) !important;
    font-style: normal !important;
    letter-spacing: .015em;
}
.pencil-edition .menu-ship-name,
.pencil-edition .diff-seg-btn { line-height: 1.36; }
.pencil-edition .menu-ship-badge { line-height: 1.34; }
.pencil-edition .pencil-orbit #center-screen-overlay.menu-bg .menu-ship-card,
.pencil-edition .pencil-orbit #center-screen-overlay.menu-bg button,
.pencil-edition .pencil-orbit #pause-overlay button,
.pencil-edition .pencil-orbit :is(#pause-btn, #pause-btn-desktop),
.pencil-edition :is(#comeback-contract-ui,#comeback-complete-ui) button {
    background: #f9f0df var(--drawn-paper, none) !important;
    color: var(--lead) !important;
    border-color: transparent !important;
    border-image: var(--sketch-border) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
.pencil-edition .pencil-orbit #center-screen-overlay.menu-bg :is(.menu-ship-card.is-selected, #start-btn, .diff-seg-btn.is-active, #space-replay, #hangar-view .ship-action-btn.is-active),
.pencil-edition .pencil-orbit #pause-overlay #resume-btn {
    background: var(--selected-strokes, var(--drawn-hatch, none) 0 0 / 18px 14px repeat), var(--selected-paper, #f4e1bd var(--drawn-paper, none)) !important;
    background-blend-mode: multiply !important;
    outline-color: transparent;
}
.pencil-edition .pencil-orbit #start-content .menu-ship-card.is-selected { outline: none; }
.pencil-edition .pencil-orbit #start-content .menu-ship-badge {
    color: #58493a;
    background: transparent;
    box-shadow: none;
}
.pencil-edition .pencil-orbit #start-content .is-selected .menu-ship-badge {
    color: #774820;
    background: var(--drawn-rule, none) center bottom / 100% 2px no-repeat;
}
.pencil-edition .pencil-orbit #menu-difficulty {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}
.pencil-edition .pencil-orbit #center-screen-overlay.menu-bg .diff-seg-btn:not(.is-active) {
    background: transparent !important;
    border-image: none !important;
}
.pencil-edition .pencil-orbit #center-screen-overlay #start-content .pencil-lettered {
    position: relative;
    font-family: 'Segoe UI', sans-serif !important;
    line-height: normal;
    color: transparent !important;
}
.pencil-edition .pencil-orbit #center-screen-overlay #start-btn { line-height: 1.333; }
.pencil-edition #start-btn::after {
    content: "";
    display: inline-block;
    width: .68em;
    height: .7em;
    margin-inline-start: .38em;
    vertical-align: -.02em;
    background-color: currentColor;
    clip-path: polygon(3% 0, 100% 51%, 0 98%);
    pointer-events: none;
}
@media (forced-colors: active) {
    .pencil-edition #start-btn::after { background-color: ButtonText; forced-color-adjust: none; }
}
.pencil-edition .pencil-button-ink {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--lead);
    font-family: var(--hand);
    line-height: 1.15;
    letter-spacing: .015em;
    pointer-events: none;
}
.pencil-edition .pencil-button-ink::before { content: attr(data-caption); }
@media (forced-colors: none) {
    .pencil-edition.graphite-buttons .pencil-orbit button {
        --sketch-border: url("../assets/pencil-button-frame.webp") 48 75 55 56 / var(--button-edge-width, 9px 15px 11px 12px) / 0 stretch;
        --selected-strokes: var(--drawn-button-hatch) center / auto calc(100% - 6px) no-repeat;
        --selected-paper: linear-gradient(98deg, #f0d6aeea, #f5e1bdee 55%, #efd6adeb) center / calc(100% - 7px) calc(100% - 5px) no-repeat;
    }
    .pencil-edition.graphite-buttons .diff-seg-btn { --button-edge-width: 6px 11px 7px 9px; }
    .pencil-edition.graphite-buttons #ui-layer-desktop #pause-btn-desktop,
    .pencil-edition.graphite-buttons #ui-layer #pause-btn {
        background: url("../assets/pencil-pause.webp") center / 100% 100% no-repeat border-box !important;
        border-color: transparent !important;
        border-image: none !important;
        transition-property: transform, filter;
    }
    .pencil-edition.graphite-buttons :is(#pause-btn, #pause-btn-desktop) > span { opacity: 0; }
}

/* Green pencil identifies the main progression buttons. */
@media (forced-colors: none) {
    .pencil-edition .pencil-orbit :is(#start-content #start-btn, #level-complete-content #next-level-btn:enabled, #outpost-results #outpost-continue) {
        --green-action-paper: linear-gradient(102deg, #c6e1adec, #e2efccee 54%, #c5deb3ec),
            var(--green-action-base, #eff4df) var(--drawn-paper, none) repeat;
        color: #29422a !important;
    }

    .pencil-edition .pencil-orbit #start-content #start-btn {
        --selected-paper: var(--green-action-paper);
    }

    .pencil-edition .pencil-orbit #start-content .menu-ship-card.is-selected {
        --selected-paper: linear-gradient(112deg, #d3e4f4eb, #e7f0f9ee 52%, #c9dff3ec),
            #f0f5fb var(--drawn-paper, none) repeat;
    }

    .pencil-edition .pencil-orbit #start-content .is-selected .menu-ship-badge {
        color: #315875;
    }
}
.pencil-edition .pencil-orbit :is(button,input):focus-visible {
    outline: 2px solid #885122 !important;
    outline-offset: 2px;
}
@media (hover: hover) {
    .pencil-edition .pencil-orbit #center-screen-overlay.menu-bg button:hover,
    .pencil-edition .pencil-orbit #pause-overlay button:hover { background-color: #ecd9b7 !important; }
    .pencil-edition .pencil-orbit :is(#start-content #start-btn, #level-complete-content #next-level-btn:enabled):hover {
        --green-action-base: #e3efcf;
    }
}
.pencil-edition body.pencil-orbit.desktop #ui-layer-desktop,
.pencil-edition body.pencil-orbit #ui-layer {
    /* Crop a single sheet on small screens to keep the pencil grain at a readable scale. */
    background: #d8d4cc url("../assets/pencil-hud-graphite.webp") center / max(100%, 960px) auto no-repeat;
    color: var(--lead);
    border-bottom-color: transparent;
    box-shadow: none;
    filter: saturate(var(--sector-chroma));
}
.pencil-edition :is(#ui-layer,#ui-layer-desktop)::after {
    content: "";
    position: absolute;
    inset: auto 0 -1px;
    height: 5px;
    background: var(--drawn-rule, none) left center / 148px 5px repeat-x;
    pointer-events: none;
}
.pencil-orbit .hud-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pencil-orbit #hud-sound {
    display: grid;
    place-items: center;
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    appearance: none;
    box-shadow: none;
    transform: none;
    color: #423c34;
    cursor: pointer;
    touch-action: manipulation;
}
#hud-sound svg { width: 24px; height: 24px; pointer-events: none; }
#hud-sound[aria-pressed="true"] .sound-cross,
#hud-sound[aria-pressed="false"] .sound-wave { display: none; }
.pencil-orbit #hud-sound:focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }
.pencil-orbit #hud-sound:active svg { transform: scale(.92); }
/* The touch HUD has an open left margin. Keep the full tap target without raising the flight bar. */
.pencil-orbit #ui-layer { grid-template-columns: minmax(44px, 1fr) auto minmax(max-content, 1fr); }
.pencil-orbit #ui-layer #hud-sound {
    position: absolute;
    left: max(4px, env(safe-area-inset-left));
    top: max(0px, calc((100% - 44px) / 2));
}
@media (forced-colors: none) {
    html:not(.pencil-edition) .pencil-orbit #ui-layer #hud-sound { color: #f7f3eb; }
}
@media (hover: none) and (pointer: coarse) {
    .pencil-orbit #ui-layer #hud-sound {
        top: var(--hud-top-clearance, env(safe-area-inset-top, 0px));
        padding-bottom: 10px;
    }
}
@media (max-width: 375px) {
    .pencil-orbit #ui-layer .hud-panel { flex-direction: column; padding: 0 3px; }
    .pencil-orbit #ui-layer .hud-value { margin-left: 0; }
}
.pencil-orbit #hud-sound:disabled { cursor: default; }
@media (forced-colors: active) {
    .pencil-orbit #hud-sound { color: ButtonText; }
}
.pencil-edition body.pencil-orbit.desktop .hud-pill,
.pencil-edition .pencil-orbit .hud-panel {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none;
}
.pencil-edition .pencil-orbit .hud-main,
.pencil-edition .pencil-orbit .hud-value { font-variant-numeric: tabular-nums; }
.pencil-edition body.pencil-orbit:not(.desktop) #ui-layer {
    --flight-bar-inset: var(--hud-top-clearance, env(safe-area-inset-top, 0px));
    height: auto;
    min-height: calc(56px + var(--flight-bar-inset));
    width: 100%;
    transform: none;
    flex-shrink: 0;
    grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
    padding: var(--flight-bar-inset) calc(8px + env(safe-area-inset-right, 0px))
             0 calc(8px + env(safe-area-inset-left, 0px));
}
/* The Home Screen status-bar blur can extend below the reported safe area.
   Keep the controls clear even when iOS reports a zero inset. */
.pencil-edition body.pencil-orbit.ios-standalone:not(.desktop) #ui-layer {
    --hud-top-clearance: max(56px, calc(env(safe-area-inset-top, 0px) + 24px));
    background-size: cover;
}
.pencil-edition #ui-layer .touch-hud-actions {
    grid-area: 1 / 1;
    justify-self: start;
}
.pencil-edition .pencil-orbit #ui-layer .touch-hud-actions :is(#pause-btn, #hud-sound) {
    position: static;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
}
.pencil-edition .touch-hud-actions #pause-btn {
    width: clamp(48px, 5.3vw, 64px);
    height: 48px;
}
.pencil-edition body.pencil-orbit:not(.desktop) #ui-layer .hud-group { gap: clamp(6px, 1vw, 18px); }
.pencil-edition body.pencil-orbit:not(.desktop) #ui-layer .hud-panel {
    gap: 1px 6px;
    padding: 2px clamp(2px, .5vw, 6px);
}
.pencil-edition body.pencil-orbit:not(.desktop) #ui-layer .hud-text {
    font-size: clamp(11px, 8px + .7vw, 16px);
    line-height: 1.2;
}
.pencil-edition body.pencil-orbit:not(.desktop) #ui-layer .hud-value {
    margin-left: 0;
    font-size: clamp(16px, 10px + 1.2vw, 24px);
    line-height: 1.2;
}
@media (max-width: 560px) {
    .pencil-edition #ui-layer .hud-panel { flex-direction: column; }
    .pencil-edition #ui-layer .hud-panel.highscore { display: none; }
    .pencil-edition #start-content #menu-ship-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 375px) {
    .pencil-edition body.pencil-orbit:not(.desktop) #ui-layer {
        padding-inline: calc(4px + env(safe-area-inset-left, 0px)) calc(4px + env(safe-area-inset-right, 0px));
    }
    .pencil-edition #ui-layer .touch-hud-actions { gap: 2px; }
    .pencil-edition body.pencil-orbit:not(.desktop) #ui-layer .hud-group { gap: 4px; }
    .pencil-edition body.pencil-orbit:not(.desktop) #ui-layer .hud-panel { padding-inline: 0; }
}
.kuiper-outpost-active :is(#ui-layer > .hud-group, #ui-layer-desktop > .hud-cluster) { display: none; }
.pencil-edition body.pencil-orbit.kuiper-outpost-active:not(.desktop) #ui-layer {
    grid-template-columns: auto minmax(0, 1fr);
}
#outpost-status:not([hidden]) {
    display: flex;
    grid-area: 1 / 2;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(6px, 1.8vw, 24px);
}
#outpost-status .hud-panel { white-space: nowrap; }
#outpost-hints:not([hidden]) {
    min-height: 44px;
    min-width: 44px;
    padding: 0 7px;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: #294b5f;
    font: 700 14px/1 var(--hand);
    text-decoration: underline;
    touch-action: manipulation;
    pointer-events: auto;
}
#outpost-hints:focus-visible { outline: 2px solid #285e78; }
#outpost-hints[aria-expanded="true"] { color: #233540; text-decoration-thickness: 2px; }
#outpost-score { position: relative; }
#outpost-score-loss:not([hidden]) {
    position: absolute;
    top: 100%;
    right: 0;
    padding: 2px 8px;
    border: 1px solid #883d31;
    border-radius: 3px;
    background: #fff0d9;
    color: #842e23;
    font: 700 16px/1.25 var(--hand);
}
#outpost-death-points { color: #842e23; }
.pencil-edition .pencil-orbit.desktop .hud-heart {
    font-size: 0;
    background: var(--drawn-heart, none) center / contain no-repeat;
    filter: none;
    text-shadow: none;
}
.pencil-edition .hud-bonus .hud-icon {
    background: var(--drawn-medal, none) center / contain no-repeat;
}
.pencil-edition .hud-bonus .hud-svg { visibility: hidden; }
.pencil-edition .pencil-orbit :is(#bonus-display,#bonus-display-desktop).bonus-text-active {
    color: #70441b !important;
    text-shadow: none !important;
}
.pencil-edition .pencil-orbit #sector-progress {
    color: var(--flight-lettering, #42382e) !important;
    text-shadow: 0 1px 2px var(--flight-halo, #f7f3e9) !important;
    border: 0;
    text-transform: none;
    font-weight: 600;
    letter-spacing: .01em;
}
.pencil-edition .pencil-orbit #shield-btn,
.pencil-edition .controls-shield-btn-visual {
    background: var(--drawn-shield, none) center / 100% 100% no-repeat !important;
    border-color: transparent !important;
    box-shadow: none !important;
    text-shadow: none;
}
.pencil-edition :is(#shield-btn span,.shield-count-visual),
.pencil-edition .controls-shield-btn-visual::before {
    font-family: var(--hand) !important;
    color: var(--lead) !important;
    text-shadow: none !important;
}
.pencil-edition .controls-shield-btn-visual::before { top: 20%; }
.pencil-edition .pencil-orbit #shield-btn span { line-height: 1.12; }
.pencil-edition .pencil-orbit #shield-label-mobile {
    font-size: 11px !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}
.pencil-edition .pencil-orbit #joystick-base {
    background: var(--drawn-ring, none) center / contain no-repeat;
    border-color: transparent;
    box-shadow: none;
}
.pencil-edition #joystick-base::after { display: none; }
.pencil-edition .pencil-orbit #joystick-stick {
    background: var(--drawn-knob, none) center / contain no-repeat;
    box-shadow: none;
}
.pencil-edition .pencil-orbit :is(#pause-overlay,#controls-tutorial) {
    background: #efe6d1dd;
    filter: none;
}
/* The orbit interface uses the pigment level of the current page. */
.pencil-edition .pencil-orbit :is(#sector-progress, #shield-btn, #joystick-zone,
    #achievement-toast, #multiplier-toast, #controls-tutorial, #launch-cutscene, #comeback-contract-ui,
    #comeback-complete-ui, #challenge-panel),
.pencil-edition .pencil-orbit :is(#game-over-content, #game-complete-content) > :not(.pilot-comment),
.pencil-edition .pencil-orbit :is(#game-over-content, #game-complete-content)::before,
.pencil-edition .pencil-orbit :is(#game-over-content, #game-complete-content)::after {
    filter: saturate(var(--sector-chroma));
}
.pencil-edition body.pencil-orbit :is(#ui-layer, #ui-layer-desktop) .sector-location {
    display: grid;
    grid-template-columns: auto auto;
    align-content: center;
    justify-content: center;
    align-items: baseline;
    gap: 0 .35em;
}
.pencil-orbit .sector-place {
    grid-column: 1 / -1;
    color: var(--sector-ink, #474747);
    font: 600 clamp(11px, 1.2vw, 15px)/1.1 var(--hand);
    letter-spacing: 0;
    text-align: center;
    text-transform: none;
}
@media (max-width: 560px) {
    .pencil-orbit .sector-place { max-width: 8ch; white-space: normal; }
}
.pencil-edition :is(#pause-difficulty,.orbit-touch-help,.flight-tip,.flight-controls strong,
    .controls-note,.key-label,.shield-count-visual,
    #comeback-contract-ui div,#comeback-complete-ui div) {
    color: var(--lead) !important;
    text-shadow: none !important;
}
.pencil-edition .controls-tutorial-title,
.pencil-edition #pause-text {
    background: var(--drawn-rule, none) left bottom / 100% 5px no-repeat;
    box-shadow: none;
    font-weight: 700;
}
.pencil-edition .controls-tutorial-inner .controls-tutorial-hint { color: var(--ochre); }
.pencil-edition .controls-tutorial-inner .controls-joystick-image {
    filter: none;
    border-radius: 0;
    box-shadow: none;
}
.pencil-edition .pencil-orbit #settings-view :is(.settings-val, .settings-check-label) {
    color: var(--lead) !important;
    text-shadow: none;
}
.pencil-edition .settings-check-label input[type="checkbox"] {
    appearance: none;
    border: 1px solid transparent;
    border-image: var(--drawn-frame,none) 39 / 4px / 0 round;
    background: #f8efdf;
}
.pencil-edition .settings-check-label input:checked {
    background: #f3dfba var(--drawn-tick,none) center / contain no-repeat;
}
@media (forced-colors: active) {
    .pencil-edition body.pencil-orbit.desktop #ui-layer-desktop,
    .pencil-edition body.pencil-orbit #ui-layer { background: Canvas; }
    .pencil-edition .settings-check-label input[type="checkbox"] { appearance: auto; }
}
.pencil-edition .settings-slider { background: var(--drawn-rule, none) center / 100% 6px no-repeat; }
.pencil-edition .settings-slider::-webkit-slider-thumb {
    background: var(--drawn-knob, none) center / contain no-repeat;
    border-color: transparent;
    box-shadow: none;
}
.pencil-edition .settings-slider::-moz-range-thumb {
    background: var(--drawn-knob, none) center / contain no-repeat;
    border-color: transparent;
    box-shadow: none;
}
.pencil-edition :is(#achievement-toast,#multiplier-toast) {
    background: #f6ecd9 var(--drawn-paper,none) !important;
    color: var(--lead) !important;
    border-image: var(--sketch-border) !important;
    text-shadow: none !important;
    box-shadow: none !important;
    font-family: var(--hand) !important;
}
.pencil-edition #achievement-toast > div { color: var(--lead) !important; }

/* The briefing notebook and the loose score sheet rest on the same walnut desk. */
.pencil-edition .pencil-orbit #center-screen-overlay:is(.start-menu-visible, .round-results-visible, .sector-complete),
.pencil-edition .pencil-orbit #center-screen-overlay:has(> #space-result:not([hidden])) {
    background:
        linear-gradient(130deg, #605b572e, #25232245),
        #41362e var(--desk-texture, url("../assets/pencil-score-desk.webp")) center / cover no-repeat;
    background-blend-mode: normal;
    touch-action: pan-y;
}
@media (max-width: 700px), (max-width: 920px) and (max-height: 500px) {
    .pencil-edition #center-screen-overlay { --desk-texture: url("../assets/pencil-score-desk-small.webp"); }
}
.pencil-edition :is(#start-content, .pilot-sheet) {
    --rule-spacing: clamp(18px, 2.7vh, 25px);
    --rule-top: clamp(20px, 4.8vh, 42px);
    --rule-gutters: clamp(26px, 4.2vw, 46px);
    --notebook-ruling:
        repeating-linear-gradient(to bottom, transparent 0 calc(var(--rule-spacing) - 1.5px),
            #697e8818 calc(var(--rule-spacing) - 1.5px), #697e8838 calc(var(--rule-spacing) - .5px),
            transparent var(--rule-spacing))
            center var(--rule-top) / calc(100% - var(--rule-gutters)) calc(100% - var(--rule-top) - 14px) no-repeat;
}
.pencil-edition .pencil-orbit #center-screen-overlay.start-menu-visible > #start-content {
    position: relative;
    background:
        var(--notebook-ruling),
        linear-gradient(110deg, #fff8e9c9, #fff8e5a8 52%, #faf0dcca),
        #f6ecd9 url("../assets/pencil-pause-paper.webp") 50% 64% / auto 160% no-repeat !important;
    box-shadow: 2px 3px 0 #e6d9bd, 3px 4px 0 #b5a384, 5px 6px 0 #f6ead1,
                6px 7px 0 #baa98c, 8px 11px 12px #58412335 !important;
}
.pencil-edition #space-objective {
    margin: 0 0 12px;
    color: var(--pencil-muted);
    font-size: 15px;
}
.pencil-edition .pencil-orbit #center-screen-overlay > #space-result {
    background: var(--notebook-ruling), #fbf4e8 var(--drawn-paper, none) repeat !important;
    border-image: none !important;
    border-radius: 2px 1.5px 2.5px 1.5px !important;
    box-shadow: inset 0 0 2.5px #ad977270, -.5px 1.5px 1.25px #e7d7bbab, 0 3px 2px #473b307d,
                3px 8px 10px -4px #17120db3, 8px 17px 26px -8px #16120d9c !important;
}
#space-result .score-sheet-edge {
    position: absolute;
    inset: -1px;
    pointer-events: none;
    border: 1px solid transparent;
    border-image: var(--crew-frame);
    opacity: .34;
    filter: blur(.35px);
}
.pencil-edition .start-menu-visible .pencil-cover {
    /* Let the rules show through the drawing's pale stock and keep its graphite tones. */
    mix-blend-mode: darken;
}
.pencil-edition .start-menu-visible .pencil-cover::before {
    mask-image: linear-gradient(to right, transparent, #000 13%, #000 92%, transparent),
                linear-gradient(to bottom, transparent, #000 8%, #000 90%, transparent);
    mask-composite: intersect;
}
.briefing-margins { display: none; }
.pencil-edition .start-menu-visible .briefing-margins {
    --coil-width: clamp(28px, calc(100vw - 820px), 48px);
    display: block;
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}
.briefing-margins::before {
    content: "";
    position: absolute;
    inset-block: 4%;
    left: calc(-.43 * var(--coil-width));
    width: var(--coil-width);
    background-image: var(--drawn-binding, none);
    background-size: 100% clamp(72px, 10.5vh, 104px);
    background-repeat: no-repeat round;
}
.pencil-edition .start-menu-visible #start-content::before,
.pencil-edition .start-menu-visible #start-content::after {
    position: absolute;
    pointer-events: none;
    background: center / contain no-repeat;
}
.pencil-edition .start-menu-visible #start-content::before {
    /* The loose chart can lie across the spine on smaller tablets. */
    z-index: 2;
    aspect-ratio: 680 / 623;
    background-image: url("../assets/pencil-sector-chart.webp");
    transform: rotate(-5deg);
}
.pencil-edition .start-menu-visible #start-content::after {
    aspect-ratio: 525 / 590;
    background-image: url("../assets/pencil-preflight-slip.webp");
    transform: rotate(3deg);
}
@media (min-width: 720px) and (min-height: 540px) {
    /* The pilot stays in the space left by the ship cards. */
    .pencil-edition .start-menu-visible .briefing-margins::after {
        content: "";
        position: absolute;
        right: 2.2%;
        bottom: 2.8%;
        width: max(0px, calc((100% - var(--ship-picker-width)) / 2 - 24px));
        height: 56%;
        background: url("../assets/pencil-cover-pilot.webp") right bottom / contain no-repeat;
        mix-blend-mode: multiply;
    }
    .pencil-edition .start-menu-visible #start-content { --side-room: calc((100vw - var(--ship-picker-width)) / 2 - 38px); }
    .pencil-edition .start-menu-visible #start-content::before {
        content: "";
        left: calc((100% - 100vw) / 2 + max(18px, env(safe-area-inset-left)));
        bottom: 9%;
        width: min(20vw, var(--side-room), 228px);
    }
    .pencil-edition .start-menu-visible #start-content::after {
        content: "";
        right: calc((100% - 100vw) / 2 + max(18px, env(safe-area-inset-right)));
        top: 3%;
        width: min(18vw, var(--side-room), max(100px, calc((100vw - 820px) / 2 + 8px)), 202px);
    }
}
@media (min-width: 1180px) and (min-height: 540px) {
    .pencil-edition .start-menu-visible #start-content { --desk-margin: calc((100vw - 820px) / 2); }
    .pencil-edition .start-menu-visible #start-content::before {
        inset: auto calc(100% - 8px) 7% auto;
        width: min(334px, calc(var(--desk-margin) - 30px));
    }
    .pencil-edition .start-menu-visible #start-content::after {
        inset: 4% auto auto calc(100% - 8px);
        width: min(260px, calc(var(--desk-margin) - 10px));
    }
}
@media (min-width: 720px) and (max-width: 1179px) and (min-height: 840px) and (orientation: portrait) {
    .pencil-edition .start-menu-visible #start-content::before,
    .pencil-edition .start-menu-visible #start-content::after {
        width: auto;
        height: min(205px, calc((100dvh - 100%) / 2 - 18px));
    }
    .pencil-edition .start-menu-visible #start-content::before { inset: calc(100% - 15px) auto auto 6%; }
    .pencil-edition .start-menu-visible #start-content::after { inset: auto 6% calc(100% - 13px) auto; }
}
@media (max-width: 719px) and (min-height: 780px) and (orientation: portrait) {
    .pencil-edition .start-menu-visible #start-content::after {
        content: "";
        inset: auto 5% calc(100% - 12px) auto;
        height: min(122px, calc((100dvh - 100%) / 2 - 15px));
    }
}
@media (max-width: 560px) {
    .pencil-edition .start-menu-visible .briefing-margins { --coil-width: 20px; }
    .briefing-margins::before { background-size: 100% 64px; }
}
@media (forced-colors: active) {
    .pencil-edition .pencil-orbit #center-screen-overlay:is(.start-menu-visible, .round-results-visible, .sector-complete) { background: Canvas; }
    .pencil-edition .pencil-orbit #center-screen-overlay.start-menu-visible > #start-content,
    .pencil-edition .pencil-orbit #center-screen-overlay > #space-result {
        background: Canvas !important;
        box-shadow: none !important;
    }
    .pencil-edition .pencil-orbit #center-screen-overlay > #space-result { border: 1px solid CanvasText !important; }
    #space-result .score-sheet-edge { display: none; }
    .pencil-edition .start-menu-visible #start-content::before,
    .pencil-edition .start-menu-visible #start-content::after,
    .pencil-edition .start-menu-visible .briefing-margins { display: none; }
}

/* Draw the crew in the journal margins. Portraits, stains and lettering stay off the flight canvas. */
.pencil-orbit {
    --crew-hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", cursive;
    --crew-title: "Ink Free", "Bradley Hand", var(--crew-hand);
    --crew-frame: url("../assets/pencil-button-frame.webp") 48 75 55 56 / 9px 15px 11px 12px stretch;
}
.pencil-edition .pencil-orbit #center-screen-overlay:has(> #space-result:not([hidden])) {
    box-sizing: border-box;
    justify-content: flex-start !important;
    overflow-y: auto !important;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) !important;
}
.pencil-edition .pencil-orbit #center-screen-overlay #space-result.pilot-sheet {
    transform: none !important;
    margin: auto 0;
    flex-shrink: 0;
}
.pencil-orbit #center-screen-overlay :is(#space-result, #level-complete-content, #game-over-content, #victory-stats-content, #game-complete-content).pilot-sheet {
    box-sizing: border-box;
    position: relative;
    isolation: isolate;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: min(990px, 100%);
    padding: clamp(16px, 3vw, 34px);
    background: var(--notebook-ruling, linear-gradient(transparent, transparent)),
        var(--result-paper, #faf1df) var(--drawn-paper, none) repeat !important;
    color: #3f352c;
    border: 1px solid #806e56;
    border-image: var(--crew-frame);
    box-shadow: 3px 4px 0 #69523720;
}
.pilot-sheet::before, .pilot-sheet::after {
    content: "";
    position: absolute;
    pointer-events: none;
    z-index: -1;
    background: center / contain no-repeat;
    mix-blend-mode: multiply;
}
.pilot-sheet::before {
    top: 4px;
    right: 5px;
    width: clamp(62px, 10vw, 132px);
    aspect-ratio: 1.2;
    opacity: .66;
    background-image: url("../assets/pencil-paper-crease.webp");
}
.pilot-sheet::after {
    bottom: 5px;
    left: 8px;
    width: clamp(55px, 9vw, 106px);
    aspect-ratio: .95;
    opacity: .49;
    transform: rotate(-23deg);
    background-image: url("../assets/pencil-coffee-ring.webp");
}
.pilot-comment {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 4px auto 12px;
    max-width: 100%;
}
.pilot-comment::before {
    content: "";
    flex: none;
    width: 64px;
    height: 70px;
    background: var(--pilot-drawing) center / contain no-repeat;
    pointer-events: none;
}
.pilot-sheet[data-pilot="ace"] { --pilot-drawing: url("../assets/pencil-pilot-ace-color.webp"); }
.pilot-sheet[data-pilot="veteran"] { --pilot-drawing: url("../assets/pencil-pilot-alien-color.webp"); }
.pilot-sheet[data-pilot="veteran"] .pilot-comment { flex-direction: row-reverse; }
.pilot-comment figcaption, .pause-mouse span, .settings-engineer figcaption {
    color: #48392d;
    font: 600 clamp(14px, 1.45vw, 20px)/1.36 var(--crew-hand);
    text-transform: none;
    letter-spacing: -.035em;
    text-align: center;
    text-wrap: balance;
}
.pilot-comment figcaption { max-width: 24ch; transform: rotate(-2deg); }
.pilot-sheet[data-pilot="veteran"] figcaption { transform: rotate(2deg); }
.pencil-orbit #center-screen-overlay .pilot-sheet :is(h1, h2, p, .hud-text span, .level-bonus-label, .level-bonus-value, .level-bonus-note) {
    color: #42382e !important;
    text-shadow: none !important;
}
.pencil-orbit #center-screen-overlay .pilot-sheet :is(h1, h2) {
    font-family: var(--crew-title);
    letter-spacing: .01em;
    background: none;
    -webkit-text-fill-color: currentColor;
    filter: none;
}
.pencil-orbit #center-screen-overlay :is(#game-over-content, #game-complete-content).pilot-sheet h1 {
    max-width: 100%;
    font-size: clamp(32px, 6.5vw, 68px) !important;
    line-height: 1.08;
    text-wrap: balance;
    margin: 4px 0 10px;
}
.pencil-orbit #game-over-content.pilot-sheet > p { margin-block: 4px !important; }
.pencil-orbit .pilot-sheet :is(#high-score-input, #high-score-input-victory) { margin-block: 12px !important; max-width: 100%; }
.pencil-orbit .pilot-sheet :is(#submit-score-btn, #submit-score-btn-victory) { margin-top: 4px; }
.pencil-orbit #level-complete-content {
    --crew-title: var(--crew-hand);
    font-family: var(--crew-hand);
}
/* Keep the notebook shading while letting the progression and reward accents hold their color. */
.pencil-edition .pencil-orbit #level-complete-content {
    --result-paper: color-mix(in srgb, #f0f0f0, #faf1df calc(var(--sector-chroma) * 100%));
}
.pencil-edition .pencil-orbit[data-orbit-sector="1"] #level-complete-content {
    background-blend-mode: luminosity;
}
.pencil-edition .pencil-orbit #level-complete-content :is(h1, h2, p, .pilot-comment figcaption, button:not(#next-level-btn)),
.pencil-edition .pencil-orbit #level-complete-content::before,
.pencil-edition .pencil-orbit #level-complete-content::after {
    filter: saturate(var(--sector-chroma));
}
.pencil-orbit #level-complete-content :is(h1, #local-pace-feedback, .level-bonus-value) { font-weight: 700; }
.pencil-orbit #level-complete-content h2 { font-weight: 400; }
.pencil-orbit #level-complete-content .level-bonus-label { letter-spacing: .025em; }
.pencil-orbit #center-screen-overlay.sector-complete .pilot-sheet .sector-complete-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 445px);
}
.pencil-orbit #level-complete-content.mars-retry #next-level-btn { grid-column: 1 / -1; }
.pencil-orbit #level-complete-content.mars-retry #level-complete-bonus-row { display: none; }
.pencil-orbit .sector-complete-actions #sector-quit-btn {
    grid-column: 1 / -1;
    justify-self: center;
    min-height: 44px;
    width: min(100%, 13rem);
}
.pencil-orbit #center-screen-overlay .pilot-sheet .level-bonus-pill {
    background: #f3e7d1;
    border: 1px solid #ac9475;
    box-shadow: none;
    color: #4a3d30;
}
.pencil-orbit #center-screen-overlay .pilot-sheet button {
    color: #40352a !important;
    background: #f8eedc !important;
    border: 1px solid #89745a !important;
    border-image: var(--crew-frame) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    font-family: var(--crew-hand);
}
.pencil-orbit #center-screen-overlay .pilot-sheet :is(#next-level-btn, #restart-btn, #victory-restart-btn) {
    background-color: #eed0a0 !important;
}
@media (forced-colors: none) {
    .pencil-edition .pencil-orbit #center-screen-overlay #level-complete-content #next-level-btn:enabled {
        background: var(--green-action-paper) !important;
    }
    .pencil-edition .pencil-orbit #center-screen-overlay #level-complete-content .level-bonus-pill {
        background: linear-gradient(108deg, #f5dda1, #fff0c2 58%, #f1d58e);
        border-color: #a47a37;
    }
    .pencil-edition .pencil-orbit #center-screen-overlay #level-complete-content .level-bonus-stack > div {
        color: #6d4612 !important;
    }
    .pencil-edition .pencil-orbit #center-screen-overlay #level-complete-content .level-bonus-pill .hud-icon {
        filter: sepia(.2);
    }
}
.pencil-orbit #center-screen-overlay #victory-stats-content.pilot-sheet {
    width: min(34rem, 100%);
    flex-direction: column;
    flex-shrink: 0;
    margin: auto 0;
    gap: clamp(10px, 2vh, 18px);
    padding: clamp(16px, 4vw, 36px);
    transform: none !important;
}
.pencil-orbit #victory-stats-content h1 {
    font-size: clamp(32px, 5vw, 50px);
    line-height: 1.1;
    margin: 0;
}
.pencil-orbit #victory-stats-content p { margin: 0; }
.mission-tally {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: min(100%, 25rem);
    margin: 0;
    text-align: left;
    font: 600 clamp(16px, 2.2vw, 21px)/1.4 var(--crew-hand);
}
.mission-tally dt, .mission-tally dd { margin: 0; padding-block: .18em; }
.mission-tally dd {
    padding-left: .7em;
    text-align: right;
    font-family: system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}
.mission-tally .mission-bonus {
    color: #38583d;
    font-size: .88em;
    padding-bottom: .65em;
}
.mission-tally .mission-total {
    padding-top: .4em;
    border-top: 2px solid #80725f;
    font-size: 1.2em;
    font-weight: 700;
}
.pencil-orbit #game-complete-content.pilot-sheet > div:has(#victory-score) {
    background: #f3e7d1 !important;
    border-color: #baa88f !important;
}
.pencil-orbit #center-screen-overlay .pilot-sheet .hud-icon { filter: sepia(.55) saturate(.65); }
.pencil-orbit #center-screen-overlay .pilot-sheet p a { color: #68412c !important; }

@media (min-width: 720px) and (min-height: 445px) {
    .pilot-sheet { --crew-column: clamp(215px, 25vw, 304px); --writing-margin: clamp(20px, 3vw, 42px); }
    .pencil-orbit #center-screen-overlay :is(#space-result, #level-complete-content, #game-over-content, #game-complete-content).pilot-sheet {
        min-height: 384px;
        padding-inline: var(--crew-column) var(--writing-margin);
    }
    .pencil-orbit #center-screen-overlay :is(#space-result, #level-complete-content, #game-over-content, #game-complete-content).pilot-sheet[data-pilot="veteran"] {
        padding-inline: var(--writing-margin) var(--crew-column);
    }
    .pencil-orbit #center-screen-overlay #space-result.pilot-sheet { width: min(850px, calc(100% - 32px)); }
    .pilot-sheet .pilot-comment {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: calc(var(--crew-column) - 25px);
        flex-direction: column;
        gap: 4px;
        margin: 0;
    }
    .pilot-sheet[data-pilot="veteran"] .pilot-comment { left: auto; right: 12px; flex-direction: column; }
    .pilot-comment::before { width: 100%; height: clamp(200px, 27vh, 268px); }
}

.pencil-orbit .pencil-hangar-intro {
    display: flex;
    align-items: center;
    gap: clamp(12px, 3vw, 30px);
    width: min(790px, 100%);
    margin: 0 auto 18px;
    text-align: center;
}
.pencil-hangar-intro h1 { margin: 0 0 6px; font: bold 42px/1.15 var(--crew-title); }
.pencil-hangar-intro p { margin: 0; line-height: 1.4; }

/* Each ship has its own specification sheet in the hangar notebook. */
.pencil-edition #hangar-view .ship-card {
    box-sizing: border-box;
    padding: clamp(14px, 2vw, 22px);
    font-family: var(--hand);
    color: var(--lead);
    border: 1px solid #aa9a83;
    border-image: var(--crew-frame);
    border-radius: 0;
    background: #fffaf0 var(--drawn-paper, none) repeat;
    background-blend-mode: multiply;
    box-shadow: 1px 2px 0 #78644925;
    backdrop-filter: none;
    opacity: 1;
}
.pencil-edition #hangar-view .is-active-ship { background-color: #f8ecd6; }
.pencil-edition #hangar-view .ship-card-top {
    gap: 8px;
    padding-bottom: 8px;
    background: var(--drawn-rule, none) bottom / 100% 3px no-repeat;
}
.pencil-edition #hangar-view .ship-card-title {
    font: bold clamp(20px, 2.2vw, 26px)/1.15 var(--hand-title);
    letter-spacing: .025em;
    color: var(--lead);
}
.pencil-edition #hangar-view .ship-card-badge {
    padding: 3px 7px;
    font: 600 12px/1.4 var(--hand);
    letter-spacing: .03em;
    color: #684c2e;
    border: 1px solid currentColor;
    border-radius: 2px 1px 3px 1px;
    background: transparent;
    transform: rotate(-2deg);
}
.pencil-edition #hangar-view .ship-card-badge-locked { color: var(--pencil-muted); border-style: dashed; }
.pencil-edition #hangar-view .ship-card-imgwrap {
    position: relative;
    isolation: isolate;
    border: 0;
    border-radius: 0;
    background: transparent;
}
.pencil-edition #hangar-view .ship-card-imgwrap::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    background-image: linear-gradient(90deg, #687d852b 1px, transparent 1px),
        linear-gradient(#687d852b 1px, transparent 1px);
    background-size: 16px 16px;
    background-position: center;
    mask-image: radial-gradient(ellipse, black 30%, transparent 73%);
}
.pencil-edition #hangar-view .ship-card-imgwrap img { object-fit: contain; }
.space-prototype #hangar-view .ship-card-imgwrap img { mix-blend-mode: multiply; }
.pencil-edition #hangar-view .ship-card-desc {
    min-height: 0;
    font-size: 15px;
    line-height: 1.4;
    color: var(--lead);
}
.pencil-edition #hangar-view .ship-stat-label {
    font: 600 13px/1.45 var(--hand);
    letter-spacing: .025em;
    text-align: left;
    color: var(--lead);
    text-shadow: none;
}
.pencil-edition #hangar-view .ship-stat-bar {
    height: 12px;
    background: #e8decb;
    border: 1px solid #a59883;
    border-radius: 3px 1px 2px 1px;
    box-shadow: none;
}
.pencil-edition #hangar-view .ship-stat-fill {
    background: var(--drawn-button-hatch, none) left center / auto 24px repeat-x,
        #877f70 url("../assets/pencil-hud-graphite.webp") center / 560px auto;
    background-blend-mode: multiply;
    border-radius: 0;
    clip-path: polygon(0 13%, 38% 4%, 72% 10%, 100% 3%, calc(100% - 3px) 94%, 46% 90%, 0 100%);
    box-shadow: none;
}
.pencil-edition #hangar-view .ship-trait {
    padding: 2px 3px 3px;
    font: 600 12px/1.45 var(--hand);
    letter-spacing: .015em;
    color: var(--pencil-muted);
    background: transparent;
    border: 0;
    border-bottom: 1px solid #82715a63;
    border-radius: 0;
    box-shadow: none;
}
.pencil-edition #hangar-view .ship-trait-con { color: #874e39; border-color: #a76e546e; }
.pencil-edition #center-screen-overlay.menu-bg #hangar-view .ship-action-btn.is-active {
    opacity: 1;
}
@media (min-width: 680px) {
    .pencil-edition #hangar-view .ship-card {
        display: grid;
        grid-template-columns: minmax(140px, 30%) minmax(0, 1fr);
        grid-template-areas: "top top" "sketch description" "sketch stats" "sketch traits" "action action";
        column-gap: 20px;
        align-items: center;
    }
    .pencil-edition #hangar-view .ship-card-top { grid-area: top; }
    .pencil-edition #hangar-view .ship-card-imgwrap { grid-area: sketch; }
    .pencil-edition #hangar-view .ship-card-desc { grid-area: description; text-align: left; margin: 0; }
    .pencil-edition #hangar-view .ship-card-stats { grid-area: stats; }
    .pencil-edition #hangar-view .ship-traits { grid-area: traits; justify-content: flex-start; }
    .pencil-edition #hangar-view .ship-action-btn { grid-area: action; }
}
@media (max-width: 679px) {
    .pencil-edition #center-screen-overlay.menu-bg > #hangar-view { padding: 15px 10px; }
    .pencil-edition #hangar-view .ship-card-imgwrap { height: 112px; }
}
@media (prefers-reduced-motion: reduce) {
    .pencil-edition #hangar-view .ship-stat-fill { transition: none; }
}
@media (forced-colors: active) {
    .pencil-edition #hangar-view .ship-card { border-image: none; border-color: CanvasText; }
    .pencil-edition #hangar-view .ship-stat-bar { border-color: CanvasText; }
    .pencil-edition #hangar-view .ship-stat-fill { background: CanvasText; forced-color-adjust: none; }
}
@media (min-width: 680px) {
    .pencil-orbit .pencil-hangar-intro { text-align: left; }
    .pencil-hangar-intro::after {
        content: "";
        flex: 0 0 35%;
        aspect-ratio: 1.65;
        background: url("../assets/pencil-hangar-sketch.webp") center / contain no-repeat;
    }
}
.pencil-orbit #game-viewport #pause-overlay,
.pencil-orbit #game-viewport #center-screen-overlay.settings-visible {
    box-sizing: border-box;
    isolation: isolate;
    background: #f3e8d5 url("../assets/pencil-pause-paper.webp") center 14% / cover no-repeat;
}
.pencil-orbit #pause-overlay .pause-menu-btn { mix-blend-mode: multiply; }
@media (max-aspect-ratio: 3/4) {
    .pencil-orbit #game-viewport #pause-overlay,
    .pencil-orbit #game-viewport #center-screen-overlay.settings-visible { background-position-x: 89%; }
}
.pencil-orbit #pause-overlay :is(#pause-text, #pause-difficulty, .orbit-touch-help) { color: #43382d !important; text-shadow: none; }
.pencil-orbit #pause-overlay::before, .pause-mouse {
    position: absolute;
    pointer-events: none;
    user-select: none;
}
.pause-mouse {
    width: clamp(72px, 7.5vw, 100px);
    right: max(5%, env(safe-area-inset-right));
    bottom: 12%;
    transform: rotate(4deg);
}
.pause-mouse::before, .pause-mouse::after {
    content: "";
    display: block;
    aspect-ratio: 335 / 326;
    background: url("../assets/pencil-paper-mouse.webp") center / contain no-repeat;
}
.pause-mouse::after { display: none; }
@media (prefers-reduced-motion: no-preference) {
    /* Only the muzzle moves. The eyes and the torn edge belong to the stationary photo below. */
    .pause-mouse::after {
        display: block;
        position: absolute;
        inset: 0 0 auto;
        mask-image: radial-gradient(ellipse 29% 17% at 53% 70%, black 42%, transparent);
        transform-origin: 53% 70%;
        animation: paper-nibble 7s ease-in-out infinite;
    }
    @keyframes paper-nibble {
        0%, 8%, 16%, 100% { transform: none; }
        4%, 12% { transform: translateY(1px) scale(1.03, .96); }
    }
}
.pause-mouse span { display: block; font-size: clamp(11px, .9vw, 13px); }
@media (min-width: 720px) and (min-height: 445px) {
    .pencil-orbit #pause-overlay::before {
        content: "";
        left: 3.5%;
        bottom: 22%;
        width: min(29%, calc(50% - 185px), 430px);
        aspect-ratio: 1.65;
        background: url("../assets/pencil-hangar-sketch.webp") center / contain no-repeat;
    }
}
@media (max-width: 719px) {
    .pause-mouse { width: 48px; right: max(12px, env(safe-area-inset-right)); bottom: auto; top: 10px; }
    .pause-mouse span { display: none; }
    .pilot-sheet::after { opacity: .3; }
}
@media (max-height: 444px) {
    .pilot-comment { margin-block: 3px 6px; }
    .pilot-comment::before, .pause-mouse, .pilot-sheet::after { display: none; }
    .pilot-comment figcaption { max-width: 42ch; transform: none; }
}

/* The headset and engineer sit in the margins of the settings sheet. */
.pencil-orbit #game-viewport #center-screen-overlay.settings-visible {
    --settings-width: clamp(404px, 52vw, 542px);
    background-blend-mode: normal;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
             max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)) !important;
    justify-content: flex-start !important;
    overflow: auto !important;
    touch-action: pan-y;
}
.pencil-orbit #center-screen-overlay.settings-visible > #settings-view {
    position: relative;
    box-sizing: border-box;
    width: min(100%, var(--settings-width));
    max-width: none;
    flex-shrink: 0;
    margin: auto 0 !important;
    transform: none !important;
    background: rgba(255, 249, 234, .55) !important;
}
.pencil-orbit #settings-view .settings-val { color: var(--pencil-ink); }
.pencil-orbit #settings-view .settings-slider { touch-action: none; }
.pencil-edition body.pencil-orbit:not(.desktop) #settings-view .settings-group {
    margin-bottom: clamp(8px, 1.2vw, 14px);
}
.pencil-edition body.pencil-orbit:not(.desktop) #settings-view .settings-label {
    margin-bottom: 2px;
    font-size: clamp(14px, 1.4vw, 18px);
    line-height: 1.25;
}
.pencil-edition body.pencil-orbit:not(.desktop) #settings-view .settings-val {
    min-width: 3.2em;
    font-size: clamp(16px, 1.5vw, 20px);
}
.pencil-edition body.pencil-orbit:not(.desktop) #settings-view .settings-slider {
    height: 44px;
    min-width: 0;
}
.pencil-edition body.pencil-orbit:not(.desktop) .settings-slider::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
}
.pencil-edition body.pencil-orbit:not(.desktop) .settings-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
}
.pencil-edition body.pencil-orbit:not(.desktop) #settings-view .settings-check-label {
    min-height: 44px;
    font-size: clamp(15px, 1.4vw, 18px);
    line-height: 1.3;
    touch-action: manipulation;
}
.pencil-edition body.pencil-orbit:not(.desktop) #settings-view .settings-check-label input {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}
.pencil-orbit #settings-back-btn { mix-blend-mode: multiply; }
.settings-engineer {
    display: none;
    position: absolute;
    pointer-events: none;
    user-select: none;
    margin: 0;
}
.settings-engineer::before {
    content: "";
    display: block;
    aspect-ratio: 760 / 616;
    background: url("../assets/pencil-settings-engineer.webp") bottom center / contain no-repeat;
}
.settings-engineer figcaption { margin-top: 4px; transform: rotate(2deg); }
@media (min-width: 720px) and (min-height: 550px) {
    #settings-view {
        --sketch-gap: clamp(14px, 2.8vw, 52px);
        --sketch-width: min(24vw, calc((100vw - var(--settings-width)) / 2 - var(--sketch-gap) - 16px), 360px);
    }
    #settings-view::before {
        content: "";
        position: absolute;
        pointer-events: none;
        user-select: none;
        right: calc(100% + var(--sketch-gap));
        top: 4%;
        width: calc(var(--sketch-width) * .82);
        aspect-ratio: 570 / 538;
        background: url("../assets/pencil-settings-headset.webp") center / contain no-repeat;
    }
    .settings-engineer {
        display: block;
        left: calc(100% + var(--sketch-gap));
        bottom: 1%;
        width: var(--sketch-width);
    }
}
/* A portrait tablet has room above and below the controls for both drawings. */
@media (min-width: 720px) and (max-width: 960px) and (min-height: 840px) and (orientation: portrait) {
    .pencil-orbit #game-viewport #center-screen-overlay.settings-visible { --settings-width: 500px; }
    #settings-view::before {
        inset: auto auto calc(100% + 12px) -6%;
        width: min(26vw, calc((100dvh - 600px) * .44), 210px);
    }
    .settings-engineer {
        inset: calc(100% + 10px) -8% auto auto;
        width: min(32vw, calc((100dvh - 660px) * .50), 248px);
    }
}
@media (max-width: 719px), (max-height: 549px) {
    .pencil-orbit #center-screen-overlay.settings-visible > #settings-view { padding: 14px 18px; }
    #settings-view .settings-container { padding: 6px 4px; }
    #settings-view .settings-group { margin-bottom: 12px; }
}
@media (max-width: 719px) and (min-height: 780px) and (orientation: portrait) {
    .settings-engineer {
        display: block;
        inset: calc(100% + 10px) 3% auto auto;
        width: min(37vw, calc((100dvh - 560px) * .46), 186px);
    }
}
@media (forced-colors: active) {
    .pilot-sheet::before, .pilot-sheet::after, .pilot-comment::before, .pause-mouse, .pencil-orbit #pause-overlay::before,
    #settings-view::before, .settings-engineer { display: none; }
    .pilot-comment figcaption { color: CanvasText; }
    .pencil-orbit #game-viewport #pause-overlay,
    .pencil-orbit #game-viewport #center-screen-overlay.settings-visible,
    .pencil-edition .pencil-orbit #center-screen-overlay:has(> #space-result:not([hidden])) { background: Canvas; }
    .pencil-orbit #center-screen-overlay.settings-visible > #settings-view { background: Canvas !important; }
    .pencil-orbit #pause-overlay .pause-menu-btn, .pencil-orbit #settings-back-btn { mix-blend-mode: normal; }
}


/* In-flight notes and the issued license use the notebook's existing ink and paper. */
.pencil-orbit #flight-lesson[hidden], .pencil-orbit #flight-skip[hidden],
.pencil-orbit #ground-controls[hidden],
.pencil-orbit #ground-controls button[hidden], .pencil-orbit #school-record[hidden],
.pencil-orbit #school-record button[hidden], .pencil-orbit #license-menu[hidden],
.pencil-orbit :is(#pilot-license, #outpost-results):not([open]) { display: none !important; }

.flight-school-active #sector-progress, .flight-school-active #ui-layer .hud-group,
.flight-school-active #ui-layer-desktop .hud-cluster { visibility: hidden; }
.surface-run-active #game-viewport :is(#joystick-zone, #shield-btn) { display: none !important; }
.surface-run-active:not(.desktop) #game-viewport #ground-controls:not([hidden]) ~ #joystick-zone {
    display: block !important;
}
.pencil-orbit.kuiper-outpost-active #ground-controls button { filter: grayscale(1); }
.pencil-orbit #game-canvas:focus { outline: none; }

#flight-lesson {
    position: absolute; top: max(64px, calc(env(safe-area-inset-top) + 52px)); left: 0; right: 0;
    z-index: 61; display: flex; justify-content: center; pointer-events: none;
    font-family: var(--hand); color: #382f29; text-align: center;
}
.flight-brief {
    box-sizing: border-box; max-width: min(620px, calc(100% - 180px)); padding: 9px 19px 11px;
    display: grid; gap: 2px; border: 1px solid #786752; border-radius: 3px 6px 2px 4px;
    background: #faf1dd var(--drawn-paper,none); box-shadow: 2px 3px 0 #30211132;
}
.pluto-maze-active #flight-lesson { top: 8px; }
.pluto-maze-active .flight-brief { max-width: min(580px, calc(100% - 26px)); }
@media (min-width: 540px) and (max-height: 460px) and (orientation: landscape) {
    .pluto-maze-active:not(.desktop) #flight-lesson {
        right: auto;
        width: min(250px, calc(24% + 58px));
        box-sizing: border-box;
        padding-inline: max(8px, env(safe-area-inset-left)) 8px;
    }
    .pluto-maze-active:not(.desktop) .flight-brief {
        max-width: 100%;
        padding-inline: 10px;
    }
}
.kuiper-outpost-active #flight-lesson { justify-content: center; }
.kuiper-outpost-active .flight-brief { max-width: min(620px, calc(100% - 28px)); }
#flight-tag { color: #774b38; font: 600 clamp(12px,1.6vw,15px)/1.3 var(--hand); }
#flight-task { font: 700 clamp(17px,2.25vw,27px)/1.18 var(--hand-title); }
#flight-hint { font: 500 clamp(14px,1.7vw,18px)/1.3 var(--hand); }
#flight-hint:empty, #outpost-radio[hidden] { display:none; }
#outpost-radio {
    position:absolute; top:calc(100% + 4px);
    left:50%; transform:translateX(-50%); width:max-content; max-width:min(600px, calc(100% - 28px));
    margin:0; padding:4px 11px; box-sizing:border-box; border-radius:3px; background:#22242de8;
    color:#fff3d8; font:500 clamp(14px,1.7vw,18px)/1.35 var(--hand); text-align:center; pointer-events:none;
}
.pencil-orbit.kuiper-outpost-active :is(.flight-brief, #outpost-radio) {
    color: #263b4d;
    background: #dcecf8 var(--drawn-paper, none) repeat;
    background-blend-mode: luminosity;
}
.pencil-orbit.kuiper-outpost-active .flight-brief { border-color: #748c9d; }
.pencil-orbit.kuiper-outpost-active #flight-tag { color: #3f5c70; }
#flight-lesson #flight-skip, #ground-controls button {
    margin:0; box-shadow:none; letter-spacing:normal; text-transform:none;
    color: #352c27; background: #f8eed7; font: 600 16px/1.15 var(--hand);
    border: 1.5px solid #665846; border-radius: 4px 2px 5px 3px; padding: 6px 12px;
    min-height: 44px; touch-action: none; user-select: none; -webkit-user-select: none;
}
#flight-lesson #flight-skip {
    position: absolute; top: 0; right: max(10px, env(safe-area-inset-right)); pointer-events: auto;
}
#ground-controls {
    position: absolute; inset: auto max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    z-index: 25; display: flex; justify-content: space-between; align-items: end; pointer-events: none;
}
#ground-controls .ground-move, #ground-controls .ground-abilities { display:flex; gap:8px; }
.kuiper-outpost-active #ground-controls .ground-move { display: none; }
.pluto-maze-active #ground-controls > div { display: none; }
.surface-run-active:not(.desktop) #ground-controls { z-index: 41; }
@media (min-width: 600px) and (min-height: 600px) {
    .kuiper-outpost-active:not(.desktop) #ground-controls {
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
    }
    .kuiper-outpost-active:not(.desktop) #ground-controls .ground-abilities { flex-direction: column; }
}
#ground-controls button { pointer-events:auto; min-width:52px; box-shadow:0 2px 4px #271f244d; }
#ground-controls [data-walk]:active { background:#dfbe85; transform:translateY(1px); }
.desktop #ground-controls [data-walk] { display:none; }
[data-flight-step="shield"] #shield-btn { outline: 3px dashed #9d5936; outline-offset: 5px; }
.pencil-orbit #school-record { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:8px; margin:10px 0 0; }
.pencil-orbit #settings-view :is(#school-record button, #settings-check-updates) { font: 600 15px/1.25 var(--hand); padding:7px 11px; min-height:44px; }
#settings-updates { max-width: 100%; margin-top: 8px; text-align: center; }
#settings-update-status { margin: 0; font: 600 15px/1.3 var(--hand); }
#settings-update-status:not(:empty) { margin-top: 6px; }
.pencil-orbit :is(#pilot-license, #outpost-results) {
    box-sizing:border-box; width:min(580px,calc(100vw - 28px)); max-height:calc(100dvh - 32px); padding:0;
    border:2px solid #51463a; border-radius:4px 3px 8px 2px; color:#3b3229;
    background:repeating-linear-gradient(0deg,transparent 0 25px,#a4967f38 25px 26px),#fff4dd var(--drawn-paper,none);
    font-family:var(--hand); box-shadow:4px 5px 0 #d3c4a8,6px 9px 20px #22161166;
}
:is(#pilot-license, #outpost-results)::backdrop { background:#30271dd4; }
.license-page { display:grid; grid-template-columns:1.45fr .75fr; gap:5px 10px; padding:clamp(18px,4vw,34px); align-items:center; }
.license-copy p { color:#514537; text-align:left; margin:0 0 9px; font: 500 clamp(14px,2.3vw,19px)/1.4 var(--hand); }
.license-copy p:first-child { color:#796044; }
:is(#pilot-license, #outpost-results) h1 { background:none; color:inherit; -webkit-text-fill-color:currentColor; filter:none; text-transform:none; text-align:left; letter-spacing:normal; }
#pilot-license h1 { font:600 clamp(34px,6.1vw,56px)/1.12 var(--hand-title); margin:0 0 12px; }
.license-page img { width:100%; max-height:190px; object-fit:contain; mix-blend-mode:multiply; }
.license-stamp { display:inline-block; transform:rotate(-4deg); border:3px double #904c35; color:#904c35; padding:3px 7px; margin:6px 0 14px; text-transform:uppercase; font:700 clamp(16px,2.8vw,23px)/1.2 var(--hand); }
.flight-dialog-actions { grid-column:1/-1; display:flex; flex-wrap:wrap; gap:10px; }
.pencil-orbit :is(#pilot-license, #outpost-results) button { margin:0; box-shadow:none; letter-spacing:normal; text-transform:none; min-height:44px; padding:8px 14px; border:1.5px solid #665846; border-radius:2px 5px 2px 4px; font:600 17px/1.2 var(--hand); background:#f9f0dc; color:#382e26; }
.pencil-orbit #pilot-license #license-continue { background:#ecd2a3; }

.pencil-orbit #outpost-results {
    width: min(490px, calc(100vw - 28px));
    padding: clamp(16px, 4vw, 30px);
    touch-action: pan-y;
    overscroll-behavior: contain;
}
#outpost-results h1 {
    margin: 0 0 15px;
    font: 600 clamp(28px, 5vw, 43px)/1.15 var(--hand-title);
}
.outpost-score-breakdown {
    margin: 0 0 18px;
    font: 600 clamp(16px, 2.5vw, 19px)/1.25 var(--hand);
}
.outpost-score-breakdown > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
}
.outpost-score-breakdown dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.outpost-score-breakdown .outpost-score-total {
    margin-top: 5px;
    border-top: 1px solid #ad9267;
    font-size: 1.22em;
    font-weight: 700;
}
.pencil-orbit #outpost-results #outpost-continue {
    background: var(--green-action-paper, #f9f0dc);
}

:where(#pilot-license,#flight-lesson,#school-record,#settings-updates,#ground-controls) button:focus-visible { outline:3px solid #285e78; outline-offset:2px; }
@media (max-width:650px) {
    #flight-lesson { top:max(54px,calc(env(safe-area-inset-top) + 47px)); justify-content:flex-start; padding:0 8px; }
    .flight-brief { max-width:calc(100% - 94px); padding:6px 10px; }
    #flight-lesson #flight-skip { right:5px; max-width:86px; font-size:14px; padding:4px 8px; }
    #ground-controls { left:8px; right:8px; }
    #ground-controls button { min-width:44px; padding:7px; }
}
@media (max-height:560px) {
    #flight-lesson { top:max(43px,calc(env(safe-area-inset-top) + 40px)); }
    .flight-brief { padding:4px 12px; gap:0; }
    #flight-task { font-size:18px; } #flight-hint { font-size:14px; }
    .pencil-orbit #settings-view #school-record { margin:2px 0; }
}
