:root {
  color-scheme: dark;
  --bg: #0a1918;
  --panel: #102622;
  --line: #65826a4d;
  --ink: #e8e1c9;
  --muted: #a0b4a3;
  --gold: #dfbe79;
  --mint: #a3dfc3;
  font:
    14px/1.6 system-ui,
    sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background:
    radial-gradient(ellipse at 20% 10%, #203c31 0, transparent 60%), var(--bg);
  color: var(--ink);
  min-height: 100dvh;
}
button,
input,
a {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  background: #19332d;
  border: 1px solid #809a7466;
  border-radius: 6px;
  color: var(--ink);
  padding: 9px 15px;
  cursor: pointer;
}
button:hover {
  background: #29473c;
  border-color: var(--gold);
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
a {
  color: var(--ink);
}
[hidden] {
  display: none !important;
}
.page {
  width: min(1200px, 100%);
  margin: auto;
  padding: 24px 36px;
}
header,
footer,
.header-actions,
.play-heading,
.play-actions,
.play-footer,
.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
header {
  padding-bottom: 23px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  text-decoration: none;
  font:
    17px Georgia,
    serif;
  letter-spacing: 3px;
}
.wordmark span {
  display: block;
  font: 8px/2 system-ui;
  letter-spacing: 3px;
  color: var(--muted);
}
.build-tag,
.eyebrow {
  font:
    10px/1.6 ui-monospace,
    monospace;
  letter-spacing: 2px;
  color: var(--gold);
}
.build-tag {
  border: 1px solid var(--line);
  padding: 4px 7px;
  font-size: 9px;
}
main {
  min-height: 72vh;
}
.home {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 70px;
  align-items: center;
  padding: 60px 0 70px;
}
.home-art {
  height: 505px;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 50%, #455a3e55 0, transparent 65%),
    repeating-linear-gradient(90deg, transparent 0 49px, #81986b08 49px 50px);
  border: 1px solid var(--line);
  border-radius: 150px 150px 8px 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.home-art:before,
.home-art:after {
  content: "";
  position: absolute;
  width: 450px;
  height: 450px;
  border: 17px solid #52624760;
  border-radius: 44%;
  transform: rotate(-25deg);
  top: 270px;
  left: -155px;
}
.home-art:after {
  left: 120px;
  transform: rotate(35deg);
  border-color: #ac986343;
  top: 260px;
}
.bell {
  width: 180px;
  height: 210px;
  border: 5px solid #e0be76;
  border-radius: 90px 90px 20px 20px;
  box-shadow:
    inset 0 0 0 10px #203c32,
    0 0 95px #adba7540;
  display: grid;
  place-items: center;
  font: 145px/1 Georgia;
  color: var(--gold);
  transform: rotate(-9deg);
  margin-top: -50px;
}
.bell:before {
  content: "";
  position: absolute;
  top: -30px;
  width: 38px;
  height: 30px;
  border: 5px solid #e0be76;
  border-bottom: 0;
  border-radius: 25px 25px 0 0;
}
.bell:after {
  content: "";
  position: absolute;
  bottom: -21px;
  width: 25px;
  height: 25px;
  background: #dfbe79;
  border-radius: 50%;
}
.art-label {
  position: absolute;
  bottom: 33px;
  font: 8px ui-monospace;
  letter-spacing: 2px;
  color: #c5c598;
}
.home h1 {
  font:
    clamp(34px, 4vw, 48px) / 1.12 Georgia,
    serif;
  font-weight: normal;
  margin: 20px 0;
}
.home-copy > p {
  color: var(--muted);
  max-width: 400px;
}
.home-buttons {
  display: grid;
  gap: 10px;
  margin: 28px 0;
}
.home-buttons button,
.home-buttons a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  padding: 15px 19px;
  text-decoration: none;
  border-radius: 6px;
}
.home-buttons a {
  color: var(--muted);
  border: 1px solid var(--line);
}
.primary {
  background: var(--gold);
  color: #182d26;
  border-color: var(--gold);
  font-weight: 650;
}
.primary:hover {
  background: #f0d59b;
  color: #14271f;
}
.scope-note {
  font-size: 11px !important;
  color: var(--muted);
  line-height: 1.6;
}
.play-heading {
  margin: 24px 0 18px;
}
.play-heading h1 {
  font: 30px/1.1 Georgia;
  margin: 4px 0;
}
.play-actions > span {
  font: 9px ui-monospace;
  color: var(--muted);
}
.hud {
  display: grid;
  grid-template-columns: 1.1fr 1.9fr 0.7fr;
  gap: 20px;
  align-items: center;
  background: #112923;
  border: 1px solid var(--line);
  padding: 16px 20px;
  border-radius: 8px 8px 0 0;
}
.vitals #hearts {
  font-size: 22px;
  letter-spacing: 2px;
  color: #ecaa8c;
  white-space: nowrap;
}
.guard-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 8px ui-monospace;
  color: var(--muted);
}
meter {
  width: 75px;
  height: 7px;
}
.guard-line b {
  color: var(--gold);
}
.weapons {
  display: flex;
  gap: 12px;
}
.weapon {
  width: 50%;
  border: 1px solid var(--line);
  padding: 7px 10px;
  border-radius: 5px;
  opacity: 0.65;
}
.weapon.active {
  border-color: var(--gold);
  opacity: 1;
  background: #34463260;
}
.weapon strong {
  display: block;
  font: 15px Georgia;
}
.weapon small {
  font: 9px ui-monospace;
  color: var(--muted);
}
.heat {
  height: 4px;
  background: #081c19;
  margin-top: 6px;
  border-radius: 4px;
  overflow: hidden;
}
.heat i {
  display: block;
  background: var(--gold);
  height: 100%;
  width: 0;
}
.heat.vent i {
  background: #f2a17b;
}
.tool-status {
  border-left: 1px solid var(--line);
  padding-left: 18px;
  display: grid;
}
.tool-status > span {
  font: 8px ui-monospace;
  color: var(--muted);
}
.tool-status b {
  font: 16px Georgia;
  color: var(--mint);
}
.tool-status small {
  font: 9px ui-monospace;
  color: var(--muted);
}
.arena-frame {
  position: relative;
  border: 1px solid var(--line);
  border-top: 0;
  background: #122822;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5/3;
  touch-action: none;
  outline: none;
}
.arena-message {
  position: absolute;
  top: 25px;
  left: 50%;
  transform: translateX(-50%);
  border: 1px solid var(--gold);
  background: #11241fec;
  padding: 14px 22px;
  text-align: center;
  border-radius: 5px;
  pointer-events: none;
}
.play-footer {
  align-items: flex-start;
  font-size: 10px;
  color: var(--muted);
  padding: 12px 0;
}
.play-footer span:first-child {
  max-width: 55%;
  color: var(--gold);
}
.play-footer span:last-child {
  text-align: right;
}
footer {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  font: 9px ui-monospace;
  color: #829989;
  letter-spacing: 1px;
}
.touch-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #102823;
  border: 1px solid var(--line);
  padding: 10px 20px;
}
#game,
.touch-controls {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.stick {
  width: 110px;
  height: 110px;
  border: 1px solid #829b7560;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  touch-action: none;
  background: #081d18;
}
.stick span {
  position: absolute;
  width: 100%;
  text-align: center;
  bottom: 10px;
  font: 8px ui-monospace;
  color: var(--muted);
  pointer-events: none;
}
.stick i {
  position: absolute;
  left: calc(50% - 19px);
  top: calc(50% - 19px);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  background: #738c6750;
  border: 1px solid #adc59070;
  pointer-events: none;
}
.touch-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.touch-buttons button {
  touch-action: none;
  min-height: 43px;
  min-width: 65px;
}
.touch-buttons button.active {
  background: #647850;
}
.atlas-intro {
  color: var(--muted);
  max-width: 780px;
  font-size: 13px;
}
.atlas-layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  margin: 22px 0;
}
.chart-panel,
.room-panel {
  background: #112823;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}
.seed-form {
  display: flex;
  align-items: center;
  gap: 10px;
}
.seed-form label {
  font: 10px ui-monospace;
  color: var(--muted);
  white-space: nowrap;
}
input {
  background: #071d18;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  padding: 9px;
  min-width: 0;
}
.seed-form input {
  width: 100%;
}
.seed-form button {
  white-space: nowrap;
  font-size: 11px;
}
.map {
  min-height: 370px;
}
.map svg {
  display: block;
  width: 100%;
  height: 390px;
}
.map .edge {
  stroke: #6b8660;
  stroke-width: 2;
}
.map .edge.locked {
  stroke: #9b7545;
  stroke-dasharray: 5 5;
}
.map button {
  padding: 0;
}
.map .node {
  cursor: pointer;
  outline: none;
}
.map .node:focus rect {
  stroke-width: 4;
  stroke: #a3dfc3;
}
.map text {
  font: 11px ui-monospace;
  fill: var(--ink);
  pointer-events: none;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font: 9px ui-monospace;
  color: var(--muted);
}
.room-panel h2 {
  font: 29px Georgia;
  margin: 8px 0;
}
.room-panel h3 {
  font: 10px ui-monospace;
  letter-spacing: 1px;
  color: var(--gold);
  margin-top: 26px;
}
.room-panel p {
  font-size: 12px;
  color: var(--muted);
}
#room-detail {
  font-size: 11px;
  color: var(--mint);
}
#room-doors {
  display: grid;
  gap: 7px;
}
#room-doors button {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
#room-doors small {
  font-size: 10px;
  color: var(--gold);
}
#progress-controls {
  display: grid;
  gap: 8px;
  margin-top: 25px;
  font-size: 11px;
  color: var(--muted);
}
#progress-controls label {
  display: flex;
  gap: 8px;
  align-items: center;
}
.save-bar {
  padding: 15px 0;
  border-top: 1px solid var(--line);
  font-size: 11px;
}
.save-bar > div {
  display: flex;
  gap: 7px;
}
.save-bar button {
  font-size: 10px;
}
.save-bar .error {
  color: #ffbd9c;
}
dialog {
  width: min(580px, calc(100% - 24px));
  padding: 0;
  border: 1px solid #b5bb8070;
  border-radius: 10px;
  background: #132b25;
  color: var(--ink);
}
dialog::backdrop {
  background: #03110dde;
  backdrop-filter: blur(4px);
}
.dialog-card {
  padding: 30px;
}
.dialog-card h2 {
  font: 32px Georgia;
  margin: 10px 0;
}
.dialog-card p {
  color: var(--muted);
  font-size: 13px;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}
