/* The Druid Circle — Responsive Tablet/Mobile, iOS Safari Zero-Zoom, 1-Thumb Shell & Reduced-Motion Overrides */
@media (max-width: 960px) and (min-width: 821px) {
  .runestone-ui.visible {
    display: flex; flex-direction: column;
    padding: 58px 14px 18px; gap: 10px;
    overflow-y: auto; -webkit-overflow-scrolling: touch; pointer-events: auto;
  }
  .rs-center-col { order: 3; padding-top: 4px; padding-bottom: 6px; flex-shrink: 0; }
  .rs-panel { max-height: none; overflow: visible; flex-shrink: 0; }
  .rs-scroll { overflow-y: visible; padding-right: 0; }
}
.bard-eulogy {
  background: #101812; border-left: 3px solid var(--gold); padding: 9px 12px;
  margin-bottom: 12px; font-family: var(--font-prose); font-style: italic;
  font-size: 14px; color: var(--ink); line-height: 1.45;
}
.trial-row {
  background: #0a120d; border: 1px solid #26382d; border-radius: 4px;
  padding: 11px 13px; margin-bottom: 9px;
}
.trial-row.done { border-color: var(--moss); background: #0d1a12; }
.trial-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.trial-title { font-family: var(--font-pixel); font-size: 15px; color: var(--gold); }
.trial-row.done .trial-title { color: var(--moss); }
.trial-status { font-family: var(--font-mono); font-size: 10.5px; padding: 2px 7px; border-radius: 3px; background: #19261e; color: var(--ink-dim); }
.trial-row.done .trial-status { background: #163624; color: #9cf0be; font-weight: 700; }
.trial-desc { font-size: 13px; color: var(--ink-dim); margin: 0; line-height: 1.45; }
.modal-box {
  width: min(560px, 100%); max-height: 86dvh; overflow-y: auto;
  background: var(--panel-solid); border: 2px solid var(--border-gold);
  border-radius: 5px; padding: 18px 20px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.82);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border-bottom: 1px solid #25362c; padding-bottom: 10px; margin-bottom: 14px;
}
.modal-head-title {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; flex: 1 1 auto;
}
.modal-head h2 { margin: 0; font-family: var(--font-pixel); font-size: 19px; color: var(--gold); min-width: 0; }
.modal-head.wallet-modal-head { margin-bottom: 10px; padding-bottom: 8px; border-bottom-color: rgba(219, 179, 98, 0.22); }
.modal-head.wallet-modal-head .wallet-modal-title { font-size: 16px; letter-spacing: 0.5px; }
.docs-head-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.docs-mobile-footer { display: none; }
.wallet-chips-row { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.wallet-sol-row { display: flex; gap: 6px; align-items: center; }
.wallet-withdraw-row { display: flex; gap: 6px; align-items: center; }
.wallet-deeplink-note {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-dim);
  line-height: 1.48; margin-bottom: 2px;
}
.wallet-deeplink-row { width: 100%; }
.wallet-deeplink-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 10px 12px; text-align: left; text-decoration: none;
  background: #0d1611; border: 1.5px solid #2e4336; border-radius: 6px; color: var(--ink);
  min-height: 48px;
}
.wallet-deeplink-btn:hover { border-color: var(--gold); background: #142219; color: var(--ink); }
.wallet-dl-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wallet-dl-left strong { font-family: var(--font-pixel); font-size: 14px; color: var(--gold); }
.wallet-dl-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-dim); }
.wallet-dl-cta {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--moss);
  border: 1px solid rgba(93, 211, 142, 0.42); background: rgba(93, 211, 142, 0.1);
  padding: 4px 8px; border-radius: 4px; white-space: nowrap; flex-shrink: 0;
}
.phosphor-canvas-wrap.touch-scrubbing {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(234, 177, 84, 0.4), inset 0 0 18px rgba(93, 211, 142, 0.14);
}
.modal-close {
  background: transparent; border: 1px solid var(--border); color: var(--ink);
  font-family: var(--font-mono); font-size: 12.5px; padding: 5px 10px;
  border-radius: 3px; cursor: pointer; flex-shrink: 0;
}
.modal-close:hover { border-color: var(--gold); color: var(--gold); }

.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-bottom: 14px; }
.detail-cell { background: #0a110d; border: 1px solid #223228; border-radius: 4px; padding: 9px 11px; font-family: var(--font-mono); }
.detail-cell .dc-k { font-size: 10px; color: var(--ink-dim); text-transform: uppercase; }
.detail-cell .dc-v { font-size: 14px; font-weight: 700; color: var(--ink); margin-top: 3px; }

.ledger-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 12px; background: #0b120e; border: 1px solid #25362c;
  border-radius: 4px; margin-bottom: 8px; cursor: pointer;
  font-family: var(--font-mono); font-size: 12px;
}
.ledger-row:hover { border-color: var(--gold); }

.oath-verse { background: #09100c; border: 1px solid #2c3e32; border-radius: 4px; padding: 12px 14px; margin-bottom: 10px; }
.oath-verse .ov-title { font-family: var(--font-pixel); font-size: 15px; color: var(--gold); display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.oath-verse .ov-glyph { font-family: var(--font-mono); color: var(--moss); }
.oath-verse p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink); }
.oath-cite { font-family: var(--font-mono); font-size: 11px; color: var(--ink-dim); margin-top: 12px; text-align: center; }

.receipt-preview-wrap {
  display: flex; justify-content: center; margin-bottom: 14px;
  background: #060908; border: 1px solid #25362c; border-radius: 4px; padding: 10px;
}
.receipt-preview-wrap img { max-width: 100%; max-height: 52dvh; border-radius: 4px; display: block; border: 1px solid var(--border-gold); }

