:root {
  color-scheme: dark;
  --brand: #00688B;
  --brand-hover: #087ca3;
  --page: #071722;
  --panel: #0d2230;
  --panel-deep: #0a1b28;
  --line: #294554;
  --text: #f0f7fa;
  --muted: #b1c6cf;
  --blue-light: #86d2ee;
  --gold: #f4c279;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font: 100%/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 0; }
html.iframe-autosize { overflow-y: hidden; }
body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(ellipse at 52% 0%, #123242, var(--page) 64%) fixed;
}
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, [tabindex="0"]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
button svg, h2 svg, h3 svg, .side-icon svg, .scene-label svg, .quiver svg, .crest svg {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.symbols, .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  pointer-events: none;
}
.shell {
  width: min(100%, 77rem);
  padding: clamp(1rem, 3.5vw, 2.8rem) clamp(.85rem, 4vw, 3rem) clamp(1.3rem, 4vw, 3.5rem);
  margin-inline: auto;
}
.masthead, .identity, .masthead-actions, .mode-controls, .mode,
.scene-label, .hunt-status, .inventory, .inventory-title, .senses h2,
.journal h2, .action h3, .action h3 label {
  display: flex;
  align-items: center;
}
.masthead { justify-content: space-between; flex-wrap: wrap; gap: .9rem 1.5rem; }
.identity { min-width: 0; gap: .95rem; }
.crest {
  width: clamp(2.75rem, 6vw, 4rem);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  flex: none;
  background: linear-gradient(145deg, var(--brand), #07405a);
  border: 1px solid #367f9a;
  border-radius: .95rem;
  color: #e6f5fb;
  box-shadow: 0 .35rem 1rem #020b1366, inset 0 1px 0 #ffffff25;
  font-size: clamp(1.5rem, 3vw, 2rem);
}
h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.85rem, 4.5vw, 3.15rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.06;
}
.identity p {
  margin-top: .25rem;
  color: var(--muted);
  font-size: clamp(.875rem, 2vw, 1rem);
}
.masthead-actions { gap: .55rem; flex-wrap: wrap; }
.button {
  min-height: 2.75rem;
  padding: .45rem .85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  border: 1px solid transparent;
  border-radius: .55rem;
  color: var(--text);
  font-weight: 650;
  font-size: .9rem;
  line-height: 1.2;
  text-align: center;
}
.primary { background: var(--brand); border-color: #37849f; box-shadow: inset 0 1px 0 #ffffff18; }
.primary:hover { background: var(--brand-hover); }
.outline, .quiet-button { border-color: var(--line); background: #112c3b; }
.outline:hover, .quiet-button:hover { background: #1b4053; border-color: #4d7b91; }
.quiet-button { background: #0a1d2a80; }

.mode-controls {
  width: fit-content;
  max-width: 100%;
  gap: .25rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 1.1rem;
  padding: .26rem;
  border: 1px solid var(--line);
  border-radius: .72rem;
  background: #081c29;
}
.mode {
  min-height: 2.75rem;
  justify-content: center;
  gap: .42rem;
  padding: .4rem .72rem;
  line-height: 1.15;
  border: 1px solid transparent;
  border-radius: .5rem;
  color: var(--muted);
  background: transparent;
  font-size: .9rem;
  font-weight: 650;
}
.mode:hover { color: var(--text); background: #153548; }
.mode[aria-pressed="true"] { color: var(--text); border-color: #37849f; background: var(--brand); }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(15rem, 28%, 20rem);
  align-items: start;
  gap: 1rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .9rem;
  box-shadow: 0 .5rem 1.5rem #020b133d;
}
.scene {
  min-height: clamp(18.5rem, 34vw, 27rem);
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  position: relative;
  padding: clamp(.85rem, 2.5vw, 1.55rem);
  border-radius: .85rem .85rem 0 0;
  background: var(--panel-deep);
}
.scene-photo {
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(0deg, #030d17 0%, #050f18e0 11%, #06162333 59%, #08152055 100%),
    url("images/grotto.webp") center 48% / cover;
}
.wumpus-encounter {
  position: absolute;
  z-index: 1;
  right: clamp(.8rem, 5vw, 2.5rem);
  bottom: clamp(3.2rem, 7vw, 4.5rem);
  width: clamp(8rem, 22vw, 13rem);
  margin: 0;
  padding: .35rem .45rem .3rem;
  border: 1px solid #c4a9d9aa;
  border-radius: .8rem;
  background: #101d29e8;
  box-shadow: 0 .6rem 1.8rem #020a10a8;
  text-align: center;
  animation: wumpus-arrive .38s ease-out both;
}
.wumpus-encounter svg { display: block; width: 100%; height: auto; }
.wumpus-encounter figcaption { color: #f0e3f8; font-size: .78rem; font-weight: 650; line-height: 1.25; }
@keyframes wumpus-arrive {
  from { opacity: 0; transform: translateY(.6rem) scale(.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .wumpus-encounter { animation: none; }
}
.scene-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: .55rem; }
.scene-label, .hunt-status {
  min-height: 1.85rem;
  gap: .4rem;
  padding: .28rem .58rem;
  color: #e6f6fc;
  border: 1px solid #7497aa88;
  background: #061624e8;
  border-radius: .38rem;
  font-size: .82rem;
  font-weight: 650;
  line-height: 1.2;
}
.hunt-status { border-radius: 2rem; white-space: nowrap; }
.hunt-status::before {
  width: .48rem;
  height: .48rem;
  flex: none;
  border-radius: 50%;
  background: #7ddfc4;
  content: "";
}
.hunt-status[data-outcome="won"]::before { background: var(--gold); }
.hunt-status[data-outcome="lost"]::before { background: #f6a39b; }
.scene-caption h2 {
  font: 700 clamp(2.4rem, 5.5vw, 4.35rem)/1 Georgia, "Times New Roman", serif;
  letter-spacing: -.04em;
}
.scene-caption p { color: #cedee6; margin-top: .42rem; font-size: 1rem; }
.scene[data-view="classic"] {
  min-height: clamp(14rem, 28vw, 21rem);
  background: repeating-linear-gradient(0deg, #102c37 0 1px, transparent 1px 5px), #0b202a;
}
.scene[data-view="classic"] .scene-photo, .scene[data-view="map"] .scene-photo { display: none; }
.scene[data-view="classic"] .scene-caption h2 {
  color: #a8e8ee;
  font-family: var(--mono);
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: -.05em;
}
.scene[data-view="classic"] .scene-caption { font-family: var(--mono); }
.scene[data-view="classic"] .scene-caption h2::before { content: "> "; color: #78beca; font-size: .8em; }
.scene[data-view="map"] { gap: .8rem; }
.scene[data-view="map"] .scene-caption h2 { font-size: clamp(1.9rem, 3.8vw, 2.7rem); }

.map-panel {
  background: radial-gradient(circle at center, #143747 0%, #0a2533 64%, #081e2b 100%);
  border: 1px solid var(--line);
  border-radius: .65rem;
  padding: .65rem;
}
.map-tools { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .45rem .8rem; }
.map-tools p, .map-key { font-size: .84rem; color: #c1d3dc; }
.map-toggle { display: flex; flex-wrap: wrap; gap: .2rem; }
.map-toggle button {
  min-height: 2.75rem;
  padding: .25rem .65rem;
  color: var(--muted);
  background: #0d2532;
  border: 1px solid var(--line);
  border-radius: .35rem;
  font-size: .875rem;
  font-weight: 650;
}
.map-toggle button[aria-pressed="true"] { background: var(--brand); color: var(--text); border-color: #37849f; }
.map-toggle button:disabled { opacity: .6; }
#cave-map { display: block; width: min(100%, 25rem); height: auto; margin: .35rem auto .45rem; overflow: visible; }
.map-edges line { stroke: #497181; stroke-width: 1.5; }
.map-edges .visited-edge { stroke: #769ba8; }
.map-edges .active-edge { stroke: #6ad1ed; stroke-width: 2.5; }
.map-edges .route-edge { stroke: var(--gold); stroke-width: 3; }
.map-nodes text { fill: #e6f4fa; font: 650 14px var(--mono); pointer-events: none; }
.map-nodes [role="button"] { cursor: pointer; }
.map-hit { fill: transparent; pointer-events: none; }
.map-available .map-hit { pointer-events: all; }
.map-dot { fill: #142c38; stroke: #557080; stroke-width: 1.5; }
.map-visited .map-dot { fill: #285065; stroke: #8aafbd; }
.map-available .map-dot { fill: #00688B; stroke: #8de4ff; stroke-width: 2; }
.map-route .map-dot, .map-current .map-dot { fill: #654c28; stroke: var(--gold); stroke-width: 2.5; }
.map-current .map-dot { fill: var(--gold); }
.map-current text { fill: #14242c; }
.map-available:hover .map-dot, .map-available:focus-visible .map-dot { stroke: white; stroke-width: 3; }
.map-key { display: flex; justify-content: center; flex-wrap: wrap; gap: .35rem .8rem; }
.map-key span { display: inline-flex; gap: .32rem; align-items: center; }
.map-key i { width: .65rem; height: .65rem; border-radius: 50%; background: #142c38; border: 1px solid #78909c; }
.map-key .key-current { background: var(--gold); border-color: var(--gold); }
.map-key .key-next { background: var(--brand); border-color: #8de4ff; }
.map-key .key-visited { background: #285065; border-color: #8aafbd; }

.action-area {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  border-top: 1px solid var(--line);
}
.action { padding: clamp(.9rem, 2.4vw, 1.35rem); min-width: 0; }
.action + .action { border-left: 1px solid var(--line); }
.action h3, .action h3 label, .senses h2, .journal h2 { gap: .45rem; }
.action h3, .sidebar h2, .hunt-end h3 { font-size: 1rem; }
.action h3 svg, .senses h2 svg, .journal h2 svg { color: var(--blue-light); }
.action p, .hunt-end p { margin-top: .2rem; color: var(--muted); font-size: .88rem; }
.exits, .shoot-controls { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }
.exit { flex: 1 0 auto; white-space: nowrap; }
.shoot-controls input {
  flex: 1 1 7rem;
  width: 0;
  min-width: 5.5rem;
  min-height: 2.75rem;
  border-radius: .48rem;
  padding: .4rem .55rem;
  border: 1px solid #4d6b7c;
  color: var(--text);
  background: #081c29;
  font-size: 1rem;
}
.shoot-controls input::placeholder { color: #a8bbc6; }
.shoot-controls input[aria-invalid="true"] { border-color: #f1a099; }
.route-feedback:empty { display: none; }
.action .route-feedback { color: #ffb6aa; margin-top: .5rem; }
.hunt-end { grid-column: 1 / -1; padding: 1.25rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; }

.sidebar { display: grid; gap: 1rem; }
.inventory { padding: 1rem; gap: .75rem; }
.side-icon {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  border-radius: .56rem;
  background: #12445c;
  color: #a1ddf0;
  flex: none;
}
.inventory-icon { font-size: 1.2rem; }
.inventory-content { flex: 1; min-width: 0; }
.inventory-title { justify-content: space-between; gap: .25rem; }
#arrow-count { font: 700 .95rem var(--mono); white-space: nowrap; color: var(--blue-light); }
.quiver { display: flex; gap: .24rem; margin-top: .26rem; }
.quiver span {
  display: grid;
  place-items: center;
  flex: 1 1 1.6rem;
  height: 1.15rem;
  border-radius: .2rem;
  font-size: .7rem;
  line-height: 1;
}
.arrow-full { background: var(--brand); color: #e2f4fa; }
.arrow-spent { background: #142b38; color: #617d8a; }
.senses { padding: .95rem 1rem 1rem; border-top: 1px solid var(--line); }
.clue-list { display: grid; gap: .42rem; margin: .55rem 0 0; padding: 0; list-style: none; }
.clue {
  display: flex;
  align-items: center;
  gap: .5rem;
  border: 1px solid #715836;
  margin: 0;
  padding: .46rem .56rem;
  border-radius: .38rem;
  color: #ffe2b3;
  background: #332b20;
  font-size: .9rem;
}
.clue-marker { width: .52rem; height: .52rem; border-radius: 50%; background: var(--gold); flex: none; }
.clue-wumpus { background: #38272b; border-color: #78474d; color: #ffd3ce; }
.clue-wumpus .clue-marker { background: #ffa79d; }
.clue-bats { background: #2a2940; border-color: #5a557a; color: #e6d9ff; }
.clue-bats .clue-marker { background: #d0b9ff; }
.clue-none { font-size: .9rem; color: var(--muted); }
.journal { padding: .95rem 1rem 1rem; }
.journal-list { padding: 0; margin: .62rem 0 0; list-style: none; }
.journal-entry { padding: .55rem 0 .55rem .75rem; border-left: 2px solid var(--line); }
.journal-entry:first-child { border-color: var(--blue-light); }
.journal-turn { color: var(--blue-light); font: 700 .78rem var(--mono); }
.journal-entry p { font-size: .92rem; color: var(--muted); }
.journal-entry:first-child p { color: var(--text); }

dialog {
  max-width: min(32rem, calc(100% - 1.5rem));
  max-height: calc(100% - 1.5rem);
  padding: clamp(1rem, 4vw, 1.65rem);
  border-radius: .8rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}
dialog::backdrop { background: #030b13bd; }
dialog p, dialog ul { color: var(--muted); margin-top: .7rem; }
dialog ul { padding-inline-start: 1.2rem; }
dialog li + li { margin-top: .4rem; }
dialog form { margin-top: 1rem; }
.dialog-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .55rem; }
.noscript { margin-top: 1rem; }

@media (max-width: 56rem) {
  .action-area { grid-template-columns: 1fr; }
  .action + .action { border-left: 0; border-top: 1px solid var(--line); }
  .exit { flex: 0 1 auto; }
}
@media (max-width: 43rem) {
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: .85rem; }
  .main-panel, .sidebar { display: contents; }
  .scene, .action-area { border: 1px solid var(--line); border-radius: .8rem; }
  .scene { min-height: clamp(16rem, 62vw, 22rem); }
  .scene[data-view="classic"] { min-height: 12rem; }
  .action-area { background: var(--panel); order: 2; }
  .status-panel { order: 1; }
  .journal { order: 3; }
  .masthead-actions { gap: .45rem; }
  .mode-controls { margin: 1.1rem 0 .8rem; }
}
@media (max-width: 27rem) {
  .mode-controls { display: grid; grid-template-columns: auto auto auto; width: 100%; }
  .mode { padding-inline: .29rem; gap: .27rem; font-size: .8rem; }
  .mode svg { width: 1em; }
}
@media (max-width: 20rem) {
  .mode svg { display: none; }
  .map-tools { gap: .3rem; }
}
