:root {
  --night-base: #170f0d;
  --night-deep: #100907;
  --night-brass: #cc966d;
  --night-brass-line: #a37558;
  --night-optic: #a0eddb;
  --night-violet: #f2a672;
  --night-ink: #f9e8d1;
  --night-muted: #e3cbb8;
  --night-line: #b58b6d62;
  --night-glass: radial-gradient(ellipse at 8% 0%, #4a3f505c, transparent 49%),
    repeating-linear-gradient(105deg, #e4b66c04 0 1px, transparent 1px 4px),
    linear-gradient(150deg, #292739, #1c2035 64%, #11152a);
  --night-metal: repeating-linear-gradient(103deg, #57340d0e 0 1px, transparent 1px 4px),
    linear-gradient(175deg, #ffeecc, #f2ca85 31%, #d6a45b 54%, #b8803e 98%);
  /* "Night CJK" holds only kana, kanji and hangul (art/type/faces.json, plan stage E): Latin falls through to the next face */
  --night-ui: "Night CJK", "Segoe UI", system-ui, sans-serif;
  --night-display: "Night CJK", Georgia, Cambria, "Noto Serif", "Times New Roman", serif;
  --night-meter: "Night CJK", Consolas, Menlo, "Noto Sans Mono", "Liberation Mono", monospace;
  --sa-control-face: Onest, var(--night-ui);
  --sa-engraving: Unbounded, var(--night-meter);
  --sa-hardware-shadow: 0 0 0 3px #161320, 0 0 0 4px #c1975f62, 0 18px 45px #060815b3,
    inset 0 0 0 3px #292134, inset 0 0 0 4px #ffe0a226;
  --sa-screw: radial-gradient(circle at 42% 41%, #4a2b20 0 13%, #eec39d 15%, #9b725c 44%,
    #422a21 55%, #1c100d 61%, transparent 66%);
}

body { color: var(--night-ink); background: var(--night-base); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--night-optic);
  outline-offset: 3px;
}

#workshop-screens {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: auto;
  background: var(--night-base);
  color: var(--night-ink);
  font: 16px var(--night-ui);
}
#workshop-screens[hidden], #workshop-screens [hidden], #sa-map-panel[hidden],
html[data-workshop-screen="home"] [data-workshop-hud],
html[data-workshop-screen="result"] [data-workshop-hud] { display: none !important; }
html[data-workshop-screen="result"] #workshop-screens { background: transparent; }

.ws-stage {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 100%;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
.ws-world, .ws-shade { position: absolute; inset: 0; z-index: -2; }
.ws-shade { z-index: -1; }
.ws-bench-frame {
  position: absolute;
  border: 1px solid;
  pointer-events: none;
}
.ws-bench-frame::before, .ws-bench-frame::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 11% 89%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 11% 89%, transparent);
}
.ws-bench-frame::before { top: 0; }
.ws-bench-frame::after { bottom: 0; transform: translateX(-50%) rotate(180deg); }
.ws-bench-frame i { position: absolute; }
.ws-bench-frame i:nth-child(1) { top: -1px; left: -1px; }
.ws-bench-frame i:nth-child(2) { top: -1px; right: -1px; transform: rotate(90deg); }
.ws-bench-frame i:nth-child(3) { bottom: -1px; right: -1px; transform: rotate(180deg); }
.ws-bench-frame i:nth-child(4) { bottom: -1px; left: -1px; transform: rotate(270deg); }
.ws-intro { position: relative; }
.ws-setting {
  display: flex;
  align-items: center;
  width: fit-content;
  text-transform: uppercase;
}
.ws-setting::before {
  content: "";
  flex: none;
  border-radius: 50%;
}
.ws-title { margin: 0; }
.ws-title span { display: block; }
.ws-title:focus, .ws-report h1:focus, .sa-dialog h2:focus { outline: none; }

.ws-button, .sa-control {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid var(--night-brass-line);
  border-radius: 5px;
  background: repeating-linear-gradient(110deg, #fff06d05 0 1px, transparent 1px 4px),
    linear-gradient(#cfb6b524, #9b8baa06 50%, #0609186b), #1d2035;
  box-shadow: inset 0 1px #d6c5ff38, inset 0 -3px #080c23, 0 3px 7px #06091588;
  color: var(--night-ink);
  font: 600 14px/1.2 var(--sa-control-face);
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}
.sa-control[aria-pressed="true"] { border-color: #70cfc7; background-color: #17364a; color: var(--night-optic); }
.sa-control:disabled { color: var(--night-muted); cursor: default; }
.ws-button, .sa-control--primary {
  border-color: #f8d89b;
  background: var(--night-metal);
  box-shadow: inset 0 2px #fff4d8, inset 0 -4px #8d5b2c, 0 3px #513425, 0 6px 11px #070a1bbf;
  color: #201929;
}
@media (hover: hover) {
  .sa-control:hover:enabled { border-color: var(--night-brass); background-color: #293158; }
  .sa-control:hover[aria-pressed="true"] { border-color: var(--night-optic); background-color: #21455b; }
  .ws-button:hover, .sa-control--primary:hover:enabled {
    border-color: #ffedcb;
    filter: brightness(1.08);
    box-shadow: inset 0 1px #fff4d8, inset 0 -4px #8d5b2c, 0 3px #4c2d25, 0 8px 20px #e4b16040;
  }
  .ws-button:hover .ws-start-icon { transform: translateX(2px); }
}
.ws-button:focus-visible, .sa-control:focus-visible { border-color: var(--night-optic); }
.sa-control:active:enabled { box-shadow: inset 0 2px 6px #080c23d9, 0 1px 3px #06091570; }
.ws-button:active, .sa-control--primary:active:enabled {
  filter: brightness(.94);
  box-shadow: inset 0 2px 5px #774711a6, inset 0 -1px #8d5b2c, 0 1px #4c2d25;
}
.ws-button {
  width: 100%;
  min-height: 54px;
  padding: 10px 22px 13px;
  font: 800 20px/1.2 var(--sa-engraving);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.ws-start-icon {
  width: 12px;
  height: 14px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transition: transform 150ms ease;
}
.sa-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.sa-home-tools { display: grid; }
.sa-actions .sa-control--primary { margin-inline-end: auto; }

.ws-result {
  grid-template-columns: minmax(0, 760px);
  place-content: safe center;
}
.ws-result .ws-shade {
  background: radial-gradient(ellipse at 46% 42%, #10152f22, #080d218c 80%),
    linear-gradient(125deg, #04071c73, #0e132c28 68%, #080d2180);
}
.ws-report, .sa-dialog {
  position: relative;
  border: 1px solid #b49060;
  border-radius: 8px;
  background: var(--night-glass);
  color: var(--night-ink);
  box-shadow: var(--sa-hardware-shadow);
}
.ws-report, .sa-dialog {
  background:
    var(--sa-screw) left 8px top 8px / 11px 11px no-repeat,
    var(--sa-screw) right 8px top 8px / 11px 11px no-repeat,
    var(--sa-screw) left 8px bottom 8px / 11px 11px no-repeat,
    var(--sa-screw) right 8px bottom 8px / 11px 11px no-repeat,
    var(--night-glass);
}
.ws-report { padding: clamp(18px, 3vw, 34px); }
.ws-result-main {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(14px, 2.6vw, 32px);
  padding-bottom: clamp(12px, 2.2vw, 24px);
  border-bottom: 1px solid #bd976478;
}
.ws-result-header, .sa-dialog-head {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.8vw, 20px);
}
.sa-optic {
  --sa-lens-color: #79ebdf;
  --sa-lens-core: #20636a;
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: clamp(58px, 6vw, 79px);
  aspect-ratio: 1;
  border: 1px solid #312438;
  border-radius: 50%;
  background: repeating-conic-gradient(#2a203960 0deg 2deg, transparent 2deg 7deg),
    conic-gradient(from 25deg, #d6aa70, #6c4936, #a97842, #f3d299, #644331, #d6aa70);
  box-shadow: 0 0 0 1px #e9bd7b9e, inset 0 0 0 2px #f8e7b57d, 0 4px 9px #0a0b1ecc;
}
.sa-optic::before {
  content: "";
  position: absolute;
  inset: 10%;
  border: 2px solid #bc8e54;
  border-bottom-color: #5d4140;
  border-radius: 50%;
  background:
    linear-gradient(142deg, #eefcf900 17%, #e7fff857 24%, #e7fff81c 38%, transparent 52%),
    radial-gradient(circle at 56% 60%, var(--sa-lens-color), var(--sa-lens-core) 24%, #132137 54%, #070e21 72%);
  box-shadow: inset 0 0 8px 3px #080c2180, 0 0 0 2px #321f2c;
}
.ws-report h1, .sa-dialog h2 {
  margin: 0 0 6px;
  color: #ffe8c2;
  font: 700 clamp(28px, 3.3vw, 48px)/.99 var(--night-display);
  letter-spacing: -.044em;
  text-shadow: 0 2px 1px #100b1b;
}
.ws-reason { margin: 0; color: var(--night-muted); font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.ws-boundary-hint {
  margin: 5px 0 0;
  color: #efd29d;
  font-size: 13px;
  line-height: 1.35;
}
.ws-stats, .sa-result-metrics, .sa-profile-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  padding: 2px;
  border: 1px solid #a48059;
  border-radius: 5px;
  background: linear-gradient(170deg, #463442, #292338 70%, #6c4b40);
  box-shadow: 0 0 0 2px #131425, inset 0 1px #dfb98380;
}
.ws-stats div, .sa-result-metrics div, .sa-profile-metrics div {
  min-width: 0;
  padding: 9px 10px 8px;
  border: 1px solid #70799264;
  border-radius: 2px;
  background: repeating-linear-gradient(#9bece707 0 1px, transparent 1px 4px),
    radial-gradient(ellipse at 35% 100%, #15404b, #0a152a 72%);
  box-shadow: inset 0 2px 5px #050719aa;
}
.ws-stats dt, .sa-result-metrics dt { color: var(--night-muted); font-size: 14px; line-height: 1.25; }
.ws-stats dd, .sa-result-metrics dd, .sa-profile-metrics dd {
  margin: 3px 0 0;
  color: var(--night-optic);
  font: 700 clamp(26px, 5vw, 42px)/1 var(--night-meter);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  text-shadow: 0 0 9px #46d5cf53;
}
.sa-result-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: stretch;
  gap: 12px 18px;
  padding-block: 14px;
  color: var(--night-muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.sa-result-metrics dd { font-size: 27px; }
.ws-result-actions {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #a17f58;
  border-radius: 5px;
  background: repeating-linear-gradient(90deg, #fddda906 0 1px, transparent 1px 4px),
    linear-gradient(#3f3440, #1e1c30 48%, #563c39);
  box-shadow: inset 0 1px #f4c99538, inset 0 -2px #121224, 0 3px 7px #070a17a6;
}
.sa-record {
  grid-column: 1 / -1;
  padding: 6px 0 0;
  border-top: 1px solid #9194b34f;
  min-width: 0;
}
.sa-record p { margin: 0; }
.sa-record-summary { display: flex; flex-wrap: wrap; gap: 2px 7px; }
.sa-record strong { color: var(--night-ink); }
.sa-record span[data-new="true"] { color: #f9daa2; }
.sa-record span[data-new="true"] strong { color: inherit; }

.sa-dialog {
  position: fixed;
  width: min(530px, calc(100% - 30px));
  max-height: calc(100% - max(28px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  padding: clamp(18px, 4.5vw, 28px);
  overflow: auto;
  font: 15px/1.35 var(--night-ui);
}
.sa-dialog::backdrop { background: radial-gradient(ellipse at 50% 46%, #080d218e, #080d21d9 82%); }
.sa-dialog-head {
  margin-bottom: 13px;
  padding: 0 0 12px;
  border-bottom: 1px solid #bd976478;
}
.sa-dialog h2 { margin: 0; font-size: clamp(26px, 5.4vw, 36px); }
.sa-dialog .sa-optic { width: clamp(41px, 8vw, 53px); }
#sa-help .sa-optic { --sa-lens-color: #e6bd78; --sa-lens-core: #835a35; }
#sa-profile .sa-optic { --sa-lens-color: #cdbcff; --sa-lens-core: #554a88; }
#sa-paused .sa-optic span {
  z-index: 1;
  width: 12px;
  height: 13px;
  border-inline: 3px solid #b5fff2;
  filter: drop-shadow(0 0 3px #79ebdf);
}
.sa-dialog p { margin: 0 0 14px; color: var(--night-muted); }
.sa-dialog dl { margin: 0 0 14px; }
.sa-dialog dd { margin-inline-start: 0; }
.sa-help-actions { margin-bottom: 14px; }
.sa-help-actions .sa-control { padding-inline: 9px; }
.sa-help-actions .sa-control--primary { margin-inline-end: 0; }
#sa-help dl {
  display: grid;
  gap: 2px;
  padding: 2px;
  border: 1px solid #a48059;
  border-radius: 4px;
  background: #392f42;
}
#sa-help dl div {
  display: grid;
  grid-template-columns: minmax(75px, 6em) 1fr;
  gap: 0 11px;
  padding: 8px 10px;
  border: 1px solid var(--night-line);
  border-inline-start: 2px solid var(--night-optic);
  border-radius: 2px;
  background: linear-gradient(105deg, #20273d, #11182c);
}
#sa-help dt { color: var(--night-optic); font-weight: 700; }
#sa-help .sa-guide-boost { border-inline-start-color: var(--night-brass); }
#sa-help .sa-guide-boost dt { color: #f7d99c; }
#sa-help .sa-guide-modules { border-inline-start-color: var(--night-violet); }
#sa-help .sa-guide-modules dt { color: #d8c5ff; }
#sa-profile { width: min(440px, calc(100% - 30px)); }
#sa-profile label { color: var(--night-muted); }
.sa-profile-name {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 7px 0 13px;
  padding: 8px 10px;
  border: 1px solid #8b80ac;
  border-radius: 3px;
  background: linear-gradient(#090d20, #131b30);
  box-shadow: inset 0 2px 6px #050719ad, 0 0 0 2px #3a3045;
  color: var(--night-ink);
  font: inherit;
}
.sa-profile-name::placeholder { color: var(--night-muted); }
.sa-profile-metrics dt { color: var(--night-muted); font-size: 12px; }
.sa-profile-metrics dd { font-size: 25px; }
.fleet-selector {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  margin-bottom: 13px;
  padding: 5px;
  border: 1px solid #a48059;
  border-radius: 5px;
  background: radial-gradient(ellipse at 50% 65%, #22505c, #131b2f 76%);
  box-shadow: inset 0 2px 6px #050719ad, 0 0 0 2px #202133;
}
.fleet-selector button { min-width: 44px; padding-inline: 6px; }
.fleet-selector [aria-live] { display: grid; justify-items: center; min-width: 0; text-align: center; }
.fleet-selector canvas { position: static; display: block; width: 100%; max-width: 256px; height: auto; }
.fleet-selector small { color: #efd29d; }
.fleet-selector strong { overflow-wrap: anywhere; }
.sa-progress {
  margin-bottom: 13px;
  padding: 9px 10px 8px;
  border: 1px solid #8776a3;
  border-radius: 4px;
  background: radial-gradient(ellipse at 55% 100%, #2d2b55, #14182d 73%);
  box-shadow: inset 0 2px 6px #080b1d, 0 0 0 2px #1a1c30;
  color: var(--night-ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.sa-progress-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px; }
.sa-progress-header span { color: #d8c5ff; font-weight: 700; }
.sa-progress progress {
  display: block;
  appearance: none;
  width: 100%;
  height: 10px;
  margin: 6px 0 4px;
  border: 1px solid #9182ac;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, #5e597c 0 1px, transparent 1px 9px), #0e1022;
  accent-color: var(--night-violet);
}
.sa-progress progress::-webkit-progress-bar { background: transparent; }
.sa-progress progress::-webkit-progress-value {
  background: repeating-linear-gradient(90deg, #34325b55 0 1px, transparent 1px 9px),
    linear-gradient(#d5d0ff, #9571f1);
}
.sa-progress progress::-moz-progress-bar {
  background: repeating-linear-gradient(90deg, #34325b55 0 1px, transparent 1px 9px),
    linear-gradient(#d5d0ff, #9571f1);
}
.sa-progress-goal { color: var(--night-muted); }
.sa-progress-rules { font-size: 13px; }
#sa-result-progress { margin: 0; }
#sa-paused { width: min(386px, calc(100% - 30px)); }
#sa-paused .sa-actions { display: grid; grid-template-columns: repeat(2, 1fr); }
#sa-resume { grid-column: 1 / -1; width: 100%; }
#sa-pause-menu { grid-column: 1 / -1; }
.sa-pause-hint { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.sa-pause-hint kbd {
  padding: 2px 5px;
  border: 1px solid #b99465;
  border-radius: 3px;
  background: linear-gradient(#3f3440, #1e1c30);
  box-shadow: 0 2px #533b38;
  color: #ffe2b7;
  font-family: var(--night-meter);
}

html .plate {
  background: repeating-linear-gradient(110deg, #ead4a107 0 1px, transparent 1px 4px),
    linear-gradient(155deg, #302c41f7, #181c32f5 64%, #27222df5);
  border-color: #b28d5e;
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px #14162c, inset 0 0 0 3px #ab8b642b, 0 3px #110f22, 0 5px 10px #080c21a9;
}
html .mass { gap: 9px; }
html .mass-mark {
  height: 22px;
  color: var(--night-optic);
  border: 2px solid #b58f60;
  border-radius: 50%;
  background: radial-gradient(circle at 58% 64%, #90f3e1, #29747a 26%, #0b162b 66%);
  box-shadow: 0 0 0 1px #190f22, 0 0 8px #72f3ee39, inset 0 0 4px #080d21;
  transform: none;
}
html .mass-mark::before { width: 8px; height: 8px; border: 1px solid #a6e9d294; border-radius: 50%; }
html .label { color: #efd29d; font-family: var(--night-meter); text-transform: uppercase; }
html #mass { color: var(--night-optic); font-family: var(--night-meter); text-shadow: 0 0 8px #72f3ee59; }
html .board { width: clamp(124px, 15vw, 172px); }
html .board .label {
  padding-bottom: 3px;
  border-bottom: 1px solid #bd976478;
}
html .board li { grid-template-columns: 2ch 6px minmax(0, 1fr) minmax(3ch, max-content); }
#ranks li span:nth-child(3) { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
#ranks li span:last-child { font-family: var(--night-meter); }
#sa-pause {
  position: fixed;
  z-index: 3;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  padding: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 46% 41%, #574356, #222035 66%);
  box-shadow: 0 0 0 2px #221726, inset 0 0 0 3px #9d77503f, 0 4px 8px #080c21c4;
  transform: translateX(-50%);
}
#sa-pause[hidden] { display: none; }
#sa-pause span {
  width: 14px;
  height: 16px;
  border-inline: 4px solid #efd29d;
  filter: drop-shadow(0 0 4px #d7ac615a);
}
html #boost {
  display: grid;
  gap: 2px;
  align-content: center;
  justify-items: center;
  width: clamp(78px, 9vw, 110px);
  aspect-ratio: 1;
  padding: 8px;
  border-color: #e1b97f;
  background:
    radial-gradient(circle at 46% 29%, #434066, #1b2039 71%) center / 79% 79% no-repeat,
    repeating-conic-gradient(#39273eaa 0deg 3deg, transparent 3deg 8deg),
    conic-gradient(from 20deg, #f0d29c, #624438, #a57a4d, #f1c78e, #6a4a36, #f0d29c);
  box-shadow: 0 5px 16px #0a0e24b0, inset 0 0 0 3px #97764c, inset 0 0 18px #aa83ff48;
}
html #boost .bolt {
  width: calc(34% + 7px);
  aspect-ratio: 23 / 29;
  height: auto;
  background: #f7d99c;
  filter: drop-shadow(0 0 4px #f7d99c80);
}
.sa-boost-label {
  display: block;
  color: #f7d99c;
  font: 700 10px/1 var(--night-ui);
  letter-spacing: .035em;
}
html #boost[data-active="true"] {
  border-color: var(--night-optic);
  background: radial-gradient(circle at 45% 26%, #315d65, #14253e 72%) center / 79% 79% no-repeat,
    repeating-conic-gradient(#111c3396 0deg 3deg, transparent 3deg 8deg), #4ba4a0;
  box-shadow: inset 0 0 0 3px #56c6c6, inset 0 0 15px #44dcf15e, 0 0 17px #72f3ee81;
}
html #boost[data-active="true"] .bolt, html #boost[data-active="true"] .sa-boost-label { color: var(--night-optic); }
html #boost[data-active="true"] .bolt { background: currentColor; filter: drop-shadow(0 0 4px #72f3eeaa); }
html #boost[data-ready="true"] { box-shadow: inset 0 0 0 3px #d7ac61, 0 0 0 3px #aa83ff; }
html #boost[data-empty="true"] { filter: none; border-color: #b6a5cd; background: #1d2040; }
html #boost[data-empty="true"]::after {
  content: "−";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 19px;
  height: 19px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: #25203c;
  color: #ded1f6;
  font: 700 15px/17px var(--night-ui);
}
html #hint { line-height: 16px; transition: opacity 450ms ease, visibility 0s linear; }
html #hint[data-hidden="true"] { visibility: hidden; transition-delay: 0s, 450ms; }

#sa-map-panel {
  position: fixed;
  z-index: 2;
  left: max(17px, env(safe-area-inset-left));
  bottom: max(77px, calc(env(safe-area-inset-bottom) + 65px));
  padding: 6px;
  border: 1px solid #b28d5e;
  border-radius: 5px;
  background: linear-gradient(#3f3440, #1e1c30 48%, #46363b);
  color: var(--night-muted);
  box-shadow: inset 0 0 0 2px #323049, 0 4px 10px #080c21ae;
  font: 700 11px/1.2 var(--night-meter);
  pointer-events: none;
}
#sa-map-panel canvas {
  position: static;
  display: block;
  width: 99px;
  height: auto;
  border: 1px solid #87927f;
  border-radius: 3px;
  box-shadow: 0 0 0 2px #141729, 0 0 8px #72f3ee3a;
}
.sa-map-score { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding: 5px 2px 1px; }
.sa-map-score b { color: var(--night-optic); font-size: 13px; }
.sa-notice {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: max(110px, calc(env(safe-area-inset-bottom) + 90px));
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 8px 11px;
  transform: translateX(-50%);
  background: #171c3b;
  border: 1px solid #8774b6;
  border-radius: 7px;
  box-shadow: 0 3px 8px #0a0e24a3;
  color: #e4d9ff;
  font: 650 14px/1.2 var(--night-ui);
  pointer-events: none;
}
.sa-notice:empty { opacity: 0; }
#sa-lesson {
  position: fixed;
  z-index: 4;
  bottom: max(15px, env(safe-area-inset-bottom));
  left: max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: min(370px, calc(100% - 116px));
  padding: 10px 11px;
  border: 1px solid var(--night-brass-line);
  border-radius: 8px;
  background: var(--night-glass);
  box-shadow: 0 6px 15px #05081bb8;
  color: var(--night-ink);
  font: 650 14px/1.35 var(--night-ui);
}
#sa-lesson[hidden], #sa-lesson [hidden] { display: none; }
#sa-lesson p { grid-column: 1 / -1; margin: 0; }
.sa-lesson-steps { display: flex; grid-column: 1 / -1; gap: 4px; }
.sa-lesson-steps i { width: 21px; height: 3px; border-radius: 4px; background: #625888; }
.sa-lesson-steps i[data-state="current"] { background: var(--night-optic); box-shadow: 0 0 7px #72f3ee80; }
.sa-lesson-steps i[data-state="done"] { background: var(--night-violet); }
#sa-lesson button { justify-self: start; padding: 6px 9px; font-size: 13px; }
#sa-open-help[data-pointed] { outline: 2px solid var(--night-optic); outline-offset: 3px; }
html[data-lesson] #hint, html[data-lesson] .board, html[data-lesson] #sa-map-panel { visibility: hidden; }

@keyframes sa-panel-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sa-backdrop-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .ws-home:not([hidden]) .ws-intro,
  .ws-result:not([hidden]) .ws-report,
  .sa-dialog[open], #sa-lesson:not([hidden]) {
    animation: sa-panel-enter 210ms ease-out;
  }
  .ws-result:not([hidden]) .ws-shade, .sa-dialog[open]::backdrop {
    animation: sa-backdrop-enter 180ms ease-out;
  }
}

@media (max-width: 600px) {
  .ws-stage { padding-inline: max(22px, env(safe-area-inset-left)) max(22px, env(safe-area-inset-right)); }
  .ws-result { grid-template-columns: minmax(0, 415px); align-content: safe center; }
  .ws-report { padding: 18px; }
  .ws-result-main { grid-template-columns: 1fr; }
  .ws-report h1 { font-size: 30px; }
  .ws-result-header .sa-optic { width: 49px; }
  .ws-stats dt, .sa-result-metrics dt { font-size: 13px; }
  .sa-result-details { grid-template-columns: 1fr; padding-block: 11px; }
  .ws-result-actions { gap: 7px; padding: 6px; }
  .ws-button { min-height: 49px; padding: 9px 9px 12px; font-size: 18px; }
  #sa-help dl div { grid-template-columns: 1fr; gap: 2px; padding-block: 6px; }
  html .mass { gap: 7px; }
  #sa-pause { top: max(14px, env(safe-area-inset-top)); left: 47%; }
  html #boost { width: 63px; right: max(14px, env(safe-area-inset-right)); }
  .sa-boost-label { font-size: 9px; }
  html #hint { line-height: 14px; }
  #sa-map-panel { left: max(13px, env(safe-area-inset-left)); }
  #sa-map-panel canvas { width: 63px; }
}
@media (max-width: 350px) {
  #sa-pause { left: 45%; }
  .sa-control { padding-inline: 8px; }
  .sa-home-tools .sa-control { font-size: 12px; }
  .ws-result-actions .ws-button { font-size: 15px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .ws-result { grid-template-columns: minmax(0, 700px); align-content: safe center; }
  .ws-report { padding: 18px; }
  .ws-report h1 { font-size: 28px; }
  .ws-result-header .sa-optic { width: 51px; }
  #sa-help dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sa-dialog { padding: 16px 20px; font-size: 13px; }
  .sa-dialog-head { margin-bottom: 8px; padding-bottom: 7px; }
  .sa-dialog h2 { font-size: 25px; }
  .sa-dialog p, .sa-dialog dl, .sa-help-actions { margin-bottom: 8px; }
  #sa-help { width: min(660px, calc(100% - 30px)); }
  #sa-profile { width: min(570px, calc(100% - 30px)); }
  #sa-profile-form .sa-progress-rules { margin: 0; }
  #sa-profile-form .sa-profile-name { margin-bottom: 6px; }
  #sa-help dl div { grid-template-columns: 1fr; gap: 3px; }
  .sa-progress { margin-bottom: 8px; }
  #sa-resume, #sa-pause-menu { grid-column: auto; }
  html #boost { width: 63px; }
  #sa-map-panel { bottom: max(55px, calc(env(safe-area-inset-bottom) + 50px)); }
  #sa-map-panel canvas { width: 63px; }
}
@media (prefers-reduced-motion: reduce) {
  html #hint, .ws-button, .sa-control, .ws-start-icon { transition: none; }
  .ws-button:hover .ws-start-icon { transform: none; }
}
@media (forced-colors: active) {
  .ws-title, .ws-title span, .ws-report h1, .sa-dialog h2, html #mass { text-shadow: none; }
  .sa-progress progress { appearance: auto; }
  #sa-pause span { border-color: ButtonText; }
}

.sa-chassis-lens canvas {
  position:absolute; z-index:1; width:70%; height:70%; border-radius:50%; pointer-events:none;
  background:radial-gradient(circle at 36% 30%,#24605f,#102b34 65%,#080e19 94%);
  box-shadow:inset 0 1px 6px #07151c,0 0 0 1px #efd19899;
}

.sa-mode-picker { min-inline-size: 0; }
.sa-mode-picker label { position: relative; display: grid; min-width: 0; cursor: pointer; }
.sa-mode-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  clip-path: inset(50%);
}
.sa-mode-picker label span {
  display: grid;
  place-items: center;
  border: 1px solid;
  text-align: center;
}
.sa-mode-picker input:focus-visible + span { outline: 3px solid var(--night-optic); outline-offset: 2px; }
#sa-mode-guide { grid-column: 1 / -1; }

#sa-objective {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 5px;
  max-width: 99px;
  padding: 1px 0 5px;
  color: #efd29d;
  font-variant-numeric: tabular-nums;
}
#sa-objective[hidden] { display: none; }
#sa-objective b { color: var(--night-optic); font-size: 13px; }
.ws-result-mode { margin: 0 0 3px; color: #efd29d; font: 700 12px/1.2 var(--night-ui); }
.sa-result-metrics--salvage { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sa-result-metrics--salvage div { padding-inline: 5px; }
.sa-result-metrics--salvage dd { font-size: clamp(19px, 5vw, 25px); }

.sa-upgrades, .sa-profile-records { margin: 0 0 14px; }
.sa-upgrades h3, .sa-upgrades h4, .sa-profile-records h3 { margin: 0; font-size: 1em; line-height: 1.3; }
.sa-upgrade-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; }
.sa-upgrade-header output { color: var(--night-optic); font-weight: 700; }
.sa-dialog .sa-upgrade-rule { margin: 3px 0 7px; font-size: 13px; }
#sa-upgrade-list, .sa-upgrade-list { display: grid; gap: 5px; }
/* the power-up modules of stage B: the module's face from the field, ten level lamps */
.sa-module .sa-module-face {
  width: var(--fl-icon, 28px);
  height: var(--fl-icon, 28px);
  background-image: var(--sa-guide-module);
  background-size: 400% 100%;
}
.sa-module[data-module="zoom"] .sa-module-face { background-position: 33.333% 0; }
.sa-module[data-module="speed"] .sa-module-face { background-position: 66.667% 0; }
.sa-module[data-module="multiplier"] .sa-module-face { background-position: 100% 0; }
.sa-module .sa-upgrade-meter i { width: 8px; }
.sa-module p { white-space: pre-line; }
/* the credits of the run and the door to the modules on the result */
.sa-result-credits { display: flex; grid-column: 1 / -1; align-items: center; justify-content: space-between; gap: 8px; }
.sa-result-credits p { display: flex; min-width: 0; align-items: center; gap: 6px; margin: 0; color: var(--night-optic); font-weight: 700; }
.sa-result-credits .sa-control { flex: none; white-space: nowrap; }
#sa-result-modules[data-ready] { border-color: #ffd36b; box-shadow: 0 0 9px #e6a23c99; }
.sa-upgrade {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 6px;
  padding: 5px 7px;
  border: 1px solid #807391;
  border-radius: 4px;
  background: linear-gradient(150deg, #282440, #11182c);
}
.sa-upgrade .sa-control { min-width: 0; padding-inline: 7px; font-size: 12px; }
.sa-upgrade .sa-control[aria-disabled="true"] { color: var(--night-muted); cursor: default; }
.sa-upgrade small { color: #d8c5ff; }
.sa-dialog .sa-upgrade p { grid-column: 1 / -1; margin: 3px 0 0; font-size: 12px; }
.sa-profile-records h3 { margin-bottom: 6px; }
.sa-profile-records .sa-profile-metrics { margin: 0; }
.sa-profile-records .sa-profile-metrics div:nth-child(n+3) dd {
  font: 700 13px/1.3 var(--night-ui);
  text-shadow: none;
}

@media (max-height: 480px) and (orientation: landscape) {
  .ws-result-main { grid-template-columns: minmax(0, 1.16fr) minmax(0, 1fr); gap: 12px; }
  .sa-result-details { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 9px 12px; }
}

/* The detent marks the selected playing surface even in monochrome. */
#sa-decks .sa-deck-grid button { position: relative; min-height: 52px; }
#sa-decks .sa-deck-grid button::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 17px;
  height: 17px;
  border-radius: 3px;
  background: #281a14;
  box-shadow: inset 0 0 0 1px #c29a75;
  opacity: .65;
  transform: translateY(-2px);
  transition: transform 120ms ease-out, background-color 120ms;
  pointer-events: none;
}
#sa-decks .sa-deck-grid button[aria-pressed=true]::after {
  content: "✓";
  background: #aadfca;
  color: #12271f;
  font: bold 14px/17px sans-serif;
  text-align: center;
  opacity: 1;
  transform: translateY(0);
}
#sa-decks .sa-deck-back::before { content: "←"; margin-inline-end: 6px; }
@media (prefers-reduced-motion: no-preference) {
  #sa-decks {
    transition: opacity 160ms ease-out, overlay 160ms allow-discrete, display 160ms allow-discrete;
  }
  #sa-decks:not([open]) { opacity: 0; }
  @starting-style { #sa-decks[open] { opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) {
  #sa-decks .sa-deck-grid button::after { transition: none; }
}