.toast {
  position: fixed; top: max(62px, calc(env(safe-area-inset-top) + 48px)); left: 50%; transform: translateX(-50%);
  z-index: var(--z-toast); background: #142219; border: 2px solid var(--moss);
  color: var(--ink); font-family: var(--font-mono); font-size: 12.5px;
  padding: 9px 15px; border-radius: 4px; display: none; max-width: calc(100vw - 24px); text-align: center;
}
.toast.error { background: #291313; border-color: var(--crimson); color: #ffd4d4; }
.toast.show { display: block; animation: riseIn 220ms ease; }

/* Mobile-Only Shell Components — Strictly hidden on Desktop (> 820px) */
.mobile-tabbar { display: none; }
.mobile-search-sheet { display: none; }
.port-mobile-controls { display: none; }
.rs-mobile-seg { display: none; }
.dock-sub-mobile { display: none; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sheetSlideUp {
  from { transform: translate3d(0, 32px, 0); opacity: 0.92; }
  to { transform: translate3d(0, 0, 0); opacity: 1; }
}
@keyframes pulseGlow {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* =========================================================================
   KILL iOS SAFARI AUTO-ZOOM FOREVER ON ALL TOUCH / MOBILE INPUTS
   ========================================================================= */
@media (max-width: 820px), (pointer: coarse) {
  input,
  textarea,
  select,
  .term-input,
  .field-input,
  .rs-search-inp,
  .phone-search-inp,
  .keeper-input,
  .tpsl-inp,
  .mss-input,
  #walletSolSigInput,
  #walletWithdrawUsd {
    font-size: 16px !important;
  }
}

/* =========================================================================
   PORTRAIT / MOBILE 1-THUMB SHELL (<= 820px)
   ========================================================================= */
@media (max-width: 820px) {
  :root {
    --m-topbar-clear: calc(max(8px, env(safe-area-inset-top)) + 36px);
    --m-hero-h: clamp(192px, 29dvh, 256px);
    --m-hero-bottom: calc(var(--m-topbar-clear) + var(--m-hero-h));
  }

  /* Clean single-column vertical scrolling — ZERO trapped overflow: hidden! */
  html, body {
    height: auto;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--obsidian);
  }

  .stage {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
    background: var(--obsidian);
    padding-bottom: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom) + 14px);
  }
  .stage[data-scene-mode="runestone"] {
    --m-hero-h: clamp(176px, 25dvh, 216px);
    --m-hero-bottom: calc(var(--m-topbar-clear) + var(--m-hero-h));
  }
  .stage[data-scene-mode="runecast"] {
    --m-hero-h: clamp(210px, 27dvh, 240px);
    --m-hero-bottom: calc(var(--m-topbar-clear) + var(--m-hero-h));
  }
  .stage[data-scene-mode="runecast"].rc-has-thumb {
    padding-bottom: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom) + 184px);
  }
  .stage[data-scene-mode="intro_city"] {
    --m-hero-h: clamp(148px, 22dvh, 206px);
    --m-hero-bottom: calc(var(--m-topbar-clear) + var(--m-hero-h));
  }
  .stage.in-intro {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  /* Clean portrait hero art window directly below fixed topbar — zero cut-off hoods or hands */
  .scene-layer,
  .face-layer,
  .hand-layer,
  .fireside-act-layer,
  .fireside-focus-layer,
  .scene-vignette,
  #emberCanvas {
    position: absolute;
    top: var(--m-topbar-clear);
    left: 0;
    right: 0;
    height: var(--m-hero-h);
    bottom: auto;
  }
  .stage[data-scene-mode="fireside"] {
    --m-hero-h: clamp(265px, 38dvh, 360px);
    --m-hero-bottom: calc(var(--m-topbar-clear) + var(--m-hero-h));
  }
  #scene-circle, #scene-circle-blink, #scene-circle-tap { background-position: 34% 12%; }
  #scene-fireside, .fireside-focus-layer {
    background-size: auto 136%;
    background-position: 50% 26%;
    transition: opacity 420ms ease-in-out, background-position 520ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .fireside-act-layer { display: none !important; }
  .stage[data-fireside-focus="scout"] #scene-fireside,
  .stage[data-fireside-focus="scout"] .fireside-focus-layer { background-position: 2% 28%; }
  .stage[data-fireside-focus="keeper"] #scene-fireside,
  .stage[data-fireside-focus="keeper"] .fireside-focus-layer { background-position: 50% 26%; }
  .stage[data-fireside-focus="bard"] #scene-fireside,
  .stage[data-fireside-focus="bard"] .fireside-focus-layer { background-position: 98% 28%; }
  .face-layer {
    -webkit-mask-image: radial-gradient(ellipse 18% 24% at 24.5% 28%, #000 60%, transparent 100%);
    mask-image: radial-gradient(ellipse 18% 24% at 24.5% 28%, #000 60%, transparent 100%);
  }
  #scene-city { background-position: 50% 12%; }
  #scene-wilderness { background-position: 58% 52%; }
  #scene-runecast { background-position: 50% 28%; }
  #scene-runestone { background-position: 50% 35%; }
  #scene-anoint { background-position: 45% 42%; }
  .scene-vignette {
    background: linear-gradient(
      to bottom,
      rgba(6, 11, 8, 0.42) 0%,
      rgba(6, 11, 8, 0.0) 14%,
      rgba(6, 11, 8, 0.0) 74%,
      rgba(7, 11, 9, 0.72) 90%,
      rgba(7, 11, 9, 1) 100%
    );
  }

  /* Strictly 3-Zone Mobile Topbar (Brand Left · Pouch Balance/P&L Middle · Mode + Wallet Right) */
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-tabbar);
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
    gap: 5px;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    background: rgba(6, 11, 8, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(201, 146, 61, 0.2);
  }
  .brand-pill {
    padding: 4px 7px;
    gap: 4px;
    border-width: 1.5px;
    flex-shrink: 0;
    cursor: pointer;
    min-height: 30px;
  }
  .brand-name { font-size: 12.5px; white-space: nowrap; }
  .ogham-mark { display: none; }

  .hud-group {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
  }
  /* Move Stones to bottom tabbar; Name/SFX/Intro live cleanly inside Pouch */
  #hudNameChip, #btnLedger, #btnAudio, #btnReplayIntro { display: none !important; }

  #hudVaultChip {
    order: 1;
    margin: 0 auto;
    padding: 4px 7px;
    border-width: 1.5px;
    font-size: 10.5px;
    gap: 4px;
    min-height: 30px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  #hudVaultChip .hud-vault-lbl { display: none; }

  .hud-btn {
    padding: 4px 7px;
    font-size: 11px;
    border-width: 1.5px;
    white-space: nowrap;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  #btnModeToggle {
    order: 2;
    padding: 4px 6px !important;
    font-size: 9.5px !important;
    letter-spacing: 0.2px !important;
    flex-shrink: 0;
  }
  #btnModeToggle .mode-extra { display: none; }
  #btnWallet {
    order: 3;
    flex-shrink: 0;
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #btnSkipIntro {
    order: 4;
    flex-shrink: 0;
  }

  /* Fixed iOS-Safe Bottom Tab Bar (4 ergonomic >=44px thumb tabs) */
  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-tabbar);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    padding: 4px max(6px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: rgba(7, 12, 9, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1.5px solid rgba(201, 146, 61, 0.45);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.68);
  }
  .mobile-tabbar.hidden { display: none !important; }
  .m-tab {
    position: relative;
    min-height: 48px;
    padding: 5px 4px 4px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: #8fa394;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    transition: color 140ms ease, background 140ms ease;
  }
  .m-tab:active { background: rgba(234, 177, 84, 0.16); }
  .m-tab.active {
    color: var(--gold);
    background: rgba(234, 177, 84, 0.11);
  }
  .m-tab.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 22%;
    right: 22%;
    height: 2px;
    border-radius: 0 0 2px 2px;
    background: var(--gold);
    box-shadow: 0 0 8px rgba(234, 177, 84, 0.65);
  }
  .m-tab-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .m-tab-label {
    font-family: var(--font-pixel);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
  .m-tab-badge {
    position: absolute;
    top: 3px;
    left: calc(50% + 7px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 99px;
    background: #1b2d21;
    border: 1px solid var(--gold);
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
  }
  .m-tab-badge.profit {
    background: #123320;
    border-color: var(--moss);
    color: #9cf0be;
  }
  .m-tab-badge.loss {
    background: #361717;
    border-color: var(--crimson);
    color: #ffb3b3;
  }

  /* Keyboard-Safe Top-Anchored Mobile Search Sheet */
  .mobile-search-sheet.open {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100dvh;
    z-index: var(--z-search-sheet);
    display: flex;
    flex-direction: column;
    background: #060b08;
    overflow: hidden;
  }
  .mss-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left));
    background: #0c1510;
    border-bottom: 1.5px solid var(--border-gold);
  }
  .mss-input-box {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    background: #070d0a;
    border: 1.5px solid var(--gold);
    border-radius: 7px;
    padding: 0 9px;
    min-height: 44px;
    box-shadow: 0 0 0 2px rgba(234, 177, 84, 0.16);
  }
  .mss-prompt {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    color: var(--gold);
    flex-shrink: 0;
    user-select: none;
  }
  .mss-input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 16px !important;
    line-height: 1.3;
    padding: 10px 0;
    -webkit-appearance: none;
    appearance: none;
  }
  .mss-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
  }
  .mss-input::placeholder { color: #758a7b; }
  .mss-clear {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #354d3d;
    background: #14221a;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 16px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
  }
  .mss-cancel {
    flex-shrink: 0;
    min-height: 44px;
    padding: 0 11px;
    border-radius: 7px;
    border: 1px solid #304538;
    background: #101b14;
    color: var(--ink);
    font-family: var(--font-pixel);
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
  }
  .mss-cancel:active { border-color: var(--gold); color: var(--gold); }
  .mss-meta-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 12px;
    background: #08100c;
    border-bottom: 1px solid #1a2a20;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--ink-dim);
  }
  .mss-results {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 6px 10px max(18px, env(safe-area-inset-bottom));
  }
  .mss-section-lbl {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7e9685;
    padding: 8px 4px 5px;
  }
  .mss-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
    padding: 10px 11px;
    margin-bottom: 6px;
    min-height: 52px;
    border-radius: 6px;
    background: #0c1510;
    border: 1px solid #24372b;
    color: var(--ink);
    font-family: var(--font-mono);
    cursor: pointer;
  }
  .mss-row:active, .mss-row.focused {
    border-color: var(--gold);
    background: #15241b;
  }
  .mss-row.disabled {
    opacity: 0.56;
    cursor: not-allowed;
  }
  .mss-row-left {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .mss-row-top {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }
  .mss-sym {
    font-size: 14px;
    font-weight: 700;
    color: var(--gold);
    white-space: nowrap;
  }
  .mss-name {
    font-size: 11px;
    color: var(--ink-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mss-row-right {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    text-align: right;
  }
  .mss-stats {
    font-size: 10.5px;
    color: var(--moss);
    white-space: nowrap;
  }
  .mss-row.disabled .mss-stats {
    color: #9ba59d;
    white-space: normal;
    max-width: 145px;
    font-size: 10px;
  }
  .mss-cta {
    font-size: 10px;
    font-weight: 700;
    color: #120d06;
    background: var(--gold);
    padding: 2px 7px;
    border-radius: 3px;
    white-space: nowrap;
  }
  .mss-empty {
    padding: 18px 12px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-dim);
    border: 1px dashed #24372b;
    border-radius: 6px;
    margin-top: 8px;
  }

  /* Show SFX / Intro controls inline inside Pouch footer on mobile */
  .port-mobile-controls {
    display: contents;
  }

  .rs-kbd { display: none; }
  .rs-search-wrap { padding: 6px 10px; min-height: 44px; }
  .detail-grid { gap: 6px; }
  .detail-cell { padding: 7px 8px; }
  .detail-cell .dc-v { font-size: 12.5px; }
  .tpsl-custom { grid-template-columns: 1fr 1fr; }
  .tpsl-custom .tpsl-save-btn { grid-column: 1 / -1; }
  .port-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .stones-layer { display: none !important; }

  .mobile-stones-strip {
    position: relative;
    z-index: var(--z-stones);
    margin-top: calc(var(--m-hero-bottom) - 10px);
    padding: 5px 10px;
    display: none;
    align-items: center;
    gap: 5px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
    scrollbar-width: none;
  }
  .mobile-stones-strip::-webkit-scrollbar { display: none; }
  .mobile-stones-strip.visible { display: flex; }
  .m-stone-card {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #101914;
    border: 1.5px solid var(--border-gold);
    border-radius: 5px;
    padding: 6px 8px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--ink);
    cursor: pointer;
    white-space: nowrap;
  }
  .m-stone-card.profit { border-color: var(--moss); }
  .m-stone-card.loss { border-color: var(--crimson); }
  .m-stone-card.empty { border-color: #2f4236; color: var(--ink-dim); }
  .m-stone-ogham { color: var(--gold); font-size: 12.5px; }
  .m-stone-card.profit .m-stone-ogham { color: var(--moss); }
  .m-stone-card.loss .m-stone-ogham { color: var(--crimson); }

  /* Intro City Mobile Polish — crisp framing on 375x667 & 393x852 with thumb-reachable CTA */
  .city-phone {
    position: relative;
    top: auto;
    right: auto;
    transform: none;
    height: auto;
    min-height: 0;
    margin: calc(var(--m-hero-bottom) - 10px) 10px 6px;
    width: auto;
    max-width: calc(100% - 20px);
    border-radius: 14px;
    border-width: 2px;
    padding: 9px 11px 10px;
    flex-shrink: 0;
  }
  .city-phone::before, .city-phone::after, .phone-status, .phone-chart, .phone-disabled-cta, .phone-homebar { display: none; }
  .phone-app-bar { padding-bottom: 4px; margin-bottom: 6px; font-size: 10px; }
  .phone-search-row { padding: 4px 8px; margin-bottom: 6px; min-height: 40px; }
  .phone-ticker strong { font-size: 18px; }
  .phone-subline { margin-bottom: 5px; font-size: 10.5px; }
  .phone-reject {
    margin: 4px 0 7px !important;
    padding: 6px 9px !important;
    font-size: 11px !important;
    line-height: 1.35 !important;
    min-height: 0 !important;
  }
  .phone-go-wild {
    min-height: 42px;
    padding: 9px 10px;
    font-size: 13px;
    margin-bottom: 6px;
  }
  .phone-tabs { gap: 5px; }
  .phone-tab { min-height: 34px; font-size: 11px; padding: 5px 4px; }
  .stage[data-scene-mode="intro_city"] .dock {
    padding: 10px 12px 11px;
    margin: 2px 10px 8px;
  }
  .stage[data-scene-mode="intro_city"] .dialogue-text {
    font-size: 13px;
    line-height: 1.42;
    margin-bottom: 8px;
  }
  .stage[data-scene-mode="intro_city"] .controls-row .speaker-sub { display: none; }
  .anoint-grid { grid-template-columns: 1fr; }
  .term-hint { display: none; }

  .runes-stage {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    margin: calc(var(--m-hero-bottom) - 10px) 10px 4px;
    flex-shrink: 0;
  }
  .runes-stage.visible {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    align-items: stretch;
    overflow: visible;
    padding-bottom: 0;
  }
  .stave-hitbox { display: none !important; }
  .casting-banner-wrap { grid-column: 1 / -1; position: relative; left: auto; top: auto; transform: none; width: 100%; display: flex; justify-content: center; }
  .rune-pin {
    position: relative;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    min-width: 0;
    max-width: none;
    width: 100%;
    padding: 6px 7px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .rune-pin:hover, .rune-pin.selected { transform: none !important; }
  .rune-pin::after { display: none; }
  .rune-pin .rc-head { font-size: 9.5px; margin-bottom: 2px; gap: 3px; }
  .rune-pin .rc-glyph { font-size: 11px; margin-right: 2px; }
  .rune-pin .rc-tap { display: none; }
  .rune-pin .rc-big { font-size: 11px; line-height: 1.2; margin-bottom: 2px; }
  .rune-pin .rc-val { font-size: 9px; line-height: 1.25; }

  /* Runestone Close-Up: Clean Mobile Segmented Toggle (Positions | Inspect $COIN), zero stacked double-scroll! */
  .runestone-ui.visible {
    position: relative;
    inset: auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: calc(var(--m-hero-bottom) - 8px) 10px 8px;
    gap: 9px;
    overflow: visible;
    pointer-events: auto;
  }
  .rs-mobile-seg {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: 9px;
    background: rgba(9, 15, 11, 0.94);
    border: 1.5px solid rgba(201, 146, 61, 0.55);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
    pointer-events: auto;
    flex-shrink: 0;
  }
  .rs-seg-btn {
    min-height: 40px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--ink-dim);
    font-family: var(--font-pixel);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
  }
  .rs-seg-btn.active {
    background: linear-gradient(180deg, rgba(234, 177, 84, 0.24), rgba(201, 146, 61, 0.14));
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: inset 0 1px 0 rgba(255, 226, 156, 0.22);
  }
  .rs-seg-btn:disabled { opacity: 0.42; cursor: not-allowed; }
  .rs-seg-count {
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 1px 6px;
    border-radius: 99px;
    background: rgba(20, 34, 25, 0.95);
    border: 1px solid #35503e;
    color: var(--moss);
  }
  .rs-seg-btn.active .rs-seg-count {
    border-color: rgba(234, 177, 84, 0.65);
    color: var(--gold);
  }
  .runestone-ui[data-rs-mobile-tab="positions"] #rsInspectorPanel { display: none !important; }
  .runestone-ui[data-rs-mobile-tab="inspect"] #rsLedgerPanel { display: none !important; }
  .rs-center-col { display: none !important; }
  #btnRsBackTop { display: none !important; }
  .rs-panel { max-height: none; overflow: visible; flex-shrink: 0; padding: 10px 11px; }
  .rs-scroll { overflow-y: visible; padding-right: 0; }
  .rs-row { min-height: 44px; padding: 9px 10px; }

  /* Pair Phosphor Chart + Carved Seals TP/SL directly together above the fold on mobile */
  #rsInspectorPanel .rs-scroll {
    display: flex;
    flex-direction: column;
  }
  #rsInspectorPanel .bard-eulogy,
  #rsInspectorPanel #rsMarketReadSlot { order: 0; }
  #rsInspectorPanel #rsPhosphorChartSlot { order: 1; }
  #rsInspectorPanel #rsTpslBox { order: 2; margin-bottom: 10px; }
  #rsInspectorPanel .detail-grid { order: 3; }
  #rsInspectorPanel .rs-actions-row { order: 4; }

  /* Touch-Friendly 16-Bit Phosphor Chart & TP/SL ergonomics */
  .phosphor-canvas-wrap, .phosphor-canvas { touch-action: none; }
  .phosphor-canvas-wrap.interactive { height: 152px; }
  .phosphor-canvas-wrap.compact { height: 132px; }
  .ph-seal-toggle { min-height: 32px; padding: 4px 9px; font-size: 10.5px; }
  .tf-pill { min-height: 30px; min-width: 34px; padding: 4px 8px; font-size: 10.5px; }
  .tpsl-btn { min-height: 34px; padding: 5px 10px; font-size: 11px; }
  .ph-lock-btn, .ph-cancel-btn { min-height: 34px; padding: 6px 11px; font-size: 11px; }

  /* Single-column natural-flow RPG Dock */
  .dock {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    width: auto;
    margin: 5px 10px 8px;
    flex: 0 0 auto;
    overflow: visible;
    padding: 11px 12px 13px;
  }
  .stage.portrait-spacer .dock { margin-top: calc(var(--m-hero-bottom) - 8px); }

  .dock-header { flex-wrap: wrap; gap: 5px; margin-bottom: 5px; }
  .dock-sub-desktop { display: none; }
  .dock-sub-mobile { display: inline; }
  .speaker-tag { font-size: 13.5px; }
  .dialogue-text { font-size: 14px; margin-bottom: 8px; }
  .rc-spoken-line { display: none; }

  /* Wave 10 — Sticky Thumb-Zone Execution Deck on Rune Cast (Mobile <= 820px) */
  .stage[data-scene-mode="runecast"].rc-has-thumb .dock {
    display: block;
    padding: 8px 10px 9px;
    margin: 4px 10px 8px;
  }
  .stage[data-scene-mode="runecast"].rc-has-thumb .rc-context-zone {
    display: block;
  }
  .stage[data-scene-mode="runecast"].rc-has-thumb .rc-thumb-deck {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom));
    z-index: calc(var(--z-tabbar) - 1);
    padding: 8px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
    background: rgba(8, 14, 11, 0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1.5px solid rgba(201, 146, 61, 0.62);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.72);
  }
  .rc-dock-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 5px;
    flex-wrap: nowrap;
  }
  .rc-head-left { gap: 6px; min-width: 0; flex: 1 1 auto; }
  .rc-dock-header .speaker-tag {
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rc-head-links { gap: 7px; flex-wrap: nowrap; flex-shrink: 0; }
  .rc-head-links .math-link { font-size: 10px; white-space: nowrap; }
  .rc-back-mob {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 7px;
    font-size: 11px;
    min-height: 28px;
    flex-shrink: 0;
  }
  .rc-back-desk { display: none !important; }
  .wb-desktop-txt { display: none; }
  .wb-mobile-txt { display: inline; }

  .wager-grid { grid-template-columns: repeat(2, 1fr); gap: 5px; margin: 6px 0; }
  .wager-btn { padding: 6px 8px; }
  .wager-btn .wb-title { font-size: 13px; }
  .wager-btn .wb-sub { font-size: 9.5px; margin-top: 1px; }

  .rc-direction-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin: 0;
  }
  .rc-direction-grid .wager-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 4px 3px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
  }
  .rc-direction-grid .wager-btn .wb-title {
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
  }
  .rc-direction-grid .wager-btn .wb-sub {
    font-size: 8.8px;
    line-height: 1.1;
    margin-top: 2px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .offer-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 10px;
    padding: 6px 9px;
    margin-bottom: 6px;
  }
  .offer-stat .os-k { font-size: 8.8px; }
  .offer-stat .os-v { font-size: 12px; }

  .payoff-ladder {
    padding: 5px 7px 6px;
    margin-bottom: 0;
  }
  .pl-head { gap: 3px 6px; margin-bottom: 4px; font-size: 9.2px; }
  .pl-bounds { font-size: 9px; gap: 4px; }
  .pl-grid { gap: 4px; }
  .pl-cell { padding: 4px 5px 5px; }
  .pl-move { font-size: 8.8px; }
  .pl-val { font-size: 11px; }

  .rc-exec-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .rc-size-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px !important;
    width: 100%;
    min-width: 0;
  }
  .rc-rail-lbl { display: none; }
  .rc-size-rail {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-right: 4px;
  }
  .rc-size-rail::-webkit-scrollbar { display: none; }
  .rc-lev-rail {
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 4px;
    padding-left: 6px;
    border-left: 1px solid #2b3f32;
  }
  .rc-size-row .rc-size-pill {
    flex: 0 0 auto;
    min-width: 48px;
    min-height: 44px;
    padding: 0 10px;
    font-size: 12px;
    justify-content: center;
    border-radius: 6px;
  }
  .rc-size-row .rc-lev-pill {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0 8px;
    font-size: 12px;
    justify-content: center;
    border-radius: 6px;
  }
  .rc-carve-cta {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    font-size: 15.5px;
    border-radius: 6px;
  }
  .pill { padding: 5px 9px; font-size: 11.5px; }
  .btn-primary { width: 100%; padding: 11px 14px; font-size: 15px; text-align: center; min-height: 44px; }
  .search-wrap { min-width: 0; flex: 1 1 100%; }
  .term-box { min-height: 44px; }
  .search-menu { display: none !important; }
  .rs-search-menu { display: none !important; }

  /* Mobile Fireside Short Board compact toolbar & rows */
  .sb-toolbar { margin-bottom: 5px; }
  .sb-filters { flex-wrap: wrap; gap: 4px; width: 100%; overflow: visible; padding-bottom: 0; }
  .sb-pill { font-size: 10px; padding: 4px 7px; }
  .sb-sep { display: none; }
  .sb-list { max-height: none; overflow: visible; }
  .sb-row { padding: 7px 8px; }

  /* Mobile Runestone action bar */
  .rs-actions-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .rs-actions-primary { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
  .rs-actions-primary .btn-primary { grid-column: 1 / -1; }
  .rs-actions-row .btn-danger { width: 100%; text-align: center; min-height: 44px; }
  .rs-actions-row .math-link { text-align: center; padding: 6px 4px; }

  /* Universal Full-Width, 100vw-Safe iOS Bottom-Sheet Modals (sticky header + swipe-to-dismiss handle!) */
  .modal-backdrop {
    align-items: flex-end;
    justify-content: center;
    padding: 0 !important;
    overflow: hidden;
    overscroll-behavior: contain;
    transition: background-color 180ms ease;
  }
  .modal-box {
    width: 100% !important;
    max-width: 100vw !important;
    max-height: 91dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-padding-top: 72px;
    border-radius: 16px 16px 0 0;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    padding: 0 14px max(18px, env(safe-area-inset-bottom)) !important;
    will-change: transform;
  }
  .modal-backdrop.open .modal-box,
  #walletModal[style*="flex"] .modal-box {
    animation: sheetSlideUp 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .modal-box.sheet-dragging {
    transition: none !important;
    animation: none !important;
    user-select: none;
  }
  .modal-box.sheet-snapping {
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1) !important;
    animation: none !important;
  }
  .modal-box.sheet-dismissing {
    transition: transform 190ms cubic-bezier(0.32, 0.72, 0, 1) !important;
    animation: none !important;
  }
  .modal-box .modal-head {
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--panel-solid);
    margin: 0 -14px 12px;
    padding: 18px 14px 10px;
    border-bottom: 1px solid #25362c;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    max-width: calc(100% + 28px);
    cursor: grab;
    touch-action: pan-x;
  }
  .modal-box.sheet-dragging .modal-head { cursor: grabbing; }
  .modal-box.modal-wallet .modal-head {
    background: #121614;
    border-bottom-color: rgba(219, 179, 98, 0.22);
  }
  .modal-box .modal-head::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 4px;
    border-radius: 99px;
    background: rgba(234, 177, 84, 0.44);
    transition: width 140ms ease, background 140ms ease, box-shadow 140ms ease;
  }
  .modal-box.sheet-dragging .modal-head::before {
    width: 56px;
    background: var(--gold);
    box-shadow: 0 0 10px rgba(234, 177, 84, 0.72);
  }
  .modal-box .modal-head > *:first-child {
    min-width: 0;
    flex: 1 1 auto;
  }
  .modal-head h2 {
    font-size: 14px;
    line-height: 1.25;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .modal-head-title {
    gap: 6px;
    flex-wrap: nowrap;
  }
  .port-chart-head {
    gap: 8px;
    font-size: 9.5px;
    align-items: center;
  }
  .port-chart-vault {
    white-space: nowrap;
    flex-shrink: 0;
  }
  .modal-close {
    flex-shrink: 0;
    min-height: 34px;
    padding: 5px 11px;
    font-size: 12px;
  }
  .modal-box.modal-portfolio {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 92dvh;
    padding: 0 !important;
  }
  .modal-box.modal-portfolio .modal-head {
    position: relative;
    top: auto;
    flex-shrink: 0;
    margin: 0;
    padding: 20px 14px 11px;
    max-width: 100%;
  }
  .modal-box.modal-portfolio .port-sheet-body {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-padding-top: 16px;
    padding: 14px 14px max(20px, env(safe-area-inset-bottom));
  }
  .modal-box.modal-portfolio .port-hero {
    gap: 10px;
    padding: 11px 12px;
    margin-top: 0;
  }
  .modal-box.modal-portfolio .port-equity-box {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid #223228;
    padding-top: 8px;
  }
  .modal-box.modal-portfolio .port-tab-scroll {
    overflow: visible;
    padding-right: 0;
  }
  .modal-box.modal-portfolio .port-footer-row {
    justify-content: flex-start !important;
    gap: 6px;
  }
  .modal-box.modal-portfolio .port-footer-row .btn-secondary {
    padding: 6px 9px;
    font-size: 11.5px;
  }
  /* Mobile Docs bottom sheet: horizontal pill nav + single smooth scroll + full-width footer CTA */
  .docs-ask-desktop { display: none !important; }
  .docs-mobile-footer {
    display: block;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #243429;
  }
  .docs-layout {
    display: flex;
    flex-direction: column;
    max-height: none;
    min-height: 0;
    gap: 10px;
  }
  .docs-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-right: none;
    border-bottom: 1px solid #26362b;
    padding: 0 0 8px;
    gap: 6px;
    max-height: none;
    scrollbar-width: none;
  }
  .docs-nav::-webkit-scrollbar { display: none; }
  .docs-nav-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 36px;
    padding: 7px 10px;
  }
  .docs-body { overflow: visible; padding: 0; }
  /* Mobile Wallet sheet responsive grids & zero horizontal overflow */
  .wallet-chips-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .wallet-chips-row .wallet-chip {
    justify-content: center;
    min-height: 38px;
  }
  .wallet-sol-row,
  .wallet-withdraw-row {
    flex-direction: column;
    align-items: stretch;
  }
  .modal-wallet .wallet-deeplink-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    padding: 10px 12px;
    white-space: normal;
  }
  #walletWithdrawUsd { width: 100% !important; }
  .receipt-preview-wrap { padding: 7px; margin-bottom: 10px; }
  .receipt-preview-wrap img { max-height: 48dvh; }
  #btnDownloadReceipt { width: 100%; min-height: 42px; text-align: center; }
  #outsideNameInput { width: 100% !important; flex: 1 1 100%; }
}

