@font-face {
  font-family: "Vault Mono";
  src: url("../../identity/type/ibmplexmono-cyrillic.woff2") format("woff2");
  font-display: swap;
  unicode-range: U+0400-052F, U+2116;
}
@font-face {
  font-family: "Vault Mono";
  src: url("../../identity/type/ibmplexmono-latin.woff2") format("woff2");
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF;
}
:root {
  color-scheme: dark;
  --ink: #101225;
  --metal: #1a1d35;
  --edge: #393e58;
  --white: #f5f2ed;
  --muted: #bcc6d6;
  --cyan: #8ef4ed;
  --amber: #ffc77c;
  --mono: "Vault Mono", Consolas, monospace;
  --sans: "Segoe UI", Arial, sans-serif;
  font: 16px/1.4 var(--sans);
  background: var(--ink);
  color: var(--white);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button {
  font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--edge); border-radius: 4px; background: var(--metal);
}
button:disabled { opacity: .44; cursor: default; }
:is(button, a, canvas):focus-visible, #menu-title:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: -3px;
}
[hidden] { display: none !important; }

#scene {
  position: relative; isolation: isolate; height: 100%; height: 100dvh;
  min-height: 0; width: 100%; display: flex; flex-direction: column; overflow: hidden;
  background: #0c1021;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#scene:fullscreen { height: 100%; width: 100%; }
