@font-face {
  font-family: "PressStart";
  src: url("vendor/fonts/ps2p.ttf") format("truetype");
  font-display: block;
}
@font-face {
  font-family: "VT323";
  src: url("vendor/fonts/vt323.ttf") format("truetype");
  font-display: block;
}
:root {
  --night: #191322;
  --wood: #2f2216;
  --wood-lite: #46331e;
  --gold: #d8a83c;
  --gold-lite: #f4cf6d;
  --cream: #f7ecd0;
  --cream-dim: #c9b78f;
  --green: #78c850;
  --green-deep: #3f8f4c;
  --red: #d95763;
  --px: "PressStart", monospace;
  --body: "VT323", monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; }
body {
  background: var(--night);
  color: var(--cream);
  font-family: var(--body);
  font-size: 20px;
  line-height: 1.25;
  overscroll-behavior: none;
}
#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: #0b0f0b;
}

/* ---------------- HUD ---------------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}
#hud-identity,
#hud .right,
#left-rail,
#quest-status,
#mobile-hero,
#hint-strip {
  background: linear-gradient(180deg, var(--wood-lite), var(--wood));
  border: 3px solid #000;
  box-shadow: 0 0 0 3px var(--gold) inset, 5px 6px 0 rgba(0, 0, 0, 0.42);
  pointer-events: auto;
}
#hud-identity {
  position: absolute;
  left: calc(24px + env(safe-area-inset-left));
  top: calc(24px + env(safe-area-inset-top));
  width: min(420px, calc(100vw - 48px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  min-height: 74px;
  padding: 15px 18px 13px;
  z-index: 20;
}
#hud .brand {
  display: block;
  font-family: var(--px);
  font-size: 10px;
  line-height: 1.5;
  color: var(--gold-lite);
  text-shadow: 2px 2px 0 #000;
}
#hud .stat {
  display: block;
  margin-top: 9px;
  font-family: var(--px);
  font-size: 8px;
  line-height: 1.6;
  color: var(--cream);
  text-shadow: 1px 1px 0 #000;
}
#hud .stat b, #hud .brand b { color: var(--gold-lite); font-weight: normal; }
#hud .right {
  position: absolute;
  right: calc(24px + env(safe-area-inset-right));
  top: calc(24px + env(safe-area-inset-top));
  min-height: 58px;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 9px 12px;
  z-index: 20;
}
#left-rail {
  position: absolute;
  left: calc(24px + env(safe-area-inset-left));
  top: calc(132px + env(safe-area-inset-top));
  width: 78px;
  display: grid;
  gap: 10px;
  padding: 12px 9px;
  z-index: 20;
}
.pxbtn {
  font-family: var(--px); font-size: 7px; color: var(--cream);
  background: var(--wood); border: 2px solid #000; border-radius: 0;
  box-shadow: 0 0 0 2px var(--gold) inset;
  min-width: 44px; min-height: 44px;
  padding: 8px 8px 7px; cursor: pointer; text-transform: uppercase;
}
.pxbtn[aria-pressed="true"] { background: var(--gold); color: #241a10; }
.pxbtn:focus-visible { outline: 2px solid var(--gold-lite); outline-offset: 2px; }
.rail-btn {
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  font-family: var(--px);
  font-size: 7px;
  line-height: 1.45;
  text-align: center;
  color: var(--cream);
  background: #22190f;
  border: 2px solid #000;
  box-shadow: 0 0 0 2px #8b6a27 inset;
  cursor: pointer;
}
.rail-btn.active,
.rail-btn[aria-pressed="true"] { background: #705123; color: var(--gold-lite); }
.rail-btn:focus-visible { outline: 2px solid var(--gold-lite); outline-offset: 2px; }
#quest-status {
  position: absolute;
  right: calc(24px + env(safe-area-inset-right));
  top: calc(132px + env(safe-area-inset-top));
  width: 282px;
  min-height: 140px;
  padding: 18px;
  z-index: 20;
}
#quest-status b {
  display: block;
  font-family: var(--px);
  font-size: 9px;
  color: var(--gold-lite);
  line-height: 1.5;
}
#quest-status span {
  display: block;
  margin-top: 14px;
  font-size: 22px;
  line-height: 1.08;
  color: var(--cream-dim);
}
#mobile-hero { display: none; }

/* ---------------- world ---------------- */
#world-wrap {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  line-height: 0;
  background: #0b0f0b;
}
#world-content {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100vw, 133.333333svh);
  height: max(100svh, 75vw);
  transform: translate(-50%, -50%);
}
#phaser-root,
#phaser-root canvas {
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
  display: block;
}