.controls-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px 16px;
  margin: 22px 0;
  font-size: 11px;
}
.controls-grid b {
  font-weight: 500;
  color: var(--gold);
}
.controls-grid span {
  color: var(--muted);
}
body:fullscreen .page {
  max-width: 1200px;
}
button svg {
  pointer-events: none;
}
@media (max-width: 800px) {
  .page {
    padding: 15px;
  }
  .home {
    gap: 30px;
    padding: 40px 0;
  }
  .home-art {
    height: 390px;
  }
  .home h1 {
    font-size: 34px;
  }
  .hud {
    padding: 10px;
    gap: 12px;
    grid-template-columns: 1fr 1.6fr;
  }
  .tool-status {
    display: none;
  }
  .atlas-layout {
    grid-template-columns: 1fr;
  }
  .map {
    min-height: 280px;
  }
  .map svg {
    height: 300px;
  }
  .vitals #hearts {
    font-size: 19px;
    letter-spacing: 0;
  }
  .weapon {
    padding: 5px 8px;
  }
  .weapon strong {
    font-size: 13px;
  }
}
@media (max-width: 560px) {
  .wordmark span {
    font-size: 7px;
  }
  .header-actions {
    gap: 5px;
  }
  .header-actions button {
    padding: 7px;
    font-size: 10px;
  }
  .build-tag {
    display: none;
  }
  .home {
    grid-template-columns: 1fr;
    padding-top: 25px;
    gap: 25px;
  }
  .home-art {
    height: 190px;
    border-radius: 95px 95px 6px 6px;
  }
  .bell {
    transform: rotate(-9deg) scale(0.55);
    margin-top: -20px;
  }
  .art-label {
    bottom: 14px;
    font-size: 6px;
  }
  .home h1 {
    font-size: 35px;
    margin: 10px 0;
  }
  .home-copy > p {
    max-width: none;
  }
  .home-buttons {
    margin: 20px 0;
  }
  .play-heading h1 {
    font-size: 25px;
  }
  .play-actions > span {
    display: none;
  }
  .play-actions button {
    font-size: 11px;
  }
  .hud {
    grid-template-columns: 0.9fr 1.5fr;
    gap: 7px;
  }
  .weapon strong {
    font-size: 11px;
  }
  .weapon small {
    font-size: 7px;
  }
  .weapons {
    gap: 5px;
  }
  .weapon {
    padding: 5px;
  }
  .vitals #hearts {
    font-size: 16px;
  }
  .guard-line {
    font-size: 7px;
  }
  meter {
    width: 48px;
  }
  .tool-status {
    display: none;
  }
  .play-footer {
    display: block;
  }
  .play-footer span {
    display: block !important;
    max-width: none !important;
    text-align: left !important;
    margin-bottom: 5px;
  }
  .touch-controls {
    padding: 8px;
    gap: 8px;
  }
  .stick {
    width: 90px;
    height: 90px;
  }
  .touch-buttons {
    gap: 5px;
  }
  .touch-buttons button {
    font-size: 11px;
    min-width: 50px;
    padding: 5px;
  }
  .chart-panel,
  .room-panel {
    padding: 17px;
  }
  .seed-form {
    gap: 6px;
  }
  .seed-form label {
    display: none;
  }
  .save-bar {
    align-items: flex-start;
    flex-direction: column;
  }
  .save-bar > div {
    flex-wrap: wrap;
  }
  .controls-grid {
    grid-template-columns: 94px 1fr;
    gap: 10px;
  }
  .dialog-card {
    padding: 22px;
  }
  footer {
    font-size: 7px;
    letter-spacing: 0;
  }
  .arena-message {
    top: 10px;
    font-size: 12px;
    padding: 8px;
    width: 75%;
  }
}
@media (max-height: 560px) and (orientation: landscape) {
  .page {
    max-width: 930px;
    padding: 8px 15px;
  }
  body:has(#play:not([hidden])) header,
  body:has(#play:not([hidden])) footer,
  #play .play-heading,
  #play .play-footer {
    display: none;
  }
  .hud {
    padding: 4px 10px;
    min-height: 55px;
  }
  .arena-frame {
    max-width: calc((100dvh - 100px) * 1.6667);
    margin: auto;
  }
  .touch-controls {
    position: fixed;
    inset: 55px 4px 4px;
    border: 0;
    background: none;
    pointer-events: none;
    padding: 0;
  }
  .touch-controls > * {
    pointer-events: auto;
  }
  .touch-buttons {
    position: absolute;
    bottom: 0;
    right: 0;
  }
  .stick {
    width: 90px;
    height: 90px;
  }
  .touch-controls #aim-stick {
    margin-bottom: 135px;
  }
  .arena-frame:has(+ .touch-controls:not([hidden])) {
    width: calc(100vw - 260px);
  }
  .home {
    padding: 30px;
    grid-template-columns: 1fr 1fr;
  }
  .home-art {
    height: 320px;
  }
  .home h1 {
    font-size: 32px;
  }
  .dialog-card {
    padding: 18px;
  }
  .controls-grid {
    gap: 7px;
    margin: 12px 0;
  }
  .dialog-card h2 {
    font-size: 25px;
  }
  .dialog-actions {
    margin-top: 12px;
  }
}

.compact-pause {
  display: none;
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 40px;
  min-height: 34px;
  padding: 3px;
  background: #132b25dd;
}
@media (max-height: 560px) and (orientation: landscape) {
  .compact-pause {
    display: block;
  }
}

dialog {
  max-height: calc(100dvh - 24px);
  overflow: auto;
}
@media (max-height: 560px) and (orientation: landscape) {
  .dialog-card {
    padding: 14px 20px;
  }
  .dialog-card h2 {
    font-size: 23px;
    margin: 5px 0;
  }
  .dialog-card p {
    font-size: 11px;
    margin: 6px 0;
  }
  .dialog-card .scope-note {
    display: none;
  }
  .controls-grid {
    font-size: 10px;
    gap: 4px 10px;
    margin: 8px 0;
  }
  .dialog-actions {
    margin-top: 10px;
  }
  .dialog-actions button {
    padding: 7px 12px;
  }
}
