:root {
  --void: #081820;
  --ink: #e0f8d0;
  --dim: #88c070;
  --wood: #88c070;
  --wood-ink: #081820;
  --cyan: #88c070;
  --hp: #346856;
  --stam: #88c070;
  --hud-portrait: none;
  --hud-hp: none;
  --hud-gold: none;
  --hud-gem: none;
  --hud-gem-icon: none;
  --hud-panel: none;
  --hud-hotbar: none;
  --hud-slot: none;
}

@font-face {
  font-family: "Fusion Pixel 8";
  src: url("/fonts/fusion-pixel-8.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Fusion Pixel";
  src: url("/fonts/fusion-pixel.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #081820;
  color: var(--ink);
  font-family: "Fusion Pixel 8", "Fusion Pixel", monospace;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0;
  font-smooth: never;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  text-rendering: geometricPrecision;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100vw;
  height: 100%;
  height: 100dvh;
  background: #081820;
}

#stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #081820;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: center;
  background: #081820;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.hud {
  position: absolute;
  top: 1.2vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  width: min(94vw, 540px);
  min-height: 56px;
  height: auto;
  pointer-events: none;
}
.hud.hidden { display: none; }

.hud-bar {
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 56px;
}

.hud-portrait {
  position: relative;
  height: 100%;
  aspect-ratio: 220 / 280;
  background: var(--hud-portrait) center / contain no-repeat;
  image-rendering: pixelated;
  overflow: hidden;
  flex: 0 0 auto;
}
.hud-portrait::before {
  content: "";
  position: absolute;
  inset: 22% 16% 16% 14%;
  background: #081820;
}
.portrait-helm {
  position: absolute;
  left: 16%;
  top: 20%;
  width: 68%;
  height: 64%;
  object-fit: contain;
  object-position: top;
  image-rendering: pixelated;
  z-index: 1;
}

.hud-vitals {
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 220px;
  height: 100%;
  background: var(--hud-hp) center / 100% 100% no-repeat;
  image-rendering: pixelated;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 12px 14px 10px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bar-row span {
  flex: 0 0 20px;
  font-size: 12px;
  color: #e0f8d0;
  line-height: 1;
}
.bar { display: block; flex: 1; min-width: 0; }
.bar-track {
  height: 8px;
  background: #081820;
  border: 1px solid #346856;
  overflow: hidden;
}
.bar-track i { display: block; height: 100%; }
.bar.hp .bar-track i { background: linear-gradient(180deg, #88c070, #346856); }
.bar.stam .bar-track i { background: linear-gradient(180deg, #88c070, #346856); }
.bar.exp .bar-track i { background: linear-gradient(180deg, #88c070, #346856); }

.hud-gold {
  height: 100%;
  width: 92px;
  flex: 0 0 92px;
  background: var(--hud-gold) center / 100% 100% no-repeat;
  image-rendering: pixelated;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 10px 0 34px;
  color: #e0f8d0;
  font-size: 12px;
  line-height: 1;
}

.hud-floor {
  height: 100%;
  min-width: 72px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0 8px;
  color: #88c070;
  font-size: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: var(--hud-slot) center / 100% 100% no-repeat;
  image-rendering: pixelated;
}

.hud-tools {
  display: flex;
  gap: 4px;
  pointer-events: auto;
  height: 100%;
  flex: 0 0 auto;
  z-index: 8;
}

.icon-btn {
  height: 100%;
  width: 48px;
  min-width: 44px;
  padding: 0;
  color: #e0f8d0;
  font-size: 12px;
  letter-spacing: 0;
  background: var(--hud-gem-icon, var(--hud-gem)) center / contain no-repeat;
  image-rendering: pixelated;
  border: none;
  box-shadow: none;
  display: grid;
  place-items: center;
}
.hud-tools .icon-btn { font-size: 0; }
.icon-btn .ico-svg {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 #081820);
}
.icon-btn.on, .icon-btn:hover {
  filter: brightness(1.18);
  box-shadow: 0 0 0 2px var(--cyan);
  color: #e0f8d0;
}

.dock {
  position: absolute;
  left: 50%;
  top: auto;
  bottom: 17%;
  transform: translate(-50%, 50%);
  z-index: 5;
  width: 128px;
  height: 128px;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.dock.hidden { display: none; }
.dock.ghost .stick {
  opacity: 0;
  pointer-events: auto;
}

.stick {
  position: absolute;
  inset: 0;
  border-radius: 0;
  pointer-events: auto;
  touch-action: none;
  background: transparent;
  border: none;
  box-shadow: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.stick-ring {
  position: absolute;
  inset: 0;
  border-radius: 0;
  border: none;
  pointer-events: none;
  background: center / 100% 100% no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 0;
  transform: translate(-50%, -50%);
  background: center / 100% 100% no-repeat;
  border: none;
  box-shadow: none;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.pie {
  display: none !important;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 230px;
  height: 230px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 6;
}
.pie.hidden { display: none; }
.pie-slice {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 40px;
  margin: 0;
  padding: 0;
  transform: translate(-50%, -50%) rotate(var(--a)) translate(78px) rotate(calc(var(--a) * -1));
  font-size: 11px;
  letter-spacing: 0;
  border-radius: 2px;
}
.pie-slice.on {
  filter: brightness(1.15);
  box-shadow: 0 0 0 2px var(--cyan);
}

button {
  font-family: inherit;
  font-weight: 400;
  cursor: pointer;
  color: #e0f8d0;
  background: linear-gradient(180deg, #346856 0%, #081820 100%);
  border: 2px solid #346856;
  padding: 8px 14px;
  letter-spacing: 0;
  text-shadow: 2px 2px 0 #081820;
  font-size: 16px;
}
button:hover, button.on {
  filter: brightness(1.14);
  box-shadow: 0 0 0 2px var(--cyan);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 16px;
  background: transparent;
  pointer-events: auto;
  touch-action: pan-y;
}
.overlay.dim {
  background: rgba(8, 24, 32, 0.5);
}
.overlay.hidden { display: none; }
.overlay:has(.title-menu) {
  background: transparent;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}

.plank {
  display: block;
  text-align: center;
  margin: 0 auto 16px;
  padding: 10px 28px;
  max-width: 280px;
  color: #e0f8d0;
  letter-spacing: 0.22em;
  font-weight: 700;
  font-size: 13px;
  background: linear-gradient(180deg, #346856 0%, #081820 100%);
  border: 2px solid #346856;
  text-shadow: 1px 0 0 #e0f8d0, 0 1px 0 #081820;
}

.menu, .sheet {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 36px 42px 32px;
  border: 28px solid transparent;
  border-image-source: var(--hud-panel);
  border-image-slice: 90 130 90 130 fill;
  border-image-width: 28px 36px;
  border-image-repeat: stretch;
  background: transparent;
  color: var(--ink);
  image-rendering: pixelated;
}
.sheet { width: min(820px, 100%); }
.menu h1, .sheet h2 { display: none; }
.menu-plain {
  border: none;
  border-image: none;
  background: rgba(8, 24, 32, 0.88);
  padding: 28px 24px 24px;
}
.title-menu {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 5vh 12px 6vh;
  border: none;
  border-image: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}
.title-brand {
  text-align: center;
  z-index: 3;
  pointer-events: none;
}
.title-word {
  font-size: 32px;
  line-height: 1;
  letter-spacing: 0.28em;
  color: #e0f8d0;
  text-shadow: 3px 0 0 #081820, 0 3px 0 #081820, 3px 3px 0 #081820;
}
.title-who {
  margin-top: 6px;
  color: #88c070;
  letter-spacing: 0.08em;
  font-size: 16px;
  text-shadow: 2px 2px 0 #081820;
}
.title-hot {
  position: absolute;
  z-index: 2;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: transparent;
  font-size: 0;
  cursor: pointer;
  min-height: 0;
  box-shadow: none;
  filter: none;
  text-shadow: none;
}
.title-hot:hover, .title-hot:focus, .title-hot.on:hover {
  border: none;
  background: rgba(224, 248, 208, 0.06);
  filter: none;
  box-shadow: none;
}
.title-hot-door {
  left: 38%;
  top: 14%;
  width: 24%;
  height: 28%;
}
.title-hot-stairs {
  left: 34%;
  top: 62%;
  width: 32%;
  height: 22%;
}
.title-menu-tiles .title-hot-door {
  left: 41%;
  top: 6%;
  width: 18%;
  height: 20%;
}
.title-hot-back {
  left: 58%;
  top: 8%;
  width: 22%;
  height: 22%;
}
.title-slab {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  min-height: 0;
  color: #e0f8d0;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-shadow: 2px 2px 0 #081820;
  background: transparent;
  border: none;
  box-shadow: none;
  filter: none;
  image-rendering: pixelated;
}
.title-slab:hover, .title-slab:focus {
  filter: none;
  background: rgba(52, 104, 86, 0.28);
  box-shadow: none;
  border: none;
}
.title-slab-load {
  left: 14%;
  top: 48%;
  width: 38%;
  height: 18%;
  transform: skewX(-8deg);
}
.title-slab-login {
  left: 46%;
  top: 66%;
  width: 40%;
  height: 18%;
  transform: skewX(-8deg);
}
.title-slab-back {
  left: 6%;
  top: 82%;
  width: 28%;
  height: 12%;
  letter-spacing: 0.28em;
  font-size: 18px;
}
.menu-item .ico-svg { display: none; }

.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  text-align: center;
  min-height: 44px;
}
.menu-item:disabled {
  opacity: 0.45;
  filter: none;
  cursor: default;
  box-shadow: none;
}
.menu-item .ico { display: none; }

.login-input {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #e0f8d0;
  text-align: center;
  letter-spacing: 0.12em;
  background: #081820;
  border: 2px solid #346856;
  outline: none;
  user-select: text;
  touch-action: manipulation;
  pointer-events: auto;
  text-shadow: 1px 0 0 #e0f8d0;
}
.login-input:focus { border-color: var(--cyan); }

.muted { color: var(--dim); font-size: 12px; text-align: center; }
.gold { color: #88c070; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; justify-content: center; }

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 16px;
  padding: 8px 4px;
  color: var(--ink);
  font-size: 13px;
}
.opt-row .icon-btn {
  width: 44px;
  height: 36px;
  font-size: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 56px));
  gap: 8px;
  max-height: min(46vh, 360px);
  overflow-y: auto;
  align-content: start;
}
.slot {
  width: 56px;
  height: 56px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background: #081820 var(--hud-slot) center / 100% 100% no-repeat;
  image-rendering: pixelated;
  border: none;
}
.slot.selected { box-shadow: 0 0 0 2px var(--cyan); }
.slot img, .slot canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.slot .qty { position: absolute; right: 3px; bottom: 1px; font-size: 11px; }
.equip-row { display: flex; gap: 12px; margin: 14px 0 18px; flex-wrap: wrap; }
.equip-slot { text-align: center; font-size: 11px; color: var(--dim); }
.desc {
  min-height: 56px;
  border-top: 1px solid #346856;
  margin-top: 12px;
  padding-top: 10px;
  font-size: 13px;
  white-space: pre-wrap;
}
.bestiary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.card {
  background: #081820 var(--hud-slot) center / 100% 100% no-repeat;
  image-rendering: pixelated;
  padding: 8px;
}
.card img { width: 100%; height: 100px; object-fit: cover; object-position: top; image-rendering: pixelated; }
.card .name { margin-top: 8px; color: #e0f8d0; font-size: 13px; }
.card-stat { margin-top: 4px; color: var(--dim); font-size: 11px; }
.shop-gold {
  text-align: center;
  color: #e0f8d0;
  font-size: 16px;
  letter-spacing: 0.08em;
  margin: -4px 0 12px;
}
.shop-gold::after { content: " 金"; color: #346856; font-size: 12px; }
.shop-port {
  display: block;
  width: 134px;
  height: 134px;
  margin: 0 auto 16px;
  object-fit: contain;
  object-position: center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: transparent;
  border: none;
}
.shop-port[src=""] { display: none; }
.shop-list { display: flex; flex-direction: column; gap: 8px; }
.shop-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 6px 14px;
  cursor: pointer;
  text-align: left;
  color: #e0f8d0;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-shadow: none;
  image-rendering: auto;
  background: linear-gradient(180deg, #081820 0%, #081820 100%);
  border: 2px solid #346856;
  box-shadow: inset 0 1px 0 rgba(224, 248, 208, 0.12);
}
button.shop-row:hover, button.shop-row:focus {
  filter: none;
  border-color: #88c070;
  color: #e0f8d0;
}
.shop-ico {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: #081820;
  border: 1px solid #346856;
}
.shop-ico img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
}
.shop-name { min-width: 0; }
.shop-price {
  color: #e0f8d0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.shop-price::after { content: " 金"; color: #346856; font-size: 11px; }
.two-col { display: grid; grid-template-columns: 1fr minmax(160px, 260px); gap: 16px; }

.card-pack, .draft-row {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}
.draft-row { grid-template-columns: 1fr; }
.owned-card, .draft-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 132px;
  padding: 16px 14px 14px;
  text-align: center;
  letter-spacing: 0;
  color: var(--ink);
  background: var(--hud-slot) center / 100% 100% no-repeat, #081820;
  image-rendering: pixelated;
  border: none;
}
.owned-card b, .draft-card b { font-size: 16px; color: #e0f8d0; letter-spacing: 0; text-align: center; }
.owned-card i, .draft-card i { font-style: normal; font-size: 16px; letter-spacing: 0; color: var(--dim); text-align: center; }
.owned-card span, .draft-card span { text-align: center; }
.seal { position: absolute; top: 8px; right: 12px; font-size: 12px; color: var(--cyan); letter-spacing: 0; }
.draft-card.on, .draft-card:hover {
  box-shadow: 0 0 0 2px var(--cyan), 0 0 14px rgba(136, 192, 112, .28);
}

.floor-map {
  display: grid;
  gap: 10px;
  justify-content: center;
  margin: 16px 0;
}
.map-cell {
  position: relative;
  min-width: 42px;
  height: 42px;
  background: #88c070;
  border: 1px solid #346856;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: #346856;
  z-index: 1;
}
.map-cell .ex {
  position: absolute;
  background: #346856;
  z-index: 0;
  pointer-events: none;
}
.map-cell .ex.n { left: 50%; top: -11px; width: 8px; height: 12px; transform: translateX(-50%); }
.map-cell .ex.s { left: 50%; bottom: -11px; width: 8px; height: 12px; transform: translateX(-50%); }
.map-cell .ex.w { top: 50%; left: -11px; width: 12px; height: 8px; transform: translateY(-50%); }
.map-cell .ex.e { top: 50%; right: -11px; width: 12px; height: 8px; transform: translateY(-50%); }
.map-cell.empty { background: transparent; border-color: transparent; }
.map-cell.empty .ex { display: none; }
.map-cell.seen {
  background: #e0f8d0;
  border-color: #e0f8d0;
  color: #081820;
}
.map-cell.seen .ex { background: #e0f8d0; }
.map-cell.boss.seen {
  background: #346856;
  border-color: #346856;
  color: #e0f8d0;
}
.map-cell.here {
  box-shadow: 0 0 0 2px #88c070;
}

.hud-log {
  margin-top: 6px;
  padding: 6px 10px;
  color: #e0f8d0;
  font-size: 11px;
  letter-spacing: 0.06em;
  background: rgba(8, 24, 32, 0.72);
  border: 1px solid #346856;
  pointer-events: none;
}

.title-verse {
  margin-top: 8px;
  color: #88c070;
  letter-spacing: 0.12em;
  font-size: 16px;
  text-shadow: 2px 2px 0 #081820;
}

.overlay:has(.story-box) {
  background: linear-gradient(180deg, transparent 35%, rgba(8, 24, 32, 0.88) 100%);
  align-items: end;
  justify-content: center;
  padding: 0 16px 28px;
}

.story-box {
  width: min(720px, 100%);
  padding: 18px 22px 16px;
  border: 2px solid #346856;
  background: linear-gradient(180deg, #081820 0%, #081820 100%);
  color: var(--ink);
  cursor: pointer;
}

.story-speaker {
  color: #88c070;
  letter-spacing: 0.18em;
  font-size: 12px;
  margin-bottom: 8px;
}

.story-body {
  color: #e0f8d0;
  font-size: 14px;
  line-height: 1.7;
  letter-spacing: 0.06em;
  white-space: normal;
}

.story-hint {
  margin-top: 12px;
  text-align: right;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.16em;
}

.story-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.ending-body {
  color: #e0f8d0;
  font-size: 13px;
  line-height: 1.7;
  text-align: left;
  margin: 0 0 16px;
}

.shop-line {
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.5;
  margin: -4px 0 12px;
}

.card-lore {
  margin-top: 6px;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: 0.03em;
}

.portrait-fallback {
  position: absolute;
  left: 22%;
  top: 24%;
  width: 56%;
  height: 52%;
  z-index: 1;
  background:
    linear-gradient(180deg, #88c070 0 8px, transparent 8px 14px, #88c070 14px 16px, #346856 16px) center 8% / 70% 22% no-repeat,
    linear-gradient(#346856, #081820);
  clip-path: polygon(20% 8%, 80% 8%, 88% 28%, 88% 78%, 50% 100%, 12% 78%, 12% 28%);
}

.overlay:has(.altar-box) {
  background: linear-gradient(180deg, transparent 42%, rgba(8, 24, 32, 0.82) 100%);
  align-items: end;
  justify-content: center;
  padding: 0 16px 24px;
  pointer-events: auto;
}

.altar-box {
  width: min(520px, 100%);
  padding: 16px 18px 14px;
  border: 2px solid #346856;
  background: #081820;
  display: flex;
  flex-direction: column;
  gap: 10px;
  image-rendering: pixelated;
}

.altar-pads {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.altar-pads-mid {
  display: flex;
  gap: 22px;
}
.altar-pads button {
  width: 64px;
  height: 36px;
  padding: 0;
  font-family: inherit;
  font-size: 14px;
  color: #e0f8d0;
  background: #346856;
  border: 2px solid #88c070;
  image-rendering: pixelated;
}
.altar-pads button:active {
  background: #88c070;
  color: #081820;
}
.altar-abort {
  align-self: flex-end;
  font-size: 12px;
  padding: 6px 12px;
  background: #081820;
}

.owned-card.empty-slot {
  min-height: 88px;
  opacity: 0.55;
}
.owned-card.incoming {
  margin: 0 auto 12px;
  max-width: 280px;
}
.owned-card.r4 .seal, .draft-card.r4 .seal { color: #e0f8d0; }
.owned-card.r5 .seal, .draft-card.r5 .seal { color: #e0f8d0; letter-spacing: 0.12em; }
.owned-card.r5, .draft-card.r5 { box-shadow: inset 0 0 0 1px #88c070; }

.tome-body {
  max-height: min(58vh, 480px);
  margin-bottom: 12px;
}

.map-cell.altar.seen { color: #081820; }
.journal-sheet { width: min(920px, 100%); }
.journal {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 16px;
  min-height: 280px;
  max-height: min(62vh, 520px);
}
.journal-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
}
.journal-tab {
  width: 100%;
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 8px 10px;
}
.journal-body {
  overflow: auto;
  padding: 4px 6px 12px;
  color: #e0f8d0;
  font-size: 13px;
  line-height: 1.75;
  letter-spacing: 0.04em;
  white-space: pre-wrap;
}

@media (max-width: 700px) {
  .journal { grid-template-columns: 1fr; max-height: min(70vh, 640px); }
  .journal-nav { flex-direction: row; flex-wrap: wrap; }
  .journal-tab { width: auto; }
}

@media (min-width: 820px) and (orientation: landscape) {
  .draft-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr 260px; }
}

@media (max-width: 700px) {
  .two-col { grid-template-columns: 1fr; }
  .hud {
    left: 8px;
    right: auto;
    transform: none;
    width: calc(100% - 16px);
    min-height: 48px;
    height: auto;
  }
  .hud-bar {
    padding-right: 148px;
    height: 48px;
  }
  .hud-gold { width: 64px; flex-basis: 64px; }
  .hud-floor { display: none; }
  .hud-tools {
    position: fixed;
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    height: 48px;
    gap: 8px;
    z-index: 8;
  }
  .hud-tools .icon-btn {
    width: 48px;
    min-width: 48px;
    height: 48px;
  }
  .icon-btn { width: 44px; min-width: 40px; }
  .overlay {
    align-items: start;
    padding: 8px;
    overflow: auto;
  }
  .menu, .sheet {
    border-width: 12px;
    border-image-width: 12px 16px;
    padding: 18px 14px 16px;
    max-height: calc(100dvh - 16px);
  }
  .grid { max-height: min(38vh, 280px); }
  .floor-map { max-width: 100%; overflow: auto; }
}