/* Compact short-screen polish for iPhone SE (375x667) Intro City above-the-fold fit */
@media (max-width: 820px) and (max-height: 700px) {
  .stage[data-scene-mode="intro_city"] {
    --m-hero-h: clamp(128px, 19.5dvh, 148px);
    --m-hero-bottom: calc(var(--m-topbar-clear) + var(--m-hero-h));
  }
  .stage[data-scene-mode="intro_city"] .city-phone {
    padding: 8px 10px 8px;
    margin-bottom: 4px;
  }
  .stage[data-scene-mode="intro_city"] .phone-reject {
    padding: 5px 8px !important;
    margin: 3px 0 6px !important;
    font-size: 10.5px !important;
  }
  .stage[data-scene-mode="intro_city"] .phone-go-wild {
    min-height: 38px;
    padding: 7px 10px;
    margin-bottom: 5px;
  }
  .stage[data-scene-mode="intro_city"] .dock {
    padding: 9px 11px 10px;
  }
  .stage[data-scene-mode="intro_city"] .dialogue-text {
    font-size: 12.5px;
    line-height: 1.38;
    margin-bottom: 7px;
  }
  .stage[data-scene-mode="runecast"] {
    --m-hero-h: clamp(116px, 18.2dvh, 132px);
    --m-hero-bottom: calc(var(--m-topbar-clear) + var(--m-hero-h));
  }
  .stage[data-scene-mode="runecast"] .runes-stage {
    margin: calc(var(--m-hero-bottom) - 10px) 10px 3px;
  }
  .stage[data-scene-mode="runecast"] .rune-pin {
    padding: 4px 6px;
  }
  .stage[data-scene-mode="runecast"] .dock {
    padding: 7px 9px 8px;
    margin: 3px 10px 6px;
  }
  .stage[data-scene-mode="runecast"] .offer-summary {
    padding: 5px 8px;
    gap: 4px 8px;
    margin-bottom: 5px;
  }
  .stage[data-scene-mode="runecast"] .offer-stat .os-v {
    font-size: 11.5px;
  }
  .stage[data-scene-mode="runecast"] .payoff-ladder {
    padding: 4px 6px 5px;
  }
  .stage[data-scene-mode="runecast"] .pl-cell {
    padding: 3px 4px 4px;
  }
  .stage[data-scene-mode="runecast"] .rc-thumb-deck {
    padding: 7px max(10px, env(safe-area-inset-right)) 7px max(10px, env(safe-area-inset-left));
    gap: 5px;
  }
}

