@font-face {
  font-family: Barlow;
  src: url("/fonts/BarlowCondensed-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --bg: #060707;
  --panel: #141715;
  --line: #383d37;
  --text: #e5e2d7;
  --muted: #b2b5ab;
  --red: #d87750;
  --safe-t: max(20px, env(safe-area-inset-top), var(--host-safe-t, 0px));
  --safe-r: max(20px, env(safe-area-inset-right), var(--host-safe-r, 0px));
  --safe-b: max(20px, env(safe-area-inset-bottom), var(--host-safe-b, 0px));
  --safe-l: max(20px, env(safe-area-inset-left), var(--host-safe-l, 0px));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  accent-color: var(--red);
  caret-color: var(--red);
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-width: 0; min-height: 100%; }
body { background: var(--bg); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { outline-offset: 4px; }
:focus-visible { outline: 2px solid #edaf8f; }
::selection { background: #9a4e31; color: #fff; }
button {
  min-width: 44px;
  min-height: 44px;
  padding: 11px 15px;
  color: var(--text);
  background: #262c26;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: background 150ms ease-out;
}
@media (hover: hover) { button:hover { background: #353d34; } }
button:active { background: #465042; }
button:disabled { opacity: .48; cursor: default; }
button.primary {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  background: #d5d0bf;
  color: #121512;
  font-weight: 600;
  text-align: center;
}
@media (hover: hover) { button.primary:hover { background: #eee9d9; } }
button.primary:active { background: #b9b59f; }
button.primary:disabled { background: #353b34; color: var(--text); }
.text-button { background: transparent; text-decoration: underline; text-underline-offset: 4px; }
p { line-height: 1.6; overflow-wrap: anywhere; }
.fine { color: var(--muted); font-size: 12px; line-height: 1.65; }
h1, h2 { margin: 0; font-family: Barlow, sans-serif; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 30px; }
a { color: inherit; text-underline-offset: 4px; }
#canvas {
  position: fixed;
  inset: auto;
  left: var(--game-left, 0px);
  top: var(--game-top, 0px);
  width: var(--game-width, 100vw);
  height: var(--game-height, 100dvh);
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  object-fit: fill;
  margin: 0;
  padding: 0;
  border: 0;
  background: #10110f;
  display: block;
  outline: none;
}
#canvas[data-viewport-container="element"] { position: absolute; }
.screen-fill-diagnostic {
  position: fixed;
  inset: auto;
  z-index: 80;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background: #071b2c;
  color: #f4f5e9;
}
.screen-fill-diagnostic > svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.screen-fill-hud {
  position: absolute;
  inset: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  overflow: auto;
  font-size: 14px;
}
.screen-fill-hud > strong, .screen-fill-hud > output, .screen-fill-hud > p {
  background: #071b2ce8;
  padding: 9px 12px;
  max-width: 100%;
  margin: 0;
}
.screen-fill-hud > output { white-space: pre-line; font-variant-numeric: tabular-nums; line-height: 1.65; }
.screen-fill-hud > button { flex: none; min-height: 44px; }
.screen-fill-hud > p { max-width: 44em; font-size: 12px; }


/* Startup is a transient surface. The native canvas owns the game and its menu. */
.shell {
  position: fixed;
  left: var(--game-left, 0px);
  top: var(--game-top, 0px);
  width: var(--game-width, 100vw);
  height: var(--game-height, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: calc(var(--safe-t) + 32px) var(--safe-r) calc(var(--safe-b) + 64px) var(--safe-l);
  background: var(--bg);
}
.boot-stage { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; }
.boot-panel { width: min(100%, 22rem); min-width: 0; padding-block: 24px; text-align: center; }
.boot-title { font-size: 24px; text-transform: uppercase; }
.boot-title span { display: block; margin-top: 6px; color: var(--muted); font-size: 15px; }
.boot-rule { width: 30px; height: 1px; margin: 23px auto; background: #8e5c40; }
.readiness { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; text-wrap: pretty; }
.boot-action { margin-top: 24px; }
.boot-action:disabled { display: none; }
.transfer-state { margin-top: 24px; text-align: left; }
.transfer-state label { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.transfer-state button { display: block; margin: 4px auto 0; font-size: 12px; }
progress { display: block; width: 100%; height: 3px; margin: 14px 0 8px; border: 0; border-radius: 0; background: #2b302a; accent-color: #c8b49a; }
progress::-webkit-progress-bar { background: #2b302a; }
progress::-webkit-progress-value { background: #c8b49a; }
progress::-moz-progress-bar { background: #c8b49a; }
.tools-menu { position: absolute; left: var(--safe-l); bottom: var(--safe-b); z-index: 3; margin: 0; }
.tools-menu > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 0;
  color: #b2b5ab;
  font-size: 12px;
  cursor: pointer;
  list-style: none;
}
.tools-menu > summary::-webkit-details-marker { display: none; }
.tools-menu > summary svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.5; fill: none; }
.tools-menu[open] > summary svg { transform: rotate(180deg); }
.tools-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: min(320px, calc(var(--game-width, 100vw) - var(--safe-l) - var(--safe-r)));
  max-height: calc(var(--game-height, 100dvh) - var(--safe-t) - var(--safe-b) - 60px);
  overflow: auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}
.tools-panel button, .tools-panel a { display: block; width: 100%; text-align: left; font-size: 13px; background: transparent; }
.tools-panel a { min-height: 44px; padding: 11px 15px; border: 1px solid transparent; border-radius: 4px; text-decoration: none; }
@media (hover: hover) { .tools-panel button:hover, .tools-panel a:hover { background: #262d25; } }
.tools-group + .tools-group, .developer-tools { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line); }
.tools-panel .profile { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.profile span { min-width: 0; max-width: 65%; color: var(--muted); text-align: right; overflow-wrap: anywhere; }
.developer-tools > summary { padding-inline: 15px; font-size: 12px; color: var(--muted); }
.developer-tools .fine { margin: 8px 15px; }
.notice {
  position: fixed;
  bottom: calc(var(--safe-b) + 4px);
  left: var(--safe-l);
  right: var(--safe-r);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 640px;
  margin-inline: auto;
  padding: 12px 14px;
  border: 1px solid #505745;
  border-radius: 6px;
  background: #262e24;
  font-size: 13px;
  line-height: 1.55;
}
.notice > span { min-width: 0; overflow-wrap: anywhere; }
.notice button { margin-left: auto; flex: none; font-size: 12px; }
.notice[data-error="true"] { background: #39201b; border-color: #815141; }
dialog {
  width: min(540px, calc(100% - var(--safe-l) - var(--safe-r)));
  max-width: none;
  max-height: calc(var(--game-height, 100dvh) - var(--safe-t) - var(--safe-b));
  margin: auto;
  padding: clamp(16px, 4vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  overflow: auto;
  overscroll-behavior: contain;
}
dialog::backdrop { background: #000c; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.dialog-head h2 { min-width: 0; overflow-wrap: anywhere; }
.dialog-head button { flex: none; background: transparent; font-size: 13px; }
fieldset { min-width: 0; border: 0; padding: 0; margin: 24px 0 32px; }
legend { margin-bottom: 12px; font-size: 13px; font-weight: 600; }
fieldset > label { display: block; margin: 20px 0; font-size: 14px; line-height: 1.5; }
fieldset > label output { float: right; margin-left: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="range"] { display: block; width: 100%; min-height: 44px; margin: 8px 0; cursor: pointer; }
select { display: block; width: 100%; min-height: 44px; margin-top: 10px; padding: 9px; border: 1px solid #555e50; border-radius: 4px; background: #262c26; color: var(--text); }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.check input { flex: none; width: 20px; height: 20px; }
fieldset p { color: var(--muted); font-size: 13px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button-row button { flex: 1 1 140px; }
dialog > button { margin: 8px 0; }
#local-profiles button { width: 100%; margin: 6px 0; text-align: left; }
dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 20px; font-size: 13px; line-height: 1.5; }
dt { color: var(--muted); overflow-wrap: anywhere; }
dd { margin: 0; overflow-wrap: anywhere; }
pre { max-height: 210px; overflow: auto; font: 11px/1.6 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; color: #d0d8c4; }
details { margin: 20px 0; }
summary { min-height: 44px; padding: 12px 0; cursor: pointer; font-size: 13px; }
.dialog-notice { margin: 12px 0 0; padding: 14px 0; border-top: 1px solid var(--line); color: #d7e5c0; font-size: 13px; line-height: 1.5; }
.dialog-notice[data-error="true"] { color: #ffb5a5; }
.backup-json { display: block; width: 100%; min-height: 160px; margin: 12px 0; padding: 12px; border: 1px solid #555e50; background: #0d100e; color: var(--text); font: 13px/1.6 ui-monospace, monospace; }
#game-toolbar {
  position: fixed;
  z-index: 10;
  top: var(--safe-t);
  left: var(--safe-l);
  right: calc(var(--safe-r) + 60px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  font-size: 12px;
  color: #ddd;
}
#game-toolbar button {
  pointer-events: auto;
  background: #252822dd;
}
#input-label {
  padding: 8px 12px;
  background: #181b16bb;
  border-radius: 5px;
}
#control-test {
  position: fixed;
  top: 20%;
  left: var(--safe-l);
  right: var(--safe-r);
  text-align: center;
  pointer-events: none;
}
#control-test h2 {
  font-size: 40px;
}
#control-test p {
  font-size: 14px;
  color: var(--muted);
}
#control-test output {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
#control-test button {
  pointer-events: auto;
  margin-top: 15px;
}
#touch-controls {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  --stick: 118px;
  --bottom: calc(var(--safe-b) + 12px);
}
.stick {
  position: absolute;
  bottom: var(--bottom);
  width: var(--stick);
  height: var(--stick);
  border: 1px solid #ebf0dc66;
  background: #252a2266;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.stick.move {
  left: calc(var(--safe-l) + 10px);
}
.stick.look {
  right: calc(var(--safe-r) + 16px);
}
.stick-thumb {
  position: absolute;
  width: 44%;
  height: 44%;
  left: 28%;
  top: 28%;
  background: #dae2cc44;
  border: 1px solid #eef5e666;
  border-radius: 50%;
  pointer-events: none;
}
.stick-label {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: #cdd4bf;
  pointer-events: none;
}
.action-cluster {
  position: absolute;
  right: calc(var(--safe-r) + 8px);
  bottom: calc(var(--bottom) + var(--stick) + 20px);
  display: grid;
  grid-template-columns: repeat(4, 54px);
  gap: 7px;
  pointer-events: auto;
}
.action-cluster button {
  font-size: 11px;
  font-weight: 700;
  padding: 0;
  min-height: 48px;
  border-radius: 50%;
  background: #30382be6;
  border: 1px solid #eaf4dc66;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.action-cluster button.fire {
  background: #c84133e6;
  color: #fff;
}
.action-cluster button:active,
.action-cluster button[data-pressed="true"] {
  background: #a8b396;
  color: #111;
}
#touch-controls[data-layout="compact"] {
  --stick: 94px;
}
#touch-controls[data-layout="large"] {
  --stick: 146px;
}
#touch-controls[data-left-handed="true"] .move {
  left: auto;
  right: calc(var(--safe-r) + 10px);
}
#touch-controls[data-left-handed="true"] .look {
  right: auto;
  left: calc(var(--safe-l) + 16px);
}
#touch-controls[data-left-handed="true"] .action-cluster {
  right: auto;
  left: calc(var(--safe-l) + 8px);
}

.input-info { max-width: min(60vw, 450px); min-width: 0; }
#input-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#controller-prompts { display: block; margin-top: 5px; padding: 5px 10px; border-radius: 4px; background: #181b16d9; color: #e0e8d2; font-size: 11px; line-height: 1.5; }
body[data-input="gamepad"] :is(button, a, input, select, textarea, summary):focus { outline: 2px solid #edaf8f; outline-offset: 4px; }
[hidden] { display: none !important; }
body[data-playing="true"] .shell { display: none; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { border-radius: 4px; background: #59634f; }
@media (max-width: 650px) {
  #touch-controls { --stick: 106px; }
  .stick.move { left: var(--safe-l); }
  .stick.look { right: var(--safe-r); }
  .action-cluster { grid-template-columns: repeat(4, 44px); gap: 6px; }
  .action-cluster button { min-height: 44px; }
  #control-test h2 { font-size: 30px; }
  #control-test p { font-size: 13px; }
  #control-test output { font-size: 12px; }
}
@media (max-height: 550px) and (min-width: 600px) {
  :root { --safe-t: max(12px, env(safe-area-inset-top), var(--host-safe-t, 0px)); --safe-b: max(12px, env(safe-area-inset-bottom), var(--host-safe-b, 0px)); }
  #touch-controls { --stick: 100px; }
  .action-cluster { grid-template-columns: repeat(4, 46px); gap: 5px; bottom: calc(var(--safe-b) + 125px); }
  .action-cluster button { min-height: 44px; }
  #control-test { top: 20%; }
  #control-test p { margin: 8px 0; }
  #control-test button { margin-top: 6px; }
}
@media (max-height: 380px) {
  .shell { padding-top: var(--safe-t); padding-bottom: calc(var(--safe-b) + 48px); }
  .boot-panel { padding-block: 8px; }
  .boot-rule { margin-block: 14px; }
  .boot-action { margin-top: 14px; }
}
@media (max-width: 360px) {
  :root { --safe-l: max(14px, env(safe-area-inset-left), var(--host-safe-l, 0px)); --safe-r: max(14px, env(safe-area-inset-right), var(--host-safe-r, 0px)); }
  .notice { flex-wrap: wrap; gap: 4px; }
  dl { gap: 12px; }
}
@media (horizontal-viewport-segments: 2) {
  #control-test { left: calc(env(viewport-segment-right 0 0) + 20px); top: 20%; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Keep unsupported browsers and failed module loads on the static entry page. */
:root:not([data-runtime="notify"]) body > :not(#runtime-gate) { display: none !important; }
:root:not([data-runtime="notify"]) dialog::backdrop { display: none !important; }
:root[data-runtime="notify"] #runtime-gate { display: none; }
.runtime-gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  background: #060707;
  text-align: center;
}
.runtime-gate > section { width: min(100%, 24rem); min-width: 0; }
.runtime-gate h1 { font: 600 clamp(24px, 5vw, 32px)/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.02em; }
.runtime-gate p { margin: 16px 0 20px; color: var(--muted); }
.runtime-gate a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; max-width: 100%; padding: 11px 16px; border: 1px solid #555b53; border-radius: 4px; overflow-wrap: anywhere; text-decoration: none; }
@media (hover: hover) { .runtime-gate a:hover { background: #262c26; } }
