/* The game has two destinations, one battlefield, and one current decision.
   All controls retain their original handlers and authoritative state. */

/* Home is a real destination, including when a battle is paused underneath it. */
body[data-screen="home"] #game-layout,
body[data-screen="home"] #journey-tools { display:none !important; }
body[data-screen="home"][data-camp-details="open"] #game-layout,
body[data-screen="home"][data-camp-details="open"] #journey-tools { display:block !important; }
body[data-home-suspended="true"] :is(#victory-growth,#trial-banner,#training-milestone,#progression-rewards,#companion-progress,#adventure-next,#voluntary-trial-panel,#home-how) { display:none !important; }
body[data-screen="adventure"] #home-how { display:none; }
body[data-screen="home"] #action-dock[hidden],
#game-layout[hidden],#game-layout .play-column > [hidden] { display:none !important; }
body[data-screen="home"] .home-resume-note { max-width:38ch; margin:0; color:#cad6c9; font-size:12px; line-height:1.65; }
.home-resume-note:empty { display:none; }
body[data-home-suspended="true"] #home-vista .arrival-copy { padding-bottom:84px; }
.topbar .adventure-nav-item[aria-current="page"] { color:#f6e7c5; background:#b4c99512; box-shadow:inset 0 -2px #d9bb7c; }
.topbar .brand { min-height:44px; }
.home-how { padding:20px 6px 8px; margin-bottom:18px; }
.mobile-downloads { margin-top:16px; color:#efdfbd; font-size:13px; }
.mobile-download-links { display:flex; flex-wrap:wrap; gap:4px 16px; }
.mobile-download-links a { display:inline-flex; align-items:center; text-decoration:underline; }
.home-how-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px; }
.home-how-heading h2 { font:500 21px/1.4 var(--font-display); color:#efdfbd; }
.home-how-heading .text-button { color:#e8cea0; min-height:44px; font-size:13px; }
.home-how-steps { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:24px; list-style:none; padding:0; margin:0; }
.home-how-steps li { display:flex; align-items:flex-start; gap:13px; min-width:0; }
.home-how-icon { display:grid; place-items:center; width:46px; height:48px; flex:none; border:1px solid #cfbc845c; border-radius:12px; color:#ead4a1; background:#19302a; }
.home-how-icon svg { width:23px; height:23px; }
.home-how-steps strong { font-size:14px; line-height:1.5; color:#e4e5cf; font-weight:600; }
.home-how-steps p { margin:5px 0 0; max-width:34ch; color:#adbfaf; font-size:12px; line-height:1.65; }
body.has-victory-growth #home-how { display:none; }

/* The title orients the player; the actual battlefield follows immediately. */
body[data-screen="adventure"] #home-vista { min-height:0; margin:0; padding:16px 0; border:0; border-radius:0; box-shadow:none; background:none; overflow:visible; }
body[data-screen="adventure"] #home-vista::before,
body[data-screen="adventure"] #home-vista::after,
body[data-screen="adventure"] #opening-key-art,
body[data-screen="adventure"] .expedition-summary { display:none; }
body[data-screen="adventure"] #home-vista .arrival-copy { width:100%; max-width:none; padding:0; }
body[data-screen="adventure"] #home-vista .eyebrow { margin-bottom:5px; font-size:10px; }
body[data-screen="adventure"] #home-vista h1 { font:500 clamp(23px,2.4vw,31px)/1.3 var(--font-display); margin:0; color:#f0e4c9; }
body[data-screen="adventure"] #arrival-description { display:inline; font-size:12px; line-height:1.6; margin:5px 14px 0 0; color:#bdcdbf; }
body[data-screen="adventure"] #arrival-checkpoint { display:inline; color:#aabfaa; font-size:11px; }
body[data-screen="adventure"] .coop-hub:has(.coop-entry-compact) { display:none; }

/* One workspace replaces the legacy three-column dashboard in either renderer. */
#game-layout { display:block; }
#game-layout > .journey-panel,#game-layout > .right-column { display:none; }
#game-layout > .play-column { display:grid; grid-template-columns:minmax(0,1fr); gap:12px; width:100%; max-width:none; margin:0; align-items:start; }
#game-layout > .play-column > * { min-width:0; width:100%; margin:0; order:initial; grid-column:1; grid-row:auto; }
#game-layout #phase-track { grid-row:1; position:static; margin:0; display:flex; padding:5px; gap:5px; }
#game-layout #phase-track[hidden] { display:none; }
#phase-track .phase-step { flex:1; min-width:0; min-height:44px; font-size:12px; line-height:1.4; }
#game-layout #arena { position:relative; top:auto; grid-row:2; }
#game-layout #campaign-diorama { grid-row:2; border-radius:16px; }
#game-layout #campaign-diorama:empty { display:none; }
#campaign-diorama iframe { height:480px; }
#game-layout #campaign-playback { grid-row:3; }
#game-layout .play-column > :is(#hand-panel,#commands-panel,#review-panel,#camp-panel,#outcome-panel,#trial-result,#recovery-coach) { grid-row:5; padding:20px; border-radius:16px; }
#game-layout .play-column > #recovery-coach { grid-row:6; }
#game-layout .play-column > #journey-coach { grid-row:4; }
#game-layout .play-column > #turn-summary { grid-row:7; }
#game-layout .play-column > #campaign-battle-details { grid-row:8; padding:0 14px; }
#campaign-view-controls { margin:0 0 10px !important; max-width:none !important; }
#campaign-view-controls .secondary-button { min-height:40px; padding:7px 12px; background:transparent; color:#c9d3bd; font-size:12px; }
#campaign-view-controls > p { font-size:12px; line-height:1.5; color:#d1c39e; }
#game-layout #hand-panel { display:flex; flex-direction:column; gap:10px; min-height:0; }
#game-layout #hand-panel > * { grid-column:auto; grid-row:auto; width:100%; margin:0; }
#game-layout #hand-panel > .hand-heading { flex-wrap:nowrap; padding-bottom:12px; border-bottom:1px solid #77877b44; }
#game-layout .hand-heading h2 { font-size:23px; line-height:1.35; }
#game-layout #quick-start { padding:0; border:0; background:none; font-size:12px; line-height:1.6; color:#c0cebf; }
#game-layout #roll-tools { order:2; padding:0; }
#game-layout #roll-tools > span { font-size:11px; }
#game-layout #hand-panel > .hand-tools { order:3; }
#game-layout #dice-danger { order:4; padding:10px; font-size:12px; }
#game-layout #dice-tray { order:5; max-width:none; grid-template-columns:repeat(4,minmax(0,1fr)); gap:9px; padding:0; }
#game-layout #skill-receipt { order:6; }
#game-layout #selection-strip { order:7; }
#game-layout #selection-hint { order:8; min-height:0; padding:2px 0; font-size:12px; line-height:1.55; }
#game-layout #move-opportunities { order:9; }
#game-layout #dice-tactics { order:9; }
#game-layout #campaign-tactics { order:10; padding:0; }
#game-layout #lock-dice { order:11; }
#game-layout #hand-panel > .hand-footnote { order:12; }
#game-layout #dice-tray .die-wrap { padding:8px 6px; gap:5px; border-radius:12px; }
#game-layout #dice-tray .die-button { width:100%; min-height:76px; max-height:none; aspect-ratio:auto; margin-inline:0; border-radius:12px; }
#game-layout #dice-tray .die-button > svg { width:36px; height:36px; }
/* Keep original illustrated dice-owner faces recognizable beside their names in every renderer. */
#game-layout #dice-tray .die-owner { min-height:52px; flex-direction:row; justify-content:center; gap:5px; font-size:12px; }
#game-layout #dice-tray .die-portrait { width:35px; height:40px; }
#game-layout #dice-tray .die-portrait > svg { width:35px; height:40px; }
#game-layout #dice-tray .die-name { font-size:12px; line-height:1.5; }
#game-layout #dice-tray :is(.die-skill,.die-inspect) { min-height:44px; font-size:11px; line-height:1.4; overflow-wrap:anywhere; }
#game-layout #dice-tray :is(.die-skill-cost,.die-skill-reason) { font-size:10px; line-height:1.5; }
#game-layout .move-opportunities { grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
#game-layout .move-chance { padding:8px; min-width:0; }
#game-layout .move-chance :is(strong,small) { font-size:11px; line-height:1.45; }
#game-layout .hand-footnote { color:#bdc8b5; font-size:11px; line-height:1.6; }
#game-layout .hand-footnote .keyboard-hint { display:none; }
#game-layout #commands-panel { display:flex; flex-direction:column; gap:12px; }
/* A stopped trial retains its engine phase while its decision controls pause. */
body[data-voluntary-stopped="true"] #game-layout :is(#hand-panel,#commands-panel) { display:none; }
#game-layout #commands-panel > * { margin:0; min-width:0; }
#game-layout #command-danger { order:1; }
#game-layout #command-decision { order:2; }
#game-layout #suggest-commands { order:3; align-self:flex-start; min-height:44px; }
#game-layout #command-list { order:4; display:grid; grid-template-columns:minmax(0,1fr); gap:14px; }
#game-layout #fate-link-command { order:5; }
#game-layout #command-tactics { order:2; }
#game-layout #command-forecast-details { order:7; }
#game-layout #command-help { order:8; }
#game-layout #resolve { order:9; }
#game-layout .command-row { min-width:0; }
#game-layout .command-legend { gap:8px; }
#game-layout #review-panel > h2 { margin-bottom:14px; font:500 27px/1.3 var(--font-display); }
#game-layout #review-message { font-size:13px; line-height:1.7; }
body[data-screen="adventure"] :is(#lock-dice,#resolve) { display:none; }

/* Keep the stage beside the current action on a full-width screen. */
@media(min-width:1100px) {
  #game-layout > .play-column { grid-template-columns:minmax(0,1.08fr) minmax(470px,1fr); gap:14px 22px; grid-template-rows:auto auto auto auto auto auto; }
  #game-layout #phase-track { grid-column:1/-1; grid-row:1; }
  #game-layout .play-column > :is(#arena,#campaign-diorama) { grid-column:1; grid-row:2; position:sticky; top:14px; }
  #game-layout .play-column > #campaign-playback { grid-column:1; grid-row:3; }
  #game-layout .play-column > #campaign-battle-details { grid-column:1; grid-row:4; }
  #game-layout .play-column > #journey-coach { grid-column:2; grid-row:2; }
  #game-layout .play-column > #turn-summary { grid-column:1; grid-row:6; }
  #game-layout .play-column > :is(#hand-panel,#commands-panel,#review-panel,#camp-panel,#outcome-panel,#trial-result) { grid-column:2; grid-row:2/span 5; }
  #game-layout .play-column:has(> #journey-coach:not([hidden])) > :is(#hand-panel,#commands-panel,#review-panel,#camp-panel,#outcome-panel,#trial-result) { grid-row:3/span 4; }
  #game-layout .play-column > #recovery-coach { grid-column:2; grid-row:7; }
}

/* One persistent next action; its real height also determines page clearance. */
body[data-screen="adventure"] { padding-bottom:var(--action-clearance,148px); }
body[data-screen="adventure"] #action-dock { position:fixed; left:50%; right:auto; bottom:14px; transform:translateX(-50%); width:calc(100% - 32px); max-width:1328px; margin:0; padding:12px 16px; border:1px solid #9cae805e; border-radius:15px; display:grid; grid-template-columns:minmax(0,1fr) auto minmax(240px,.7fr); gap:12px; align-items:center; z-index:45; }
#action-dock .dock-context { grid-column:auto; display:block; width:auto; min-width:0; }
#action-dock .dock-context > span { display:block; color:#ebdcb6; font-size:11px; line-height:1.5; }
#action-dock .dock-context > strong { display:block; font-size:13px; line-height:1.5; margin-top:3px; color:#d2deca; text-align:left; overflow-wrap:anywhere; }
#action-dock :is(.primary-button,.secondary-button) { min-height:52px; font-size:14px; line-height:1.4; padding:12px 18px; }
#action-dock:has(#dock-assist[hidden]) #dock-primary { grid-column:2/-1; }
body[data-screen="adventure"] #action-dock:has(#voluntary-stop-shortcut:not([hidden])) { grid-template-columns:minmax(0,1fr) auto minmax(220px,.7fr) auto; }

@media(max-width:800px) {
  .topbar .adventure-nav { grid-template-columns:repeat(4,minmax(0,1fr)); }
  body[data-screen="adventure"] #home-vista { padding-block:12px; }
  body[data-screen="adventure"] #arrival-checkpoint { display:block; margin-top:3px; }
  .home-how-steps { gap:15px; }
  .home-how-steps li { flex-direction:column; gap:9px; }
  .home-how-steps strong { font-size:13px; }
  .home-how-steps p { font-size:12px; }
}
@media(max-width:640px) {
  body[data-screen] .app-shell { padding-inline:12px; }
  #game-layout > .play-column { gap:10px; }
  #game-layout .play-column > :is(#hand-panel,#commands-panel,#camp-panel,#review-panel,#outcome-panel) { padding:15px 12px; }
  #phase-track .phase-step { font-size:11px; min-height:44px; padding:7px 5px; gap:5px; }
  #phase-track .phase-step > b { width:22px; height:22px; flex:none; }
  #game-layout #dice-tray { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  #game-layout #dice-tray .die-wrap { padding:9px; }
  #game-layout #dice-tray .die-owner { font-size:13px; }
  #game-layout #dice-tray .die-button { min-height:78px; }
  #game-layout #dice-tray :is(.die-skill,.die-inspect) { font-size:12px; }
  #game-layout #dice-tray :is(.die-skill-cost,.die-skill-reason) { font-size:11px; }
  #game-layout .hand-heading h2 { font-size:21px; }
  #game-layout #command-list { grid-template-columns:1fr; gap:10px; }
  /* Keep all four real round metrics legible through dice, commands and review. */
  #game-layout .hand-panel .buff-grid,
  #game-layout .commands-panel .combat-forecast,
  #game-layout .review-panel .review-totals { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #game-layout #campaign-diorama { border-radius:12px; }
  #campaign-diorama iframe { height:450px; }
  body[data-screen="adventure"] #action-dock { left:0; bottom:0; transform:none; width:100%; max-width:none; border-radius:16px 16px 0 0; padding:10px 12px max(10px,env(safe-area-inset-bottom)); grid-template-columns:minmax(98px,.7fr) minmax(0,1.3fr); gap:8px 10px; }
  #action-dock .dock-context { grid-column:1/-1; display:flex; gap:8px; align-items:center; justify-content:space-between; }
  #action-dock .dock-context > strong { margin:0; text-align:right; font-size:12px; }
  #action-dock :is(.primary-button,.secondary-button) { min-height:50px; min-width:0; width:100%; padding:10px; font-size:13px; }
  #action-dock:has(#dock-assist[hidden]) #dock-primary { grid-column:1/-1; }
  body[data-screen="adventure"] #action-dock:has(#voluntary-stop-shortcut:not([hidden])) { grid-template-columns:1fr 1fr; }
  #voluntary-stop-shortcut:not([hidden]) { grid-column:1/-1; }
  body[data-screen="home"] #home-vista { padding-top:180px; padding-bottom:106px; }
  body[data-screen="home"] .home-key-art { height:320px; }
  body[data-screen="home"] #home-vista h1 { font-size:38px; line-height:1.12; margin-bottom:12px; }
  html[lang="zh-Hant"] body[data-screen="home"] #home-vista h1 { font-size:31px; line-height:1.3; }
  body[data-home-suspended="true"] #home-vista .arrival-copy { padding-bottom:0; }
  .home-how-heading { gap:8px; }
  .home-how-heading h2 { font-size:18px; }
  .home-how-steps { grid-template-columns:1fr; gap:16px; }
  .home-how-steps li { flex-direction:row; align-items:center; }
  .home-how-steps p { max-width:none; }
  .home-how-icon { width:40px; height:44px; }
}
@media(max-width:360px) {
  .topbar .brand > span:last-child { font-size:15px; }
  .topbar .top-actions { gap:0; }
  .topbar .top-actions > .quiet-button,.home-tools > summary { padding-inline:6px; }
  body[data-screen="home"] #home-vista { padding-top:150px; padding-inline:19px; }
  body[data-screen="home"] .home-key-art { height:285px; }
  #game-layout .hand-heading h2 { font-size:19px; }
}
@media(max-height:560px) and (min-width:700px) {
  body[data-screen="adventure"] #action-dock { position:sticky; left:auto; bottom:0; transform:none; width:auto; margin:12px; }
  #game-layout .play-column > :is(#arena,#campaign-diorama) { position:relative; top:auto; }
}
html[data-text-size="large"] #game-layout .hand-heading h2 { font-size:1.6rem; }
html[data-text-size="large"] #game-layout #dice-tray { grid-template-columns:repeat(2,minmax(0,1fr)); }
html[data-text-size="large"] #game-layout #command-list { grid-template-columns:1fr; }
html[data-text-size="large"] #game-layout :is(.die-owner,.die-skill,.die-inspect,.hand-footnote,#quick-start) { font-size:.95rem; }
html[data-text-size="large"] #action-dock :is(.primary-button,.secondary-button) { font-size:1rem; }
@media(max-width:800px) {
  /* Keep the decision reachable without reducing accessible text. Extreme
     wrapping can scroll inside the dock instead of covering the whole game.
     ResizeObserver reserves this actual height below the page and for focus. */
  html[data-text-size="large"] body[data-screen="adventure"] #action-dock {
    max-height:50vh; max-height:50dvh; overflow-y:auto; scroll-padding-block:8px;
  }
}
html[data-contrast="high"] :is(.home-how-steps p,.home-resume-note,#game-layout #quick-start,#action-dock .dock-context > strong) { color:#f0eedb; }
@media(prefers-reduced-motion:reduce) { .home-how-icon,.home-primary { transition:none; animation:none; } }
