/* Room layout overrides are last, and scoped to the current UI. */
.has-room-layout .mobile-tabs, .has-room-layout #mobile-nav, .has-room-layout .party-rail-m { display: none !important; }
.has-room-layout #room-sidebar { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.has-room-layout #room-sidebar h2 { font-size: 16px; margin: 0 0 10px; }
.has-room-layout #room-sidebar > section { padding: 14px; border: 1px solid var(--v2-line); border-radius: 10px; background: var(--v2-panel); }
.has-room-layout #room-sidebar #my-inventory { margin: 0 !important; border: 0; }
.has-room-layout #room-quests-empty { color: var(--v2-muted); font-size: 14px; line-height: 1.5; }
.room-mobile-nav, #room-mobile-nav { display: none; }
@media (min-width: 1180px) {
  .has-room-layout #room-grid { display: grid; grid-template-columns: minmax(210px, 260px) minmax(420px, 1fr) minmax(220px, 290px); align-items: start; gap: 18px; }
}
@media (min-width: 861px) and (max-width: 1179px) {
  .has-room-layout #room-grid { display: grid; grid-template-columns: minmax(210px, 260px) minmax(0, 1fr); }
  .has-room-layout #room-sidebar { grid-column: 2; }
}
@media (max-width: 860px) {
  .has-room-layout #room-grid { display: block; padding-bottom: calc(82px + env(safe-area-inset-bottom)); scroll-margin-top: 8px; }
  .has-room-layout #room-grid .party-column, .has-room-layout #room-grid .center-column, .has-room-layout #room-grid #room-sidebar, .has-room-layout #room-sidebar > section { display: none !important; }
  .has-room-layout #room-grid[data-view="journal"] .center-column, .has-room-layout #room-grid[data-view="hero"] .party-column, .has-room-layout #room-grid[data-view="inventory"] #room-sidebar, .has-room-layout #room-grid[data-view="quests"] #room-sidebar { display: flex !important; flex-direction: column; }
  .has-room-layout #room-grid[data-view="inventory"] #room-inventory, .has-room-layout #room-grid[data-view="quests"] #room-quests { display: block !important; }
  .has-room-layout #room-grid[data-view="gm"] .party-column { display: flex !important; flex-direction: column; }
  .has-room-layout #room-grid[data-view="gm"] .party-column > :not(.my-char-card), .has-room-layout #room-grid[data-view="gm"] .my-char-card > :not(#char-tools), .has-room-layout #room-grid[data-view="gm"] #char-tools > :not(#gm-panel):not(#gm-peek) { display: none !important; }
  .has-room-layout #room-grid[data-view="gm"] .my-char-card { padding: 0; border: 0; background: transparent; }
  .has-room-layout #room-mobile-nav:not([hidden]):has(#room-tab-gm:not([hidden])) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .has-room-layout #room-mobile-nav button[hidden] { display: none; }
  #gm-peek { display: none; }
  .has-room-layout #room-grid[data-view="gm"] #gm-peek { display: block; position: sticky; top: 0; z-index: 70; margin: 0 0 8px; padding: 8px 10px; border: 1px solid var(--v2-line); border-radius: 8px; background: #211b15; font-size: 13px; line-height: 1.4; max-height: 22vh; overflow: auto; }
  .has-room-layout #gm-peek small { display: block; opacity: .7; margin-bottom: 2px; }
  .has-room-layout #gm-peek div + div { margin-top: 3px; }
  .has-room-layout #room-mobile-nav:not([hidden]) { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); gap: 4px; border-top: 1px solid var(--v2-line); background: #181410; }
  .has-room-layout #room-mobile-nav button { min-height: 48px; padding: 6px 3px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--v2-muted); font: 600 13px system-ui; }
  .has-room-layout #room-mobile-nav button[aria-selected="true"] { color: var(--v2-gold); border-color: var(--v2-gold); background: #302516; }
  .has-room-layout #room-grid .scene-panel, .has-room-layout #room-grid #focus-strip, .has-room-layout #room-grid #my-badge { display: none !important; }
  .has-room-layout #room-grid .log-panel:not(.is-fullscreen) .log-feed { height: 52dvh; min-height: 230px; max-height: none; }
  .has-room-layout #room-grid .log-form { position: static; margin: 10px 0 0; }
  .has-room-layout .room-mobile .site-header { padding-block: 8px; }
  .has-room-layout #room-hero .char-portrait { max-width: 120px; }
  .has-room-layout .room-running #scenario-line, .has-room-layout .room-running #difficulty-line, .has-room-layout .room-running #scenario-panel { display: none !important; }
  body:has(#log-panel.is-fullscreen) #room-mobile-nav { display: none !important; }
}

#room-action-bar { display: none; }
.has-room-layout #room-tools { position: relative; margin-left: auto; }
.has-room-layout #room-tools summary { cursor: pointer; padding: 12px; border: 1px solid var(--v2-line); border-radius: 8px; min-height: 44px; }
.has-room-layout #room-tools > div { position: absolute; right: 0; top: 100%; z-index: 150; min-width: 240px; padding: 10px; background: #211b15; border: 1px solid var(--v2-line); border-radius: 8px; display: grid; gap: 6px; }
.has-room-layout #room-tools:not([open]) > div { display: none; }
.has-room-layout #room-tools .btn { display: flex; justify-content: flex-start; gap: 10px; width: 100%; min-height: 44px; }
.has-room-layout #room-tools .btn[hidden] { display: none; }
.has-room-layout #room-party-strip { display: flex; overflow-x: auto; gap: 6px; margin-bottom: 10px; }
.has-room-layout #room-party-strip button { flex: 0 0 110px; min-height: 48px; background: #211b15; border: 1px solid var(--v2-line); border-radius: 8px; padding: 6px 8px; color: var(--text, #eee5d3); text-align: left; }
.has-room-layout #room-party-strip span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.has-room-layout #room-party-strip small { color: var(--v2-muted); }
.has-room-layout button, .has-room-layout input, .has-room-layout select { touch-action: manipulation; }
.has-room-layout :is(button, summary, input, select):focus-visible { outline: 2px solid var(--v2-gold); outline-offset: 3px; }
@media (max-width: 860px) {
  .has-room-layout .room-mobile .site-header { display: none; }
  .has-room-layout .room-topbar .ready-count { display: none; }
  .has-room-layout .room-topbar .btn { min-width: 44px; min-height: 44px; }
  .has-room-layout #room-action-bar:not([hidden]) { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: calc(69px + env(safe-area-inset-bottom)); z-index: 81; padding: 5px 8px; gap: 5px; background: #211b15; border-top: 1px solid var(--v2-line); }
  .has-room-layout #room-action-bar button { min-height: 44px; border: 1px solid var(--v2-line); border-radius: 7px; color: var(--v2-gold); background: #302516; font: 600 12px system-ui; }
  .has-room-layout #room-action-bar button:disabled { color: #aaa; background: #211b15; }
  .has-room-layout #room-grid[data-view="journal"] #form-message { position: fixed; left: 8px; right: 8px; bottom: calc(124px + env(safe-area-inset-bottom)); z-index: 82; margin: 0; background: #211b15; padding: 7px; border: 1px solid var(--v2-line); border-radius: 8px; }
  .has-room-layout #room-grid .log-panel:not(.is-fullscreen) .log-feed { height: max(160px, calc(var(--room-visible-height, 100dvh) - 350px)); min-height: 160px; }
  .has-room-layout #quick-actions { display: none !important; }
  .has-room-layout #room-grid { padding-bottom: 200px; }
  .has-room-layout .room-keyboard #room-mobile-nav, .has-room-layout .room-keyboard #room-action-bar { display: none !important; }
  .has-room-layout .room-keyboard #room-grid[data-view="journal"] #form-message { bottom: calc(var(--room-keyboard-offset, 0px) + 8px); }
  .has-room-layout #log-panel-head-actions button, .has-room-layout .log-panel-head-actions button { min-width: 44px; min-height: 44px; }
  .has-room-layout #message-input { font-size: 16px; min-height: 44px; }
}

.has-room-layout #room-view-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; align-items: start; }
.has-room-layout #room-view-options button, .has-room-layout #room-reading summary { min-height: 44px; padding: 10px 14px; border: 1px solid var(--v2-line); border-radius: 8px; background: #211b15; color: var(--v2-gold); cursor: pointer; }
.has-room-layout #room-reading { position: relative; margin-left: auto; }
.has-room-layout #room-reading[open] { padding: 10px; background: #211b15; border: 1px solid var(--v2-line); border-radius: 8px; }
.has-room-layout #room-reading label { display: grid; grid-template-columns: 1fr minmax(140px, 1fr); align-items: center; gap: 12px; margin-top: 10px; color: var(--v2-muted); }
.has-room-layout #room-reading select { min-height: 44px; }
.has-room-layout .log-entry { font-size: var(--room-font, 16px); line-height: 1.65; }
.has-room-layout .log-entry-body { max-width: var(--room-text-width, 72ch); }
.has-room-layout #room-status { padding: 10px 12px; margin: 0 0 10px; color: var(--v2-muted); border-left: 3px solid var(--v2-line); font-size: 14px; }
.has-room-layout #room-status.is-important { color: var(--v2-gold); border-color: var(--v2-gold); background: #302516; }
.has-room-layout #room-hero .my-char-card > .char-portrait, .has-room-layout #room-hero .my-char-card > h3, .has-room-layout #focus-strip, .has-room-layout #my-badge { display: none !important; }
.has-room-layout #room-inventory > h2 { display: none; }
.has-room-layout #room-grid > .party-column > .party-list, .has-room-layout #room-grid > .party-column > .col-title { display: none; }
.has-room-layout #room-grid .my-char-card, .has-room-layout #room-grid .log-panel:not(.is-fullscreen) { box-shadow: none; }
.room-reduce-motion *, .room-reduce-motion *::before, .room-reduce-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
@media (min-width: 861px) {
  .has-room-layout #room-grid.hero-closed .party-column, .has-room-layout #room-grid.side-closed #room-sidebar { display: none; }
  .has-room-layout #room-grid.hero-closed { grid-template-columns: minmax(420px, 1fr) minmax(220px, 290px); }
  .has-room-layout #room-grid.hero-closed #room-sidebar { grid-column: 2; }
  .has-room-layout #room-grid.side-closed { grid-template-columns: minmax(210px, 260px) minmax(420px, 1fr); }
  .has-room-layout #room-grid.hero-closed.side-closed { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .has-room-layout #room-view-options > button { display: none; }
  .has-room-layout #room-view-options { margin: 0 0 6px; }
  .has-room-layout #room-reading { margin-left: 0; width: 100%; }
  .has-room-layout #room-reading:not([open]) { width: auto; }
  .has-room-layout #room-reading summary { padding: 7px 10px; min-height: 36px; font-size: 13px; }
  .has-room-layout #room-action-bar button[aria-disabled="true"] { opacity: .6; }
  .has-room-layout #quick-actions:has(#quick-targets:not([hidden])) { display: block !important; position: fixed; left: 8px; right: 8px; bottom: calc(185px + env(safe-area-inset-bottom)); z-index: 90; padding: 12px; background: #211b15; border: 1px solid var(--v2-gold); border-radius: 8px; }
  .has-room-layout #quick-actions #quick-row { display: none; }
  .has-room-layout #quick-targets .quick-btn { min-height: 44px; }
}

.has-room-layout #room-party-strip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; object-position: center 12%; float: left; margin-right: 5px; }
.has-room-layout #room-party-detail { width: min(90vw, 400px); border: 1px solid var(--v2-gold); border-radius: 12px; background: #211b15; color: #eee5d3; padding: 24px; }
.has-room-layout #room-party-detail::backdrop { background: rgba(0,0,0,.65); }
.has-room-layout #room-party-detail button { min-height: 44px; padding: 10px 20px; }
@media (max-width: 860px) { .has-room-layout.room-show-scene #room-grid .scene-panel:not([hidden]) { display: block !important; } .has-room-layout #room-grid .scene-art { height: 140px; } }

@media (max-width: 860px) {
 .has-room-layout .log-panel-head { flex-direction: column; gap: 8px; }
 .has-room-layout .log-panel-head-actions { max-width: 100%; width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: 5px; }
 .has-room-layout #lang-switch { position: static; margin: 8px; }
 .has-room-layout #room-reading summary { min-height: 44px; }
}

.has-room-layout #room-grid { grid-template-rows: auto; }
.has-room-layout #room-grid > .party-column { display: flex; flex-direction: column; gap: 12px; grid-column: auto; grid-row: auto; min-width: 0; }
.has-room-layout #room-grid > .center-column, .has-room-layout #room-grid > #room-sidebar { grid-row: auto; grid-column: auto; min-width: 0; }
.has-room-layout #room-grid .party-column > .my-char-card { margin: 0; }
.has-room-layout .log-panel-head { flex-wrap: wrap; gap: 8px; }
.has-room-layout .log-panel-head-actions { max-width: 100%; flex-wrap: wrap; }
@media (min-width:861px) and (max-width:1179px) { .has-room-layout #room-grid > #room-sidebar { grid-column: 2; } }
@media (min-width:861px) { .has-room-layout #room-grid.hero-closed > .party-column, .has-room-layout #room-grid.side-closed > #room-sidebar { display:none; } }

.has-room-layout #room-tools #lang-switch { position: static !important; margin: 4px; }
@media (max-width: 860px) { .has-room-layout .log-panel-head-actions { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; } .has-room-layout .log-panel-head-actions > * { flex-shrink: 0; } }

@media (max-width: 860px) {
 .has-room-layout #room-grid[data-view="journal"] .log-panel.is-fullscreen #form-message { position: static; margin-top: 10px; }
 .has-room-layout body:has(#log-panel.is-fullscreen) #room-action-bar { display: none !important; }
}

.has-room-layout .room-language { display:flex; gap:8px; }
.has-room-layout .room-language a { display:inline-flex; align-items:center; justify-content:center; min-width:44px; min-height:44px; color:var(--v2-gold); }
.has-room-layout body.room-mobile > #lang-switch { display:none !important; }

.has-room-layout #screen-room .room-topbar { position:relative; z-index:160; overflow:visible; }
.has-room-layout #room-tools .btn { width:100% !important; max-width:none; height:auto; white-space:normal; text-align:left; }
.has-room-layout #room-tools .btn > span { display:none; }
.has-room-layout #room-tools .btn { display:flex !important; align-items:center; gap:10px; }
.has-room-layout #room-tools .btn::after { content:attr(aria-label); font-size:14px; letter-spacing:normal; }
.has-room-layout #room-tools > div { max-height:65dvh; overflow-y:auto; }

/* Keep optional log controls out of the reading area. */
.has-room-layout #room-log-tools { position:relative; }
.has-room-layout #room-log-tools summary { min-height:44px; padding:10px; cursor:pointer; border:1px solid var(--v2-line); border-radius:7px; color:var(--v2-gold); font:600 13px system-ui; }
.has-room-layout #room-log-tools > div { position:absolute; right:0; top:100%; z-index:170; width:260px; padding:8px; background:#211b15; border:1px solid var(--v2-line); border-radius:8px; display:grid; gap:5px; }
.has-room-layout #room-log-tools:not([open]) > div { display:none; }
.has-room-layout #room-log-tools button { display:flex; align-items:center; gap:10px; width:100%; min-height:44px; text-align:left; }
.has-room-layout #room-log-tools button::after { content:attr(aria-label); font:14px var(--font-body); }
.has-room-layout .log-panel-head-actions { overflow:visible; }
.has-room-layout #room-action-help { margin-top:12px; padding:10px; border-top:1px solid var(--v2-line); font:14px/1.5 var(--font-body); }
.has-room-layout #room-action-help summary { min-height:44px; cursor:pointer; color:var(--v2-gold); display:list-item; padding-top:10px; }
.has-room-layout #room-action-help p { color:var(--v2-muted); }
.has-room-layout #room-action-help button, .has-room-layout #room-action-help a { display:block; min-height:44px; margin:6px 0; padding:10px; border:1px solid var(--v2-line); border-radius:7px; background:#211b15; color:var(--v2-gold); text-align:left; font:14px var(--font-body); }
@media (max-width:860px) { .has-room-layout .log-panel-head-actions { flex-wrap:wrap; } .has-room-layout #room-log-tools > div { left:0; right:auto; width:min(260px,75vw); } }

/* Scene illustrations are shown by default; the explicit user toggle hides them. */
.has-room-layout:not(.room-show-scene) #room-grid .scene-panel { display:none !important; }
.has-room-layout #room-tools .idle-skip-toggle { display:flex; align-items:center; gap:10px; width:100%; margin:0; padding:10px 12px; box-sizing:border-box; font-size:14px; white-space:normal; }
.journey-help,.journey-weekly,.journey-return { border:1px solid #73603b; border-radius:12px; padding:14px 16px; margin:12px 0; background:var(--panel,#211b14); color:var(--text,#eee5d3); }
.journey-help p,.journey-weekly p,.journey-return p { margin:8px 0; }
.journey-actions { display:flex; flex-wrap:wrap; gap:8px; margin:10px 0; }
.journey-goal { border-left:3px solid #d9b25a; padding:8px 12px; margin:8px 0; overflow-wrap:anywhere; }
.journey-dialog { max-width:600px; width:calc(100% - 40px); max-height:85dvh; overflow:auto; box-sizing:border-box; border:1px solid #d9b25a; border-radius:14px; background:#211b14; color:#eee5d3; padding:20px; }
.journey-dialog::backdrop { background:rgba(0,0,0,.65); }
.journey-dialog textarea,.journey-dialog select { display:block; box-sizing:border-box; width:100%; padding:10px; margin:10px 0; font:inherit; color:inherit; background:#17120e; border:1px solid #73603b; border-radius:8px; }
.journey-dialog button,.journey-help button { margin:4px; }
.journey-dialog p { overflow-wrap:anywhere; }
.journey-card-preview { display:block; width:100%; height:auto; margin:14px 0; border-radius:8px; }
.journey-card-preview[hidden] { display:none; }
.journey-dialog .journey-card-size { font-size:13px; color:#cfc2aa; }
.journey-dialog .journey-card-error { color:#ffd0aa; }
.journey-help[hidden],.journey-goal[hidden] { display:none!important; }
