/* Shared rows use the same inset, height and baseline as the application header. */
.controls, body.index-open .controls { top: calc(18px + var(--sa-t)); padding: 4px 6px; gap: 4px; align-items: center; }
.controls > .btn, .controls > .menu { flex: 1 1 0; min-width: 0; }
.controls > .btn, .controls > .menu > summary { height: 44px; display: flex; align-items: center; justify-content: center; padding: 8px 12px; gap: 6px; line-height: 1; }
.controls .btn .g { margin: 0; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: none; }
.controls .btn .chev { margin: 0 0 0 2px; }
.controls .btn .g img { width: 24px; height: 24px; object-fit: cover; border-radius: 5px; }
.controls { width: 354px; }
[data-menu="mode"] .menu-body { width: 304px; }
[data-menu="mode"] .menu-body .btn { display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 6px; min-height: 57px; font-size: 14px; text-transform: none; letter-spacing: .02em; }
[data-menu="mode"] .menu-body .btn .g { width: 72px; height: 45px; }
[data-menu="mode"] .menu-body .btn img { width: 72px; height: 45px; object-fit: cover; border-radius: 6px; }
.intro-modes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.intro-mode { padding: 0 0 12px; overflow: hidden; }
.intro-mode img { width: 100%; height: auto; aspect-ratio: 8/5; object-fit: cover; display: block; }
.intro-mode strong, .intro-mode small { padding: 0 8px; }
/* The existing play header also contains the guide. No extra legend strip. */
.bv-rail { order: 1; align-items: center; }
.bv-grid, body.board-only .bv-grid { order: 3; }
.bv-rail > .bv-guide { width: auto; flex: 0 0 auto; align-self: center; order: 3; background: transparent; border: 0; box-shadow: none; }
.bv-rail .bv-guide > summary, .bv-rail .bv-tools > summary, .bv-rail .bv-options > summary { min-height: 44px; height: 44px; display: flex; align-items: center; justify-content: center; padding: 8px 10px; font: 12px/1.2 "IBM Plex Mono", monospace; letter-spacing: .02em; text-transform: none; border-radius: var(--radius-in); }
.bv-rail .bv-guide-title { font: inherit; max-width: none; white-space: nowrap; }
/* The guide is the first of three equal menu cells; it wears their frame. */
.bv-rail .bv-guide > summary { border: 1px solid var(--rule-2); color: var(--ink-2); transition: color .16s, background-color .16s, border-color .16s; }
.bv-rail .bv-guide > summary:hover { color: var(--ink); background: var(--hi); border-color: var(--ink-3); }
/* With one row to share, the die and the view switch take the menus' height. */
@media (min-width: 701px) {
  .bv-rail > .die-face { width: 44px; height: 44px; }
  body.game-view .bv-rail > .bv-views .btn { min-height: 42px; }
}
.bv-rail .bv-guide-key { display: none; }
.bv-rail .bv-tools { order: 5; }
.bv-rail .bv-options { order: 4; }
.bv-guide-body { transform: none; }
/* panel-layout.js attaches dropdowns directly below their own summary. */
.dropdown-positioned, body.board-only .dropdown-positioned, body.night .dropdown-positioned {
  position: fixed; inset: auto; top: var(--drop-top); left: var(--drop-left); bottom: auto;
  width: var(--drop-width); max-height: var(--drop-room); transform: none;
  box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain; z-index: 18;
}
.menu, body.night .menu, .bv-guide, body.night .bv-guide { backdrop-filter: none; -webkit-backdrop-filter: none; }
.controls, body.night .controls { backdrop-filter: none; -webkit-backdrop-filter: none; }
.resizable-panel { box-sizing: border-box; }
.resizable-panel[data-panel-height] { height: min(var(--panel-height), var(--panel-room, 76dvh)); max-height: min(var(--panel-room, 76dvh), 100%) !important; overflow: hidden; }
.resizable-panel > .panel-resize-handle { display: flex; align-items: center; justify-content: center; flex: none; width: 100%; height: 24px; min-height: 24px; padding: 0; border: 0; border-radius: 6px; color: var(--ink-2); background: var(--paper); cursor: ns-resize; touch-action: none; }
.panel-resize-handle::before { content: ''; width: 40px; height: 4px; border-radius: 4px; background: currentColor; opacity: .45; }
.panel-resize-handle:hover::before, .panel-resize-handle:focus-visible::before { opacity: 1; }
.resizable-panel .sheet-scroll, .resizable-panel .tour-scroll, .resizable-panel .lm-scroll, .resizable-panel .jy-scroll { min-height: 0; flex: 1 1 auto; overflow-y: auto; }
.panel-minimized.sheet .sheet-scroll > :not(h2):not(.sub),
.panel-minimized.tour-panel .tour-scroll > :not(h2):not(.tour-title),
.panel-minimized.mandala-note > :not(.mode-tabs):not(h3):not(.playbar):not(.panel-resize-handle),
.panel-minimized.lm-panel .lm-scroll, .panel-minimized.jy-panel .jy-scroll { display: none !important; }
.panel-minimized.sheet .sheet-scroll { padding-top: 8px; padding-bottom: 8px; }
.panel-minimized .sub { margin: 3px 0 0; }
body.resizing-panel { user-select: none; cursor: ns-resize; }
.world-ending { position: fixed; z-index: 9; right: calc(22px + var(--sa-r)); bottom: 24px; width: min(460px, calc(100vw - 44px - var(--sa-l) - var(--sa-r))); padding: 14px 16px 0; pointer-events: auto; color: var(--ink); background: var(--menu); border-radius: var(--radius); box-shadow: var(--shadow); }
.world-ending[hidden] { display: none; }
.world-ending-head { display: flex; gap: 10px; align-items: center; }
.world-ending-head h2 { flex: 1; margin: 0; font-size: 23px; font-weight: 500; }
.world-ending-head .btn { width: 44px; min-height: 44px; }
.world-ending-types { display: flex; gap: 6px; margin: 8px 0; }
.world-ending-types .btn { flex: 1; min-height: 44px; font-size: 12px; text-transform: none; }
.world-ending-types [aria-pressed="true"] { background: var(--accent); color: var(--paper); }
.world-ending-stage { font-size: 18px; margin: 10px 0 5px; }
.world-ending-copy { font-size: 15px; line-height: 1.4; margin: 0 0 10px; color: var(--ink-2); }
.world-ending-controls { display: flex; align-items: center; gap: 10px; }
.world-ending-controls button { min-width: 76px; min-height: 44px; }
.world-ending-controls input { min-width: 0; width: 100%; accent-color: var(--accent); }
.world-ending-source { font-size: 12px; line-height: 1.4; color: var(--ink-2); margin: 10px 0; }
.panel-minimized.world-ending > :is(.world-ending-copy,.world-ending-source,.world-ending-types) { display: none; }
.world-end-entry { min-height: 44px; margin-top: 12px; width: 100%; background: var(--hi-2); }
@media (min-width: 701px) {
  .panel-dock { top: var(--chrome-clearance, var(--header-clearance)); bottom: 24px; }
  .bv-rail .bv-act { flex-basis: 170px; }
  .bv-rail .bv-mid { flex: 1 1 200px; }
}
@media (max-width: 700px) {
  .controls, body.index-open .controls, body.board-only .controls, body.board-only.index-open .controls { width: auto; left: calc(9px + var(--sa-l)); right: calc(9px + var(--sa-r)); top: auto; bottom: calc(9px + var(--sa-b)); transform: none; padding: 4px; }
  .controls > .btn, .controls .menu > summary { padding: 8px 5px; }
  .controls .btn .g { width: 22px; height: 22px; }
  .bv-rail { gap: 4px; }
  .bv-rail > .bv-guide { flex: 1 1 0; }
  .bv-rail > .bv-options, .bv-rail > .bv-tools { flex: 1 1 0; }
  .bv-rail .bv-guide > summary, .bv-rail .bv-tools > summary, .bv-rail .bv-options > summary { padding: 8px 4px; font-size: 11px; }
  .bv-rail .bv-guide-title { white-space: normal; text-align: center; }
  .intro-modes { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .intro-mode img { max-height: 94px; }
  .world-ending { left: 9px; right: 9px; bottom: calc(70px + var(--sa-b)); width: auto; padding: 10px 12px 0; }
  .world-ending-head h2 { font-size: 21px; }
  .resizable-panel > .panel-resize-handle { order: -1; }
}
.index.resizable-panel[data-panel-height] { overflow-y: auto; }
.resizable-panel > .panel-resize-handle { position: sticky; bottom: 0; z-index: 2; }
@media (max-width: 700px) { .resizable-panel > .panel-resize-handle { top: 0; bottom: auto; } }
.controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: var(--utility-width, 414px); }
.controls > .btn, .controls > .menu, .controls > .menu > summary { width: 100%; }
.controls .btn .t { line-height: 1.2; white-space: normal; text-align: center; }
@media (max-width: 700px) {
  .controls, body.board-only .controls { width: auto; }
  /* Shares sized to what they say (app-chrome.css): equal thirds cut off
     "Explorer" at 320 px and "Eksplorator" up to 390 px. */
  .controls { grid-template-columns: repeat(3, auto); }
  .controls .btn .t { font-size: 11px; }
}
.dropdown-positioned, body.board-only .dropdown-positioned { min-width: 0; }
[data-menu="mode"] .menu-body .btn .t { text-align: left; }
/* Opening a bottom control raises its whole stacking context above play cards. */
.controls:has(.menu[open]) { z-index: 20; }
.panel-minimized.bv-guide-body .bv-guide-groups,
.panel-minimized.bv-guide-body .bv-guide-bhumis,
.panel-minimized.bv-guide-body .bv-guide-rule { display: none; }
body.board-only .controls, body.board-only.index-open .controls {
  transform: none; left: calc(50% - var(--utility-half, 207px)); right: auto; width: var(--utility-width, 414px);
}
@media (max-width: 700px) {
  body.board-only .controls, body.board-only.index-open .controls { left: calc(9px + var(--sa-l)); right: calc(9px + var(--sa-r)); width: auto; }
}
.world-ending.resizable-panel[data-panel-height]:not(.panel-minimized) { overflow-y: auto; }
/* The three game menus occupy three equal cells of the existing play header. */
body.game-view .bv-rail > :is(.bv-guide,.bv-options,.bv-tools) { width: 136px; flex: 0 0 136px; min-width: 0; }
body.game-view .bv-rail > :is(.bv-guide,.bv-options,.bv-tools) > summary { width: 100%; }
body.game-view .bv-rail .bv-mid { order: 6; flex: 1 1 100%; }
@media (min-width: 701px) and (max-width: 1080px) {
  body.game-view .bv-rail > :is(.bv-guide,.bv-options,.bv-tools) { width: 118px; flex-basis: 118px; }
  body.board-only .bv-rail .bv-act { flex: 1 1 140px; }
}
@media (max-width: 700px) {
  body.game-view .bv-rail { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
  body.game-view .bv-rail .die-face { grid-column: 1; order: 0; }
  body.game-view .bv-rail .bv-views { grid-column: 2 / -1; order: 1; width: 100%; padding: 0; border: 0; }
  body.game-view .bv-rail .bv-views .btn { flex: 1; }
  body.game-view .bv-rail .bv-act { grid-column: 1 / -1; order: 2; border: 0; padding: 0; }
  body.game-view .bv-rail > :is(.bv-guide,.bv-options,.bv-tools) { width: 100%; min-width: 0; }
  body.game-view .bv-rail .bv-guide { grid-column: 1; order: 3; }
  body.game-view .bv-rail .bv-options { grid-column: 2; order: 4; }
  body.game-view .bv-rail .bv-tools { grid-column: 3; order: 5; }
  body.game-view .bv-rail .bv-mid { grid-column: 1 / -1; order: 6; }
}
body.game-view.guided-game .bv-rail { display: none; }

/* Keep application controls and the play header in separate rows. */
:root[data-header-rows="2"] .controls { top: var(--header-clearance); }
:root[data-header-rows="2"] body.board-only .controls { top: auto; }
@media (min-width: 701px) {
  body.world-only .board-view, body.world-only.index-open .board-view {
    top: var(--chrome-clearance, var(--header-clearance));
  }
  body.world-only { --world-panel-width: min(390px, 36vw); }
  body.world-only .bv-card {
    inset: var(--world-card-top, calc(var(--chrome-clearance, var(--header-clearance)) + 72px)) calc(22px + var(--sa-r)) calc(88px + var(--sa-b)) auto;
    width: var(--world-panel-width); display: flex; align-items: flex-start; justify-content: center;
  }
  body.world-only .bv-card-in { width: 100%; max-width: none; max-height: 100%; }
  body.world-only .bv-advance {
    left: auto; right: calc(22px + var(--sa-r)); bottom: calc(24px + var(--sa-b)); transform: none;
    width: var(--world-panel-width);
  }
  body.world-only .game-focus {
    left: auto; right: calc(22px + var(--sa-r)); bottom: calc(88px + var(--sa-b));
    width: var(--world-panel-width); max-width: none;
  }
  body.world-only .panel-dock {
    top: var(--world-card-top, var(--chrome-clearance, var(--header-clearance)));
    bottom: calc(88px + var(--sa-b)); width: var(--world-panel-width);
  }
  body.world-only:has(.game-focus:not([hidden])) .panel-dock { bottom: var(--world-focus-clearance, 250px); }
  /* a presentation hides the throw, and the room kept for it */
  body.world-only.presentation-view .panel-dock { bottom: 24px; }
}
@media (max-width: 700px) {
  .game-focus { bottom: calc(140px + var(--sa-b)); }
  body.game-view .panel-dock { bottom: calc(140px + var(--sa-b)); }
  body.game-view.presentation-view .panel-dock { bottom: calc(66px + var(--sa-b)); }
  body.world-only:has(.game-focus:not([hidden])) .panel-dock { bottom: calc(var(--world-focus-clearance, 280px) + var(--sa-b)); }
}
/* The visit panel on a phone held sideways. Between the rail above and the throw
   below there is less than the panel's height — with its note and a second row of
   buttons it stood under the rail (and, at 812×375 and 844×340, under the controls
   as well), so Focus here and Return to world could not be touched. On a short
   screen it is one compact piece, the note kept for a screen reader and not for
   the eye, and it is set where nothing else is.
   Wide enough for the throw to have a column of its own: the foot of the screen,
   to the left of the throw. */
@media (max-height: 500px) and (min-width: 701px) {
  body.world-only .game-focus {
    left: calc(22px + var(--sa-l)); right: auto; top: auto; bottom: calc(24px + var(--sa-b));
    width: min(470px, calc(100vw - var(--world-panel-width) - 66px - var(--sa-l) - var(--sa-r)));
    padding: 8px 10px; z-index: 12;
  }
  body.world-only .game-focus strong { font-size: 16px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.world-only .game-focus nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-top: 6px; }
  body.world-only .game-focus .btn { min-height: 36px; padding: 6px 8px; font-size: 10px; white-space: normal; line-height: 1.25; text-align: center; }
}
/* Narrower than that (667×375, 568×320) the throw runs across the middle and the
   controls along the foot: the panel is one row directly under the rail, the
   name beside the three buttons. */
@media (max-height: 430px) and (max-width: 700px) {
  body.world-only .game-focus {
    top: var(--world-card-top, auto); bottom: auto; left: calc(9px + var(--sa-l)); right: calc(9px + var(--sa-r)); z-index: 12;
    display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 2.4fr); align-items: center; gap: 8px; padding: 6px 10px;
  }
  body.world-only .game-focus strong { font-size: 15px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.world-only .game-focus nav { gap: 5px; }
  body.world-only .game-focus .btn { min-height: 36px; padding: 5px 6px; }
}
@media (max-height: 500px) {
  body.world-only .game-focus > p {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}

@media (min-width: 701px) {
  body.world-only .bv-card-acts {
    position: sticky; bottom: -18px; z-index: 1; flex: none;
    padding: 9px 0; background: var(--card); width: 100%;
  }
  body.world-only:has(.bv-card:not([hidden]):not(.out)) .rb-label { visibility: hidden; }
}
@media (max-width: 700px) {
  body.world-only .bv-card {
    inset: var(--world-card-top, calc(var(--header-clearance) + 100px)) calc(9px + var(--sa-r)) calc(140px + var(--sa-b)) calc(9px + var(--sa-l));
    width: auto; display: flex; align-items: flex-end; justify-content: center;
  }
  body.world-only .bv-card-in { width: 100%; max-width: none; max-height: min(100%, 44dvh); }
  body.world-only .bv-card-acts {
    position: sticky; bottom: -14px; z-index: 1; flex: none; padding: 8px 0;
    width: 100%; background: var(--card);
  }
}

@media (min-width: 701px) { body.world-only .bv-guide-groups { grid-template-columns: minmax(0, 1fr); } }

/* ── a phone held sideways: two cards a side, and Meru between them ─────────
   The header and the control strip are one width and a corner each
   (app-chrome.js). The rail under them was a third card the whole width of
   the screen, and it stood across the middle of the model — the spire of the
   heavens, which is what rises there, went behind it. Here the rail is two
   cards the width of the two above, one under each, so the screen is a
   mirrored pair of columns and a clear middle. The turn and Realms & path
   stand under the header; what is shown, Destinations and Game under the
   strip. Each is laid out against the width of those cards (--utility-width),
   so the four edges line up in either language. The rail itself draws
   nothing and takes no touches: the gap between its cards belongs to the
   model, and still turns it. */
@media (min-width: 701px) and (max-height: 500px) {
  body.world-only .board-view,
  body.world-only.index-open .board-view { pointer-events: none; }
  body.world-only .board-view > :not(.bv-rail) { pointer-events: auto; }
  body.world-only.game-view .bv-rail {
    --w: var(--utility-width, 336px);
    display: grid; align-items: center; gap: 0; padding: 0; border: 0; background: none;
    box-shadow: none; pointer-events: none;
    grid-template-columns:
      minmax(0, calc(var(--w) * .52)) minmax(0, calc(var(--w) * .48))
      minmax(0, 1fr)
      minmax(0, calc(var(--w) * .46)) minmax(0, calc(var(--w) * .28)) minmax(0, calc(var(--w) * .26));
    grid-template-rows: auto;
  }
  body.world-only.game-view .bv-rail::before,
  body.world-only.game-view .bv-rail::after {
    content: ''; grid-row: 1; align-self: stretch; z-index: 0; pointer-events: auto;
    background: var(--menu); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  body.world-only.game-view .bv-rail::before { grid-column: 1 / 3; }
  body.world-only.game-view .bv-rail::after { grid-column: 4 / 7; }
  body.world-only.game-view .bv-rail > * {
    position: relative; z-index: 1; grid-row: 1; order: 0; margin: 6px 3px; min-width: 0;
    pointer-events: auto;
  }
  body.world-only.game-view .bv-rail > .die-face,
  body.world-only.game-view .bv-rail > .bv-mid { display: none; }
  body.world-only.game-view .bv-rail > .bv-act { grid-column: 1; margin-left: 12px; max-width: none; flex: none; }
  body.world-only.game-view .bv-rail > .bv-guide { grid-column: 2; width: auto; margin-right: 6px; }
  body.world-only.game-view .bv-rail > .bv-views { grid-column: 4; width: auto; margin-left: 6px; }
  body.world-only.game-view .bv-rail > .bv-options { grid-column: 5; width: auto; }
  body.world-only.game-view .bv-rail > .bv-tools { grid-column: 6; width: auto; margin-right: 6px; }
  body.world-only.game-view .bv-rail > .bv-skip { grid-row: 2; grid-column: 1 / 3; margin: 6px 0 0; }
  body.world-only.game-view .bv-rail > .bv-views .btn { flex: 1 1 0; min-width: 0; padding: 8px 4px; letter-spacing: 0; font-size: 10px; }
  body.world-only.game-view .bv-rail > .bv-views .btn .g { display: none; }
  body.world-only.game-view .bv-rail > :is(.bv-guide, .bv-options, .bv-tools) > summary { width: 100%; box-sizing: border-box; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-inline: 4px; font-size: 10.5px; letter-spacing: .02em; }
  body.world-only.game-view .bv-rail .bv-guide-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.world-only.game-view .bv-rail .bv-guide > summary { display: flex; align-items: center; justify-content: center; }
  body.world-only.game-view .bv-rail .bv-turn { margin: 0; font-size: 12px; line-height: 1.25; }
}
/* On a phone upright the die is gone from the world's rail, and the switch
   between the board and the world was left in two thirds of its row under
   an empty third. It takes the row. */
@media (max-width: 700px) {
  body.world-only.game-view .bv-rail .bv-views { grid-column: 1 / -1; }
}
/* A small phone on its side (a width under 700px with 375px or less of
   height) has no room for two rows of controls over the model: the same
   four controls stand in one row. */
@media (max-width: 700px) and (max-height: 430px) {
  body.world-only.game-view .bv-rail { grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); }
  body.world-only.game-view .bv-rail .bv-views { grid-column: 1; grid-row: 1; order: 0; }
  body.world-only.game-view .bv-rail .bv-guide { grid-column: 2; grid-row: 1; order: 0; }
  body.world-only.game-view .bv-rail .bv-options { grid-column: 3; grid-row: 1; order: 0; }
  body.world-only.game-view .bv-rail .bv-tools { grid-column: 4; grid-row: 1; order: 0; }
  body.world-only.game-view .bv-rail > .bv-act { display: none; }
  body.world-only.game-view .bv-rail > .bv-skip { grid-column: 1 / -1; grid-row: 2; }
}
/* The three controls along the foot share it as thirds, as the two cards at
   the top of a wider screen do, and give way only to a word that will not
   fit: sized to their words they stood unevenly, each centred in a different
   share of the bar. */
@media (max-width: 700px) {
  .controls, body.board-only .controls { grid-template-columns: repeat(3, minmax(min-content, 1fr)); }
}
