/* Mobile controls use the same game buttons and data as the desktop view. */
.mobile-only { display: none; }
#mobile-menu { padding: 0; color: var(--ink); background: var(--panel); border: 1px solid var(--gold); border-radius: 18px; width: min(430px, calc(100vw - 20px)); max-height: calc(100dvh - 24px); overflow: auto; }
#mobile-menu::backdrop { background: #080912b8; backdrop-filter: blur(5px); }
.mobile-menu-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; position: sticky; top: 0; z-index: 2; background: var(--panel); border-bottom: 1px solid var(--line-2); }
.mobile-menu-content { padding: 12px 16px 20px; }
.mobile-menu-content h3 { font-size: 14px; margin: 16px 0 8px; }
.mobile-menu-content .hud-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mobile-menu-content .hud-actions .btn { min-height: 46px; justify-content: center; white-space: normal; font-size: 14px; }
.mobile-menu-content .hud-actions #btn-report { display: inline-flex; }
.mobile-menu-content #seg-speed { display: flex; flex-wrap: wrap; gap: 6px; }
.mobile-menu-content #seg-speed button { min-width: 48px; min-height: 44px; font-size: 15px; justify-content: center; }
.mobile-menu-content #btn-autopause { min-height: 44px; margin: 8px 0; font-size: 14px; }
.mobile-menu-content :is(#seg-layout,#seg-density) { display: flex; flex-wrap: wrap; gap: 6px; background: none; border: 0; }
.mobile-menu-content :is(#seg-layout,#seg-density) .seg-btn { flex: 1; min-height: 44px; padding: 7px 10px; font-size: 14px; justify-content: center; }
.mobile-menu-content #seg-density > span { display: none; }
.mobile-menu-content #powers { position: static; width: 100%; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 0; margin: 0; border: 0; background: none; box-shadow: none; overflow: visible; }
.mobile-menu-content #powers .powers-title { display: none; }
.mobile-menu-content #powers .pay-faith { grid-column: 1 / -1; }
.mobile-menu-content #powers .power { min-width: 0; }
.mobile-menu-content #powers .power small { white-space: normal; }
.mobile-command-note { margin: 4px 0 10px; font-size: 12px; color: var(--ink-2); }
.mobile-menu-content #th-toolbar { position: static; width: 100%; padding: 12px; box-shadow: none; border: 1px solid var(--line-2); margin-top: 12px; }
.mobile-menu-content #th-toolbar summary { font-size: 14px; }
.mobile-menu-content #th-toolbar :is(a,button) { min-height: 44px; }
.mobile-panel-head { align-items: center; justify-content: space-between; padding: 6px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.mobile-zoom { position: absolute; right: 8px; bottom: 60px; z-index: 5; flex-direction: column; gap: 6px; }
.mobile-powers-trigger { position: absolute; left: 8px; bottom: 60px; z-index: 5; align-items: center; justify-content: center; min-height: 44px; padding: 6px 12px; background: var(--panel-glass); backdrop-filter: blur(5px); }
.mobile-zoom button { width: 44px; height: 44px; padding: 0; justify-content: center; font: 600 22px var(--font-body); background: var(--panel-glass); backdrop-filter: blur(5px); }
.mobile-rite-nav { position: absolute; top: calc(48px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 5; overflow-x: auto; gap: 6px; padding: 5px 12px; background: var(--panel-glass); backdrop-filter: blur(8px); border-block: 1px solid var(--line); scroll-snap-type: x proximity; }
.mobile-rite-nav button { flex: none; min-height: 42px; scroll-snap-align: start; font-size: 13px; }
@media (max-width: 760px), (max-width: 980px) and (max-height: 520px) and (pointer: coarse) {
  .mobile-only { display: flex; }
  html, body { width: 100%; min-width: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
  #app { height: 100dvh; padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); gap: 6px; }
  .hud { display: flex; gap: 6px 10px; align-items: center; }
  .brand { display: none; }
  .clock { order: 1; flex: 1 1 calc(100% - 64px); flex-wrap: nowrap; gap: 8px; min-width: 0; }
  .clock-year { min-width: 45px; }
  .clock-year b { font-size: 24px; }
  .clock-year .lbl { font-size: 10px; }
  .clock-ctrl { flex-wrap: nowrap; gap: 8px; }
  #btn-play { width: 46px; height: 46px; }
  #btn-step { min-height: 44px; padding-inline: 12px; font-size: 14px; }
  .mobile-menu-trigger { order: 2; flex: 0 0 50px; min-height: 46px; min-width: 50px; padding: 5px 10px; justify-content: center; }
  .warp-meter { order: 3; flex: 1 1 80px; min-width: 0; grid-template-columns: auto auto; gap: 0 6px; }
  .warp-meter .lbl { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .warp-track { width: 50px; }
  .warp-read b { font-size: 18px; }
  .warp-read small { font-size: 11px; }
  .gauge { order: 4; flex: 0 0 auto; min-width: 35px; }
  .gauge .lbl { font-size: 10px; }
  .gauge b { font-size: 18px; }
  .mobile-next-trigger { order: 5; flex: 0 0 auto; min-height: 44px; padding: 5px 10px; font-size: 13px; justify-content: center; }
  .stage { grid-template-columns: minmax(0, 1fr); position: relative; overflow: hidden; border-radius: 14px; min-height: 180px; }
  .graph-top { inset: 6px 6px auto; gap: 4px; }
  .graph-top .tool { min-height: 40px; font-size: 12px; padding-inline: 8px; }
  .era-stamp { min-height: 40px; max-width: 48%; justify-content: center; }
  .era-stamp b { font-size: 13px; }
  .era-name { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .era-mode { display: none; }
  .graph-tools { width: auto; flex-basis: auto; margin-left: 0; gap: 4px; }
  #seg-layout { display: flex; flex: 1; }
  #seg-layout .seg-btn { flex: 1; justify-content: center; min-height: 40px; padding: 4px 6px; font-size: 12px; }
  #seg-density { display: none; }
  #trial-chip { display: none; }
  #graph { touch-action: none; }
  #graph .node { touch-action: none; }
  #graph[data-compact-overview="true"] .node :is(.label,.sub,.glyph,.npt,.badges,.ring,.halo,.aura,.fx), #graph[data-compact-overview="true"] :is(.gPOI,.gHulls,.m-labels) { display: none; }
  #graph[data-compact-overview="true"] .node .body { r: 3px; stroke-width: .8px; }
  .powers { left: 6px; right: 6px; top: auto; bottom: 58px; width: auto; display: flex; flex-direction: row; overflow-x: auto; padding: 4px; gap: 5px; scrollbar-width: thin; overscroll-behavior-x: contain; touch-action: pan-x; }
  .powers .power { min-height: 44px; flex: none; padding: 5px 9px; grid-template-columns: 18px auto; grid-template-rows: auto auto; }
  .powers .power svg { width: 18px; height: 18px; grid-row: 1 / 3; }
  .powers .power b { font-size: 12px; }
  .powers .power small { display: block; white-space: nowrap; font-size: 10px; line-height: 1.2; }
  .powers .pay-faith { min-width: 90px; min-height: 44px; font-size: 12px; }
  .powers .pay-faith input { width: 22px; height: 22px; }
  .monster-pick { left: 8px; right: 8px; top: auto; bottom: 118px; width: auto; max-height: min(58%, 280px); overflow: auto; overscroll-behavior: contain; }
  .panel { position: absolute; inset: auto 0 0; z-index: 7; box-shadow: var(--shadow); height: min(82%, 620px); border-radius: 12px 12px 0 0; transform: translateY(calc(100% - 52px)); transition: transform .25s ease; }
  .panel.open { transform: none; }
  .panel-tabs { flex: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; padding: 0; min-height: 52px; }
  .panel-tabs .tab, .mobile-map-tab { min-width: 0; min-height: 52px; padding: 5px 2px; font-size: 11px; line-height: 1.45; white-space: normal; justify-content: center; text-align: center; overflow-wrap: anywhere; }
  .mobile-map-tab { border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-2); align-items: center; }
  .mobile-map-tab[aria-selected="true"] { color: var(--gold-ink); border-bottom-color: var(--gold); font-weight: 700; }
  .panel-tabs #panel-grip { display: none; }
  .panel-body { font-size: 14px; overflow-x: hidden; overscroll-behavior: contain; }
  .panel-body :is(p,li,dd) { overflow-wrap: anywhere; }
  .panel-body :is(.tool,.btn,.seg-btn) { min-height: 40px; }
  .panel-body select, .panel-body input:not([type="checkbox"]):not([type="range"]) { font-size: 16px; min-height: 44px; }
  .panel-body input[type="checkbox"] { width: 20px; height: 20px; }
  .toasts { bottom: 116px; right: 6px; max-height: 30%; overflow: auto; pointer-events: none; }
  .toasts .toast { font-size: 12px; }
  .toasts button { pointer-events: auto; }
  .timebar { padding: 4px 8px; gap: 6px; min-height: 42px; }
  .timebar .round { width: 40px; height: 40px; }
  #tl-range { min-height: 36px; }
  .tl-year { min-width: 40px; font-size: 15px; }
  .veil { padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .veil-card { width: 100%; max-width: 100%; padding: 22px 16px 18px; }
  html[lang="th"] .title-card { padding-top: 26px; }
  html[lang="th"] .title-main { font-size: clamp(25px, 7vw, 34px); line-height: 1.5; }
  .title-lead { font-size: 15px; }
  .title-steps { font-size: 13px; text-align: left; }
  .scn-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 9px; }
  .scn { min-height: 72px; padding: 12px; }
  .scn b { font-size: 15px; }
  .scn small { font-size: 13px; }
  .shape-grid { grid-template-columns: minmax(0, 1fr); }
  .desk-continue { display: grid; }
  .veil-actions { gap: 8px; }
  .veil-actions .btn { min-height: 44px; font-size: 14px; }
  .room { height: 100dvh; }
  .room-grid { grid-template-columns: minmax(0, 1fr); }
  .room-annals { top: max(6px, env(safe-area-inset-top)); right: 10px; min-height: 40px; }
  .room-inner { padding: calc(112px + env(safe-area-inset-top)) 12px 22px; }
  .room-narr { font-size: 16px; line-height: 1.75; }
  #soul, #rite .step { scroll-margin-top: calc(112px + env(safe-area-inset-top)); }
  .soul-card { position: relative; padding: 18px 14px; }
  .soul-name { font-size: 25px; }
  .soul-meta, .film p, .soul-line { font-size: 14px; }
  .step { padding: 14px 0; }
  .step legend { font-size: 17px; line-height: 1.6; }
  .step legend small { display: block; margin-left: 30px; font-size: 12px; }
  .row { flex-wrap: wrap; }
  .row-label { flex-basis: 100%; font-size: 14px; }
  .name-row input { width: 100%; min-width: 0; min-height: 46px; font-size: 16px; }
  .seg-btn, .word, .pick { min-height: 44px; }
  .seg-btn { padding: 8px 12px; font-size: 14px; }
  .stat-row { min-height: 48px; grid-template-columns: 82px minmax(0, 1fr) 48px; }
  .stat-row input[type="range"] { min-height: 36px; }
  .thread-row { flex-direction: column; align-items: stretch; }
  .thread-row select { width: 100%; font-size: 16px; min-height: 46px; }
  .skill-grid, .word-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .skill { padding: 12px 10px; }
  .sk-name { font-size: 15px; }
  .sk-desc { font-size: 12px; }
  .room-foot { max-height: 32dvh; overflow: auto; padding: 8px 10px max(8px, env(safe-area-inset-bottom)); }
  .foot-in { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .proj { min-width: 0; width: 100%; }
  .proj-top { font-size: 12px; gap: 6px; }
  .proj-bar { display: none; }
  .fate { order: 0; flex-basis: auto; flex-wrap: nowrap; overflow-x: auto; min-height: 22px; font-size: 11px; white-space: nowrap; }
  .foot-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .foot-actions .btn, .foot-actions .btn.big { min-height: 46px; width: 100%; padding: 5px 4px; font-size: 12px; justify-content: center; white-space: normal; line-height: 1.45; }
  #th-toolbar:not(.mobile-menu-content #th-toolbar) { right: 8px; top: 8px; }
}
@media (max-width: 760px) and (max-height: 520px), (max-width: 980px) and (max-height: 520px) and (pointer: coarse) {
  .hud { gap: 4px 8px; }
  .clock { flex: 0 1 auto; }
  .mobile-menu-trigger { order: 8; margin-left: auto; }
  .warp-meter { flex: 0 1 110px; }
  .gauge { min-width: 25px; }
  .mobile-next-trigger { min-width: 68px; }
  .stage { min-height: 120px; }
  .timebar { min-height: 32px; }
  .timebar .round { width: 32px; height: 32px; }
  .room-foot { max-height: 35dvh; }
  .fate { display: none; }
  .shape-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-zoom { flex-direction: row; bottom: 60px; }
}