/* Large iPhone Pro Max (430x932) generous portrait balance */
@media (max-width: 820px) and (min-height: 880px) {
  :root {
    --m-hero-h: clamp(260px, 31dvh, 305px);
    --m-hero-bottom: calc(var(--m-topbar-clear) + var(--m-hero-h));
  }
  .stage[data-scene-mode="runecast"] {
    --m-hero-h: clamp(248px, 29.5dvh, 286px);
    --m-hero-bottom: calc(var(--m-topbar-clear) + var(--m-hero-h));
  }
  .stage[data-scene-mode="runecast"] .rune-pin {
    padding: 7px 8px;
  }
  .stage[data-scene-mode="runecast"].rc-has-thumb .dock {
    padding: 10px 12px 11px;
  }
  .stage[data-scene-mode="runecast"] .payoff-ladder {
    padding: 7px 9px 8px;
  }
  .stage[data-scene-mode="runecast"] .pl-val {
    font-size: 12px;
  }
}

/* Narrow-width iPhone SE (<= 380px) micro-polish */
@media (max-width: 380px) {
  .m-stone-card { padding: 5px 7px; font-size: 10px; }
  .rune-pin .rc-val { font-size: 8.4px; }
  .modal-head h2 { font-size: 13.2px; }
  .rc-head-links .math-link { font-size: 9.2px; }
  .rc-head-links { gap: 5px; }
  .pl-val { font-size: 10.5px; }
}