/* DFK-style ornate scroll nameplate */
.sign {
  position: absolute; transform: translate(-50%, 0);
  font-family: var(--px); font-size: 8px; line-height: 1;
  color: #5c3a1e; text-transform: capitalize;
  background: linear-gradient(180deg, #f9ecc4, #edd9a2);
  border: 2px solid #7a4d21;
  border-radius: 7px;
  box-shadow: 0 0 0 2px #d8a83c inset, 2px 3px 0 rgba(0, 0, 0, 0.45);
  min-width: 44px;
  min-height: 44px;
  padding: 8px 14px 6px; cursor: pointer; z-index: 10;
}
.sign::before, .sign::after {
  content: ""; position: absolute; top: 50%; width: 8px; height: 14px;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #e8bf58, #b9832c);
  border: 2px solid #7a4d21; border-radius: 4px;
}
.sign::before { left: -7px; }
.sign::after { right: -7px; }
.sign:active { transform: translate(-50%, 2px); }
.sign:focus-visible { outline: 2px solid var(--gold-lite); outline-offset: 3px; }
#hint-strip {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: min(560px, calc(100vw - 48px));
  max-width: calc(100vw - 48px);
  padding: 16px 24px 15px;
  font-family: var(--px);
  font-size: 9px;
  line-height: 1.3;
  text-align: center;
  color: var(--cream);
  text-shadow: 1px 1px 0 #000;
  z-index: 20;
}

/* ---------------- RPG sheet ---------------- */
#sheet-veil { position: fixed; inset: 0; background: rgba(6, 9, 7, 0.72); z-index: 30; }
#sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(calc(100vw - 48px), 880px);
  max-height: min(calc(100svh - 48px), 660px);
  transform: translate(-50%, -50%);
  background: var(--wood);
  border: 3px solid #000;
  box-shadow: 0 0 0 3px var(--gold) inset, 0 0 0 6px #000 inset, 0 18px 45px rgba(0, 0, 0, 0.68);
  z-index: 40; display: flex; flex-direction: column;
}
#sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px 16px; }
#sheet-title { font-family: var(--px); font-size: 11px; color: var(--gold-lite); text-shadow: 2px 2px 0 #000; }
#sheet-body { overflow-y: auto; padding: 4px 16px 18px; }
#sheet-body p.flavor { color: var(--cream-dim); margin: 2px 0 10px; }
#sheet[data-panel="wallet"] { z-index: 50; }
@media (prefers-reduced-motion: no-preference) {
  #sheet { animation: rise 0.18s ease-out; }
  @keyframes rise { from { transform: translate(-50%, calc(-50% + 24px)); opacity: 0.5; } to { transform: translate(-50%, -50%); opacity: 1; } }
}

