:root {
  color-scheme: dark;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background:
    radial-gradient(circle at 50% 16%, rgba(70, 151, 118, .19), transparent 34%),
    radial-gradient(circle at 17% 80%, rgba(212, 153, 66, .08), transparent 30%),
    linear-gradient(155deg, #06120f 0%, #0b241c 52%, #071511 100%);
  color: #f6f2e8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
  touch-action: none;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background-image:
    linear-gradient(rgba(255,255,255,.016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.012) 1px, transparent 1px);
  background-size: 34px 34px;
}

#game-root {
  position: fixed;
  inset: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  display: grid;
  place-items: center;
  outline: none;
}
#game-root canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  image-rendering: auto;
  outline: none;
}

#boot-fallback {
  position: fixed;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  z-index: 20;
  pointer-events: none;
  transition: opacity .35s ease, visibility .35s ease;
}
#boot-fallback.hidden { opacity: 0; visibility: hidden; }
#boot-fallback h1 { margin: 0; font-size: clamp(28px, 5vw, 52px); letter-spacing: -.03em; }
#boot-fallback p { margin: 0; color: #bdc9bf; }
.boot-logo {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(244, 193, 98, .82);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(29, 73, 56, .95), rgba(9, 25, 20, .98));
  box-shadow: 0 22px 70px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.12);
  color: #ffd88a;
  font: 800 32px/1 Georgia, serif;
  transform: rotate(-4deg);
}

#dom-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.dom-modal-backdrop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: auto;
  background: rgba(2, 10, 8, .72);
  backdrop-filter: blur(12px);
  animation: overlay-in .18s ease-out both;
}
.dom-modal {
  width: min(520px, 100%);
  max-height: min(720px, 92vh);
  overflow: auto;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 24px;
  padding: 24px;
  background: linear-gradient(160deg, rgba(28, 54, 44, .98), rgba(8, 22, 17, .99));
  box-shadow: 0 30px 90px rgba(0,0,0,.52);
}
.dom-modal h2 { margin: 0 0 8px; font-size: 25px; }
.dom-modal p { margin: 0 0 18px; color: #c8d3cc; line-height: 1.55; }
.dom-modal label { display: block; margin: 12px 0 7px; font-weight: 700; }
.dom-modal input, .dom-modal textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 13px;
  padding: 13px 14px;
  background: rgba(0,0,0,.22);
  color: white;
  font: inherit;
  outline: none;
}
.dom-modal input:focus, .dom-modal textarea:focus { border-color: #f2bd63; box-shadow: 0 0 0 3px rgba(242, 189, 99, .14); }
.dom-modal textarea { min-height: 230px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.dom-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.dom-actions button {
  border: 0;
  border-radius: 13px;
  padding: 12px 17px;
  background: #e8b65d;
  color: #152119;
  font: 800 14px/1 inherit;
  cursor: pointer;
}
.dom-actions button.secondary { background: rgba(255,255,255,.1); color: white; }
.dom-actions button.danger { background: #d75f58; color: white; }
.dom-actions button:hover { filter: brightness(1.08); transform: translateY(-1px); }

.fatal-panel {
  position: fixed;
  inset: 20px;
  margin: auto;
  width: min(520px, calc(100% - 40px));
  height: max-content;
  z-index: 100;
  padding: 26px;
  border-radius: 20px;
  background: #14251e;
  border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.fatal-panel h1 { margin-top: 0; }

.skip-link {
  position: fixed;
  z-index: 200;
  left: 12px;
  top: -80px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff;
  color: #111;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