/* =========================================================================
   WAVE 10: LANDSCAPE MOBILE CONSOLE LAYOUT (e.g. 852x393, 844x390, 667x375)
   Strictly scoped to landscape (min-width: 560px) so portrait keyboard-open
   (393x460) stays in the portrait mobile shell!
   ========================================================================= */
@media (min-width: 560px) and (max-width: 960px) and (max-height: 500px) {
  input,
  textarea,
  select,
  .term-input,
  .field-input,
  .rs-search-inp,
  .phone-search-inp,
  .keeper-input,
  .tpsl-inp,
  .mss-input,
  #walletSolSigInput,
  #walletWithdrawUsd {
    font-size: 16px !important;
  }

  html, body {
    height: auto;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--obsidian);
  }

  .stage {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
    padding-top: 44px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--obsidian);
  }
  .stage[data-scene-mode="runecast"].rc-has-thumb {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  /* Full-bleed atmospheric backdrop pinned behind crisp console cards */
  .scene-layer,
  .face-layer,
  .hand-layer,
  .fireside-act-layer,
  .fireside-focus-layer,
  .scene-vignette,
  #emberCanvas {
    position: fixed;
    inset: 0;
    height: 100dvh;
    top: 0;
    bottom: 0;
  }
  .scene-vignette {
    background: linear-gradient(
      to bottom,
      rgba(6, 11, 8, 0.62) 0%,
      rgba(6, 11, 8, 0.25) 28%,
      rgba(6, 11, 8, 0.66) 72%,
      rgba(6, 11, 8, 0.92) 100%
    );
  }

  /* Hide portrait bottom tabbar in landscape — single sleek topbar holds all navigation cleanly */
  .mobile-tabbar { display: none !important; }
  .stones-layer { display: none !important; }

  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-tabbar);
    padding: 5px max(12px, env(safe-area-inset-right)) 5px max(12px, env(safe-area-inset-left));
    gap: 6px;
    flex-wrap: nowrap;
    background: rgba(6, 11, 8, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(201, 146, 61, 0.28);
  }
  .brand-pill { padding: 4px 8px; min-height: 28px; border-width: 1.5px; }
  .brand-name { font-size: 13px; }
  .ogham-mark { display: none; }
  .hud-group { flex-wrap: nowrap; gap: 5px; min-width: 0; }
  #hudNameChip, #btnAudio, #btnReplayIntro { display: none !important; }
  .stage:not(.in-intro) #btnLedger { display: inline-flex !important; }
  #hudVaultChip {
    order: 0;
    margin: 0;
    padding: 4px 8px;
    font-size: 11px;
    min-height: 28px;
    border-width: 1.5px;
    white-space: nowrap;
  }
  .hud-btn {
    padding: 4px 9px;
    font-size: 11.5px;
    min-height: 28px;
    border-width: 1.5px;
  }
  #btnModeToggle { order: 0; padding: 4px 8px !important; font-size: 10px !important; }
  #btnWallet { order: 0; max-width: none; }

  /* Compact stone/council strip above dock in Circle/Fireside */
  .mobile-stones-strip {
    position: relative;
    z-index: var(--z-stones);
    margin: 4px auto 4px;
    width: min(824px, calc(100vw - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right))));
    padding: 0;
    gap: 6px;
    display: none;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .mobile-stones-strip::-webkit-scrollbar { display: none; }
  .mobile-stones-strip.visible { display: flex; }
  .m-stone-card {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(12, 20, 15, 0.92);
    border: 1.5px solid var(--border-gold);
    border-radius: 5px;
    padding: 5px 9px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink);
    cursor: pointer;
    white-space: nowrap;
  }
  .m-stone-card.empty { border-color: #2f4236; color: var(--ink-dim); }

  /* Single-column natural dock on Circle / Fireside / Wilderness / Anoint */
  .dock {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    width: min(824px, calc(100vw - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right))));
    margin: 4px auto 10px;
    padding: 9px 12px 10px;
    overflow: visible;
  }
  .stage.portrait-spacer .dock { margin-top: 8px; }
  .dock-header { margin-bottom: 4px; }
  .dialogue-text { font-size: 13px; line-height: 1.38; margin-bottom: 7px; }
  .sb-list { max-height: 170px; overflow-y: auto; }

  /* Intro City 2-column side-by-side landscape layout */
  .stage[data-scene-mode="intro_city"] {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(260px, 0.92fr);
    gap: 10px;
    align-items: start;
    padding: 48px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  }
  .stage[data-scene-mode="intro_city"] .dock {
    order: 1;
    width: 100%;
    margin: 0;
  }
  .stage[data-scene-mode="intro_city"] .city-phone {
    order: 2;
    position: relative;
    top: auto;
    right: auto;
    transform: none;
    width: 100%;
    max-width: none;
    min-height: 0;
    height: auto;
    margin: 0;
    border-radius: 14px;
    border-width: 2px;
    padding: 8px 10px;
  }
  .stage[data-scene-mode="intro_city"] .city-phone::before,
  .stage[data-scene-mode="intro_city"] .city-phone::after,
  .stage[data-scene-mode="intro_city"] .phone-status,
  .stage[data-scene-mode="intro_city"] .phone-chart,
  .stage[data-scene-mode="intro_city"] .phone-disabled-cta,
  .stage[data-scene-mode="intro_city"] .phone-homebar {
    display: none;
  }
  .stage[data-scene-mode="intro_city"] .phone-reject {
    min-height: 0 !important;
    padding: 5px 8px !important;
    margin: 4px 0 6px !important;
    font-size: 10.5px !important;
  }

  /* Rune Cast 2-column horizontal execution console on Landscape Mobile (852x393) */
  .runes-stage {
    position: relative;
    inset: auto;
    width: min(824px, calc(100vw - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right))));
    margin: 2px auto 5px;
    flex-shrink: 0;
  }
  .runes-stage.visible {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    align-items: stretch;
  }
  .stave-hitbox { display: none !important; }
  .rune-pin {
    position: relative;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    min-width: 0;
    max-width: none;
    width: 100%;
    padding: 5px 8px;
  }
  .rune-pin::after, .rune-pin .rc-tap { display: none; }
  .rune-pin .rc-head { font-size: 9.5px; margin-bottom: 1px; }
  .rune-pin .rc-big { font-size: 12px; margin-bottom: 1px; }
  .rune-pin .rc-val { font-size: 9.5px; line-height: 1.2; }

  .stage[data-scene-mode="runecast"].rc-has-thumb .dock {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 10px;
    align-items: start;
    padding: 8px 10px 9px;
    margin: 0 auto 10px;
  }
  .stage[data-scene-mode="runecast"].rc-has-thumb .rc-context-zone {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
  }
  .stage[data-scene-mode="runecast"].rc-has-thumb .rc-thumb-deck {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 7px 8px;
    background: rgba(7, 13, 10, 0.86);
    border: 1px solid #2b4032;
    border-radius: 6px;
    box-shadow: none;
    backdrop-filter: none;
  }
  .rc-spoken-line { display: none; }
  .rc-back-mob { display: inline-flex; align-items: center; padding: 3px 7px; font-size: 11px; min-height: 26px; }
  .rc-back-desk { display: none !important; }
  .wb-desktop-txt { display: none; }
  .wb-mobile-txt { display: inline; }
  .rc-dock-header { margin-bottom: 0; flex-wrap: nowrap; gap: 6px; }
  .rc-dock-header .speaker-tag { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rc-head-links { gap: 7px; flex-wrap: nowrap; flex-shrink: 0; }
  .rc-head-links .math-link { font-size: 10px; white-space: nowrap; }
  .rc-offer-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 8px;
    padding: 6px 8px;
    margin-bottom: 0;
  }
  .rc-offer-summary .os-k { font-size: 8.8px; }
  .rc-offer-summary .os-v { font-size: 12px; }
  .payoff-ladder { padding: 5px 7px 6px; margin-bottom: 0; }
  .pl-head { font-size: 9px; margin-bottom: 4px; }
  .pl-bounds { font-size: 9px; }
  .pl-grid { gap: 4px; }
  .pl-cell { padding: 4px 5px; }
  .pl-val { font-size: 11px; }

  .rc-direction-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    margin: 0;
  }
  .rc-direction-grid .wager-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 4px 6px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
  }
  .rc-direction-grid .wager-btn .wb-title { font-size: 12px; line-height: 1.1; }
  .rc-direction-grid .wager-btn .wb-sub { font-size: 9px; line-height: 1.1; margin-top: 2px; }
  .rc-exec-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .rc-size-row { flex-wrap: nowrap; gap: 5px !important; width: 100%; min-width: 0; }
  .rc-rail-lbl { display: none; }
  .rc-size-rail {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .rc-size-rail::-webkit-scrollbar { display: none; }
  .rc-lev-rail { display: inline-flex; flex: 0 0 auto; flex-wrap: nowrap; gap: 4px; padding-left: 5px; border-left: 1px solid #2b3f32; }
  .rc-size-row .rc-size-pill,
  .rc-size-row .rc-lev-pill {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0 8px;
    font-size: 11.5px;
    justify-content: center;
    border-radius: 5px;
  }
  .rc-carve-cta { width: 100%; min-height: 44px; padding: 9px 12px; font-size: 14.5px; }

  /* Runestone Close-Up: Clean 2-column Ledger + Inspector split in Landscape Mobile */
  .runestone-ui.visible {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    height: calc(100dvh - 48px);
    padding: 4px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
    overflow: hidden;
    pointer-events: auto;
    align-items: stretch;
  }
  .rs-mobile-seg, .rs-center-col { display: none !important; }
  .runestone-ui[data-rs-mobile-tab="positions"] #rsInspectorPanel,
  .runestone-ui[data-rs-mobile-tab="inspect"] #rsLedgerPanel {
    display: flex !important;
  }
  .rs-panel { max-height: 100%; overflow: hidden; padding: 8px 10px; }
  .rs-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-right: 3px; }
  .phosphor-canvas-wrap.interactive { height: 110px; }

  /* Landscape Mobile Bottom Sheets (Pouch, Wallet, Receipt, Docs) with Swipe-to-Dismiss */
  .modal-backdrop {
    align-items: flex-end;
    justify-content: center;
    padding: 0 !important;
    overflow: hidden;
    transition: background-color 180ms ease;
  }
  .modal-box {
    width: min(740px, 100vw) !important;
    max-width: 100vw !important;
    max-height: 92dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border-radius: 14px 14px 0 0;
    border-bottom: none !important;
    padding: 0 14px max(14px, env(safe-area-inset-bottom)) !important;
    will-change: transform;
  }
  .modal-box.sheet-dragging { transition: none !important; animation: none !important; user-select: none; }
  .modal-box.sheet-snapping { transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1) !important; animation: none !important; }
  .modal-box.sheet-dismissing { transition: transform 190ms cubic-bezier(0.32, 0.72, 0, 1) !important; animation: none !important; }
  .modal-box .modal-head {
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--panel-solid);
    margin: 0 -14px 10px;
    padding: 15px 14px 8px;
    border-bottom: 1px solid #25362c;
    max-width: calc(100% + 28px);
    cursor: grab;
    touch-action: pan-x;
  }
  .modal-box.modal-wallet .modal-head { background: #121614; border-bottom-color: rgba(219, 179, 98, 0.22); }
  .modal-box .modal-head::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 4px;
    border-radius: 99px;
    background: rgba(234, 177, 84, 0.44);
    transition: width 140ms ease, background 140ms ease, box-shadow 140ms ease;
  }
  .modal-box.sheet-dragging .modal-head::before {
    width: 56px;
    background: var(--gold);
    box-shadow: 0 0 10px rgba(234, 177, 84, 0.72);
  }
  .modal-box.modal-portfolio {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 92dvh;
    padding: 0 !important;
  }
  .modal-box.modal-portfolio .modal-head {
    position: relative;
    top: auto;
    flex-shrink: 0;
    margin: 0;
    padding: 16px 14px 9px;
    max-width: 100%;
  }
  .modal-box.modal-portfolio .port-sheet-body {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-padding-top: 14px;
    padding: 12px 14px max(16px, env(safe-area-inset-bottom));
  }
  .modal-box.modal-portfolio .port-tab-scroll { overflow: visible; }
  .receipt-preview-wrap img { max-height: 44dvh; }
  .docs-layout { max-height: none; min-height: 0; display: grid; grid-template-columns: 185px minmax(0, 1fr); gap: 10px; }
  .docs-nav { flex-direction: column; overflow-y: auto; border-right: 1px solid #26362b; border-bottom: none; padding: 0 8px 0 0; }
  .docs-body { overflow: visible; padding: 0; }
  .docs-ask-desktop { display: inline-flex !important; }
  .docs-mobile-footer { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .scene-layer, .stone-hotspot, .rune-card { transition: none !important; animation: none !important; }
}

/* =====================================================================
   SHORT BOARD INLINE PREVIEW & OATH-STONE RENEWAL — MOBILE SAFETY (0px OVERFLOW)
   ===================================================================== */
@media (max-width: 820px) {
  .sb-list.has-preview { max-height: none; overflow: visible; }
  .sb-preview-drawer { padding: 7px 7px; margin-top: 6px; }
  .sb-preview-head { gap: 6px; }
  .sb-preview-stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 8px;
    font-size: 10.5px;
  }
  .sb-pstat {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sb-preview-canvas { height: 104px; }
  .sb-preview-foot {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .sb-preview-cast {
    width: 100%;
    min-height: 38px;
    text-align: center;
  }
  .oath-renew-backdrop { padding: 14px; }
  .oath-renew-card { padding: 22px 18px 18px; max-width: 100%; }
  .oath-renew-heading { font-size: 21px; }
  .oath-renew-copy { font-size: 13.5px; }
}