.rpg-table { width: 100%; border-collapse: collapse; }
.rpg-table td, .rpg-table th { padding: 5px 4px; text-align: left; border-bottom: 2px solid rgba(0, 0, 0, 0.4); }
.rpg-table th { font-family: var(--px); font-size: 7px; color: var(--cream-dim); text-transform: uppercase; }
.rpg-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--green); }
.down { color: var(--red); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-box { background: rgba(0, 0, 0, 0.32); border: 2px solid #000; box-shadow: 0 0 0 2px var(--wood-lite) inset; padding: 7px 10px; }
.stat-box .k { font-family: var(--px); font-size: 6.5px; color: var(--cream-dim); text-transform: uppercase; }
.stat-box .v { font-size: 22px; color: var(--gold-lite); font-variant-numeric: tabular-nums; }

/* The Sovereign's Path — onboarding quest log */
#quests-btn.path-live { box-shadow: 0 0 0 2px var(--gold) inset; animation: pathPulse 2.4s ease-in-out infinite; }
@keyframes pathPulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }

.path-bar { height: 10px; background: rgba(0, 0, 0, 0.45); border: 2px solid #000; margin: 4px 0 3px; }
.path-fill { height: 100%; background: var(--gold); transition: width 240ms ease-out; }
.path-count { font-family: var(--px); font-size: 6.5px; color: var(--cream-dim); text-transform: uppercase; margin-bottom: 10px; }

.path-list { display: flex; flex-direction: column; gap: 6px; }
.path-step {
  display: flex; gap: 10px; padding: 8px 10px;
  background: rgba(0, 0, 0, 0.28); border: 2px solid #000;
  box-shadow: 0 0 0 2px var(--wood-lite) inset;
}
.path-step.current { box-shadow: 0 0 0 2px var(--gold) inset; background: rgba(120, 78, 20, 0.32); }
.path-step.done .path-title { color: var(--cream-dim); }
.path-mark {
  flex: 0 0 26px; height: 26px; display: grid; place-items: center;
  font-family: var(--px); font-size: 9px;
  background: rgba(0, 0, 0, 0.4); color: var(--cream-dim); border: 2px solid #000;
}
.path-step.done .path-mark { background: var(--gold); color: #241a10; }
.path-step.current .path-mark { color: var(--gold-lite); }
.path-title { font-size: 18px; color: var(--gold-lite); }
.path-why { font-size: 14px; color: var(--cream-dim); line-height: 1.5; margin-top: 3px; }
.path-how { font-size: 15px; color: var(--cream); margin-top: 5px; }
.path-reward { font-size: 14px; color: var(--gold); margin-top: 4px; }
.path-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.path-link {
  font-family: var(--px); font-size: 7px; text-transform: uppercase; text-decoration: none;
  color: #241a10; background: var(--gold); border: 2px solid #000; padding: 5px 7px;
}
.path-link:hover { background: var(--gold-lite); }

/* Wallet chooser */
.wallet-list { display: flex; flex-direction: column; gap: 8px; }
.wallet-opt {
  display: flex; align-items: center; gap: 10px;
  font-family: inherit; font-size: 18px; text-align: left;
  color: var(--cream); background: rgba(0, 0, 0, 0.32);
  border: 2px solid #000; box-shadow: 0 0 0 2px var(--wood-lite) inset;
  padding: 10px 12px; cursor: pointer;
}
.wallet-opt:hover { box-shadow: 0 0 0 2px var(--gold) inset; color: var(--gold-lite); }
.wallet-opt img { width: 26px; height: 26px; image-rendering: auto; }
.wallet-dot { width: 26px; height: 26px; background: var(--wood-lite); display: inline-block; }

/* Season banner — the one place the CROWN economy has a clock on it, so it gets
   a warmer frame than the flat stat boxes around it. */
.season-box {
  border: 2px solid #000; box-shadow: 0 0 0 2px var(--gold) inset;
  background: rgba(120, 78, 20, 0.35);
  padding: 9px 11px; margin-bottom: 10px; font-size: 17px; color: var(--gold-lite);
}
.season-box b { color: #ffe9a8; }
.season-sub { margin-top: 5px; font-size: 15px; color: var(--cream-dim); line-height: 1.45; }
.season-claims { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }

.act {
  font-family: var(--px); font-size: 8px; text-transform: uppercase;
  color: #241a10; background: var(--gold);
  border: 2px solid #000; box-shadow: 0 0 0 2px var(--gold-lite) inset, 0 3px 0 #000;
  padding: 8px 10px 7px; cursor: pointer; line-height: 1.4;
}
.act:not(:disabled):active { transform: translateY(2px); box-shadow: 0 0 0 2px var(--gold-lite) inset, 0 1px 0 #000; }
.act.green { background: var(--green-deep); color: var(--cream); box-shadow: 0 0 0 2px var(--green) inset, 0 3px 0 #000; }
.act.red { background: #a33; color: var(--cream); box-shadow: 0 0 0 2px var(--red) inset, 0 3px 0 #000; }
.act.dim { background: var(--wood-lite); color: var(--cream); box-shadow: 0 0 0 2px #6b4423 inset, 0 3px 0 #000; }
.act:disabled { opacity: 0.4; cursor: not-allowed; }
.act:focus-visible { outline: 2px solid var(--gold-lite); outline-offset: 2px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
select.rpg, input.rpg {
  font-family: var(--body); font-size: 19px; color: var(--cream);
  background: rgba(0, 0, 0, 0.4); border: 2px solid #000; box-shadow: 0 0 0 2px var(--wood-lite) inset;
  padding: 5px 8px;
}
input.rpg { max-width: 110px; }

.hero {
  display: grid; grid-template-columns: 64px 1fr; gap: 4px 12px;
  background: rgba(0, 0, 0, 0.28); border: 2px solid #000;
  box-shadow: 0 0 0 2px var(--wood-lite) inset;
  padding: 10px; margin: 10px 0;
}
.hero canvas { width: 56px; height: auto; image-rendering: pixelated; grid-row: span 3; align-self: start; }
.hero h3 { margin: 0; font-family: var(--px); font-size: 9px; color: var(--gold-lite); text-shadow: 1px 1px 0 #000; }
.hero .sub { color: var(--cream-dim); font-size: 18px; }
.hero .full { grid-column: 2; }
.xp-rail { background: #000; height: 12px; border: 2px solid #000; box-shadow: 0 0 0 1px var(--wood-lite); margin: 6px 0 2px; }
.xp-fill { background: linear-gradient(180deg, var(--green), var(--green-deep)); height: 100%; width: 0; }
.quest-strip { background: rgba(63, 143, 76, 0.25); border-left: 4px solid var(--green); padding: 6px 8px; margin: 6px 0; font-size: 19px; }
.quest-strip b, .vault b { color: var(--gold-lite); font-variant-numeric: tabular-nums; }
.vault { font-size: 18px; color: var(--cream-dim); }

/* The Sovereign's Portfolio — one ledger for the wallet, token-bound vaults, and
   deployed quest capital. It stays square and dense like the rest of the RPG UI. */
.portfolio-hero {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.65fr); gap: 10px;
  margin: 2px 0 10px;
}
.portfolio-networth, .portfolio-identity {
  border: 2px solid #000; box-shadow: 0 0 0 2px var(--wood-lite) inset;
  background: rgba(0, 0, 0, 0.3); padding: 12px 14px;
}
.portfolio-networth { background: linear-gradient(135deg, rgba(120, 78, 20, 0.48), rgba(0, 0, 0, 0.32)); }
.portfolio-eyebrow, .portfolio-identity span, .portfolio-hero-value span,
.portfolio-location-label, .portfolio-breakdown span, .portfolio-section-head h2,
.portfolio-count, .portfolio-identity small {
  font-family: var(--px); font-size: 6.5px; color: var(--cream-dim); text-transform: uppercase;
}
.portfolio-total { font-size: clamp(36px, 7vw, 58px); line-height: 0.95; color: var(--gold-lite); font-variant-numeric: tabular-nums; }
.portfolio-networth p { margin: 8px 0 0; color: var(--cream-dim); font-size: 15px; }
.portfolio-identity { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.portfolio-identity b { color: var(--cream); font-size: 23px; font-weight: normal; overflow-wrap: anywhere; }
.portfolio-identity small { margin-top: 8px; line-height: 1.45; }

.portfolio-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 16px; }
.portfolio-breakdown > div {
  display: flex; flex-direction: column; min-height: 58px; padding: 8px 10px;
  border: 2px solid #000; border-left: 4px solid var(--gold); background: rgba(0, 0, 0, 0.26);
}
.portfolio-breakdown b { margin-top: auto; color: var(--gold-lite); font-size: 23px; font-weight: normal; font-variant-numeric: tabular-nums; }
.portfolio-breakdown small { color: var(--cream-dim); font-size: 14px; }

.portfolio-section-head {
  display: flex; justify-content: space-between; align-items: end; gap: 10px;
  margin: 12px 0 7px; padding-bottom: 6px; border-bottom: 3px double var(--gold);
}
.portfolio-section-head > div:first-child { display: flex; align-items: baseline; gap: 8px; }
.portfolio-section-head > div:first-child > span { font-family: var(--px); font-size: 7px; color: var(--gold); }
.portfolio-section-head h2 { margin: 0; color: var(--gold-lite); font-size: 9px; }
.portfolio-section-head .act { padding: 5px 7px 4px; font-size: 6px; }
.portfolio-count { color: var(--cream-dim); padding-bottom: 3px; }
.portfolio-table-wrap { border: 2px solid #000; padding: 0 8px; background: rgba(0, 0, 0, 0.2); }
.portfolio-table td:first-child { color: var(--cream); }
.portfolio-table tr.zero { opacity: 0.5; }
.portfolio-rune {
  display: inline-grid; place-items: center; width: 25px; height: 25px; margin-right: 8px;
  border: 2px solid #000; background: var(--wood-lite); color: var(--gold-lite); vertical-align: middle;
}
.portfolio-rune.usdg { color: #b8efff; }
.portfolio-rune.stock { color: var(--green); }
.portfolio-muted { color: var(--cream-dim); }

.portfolio-hero-list { display: flex; flex-direction: column; gap: 9px; }
.portfolio-hero {
  border: 2px solid #000; box-shadow: 0 0 0 2px var(--wood-lite) inset;
  background: rgba(0, 0, 0, 0.27); padding: 10px 12px;
}
.portfolio-hero-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.portfolio-hero h3 { margin: 2px 0; font-family: var(--px); font-size: 9px; color: var(--gold-lite); }
.portfolio-address { color: var(--cream-dim); font-size: 16px; }
.portfolio-hero-value { display: flex; flex-direction: column; text-align: right; white-space: nowrap; }
.portfolio-hero-value b { color: var(--gold-lite); font-size: 26px; font-weight: normal; line-height: 1; font-variant-numeric: tabular-nums; }
.portfolio-location-label { margin-top: 10px; color: var(--cream-dim); }
.portfolio-assets { display: flex; flex-wrap: wrap; gap: 5px; min-height: 26px; margin-top: 4px; }
.asset-chip { border-left: 3px solid var(--gold); background: rgba(120, 78, 20, 0.28); padding: 3px 7px; color: var(--cream-dim); }
.asset-chip b { color: var(--cream); font-weight: normal; font-variant-numeric: tabular-nums; }
.portfolio-position {
  display: grid; grid-template-columns: minmax(140px, 0.7fr) 1fr 1fr; gap: 6px 12px;
  margin-top: 8px; padding: 7px 9px; border-left: 4px solid var(--green);
  background: rgba(63, 143, 76, 0.2); color: var(--cream-dim); font-size: 17px;
}
.portfolio-position-title { color: var(--green); }
.portfolio-position b, .portfolio-season b { color: var(--cream); font-weight: normal; font-variant-numeric: tabular-nums; }
.portfolio-resting { margin-top: 8px; padding: 6px 8px; border-left: 4px solid var(--wood-lite); color: var(--cream-dim); }
.portfolio-season { margin-top: 7px; color: var(--gold); font-size: 16px; }
.portfolio-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.portfolio-actions .act { padding: 5px 7px 4px; font-size: 6px; }

.portfolio-empty {
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
  border: 2px dashed var(--wood-lite); background: rgba(0, 0, 0, 0.18); padding: 14px;
}
.portfolio-empty b { font-family: var(--px); font-size: 8px; color: var(--gold-lite); }
.portfolio-empty span { color: var(--cream-dim); }
.portfolio-empty .act { margin-top: 5px; }
.portfolio-loading {
  min-height: 210px; display: flex; align-items: center; justify-content: center; gap: 14px;
  border: 2px solid #000; background: rgba(0, 0, 0, 0.28); padding: 24px;
}
.portfolio-loading-rune { color: var(--gold-lite); font-size: 34px; animation: ledgerPulse 1.2s steps(2, end) infinite; }
.portfolio-loading div { display: flex; flex-direction: column; }
.portfolio-loading b { font-family: var(--px); font-size: 8px; color: var(--gold-lite); }
.portfolio-loading span:not(.portfolio-loading-rune) { color: var(--cream-dim); margin-top: 6px; }
@keyframes ledgerPulse { 50% { opacity: 0.35; transform: scale(0.85); } }
.portfolio-warning { border-left: 4px solid var(--red); background: rgba(217, 87, 99, 0.15); color: var(--cream); padding: 7px 10px; margin-bottom: 8px; }
.portfolio-footnote { color: var(--cream-dim); font-size: 14px; margin: 12px 0 0; }

.portal-summon {
  display: grid;
  grid-template-columns: minmax(210px, 0.78fr) minmax(280px, 1fr);
  gap: 28px;
  padding-top: 10px;
}
.portal-preview {
  min-height: 360px;
  padding: 18px;
  background: linear-gradient(145deg, #2f4b36, #17231c);
  border: 2px solid #000;
  box-shadow: 0 0 0 2px #795e27 inset;
}
.portal-preview b,
.portal-copy h3,
.portal-line span {
  font-family: var(--px);
  font-size: 8px;
  color: var(--gold-lite);
  text-transform: uppercase;
}
.portal-figure {
  width: min(72%, 190px);
  height: 250px;
  margin: 34px auto 0;
  background: linear-gradient(#9ed66d, #44733f);
  clip-path: polygon(35% 0, 65% 0, 76% 12%, 71% 31%, 87% 51%, 77% 61%, 85% 100%, 15% 100%, 23% 61%, 13% 51%, 29% 31%, 24% 12%);
  filter: drop-shadow(6px 8px #10150e);
}
.portal-copy {
  min-width: 0;
}
.portal-copy h3 {
  margin: 0 0 16px;
  color: var(--cream);
}
.portal-copy p {
  margin: 0 0 18px;
  font-size: 25px;
  line-height: 1.12;
  color: var(--cream-dim);
}
.portal-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #1f1710;
  border: 2px solid #000;
  box-shadow: 0 0 0 2px #715523 inset;
  font-size: 22px;
}
.portal-line strong {
  color: var(--green);
  font-weight: normal;
}
.portal-line strong.down { color: var(--red); }
.portal-primary {
  width: 100%;
  min-height: 60px;
  margin-top: 8px;
}

@media (max-width: 1199px) and (min-width: 900px) {
  #quest-status { display: none; }
  #hud-identity { width: 360px; }
  #hud .stat { font-size: 7px; }
}

@media (max-width: 899px) {
  #hud-identity {
    left: calc(16px + env(safe-area-inset-left));
    top: calc(16px + env(safe-area-inset-top));
    width: min(360px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    min-height: 64px;
    padding: 13px 14px 11px;
  }
  #hud .right {
    right: calc(16px + env(safe-area-inset-right));
    top: calc(16px + env(safe-area-inset-top));
    max-width: calc(100vw - 32px);
    padding: 7px;
  }
  #left-rail {
    left: calc(16px + env(safe-area-inset-left));
    right: calc(16px + env(safe-area-inset-right));
    top: auto;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: auto;
    height: 72px;
    grid-template-columns: repeat(5, minmax(44px, 1fr));
    gap: 6px;
    padding: 8px;
  }
  #quest-status {
    left: calc(16px + env(safe-area-inset-left));
    right: calc(16px + env(safe-area-inset-right));
    top: auto;
    bottom: calc(104px + env(safe-area-inset-bottom));
    width: auto;
    min-height: 112px;
    padding: 15px 16px;
  }
  #hint-strip { display: none; }
  #sheet {
    width: calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-height: calc(100svh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (max-width: 639px) {
  #hud-identity {
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    top: calc(12px + env(safe-area-inset-top));
    width: auto;
    min-height: 56px;
    padding: 12px;
  }
  #hud .brand { font-size: 8px; }
  #hud .brand b { display: none; }
  #hud .stat {
    margin-top: 6px;
    font-size: 7px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #hud .right {
    top: calc(80px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
    min-height: 56px;
  }
  #mobile-hero {
    position: absolute;
    display: grid;
    place-items: center;
    left: calc(12px + env(safe-area-inset-left));
    top: calc(80px + env(safe-area-inset-top));
    min-width: 132px;
    min-height: 56px;
    padding: 10px 12px;
    pointer-events: none;
  }
  #mobile-hero b {
    font-family: var(--px);
    font-size: 7px;
    line-height: 1.4;
    color: var(--gold-lite);
    font-weight: normal;
  }
  #hud .right .pxbtn {
    width: 44px;
    height: 44px;
    padding: 5px;
    overflow: hidden;
  }
  #connect { width: auto !important; max-width: 120px; padding-inline: 8px !important; }
  #left-rail {
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
    height: 72px;
  }
  .rail-btn { font-size: 6px; }
  #quest-status {
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(96px + env(safe-area-inset-bottom));
    min-height: 96px;
    padding: 14px;
  }
  #quest-status span { margin-top: 10px; font-size: 19px; }
  .sign {
    min-width: 44px;
    min-height: 44px;
    padding: 10px 12px 8px;
    font-size: 6px;
  }
  #sheet {
    width: calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-height: calc(100svh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  #sheet-head { padding: 11px 10px 8px 12px; }
  #sheet-title { font-size: 8px; line-height: 1.35; }
  #sheet-body { padding: 4px 10px 16px; }
  .portal-summon { grid-template-columns: 1fr; gap: 14px; }
  .portal-preview { min-height: 190px; }
  .portal-figure { width: 112px; height: 140px; margin-top: 16px; }
  .portal-copy p { font-size: 20px; }
  .portal-line { font-size: 18px; flex-direction: column; gap: 5px; }
  .portfolio-hero { grid-template-columns: 1fr; }
  .portfolio-total { font-size: 40px; }
  .portfolio-breakdown { grid-template-columns: 1fr; }
  .portfolio-breakdown > div { min-height: 50px; }
  .portfolio-section-head { align-items: center; }
  .portfolio-hero-head { flex-direction: column; }
  .portfolio-hero-value { text-align: left; }
  .portfolio-position { grid-template-columns: 1fr; }
  .portfolio-actions .act { width: 100%; }
  .portfolio-table { font-size: 17px; }
  .portfolio-table th { font-size: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-loading-rune { animation: none; }
}

#say {
  position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: calc(100% - 24px); max-width: 616px;
  background: var(--wood); border: 3px solid #000;
  box-shadow: 0 0 0 2px var(--gold) inset, 0 6px 20px rgba(0, 0, 0, 0.6);
  padding: 10px 14px; z-index: 60; font-size: 20px;
}
#say::before { content: "❖ "; color: var(--gold-lite); }
.hidden { display: none !important; }
