:root {
  color-scheme: dark;
  font: 112.5%/1.55 system-ui, sans-serif;
  background: #111515;
  color: #e9ede7;
  --panel: #1b2221;
  --border: #536461;
  --accent: #afded1;
  --muted: #bac7c2;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0 auto; max-width: 56rem; min-height: 100dvh; display: flex; flex-direction: column; }
main { display: flex; flex: 1; min-height: 0; flex-direction: column; }
h1, h2, h3, p { margin: 0; }
h1 { font: 600 1.25rem/1.2 Georgia, serif; }
.top, .prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem;
  padding: .65rem clamp(.65rem, 4vw, 1.35rem);
  background: #161c1b;
  position: sticky;
  z-index: 1;
}
.top { top: 0; justify-content: space-between; border-bottom: 1px solid var(--border); }
#clock { color: var(--accent); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.login, .lobby { display: grid; gap: .75rem; padding: 1rem; }
.login { width: min(100%, 25rem); margin: auto; }
.login label { display: grid; gap: .25rem; }
.login .check { display: flex; gap: .5rem; align-items: center; min-height: 2.5rem; }
input, button {
  font: inherit;
  min-height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: .3rem;
  color: inherit;
  background: var(--panel);
  padding: .4rem .55rem;
  min-width: 0;
}
input[type="checkbox"] { min-height: 1.15rem; min-width: 1.15rem; accent-color: var(--accent); }
button { cursor: pointer; color: var(--accent); }
button:disabled { cursor: default; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#game { position: relative; display: flex; flex: 1; flex-direction: column; min-height: 0; }
body:has(#game[hidden]) #map-panel { display: none; }
#map-panel { flex: none; }
summary { cursor: pointer; min-height: 2.5rem; display: list-item; align-content: center; color: var(--accent); }
#map {
  position: absolute;
  inset-block-start: 100%;
  inset-inline-end: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  max-width: 100%;
  max-height: 35cqh;
  overflow: auto;
  padding: .45rem;
  margin: 0;
  list-style: none;
  background: #161c1b;
  border: 1px solid var(--border);
  border-radius: .3rem;
}
#map:empty { display: none; }
#map li { display: grid; background: var(--panel); padding: .3rem .65rem; border: 1px solid var(--border); border-radius: .3rem; overflow-wrap: anywhere; }
#map span { color: var(--muted); }
.scroll { flex: 1; overflow-y: auto; padding: .85rem clamp(.65rem, 4vw, 1.35rem); }
html:has(#prompt:not([hidden])) { overflow: hidden; }
body:has(#prompt:not([hidden])) {
  position: fixed;
  inset-inline: 0;
  top: var(--visible-top, 0px);
  height: var(--visible-height, 100dvh);
  min-height: 0;
  container-type: size;
}
body:has(#prompt:not([hidden])) .scroll { min-height: 40cqh; }
.story, .echo { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: .5rem; }
.echo { color: var(--accent); font-family: ui-monospace, monospace; }
.options { display: grid; gap: .35rem; padding: .45rem; margin: .65rem 0; border: 1px solid var(--border); border-radius: .4rem; }
.options button { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem .75rem; text-align: left; overflow-wrap: anywhere; }
.options code { color: var(--muted); }
.options.spent { border-style: dashed; }
.prompt {
  --control-size: min(2.5rem, 22cqh);
  bottom: 0;
  border-top: 1px solid var(--border);
  flex-wrap: nowrap;
  padding-bottom: max(.65rem, env(safe-area-inset-bottom));
}
.prompt input {
  flex: 1 1 0;
  min-height: var(--control-size);
  line-height: 1.2;
  padding-block: 0;
}
.prompt button {
  flex: 0 0 var(--control-size);
  min-height: var(--control-size);
  padding: 0;
  line-height: 1;
  white-space: nowrap;
}
.prompt label { flex: none; color: var(--accent); font-family: ui-monospace, monospace; }

@container (max-width: 600px) or (max-height: 480px) {
  .top { flex-wrap: nowrap; padding-block: min(.25rem, 2cqh); }
  .top h1 { display: none; }
  #clock {
    font-size: min(1rem, 10cqh);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #map-panel summary { min-height: min(2.5rem, 22cqh); }
  .prompt {
    padding-top: min(.25rem, 2cqh);
    padding-bottom: max(min(.25rem, 2cqh), env(safe-area-inset-bottom));
    font-size: min(1rem, 16cqh);
  }
}

@container (max-width: 240px) {
  .prompt { gap: 4px; padding-inline: 4px; }
  .prompt input { padding-inline: 4px; }
  .prompt button { flex-basis: 32px; }
  .prompt label { font-size: min(1em, 24px); }
}