#scene:not([data-mode="play"]) .play-only { display: none; }
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; flex: 0 0 auto;
  min-height: 56px; padding: 5px clamp(12px, 3.2vw, 64px); z-index: 2;
  background: linear-gradient(180deg,#21243a 0%,#191b31 48%,#17192d 100%);
  border-bottom: 1px solid #43435a; box-shadow: 0 3px 13px #08091955;
}
.exit {
  justify-self: start; display: inline-flex; align-items: center; gap: 10px; min-height: 38px;
  font-size: 13px; font-weight: 600; color: #d6d7e2; text-decoration: none; padding: 0 6px;
}
.exit i { width: 8px; height: 8px; border: solid var(--amber); border-width: 0 0 2px 2px; transform: rotate(45deg); }
.wordmark { display: flex; align-items: center; gap: 12px; font-weight: 650; font-size: 17px; white-space: nowrap; letter-spacing: -.035em; }
.vault-mark { width: 15px; height: 15px; transform: rotate(45deg); border: 2px solid var(--amber); position: relative; }
.vault-mark::before { content: ""; position: absolute; inset: 2px; border: 1px solid var(--amber); }
.vault-mark::after { content: ""; position: absolute; height: 1px; width: 14px; right: 2px; bottom: 2px; transform: rotate(-45deg); background: #7fd9d8; }
.system-tools { justify-self: end; display: flex; align-items: center; gap: 5px; }
.language-slot { display: flex; align-items: center; }
.language-slot:empty { display: none; }
.actions #hint[aria-pressed="true"] { border-color: var(--amber); background: #493b36; }
@media (max-width: 510px) {
  .wordmark span { max-width: 27vw; overflow: hidden; text-overflow: ellipsis; }
}
.tool-icon {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 38px; padding: 0;
  color: #d9dceb; background: #1a1c30; border-color: #3b3d53; font-weight: 650;
}
.speaker { display: block; width: 22px; height: 18px; position: relative; }
.speaker::before { content: ""; position: absolute; left: 1px; top: 2px; width: 13px; height: 14px; background: currentColor; clip-path: polygon(0 33%,34% 33%,88% 0,88% 100%,34% 67%,0 67%); }
.speaker::after { content: ""; position: absolute; top: 4px; right: 1px; width: 8px; height: 10px; border: solid currentColor; border-width: 0 2px 0 0; border-radius: 50%; }
.sound[aria-pressed=false] .speaker::after { width: 20px; height: 2px; top: 9px; left: 0; border: 0; border-radius: 0; transform: rotate(-42deg); background: currentColor; box-shadow: 0 1px #1a1c30; }
.pause span { width: 11px; height: 13px; border-inline: 4px solid currentColor; }
.help span { width: 17px; height: 17px; border: 1.5px solid currentColor; border-radius: 50%; font: 700 13px/15px var(--sans); }
.telemetry {
  flex: 0 0 auto; display: flex; align-items: center; gap: clamp(14px,3vw,46px);
  padding: 7px clamp(15px,3.5vw,72px); background: #171b31; border-bottom: 1px solid #383c53;
}
.room-id { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 13px; margin-right: auto; min-width: 0; }
#room-index { font: 11px/1.25 var(--mono); color: var(--amber); }
#room-title { font-size: clamp(14px,1.3vw,21px); font-weight: 650; line-height: 1.15; }
.reading { display: flex; align-items: center; gap: 9px; font: 11px var(--mono); color: #b6bbcf; white-space: nowrap; }
.reading b { font-size: 15px; color: #f1f2f7; }
.reading.receiver b { color: var(--cyan); }

.viewport {
  flex: 1 1 0; position: relative; isolation: isolate; min-height: 0; min-width: 0; overflow: hidden;
  background: radial-gradient(ellipse at 69% 41%,#303556 0,#1b253e 39%,#11162c 74%,#101325);
}
#world { display: block; position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.frame-lines {
  pointer-events: none; position: absolute; inset: 9px; z-index: 1; opacity: .65;
  --tick: #829599; --len: 14px;
  background:
    linear-gradient(var(--tick),var(--tick)) left top/var(--len) 1px,
    linear-gradient(var(--tick),var(--tick)) left top/1px var(--len),
    linear-gradient(var(--tick),var(--tick)) right top/var(--len) 1px,
    linear-gradient(var(--tick),var(--tick)) right top/1px var(--len),
    linear-gradient(var(--tick),var(--tick)) left bottom/var(--len) 1px,
    linear-gradient(var(--tick),var(--tick)) left bottom/1px var(--len),
    linear-gradient(var(--tick),var(--tick)) right bottom/var(--len) 1px,
    linear-gradient(var(--tick),var(--tick)) right bottom/1px var(--len);
  background-repeat: no-repeat;
}
.overlay {
  position: absolute; z-index: 2; inset: 0; display: grid; align-items: center; justify-items: start;
  padding: clamp(22px,5vw,78px);
  background: linear-gradient(90deg, #0a0e20ce 0%, #100f2247 47%, transparent 72%);
}
.panel {
  position: relative; width: min(100%, 438px); max-height: 100%; min-height: 0;
  padding: clamp(22px,2.5vw,37px); border: 1px solid #60637c;
  border-radius: 3px 14px 3px 3px; color: var(--white);
  background: linear-gradient(138deg,#292d47 0,#191d35 53%,#14182b 100%);
  box-shadow: inset 0 1px #ffffff11, inset 0 -3px #0a0e21, 0 18px 54px #080a1d73, 0 0 0 5px #14172a5c;
}
.panel::before { content: ""; position: absolute; inset: 1px auto 1px -1px; width: 3px; background: linear-gradient(#ffe2a0 0,#dda36c 34%,#626477 34%,#353a52); border-radius: 2px; }
.panel-trim {
  display: flex; gap: 3px; justify-content: flex-end;
  position: absolute; right: 14px; top: 13px; pointer-events: none;
}
.panel-trim i { width: 8px; height: 2px; background: #85869a; transform: skewX(-32deg); }
.panel-trim i:first-child { background: #e4ac70; }
#menu-kicker { margin: 0 0 13px; color: var(--amber); font: 11px/1.3 var(--mono); letter-spacing: .045em; }
#menu-title {
  margin: 0; font-family: var(--sans); font-size: clamp(34px,3.75vw,64px); font-weight: 720;
  line-height: .99; letter-spacing: -.055em; text-wrap: balance; overflow-wrap: anywhere;
}
#menu-copy { margin: 16px 0 0; color: #c7cedd; font-size: clamp(14px,1.1vw,17px); line-height: 1.5; }
.menu-actions { margin-top: 24px; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 7px; }
.menu-actions button, #chapter-list button {
  min-width: 0; min-height: 40px; padding: 7px 9px; font-weight: 600; font-size: 14px;
  line-height: 1.25; border-color: #484e67; background: #22283e;
}
#menu-primary {
  position: relative; grid-column: 1/-1; text-align: left; min-height: 45px; padding: 8px 36px 9px 15px;
  font-size: 16px; color: #1a1c2a; background: linear-gradient(105deg,#a6f7e7,#83ded9); border-color: #b6fff2;
  box-shadow: inset 0 -2px #4d999f;
}
#menu-primary::after { content: "→"; position: absolute; right: 14px; top: 50%; transform: translateY(-53%); font: 20px var(--sans); }
.menu-actions button:only-child, #menu-secondary:has(+ [hidden]), #menu-secondary[hidden] + #menu-tertiary { grid-column: 1/-1; }
#chapter-list { margin-top: 14px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
#chapter-list button { text-align: left; border-left: 2px solid #789caa; overflow-wrap: anywhere; }
#chapter-list button[aria-current], #chapter-list button[aria-pressed=true] { border-left-color: var(--amber); }
#chapter-list button small { display: block; color: var(--muted); }
#menu-details { margin-top: 13px; color: #c1cbdd; font-size: 13px; line-height: 1.4; }
#menu-details :is(p,ul,ol,dl) { margin: 4px 0; }
#menu-details p { display: grid; grid-template-columns: 4.3em minmax(0,1fr); gap: 8px; align-items: baseline; }
#menu-details p b { font: 12px/1.3 var(--mono); color: var(--amber); white-space: nowrap; }
#menu-details p + p { padding-top: 5px; border-top: 1px solid #34394f; }
#menu-details :is(ol,ul) { padding-left: 1.2em; }
#menu-details kbd { font: 11px var(--mono); color: #e9e3cf; }

.controls {
  display: grid; grid-template-columns: auto minmax(150px,1fr) auto; align-items: center;
  gap: clamp(12px,2.2vw,35px); padding: 9px clamp(15px,3.5vw,72px); flex: 0 0 auto;
  border-top: 1px solid #494b63; background: linear-gradient(#22253a 0%,#191c32 78%);
}
.direction-pad {
  --step: 35px; display: grid; grid-template-columns: repeat(3,var(--step)); grid-template-rows: repeat(2,var(--step));
  gap: 3px; justify-content: start;
}
.direction-pad button { font: 20px/1 var(--sans); padding: 0; border-color: #53596e; background: #2b3047; color: #eff4fb; }
.direction-pad [data-dir="0"] { grid-column: 2; grid-row: 1; }
.direction-pad [data-dir="3"] { grid-column: 1; grid-row: 2; }
.direction-pad [data-dir="2"] { grid-column: 2; grid-row: 2; }
.direction-pad [data-dir="1"] { grid-column: 3; grid-row: 2; }
.mission { min-width: 0; }
#objective { display: block; font: 650 15px/1.2 var(--sans); color: var(--cyan); }
#notice { margin: 4px 0 0; max-width: 70ch; color: #c5ccda; font-size: 13px; line-height: 1.32; overflow-wrap: anywhere; }
#notice:empty { display: none; }
.actions { display: flex; gap: 5px; align-items: center; }
.actions button { display: grid; justify-items: center; gap: 2px; min-width: 50px; min-height: 42px; padding: 4px 7px; color: #dce2eb; }
.actions button span { font: 19px/1 var(--sans); color: #d6dff0; }
.actions button b { font: 10px/1.2 var(--sans); }
.actions #hint span { color: var(--amber); }
@media (hover:hover) {
  :is(.tool-icon,.actions button,.menu-actions button,#chapter-list button,.direction-pad button):not(:disabled):hover { border-color: #85b4bd; background: #354159; }
  #menu-primary:not(:disabled):hover { background: #bbfff0; }
  .exit:hover { color: var(--amber); }
}
button:active:not(:disabled) { transform: translateY(1px); }
@media (pointer: coarse) {
  .direction-pad { --step: 43px; }
  .actions button { min-height: 44px; }
}
@media (max-width: 760px) {
  .topbar { min-height: 47px; padding: 3px 9px; }
  .wordmark { gap: 8px; font-size: 15px; }
  .tool-icon { width: 37px; height: 36px; }
  .telemetry { gap: 12px; padding: 7px 12px; }
  .room-id { gap: 2px 6px; }
  .reading { display: grid; gap: 0; font-size: 9px; }
  .reading b { line-height: 1.2; font-size: 13px; }
  .controls { gap: 9px; padding: 7px 10px; }
  .actions { gap: 3px; }
  .actions button { min-width: 36px; padding: 4px; }
  .panel { width: min(100%,370px); }
  .overlay { padding: 20px; }
}
@media (max-width: 540px) and (orientation: portrait) {
  .topbar { grid-template-columns: 37px minmax(0,1fr) auto; }
  .exit { width: 36px; justify-content: center; }
  .exit span { display: none; }
  .wordmark { justify-self: start; padding-left: 4px; }
  .system-tools { gap: 3px; }
  .overlay { align-items: end; justify-items: center; padding: 12px 12px clamp(12px,3.8vh,34px); background: linear-gradient(0deg,#0e1228e0,transparent 79%); }
  .panel { padding: 18px 19px; }
  #menu-title { font-size: clamp(33px,8.5vw,46px); }
  #menu-kicker { margin-bottom: 8px; }
  #menu-copy { margin-top: 10px; font-size: 14px; line-height: 1.35; }
  .menu-actions { margin-top: 15px; }
  .controls { grid-template-columns: auto minmax(0,1fr); grid-template-rows: auto auto; gap: 6px 12px; }
  .mission { grid-row: 1; grid-column: 1/-1; }
  #objective { font-size: 13px; }
  #notice { font-size: 12px; margin-top: 3px; }
  .direction-pad { grid-column: 1; grid-row: 2; --step: clamp(42px,10.7vw,47px); }
  .actions { grid-column: 2; grid-row: 2; justify-self: end; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 3px; }
  .actions button { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: clamp(42px,10.7vw,47px); padding: 3px 5px; }
  .actions button b { font-size: 11px; }
  .actions button span { font-size: 16px; }
  .room-id { display: grid; gap: 1px; }
  #room-index { font-size: 9px; }
  #room-title { font-size: 14px; }
}
@media (max-width: 359px) and (orientation: portrait) {
  .topbar .wordmark { min-width: 0; max-width: 100%; gap: 4px; padding-left: 0; }
  .topbar .wordmark span { min-width: 0; max-width: 100%; white-space: normal; font-size: 11px; line-height: 1.1; }
  .controls { column-gap: 7px; }
  .wordmark { font-size: 13px; }
  .actions button { padding-inline: 4px; }
}
@media (max-height: 540px) and (orientation: landscape) {
  #scene[data-mode="play"] { display: grid; grid-template-columns: minmax(0,1fr) clamp(150px,26vw,235px); grid-template-rows: 36px auto minmax(0,1fr); }
  .topbar { grid-column: 1/-1; min-height: 36px; padding: 1px 8px; }
  .wordmark { font-size: 14px; }
  .exit { min-height: 32px; }
  .tool-icon { height: 31px; width: 36px; }
  .telemetry { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: auto auto; align-items: end; gap: 5px; padding: 7px 10px; border-left: 1px solid #43485d; }
  .room-id { grid-column: 1/-1; display: grid; gap: 0; }
  #room-index { font-size: 9px; }
  #room-title { font-size: 13px; }
  .reading { font-size: 9px; display: block; }
  .reading b { margin-left: 4px; font-size: 11px; }
  #scene[data-mode="play"] .viewport { grid-column: 1; grid-row: 2/4; }
  .controls { grid-column: 2; grid-row: 3; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 5px; padding: 5px 7px 7px; border-top: 0; border-left: 1px solid #43485d; }
  .mission { margin-bottom: auto; }
  #objective { font-size: 11px; }
  #notice { font-size: 10px; line-height: 1.24; }
  .direction-pad { --step: clamp(32px,12.8vh,44px); justify-content: center; gap: 2px; }
  .actions { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 2px; }
  .actions button { padding: 3px 0; min-width: 0; min-height: 32px; }
  .actions button span { font-size: 15px; }
  .actions button b { font-size: 8px; }
  .overlay { padding: 10px clamp(15px,3.2vw,42px); }
  .panel { width: min(76%,490px); padding: 12px 19px; }
  #menu-kicker { font-size: 10px; margin: 0 0 4px; }
  #menu-title { font-size: clamp(25px,6.6vh,36px); }
  #menu-copy { margin-top: 6px; font-size: 13px; line-height: 1.25; }
  .menu-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
  .menu-actions button { font-size: 12px; min-height: 33px; flex: 1 1 auto; }
  #menu-primary { min-height: 34px; font-size: 13px; padding: 6px 23px 6px 8px; }
  #menu-primary::after { right: 6px; font-size: 16px; }
  #chapter-list, #menu-details { margin-top: 6px; }
  #chapter-list button { min-height: 30px; font-size: 12px; padding: 3px 6px; }
  #menu-details, #menu-details kbd { font-size: 11px; line-height: 1.3; }
  #menu-details p + p { padding-top: 2px; }
  #scene[data-mode="help"] .panel { width: min(100%,650px); }
  #menu-details { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px 14px; }
  #menu-details p { display: block; margin: 0; }
  #menu-details p + p { border: 0; padding-top: 0; }
  #menu-details p b { margin-right: 6px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  button:active:not(:disabled) { transform: none; }
}

#scene[data-mode="start"] .viewport {
  background: linear-gradient(85deg,#081816f7 3%,#0c1a16dc 26%,#08201933 73%),
    url("../../launcher-art/signal-vault.webp") 62% 50% / cover;
}
#scene[data-mode="start"] :is(#world,.frame-lines,.panel-trim,.panel::before,.wordmark,#menu-kicker) { visibility: hidden; }
#scene[data-mode="start"] .topbar { background: #0b1515; border-color: #385044; color: #e5e3cc; }
#scene[data-mode="start"] .overlay { align-items: end; padding-bottom: clamp(1.3rem,10vh,7rem); background: transparent; }
#scene[data-mode="start"] .panel {
  width: min(100%, 39rem); padding: 0; background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
#scene[data-mode="start"] #menu-title {
  font: 650 clamp(3.3rem,7.3vw,7.5rem)/.94 Georgia, "Times New Roman", serif; letter-spacing: -.065em; text-shadow: 0 2px 24px #03221a;
}
#scene[data-mode="start"] #menu-copy:empty { display: none; }
#scene[data-mode="start"] .menu-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#scene[data-mode="start"] .menu-actions button { border-radius: 0; padding-inline: 1em; min-height: 44px; background: #101e1de6; border-color: #bac7aa66; color: #e7e9d6; }
#scene[data-mode="start"] #menu-primary { padding-right: 2.8em; background: #f4d19a; color: #192720; box-shadow: none; border-color: #ffdea7; }
#scene:not([data-mode="start"]) .panel { border-radius: 0; border-left: 3px solid var(--amber); box-shadow: 0 12px 38px #06111a68; }
@media (max-width: 600px) and (orientation: portrait) {
  #scene[data-mode="start"] .viewport { background-image: linear-gradient(0deg,#081814 2%,#0a1c16e6 29%,#071a141a 79%),url("../../launcher-art/signal-vault.webp"); }
  #scene[data-mode="start"] .overlay { justify-items: start; padding: 18px 18px max(25px,6vh); }
}
