/* The adventure-book presentation. Game rules and server events stay unchanged. */
:root {
  --bg: #101511; --panel: #19201a; --input: #101711;
  --text: #ece8dc; --muted: #a7b09e; --accent: #d6b77c; --line: #354133;
}
body { background: var(--bg); }
.app { max-width: 1360px; padding: 28px 40px 48px; }
header { display: flex; align-items: center; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid #a6af9428; margin-bottom: 32px; }
header h1 { font-size: 20px; letter-spacing: .12em; display: flex; align-items: center; gap: 12px; }
.brand-mark { color: var(--accent); font-size: 28px; }
.brand-subtitle { font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); }
.subtitle { margin: 0 60px 0 auto; font: 12px var(--ui); }
.backdrop-shade { background: linear-gradient(90deg, #0c120feb, #0c120f99 60%, #0c120f55), linear-gradient(0deg, #0b110fe8, transparent 70%); }
#backdrop.landing .backdrop-shade { background: linear-gradient(90deg, #0c120fe0, #0c120fa8 54%, #0c120f4d), linear-gradient(0deg, #0b110fb8, transparent 70%); }
#backdrop.landing .backdrop-layer { background-position: 65% center; }
#backdrop.tense .backdrop-shade { background: linear-gradient(90deg, #170e0be8, #10150c99), linear-gradient(0deg, #130d09e0, transparent); }
/* A shared party backdrop, while the landing page keeps its own scene. */
body.in-play #backdrop { background: #0e1613 url("/assets/backgrounds/party.png?v=1") center / cover no-repeat; }
body.in-play #backdrop .backdrop-layer { display: none; }
body.in-play #backdrop .backdrop-shade { background: linear-gradient(180deg, #06120e18, #06120e4d); }
@media (max-width: 860px) {
  body.in-play #backdrop { background-size: auto calc(100% + 100px); background-position: center bottom; }
}
.sound-toggle { top: 31px; right: max(24px, calc((100vw - 1280px) / 2)); }
.sound-panel { top: 68px; background: #161d18; border-color: var(--line); border-radius: 8px; padding: 18px; }
.eyebrow, .section-caption { font: 11px var(--ui); text-transform: uppercase; letter-spacing: .2em; color: var(--accent); }
.creation-intro { margin: 38px 0 30px; }
.creation-intro h2 { font: normal clamp(32px, 4.3vw, 58px)/1.08 var(--story); letter-spacing: -.025em; margin: 16px 0; }
.creation-intro > p:last-child { max-width: 48ch; color: #bcc4b5; line-height: 1.7; font-size: 16px; }
.create-layout { grid-template-columns: minmax(0, 560px) minmax(270px, 370px); justify-content: space-between; gap: 60px; }
#create-form { padding: 26px 30px; background: #151d17ed; border: 1px solid #6f805145; border-radius: 8px; }
#create-form .section-caption { margin: 0 0 24px; }
label { color: #c6cbbb; font-size: 12px; }
input, select { background: #0c140f; border-color: #3a4937; border-radius: 4px; font: 15px var(--ui); padding: 13px 14px; margin-bottom: 20px; }
input::placeholder { color: #869180; opacity: 1; }
button, input, summary { transition: border-color .18s, background-color .18s; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
input:focus { outline: 2px solid #d6b77c66; outline-offset: 1px; border-color: var(--accent); }
.class-grid { gap: 10px; margin: 14px 0 20px; }
.class-card { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 0 10px; align-items: center; padding: 13px; border-radius: 5px; background: #101812; }
.class-card .avatar { grid-row: span 2; width: 30px; height: 30px; opacity: .8; }
.class-card strong { font-size: 14px; margin: 0 0 4px; }
.class-card .class-hp { margin: 0; color: var(--muted); font-size: 11px; }
.class-card.selected { border-color: var(--accent); background: #d6b77c12; }
.class-card.selected::after { content: '✓'; position: absolute; right: 9px; top: 8px; color: var(--accent); font-size: 10px; }
#create-form button[type=submit] { min-height: 48px; border-radius: 4px; display: flex; justify-content: space-between; align-items: center; padding: 13px 18px; font-size: 14px; }
#create-form .hint { font: 11px/1.65 var(--ui); margin: 12px 0 0; }
#create-error:not(:empty) { color: #efaaa0; margin-bottom: 12px; }
.class-portrait { padding: 0 26px 24px; align-self: start; margin-top: -180px; background: #101710ba; border: 1px solid #93a08038; border-radius: 120px 120px 8px 8px; }
.class-portrait > .eyebrow { margin: 32px 0 18px; font-size: 9px; }
.portrait-frame { width: 100%; display: flex; justify-content: center; border-bottom: 1px solid #a4aa7c45; background: radial-gradient(ellipse at center, #64744735, transparent 65%); }
.class-portrait img { width: 280px; max-width: 100%; background: transparent; border: 0; image-rendering: auto; }
.class-portrait #class-portrait-name { font: 30px var(--story); color: var(--text); text-transform: none; letter-spacing: 0; margin: 18px 0; }
#class-details { width: 100%; font: 12px/1.75 var(--ui); color: #c2c9b8; }
#class-details > span > .avatar, #class-details > span > strong { display: none; }
#class-details > span > span { display: block; margin-bottom: 12px; }
#class-details .class-hp { color: var(--accent); text-align: center; font-size: 11px; letter-spacing: .08em; }
.resume-section { max-width: 560px; margin: 20px 0 0; color: var(--muted); font: 12px/1.6 var(--ui); }
.resume-section summary { cursor: pointer; padding: 12px 0; }
#resume-form { padding: 16px; background: #111912; border: 1px solid var(--line); border-radius: 5px; }
#resume-form input { margin-bottom: 12px; }
body.in-play .app { height: 100dvh; padding: 18px 28px 0; }
body.in-play header { flex: none; padding-bottom: 12px; margin-bottom: 20px; }
body.in-play header h1 { margin: 0; }
body.in-play .sound-toggle { top: 25px; }
.stage { grid-template-columns: 190px minmax(0, 1fr) 126px; gap: 24px; }
.party-panel { min-width: 0; min-height: 0; overflow: auto; }
.party-panel > .section-caption { margin: 0 0 18px; color: var(--muted); }
.party-col { position: static; gap: 12px; max-height: none; scrollbar-color: #526046 #141b15; scrollbar-width: thin; }
.hero-card { background: #111913dd; border-color: #78836338; padding: 14px 10px; border-radius: 5px; }
.hero-card.me { background: #222d20e8; border-color: #8d97634f; }
.hero-card .avatar { width: 38px; height: 38px; border-radius: 7px; background: #b9b9890d; }
.hero-card .who strong { font: normal 17px var(--story); overflow-wrap: anywhere; }
.hero-card .who .muted { font-size: 10px; }
.hero-card .hp-line { margin-top: 10px; gap: 6px; }
.hero-card .hp-num { font-size: 10px; }
.hero-card .status { margin-top: 7px; font-size: 9px; letter-spacing: .06em; }
.side-rail { position: static; gap: 12px; overflow: auto; }
.rail-button { padding: 14px 10px; background: #182219; border-color: #78836345; border-radius: 4px; font-size: 10px; }
.side-rail .ghost-button { font-size: 9px; letter-spacing: .06em; }
.die-window, .turn-window { background: #131b15c9; border-color: #78836338; border-radius: 5px; padding: 16px 8px; }
.die-window { order: -1; }
.die-face { font: 40px var(--story); color: var(--accent); }
.turn-count { font: 24px var(--story); }
.rail-caption { font-size: 9px; }
.die-note { font-size: 10px; line-height: 1.5; }
.adventure { position: relative; padding: 0 0 16px; }
.adventure h2 { font: normal clamp(23px, 2.6vw, 36px)/1.16 var(--story); color: #e8dfc9; overflow-wrap: anywhere; }
.adventure .location { color: #b4c1a5; font-size: 11px; margin: 8px 0 0; }
#new-adventure { font-size: 9px; letter-spacing: .05em; padding-top: 10px; }
.journal-heading { display: flex; justify-content: space-between; align-items: center; padding: 13px 28px; background: #1a241b; border: 1px solid #74815d55; border-bottom: 0; border-radius: 7px 7px 0 0; font: 10px var(--ui); letter-spacing: .15em; text-transform: uppercase; color: var(--accent); }
#log { background: #141b15f5; border: 1px solid #74815d55; border-top-color: #74815d30; border-radius: 0 0 7px 7px; padding: 26px 32px 40px; font-size: 18px; box-shadow: 0 16px 50px #00000020; scrollbar-color: #526046 #141b15; scrollbar-width: thin; overflow-wrap: anywhere; }
#log .game-master { line-height: 1.85; white-space: pre-wrap; color: #e2e5d7; margin: 12px 0 26px; }
#log .round-title { display: flex; align-items: center; gap: 14px; margin: 26px 0 16px; color: var(--accent); font-size: 10px; letter-spacing: .18em; }
#log .round-title::after { content: ''; height: 1px; flex: 1; background: #8b976536; }
#log > .round-title:first-child { margin-top: 0; }
#log .quote { font-size: .84em; color: #adb7a4; padding-left: 12px; border-left: 1px solid #536447; }
#log .quote-name { color: #d0d9c3; font-size: 11px; }
#log .system { font: 11px/1.7 var(--ui); color: #9aa68e; }
.dice-card { padding: 12px 16px; border-radius: 4px; background: #a0b48d08; margin: 4px 0 10px; }
.dice-kicker { font-size: 10px; letter-spacing: .12em; }
.dice-grid { margin: 12px 0; }
.tone-success { border-left-color: #81bb8c; background: #79c99009; }
.tone-crit-success { border-left-color: #94d5a0; background: #79c9900c; box-shadow: inset 0 0 0 1px #94d5a030; }
#log .tone-success .dice-kicker, #log .tone-success .dice-result,
#log .tone-crit-success .dice-kicker, #log .tone-crit-success .dice-result,
.die-window.tone-crit-success .die-face, .die-window.tone-crit-success .die-note { color: #a7d9ae; }
.tone-failure, .tone-crit-failure { border-left-color: #df8179; background: #d477760b; }
.tone-loot { border-left-color: #b598e0; background: #ba96e20c; }
#log .tone-loot .dice-kicker, #log .tone-loot .dice-note { color: #d0b8ed; }
.tone-discovery { border-left-color: #88b9dc; background: #88b9dc0a; }
.tone-important { border-left-color: var(--accent); background: #d6b77c09; }
.action-dock { grid-template-columns: 190px minmax(0, 1fr) 126px; gap: 8px 24px; padding: 16px 0 18px; background: linear-gradient(0deg, #101710, #101710f5 70%, #10171000); }
.action-dock input { background: #101912; border: 1px solid #74815d70; border-radius: 4px; padding: 14px; font-size: 15px; }
.action-dock input:focus { outline: 2px solid #d6b77c77; outline-offset: 1px; }
.action-dock .hint { font-size: 10px; line-height: 1.5; color: #b7c0ae; }
.action-dock button { min-width: 110px; padding: 15px; border-radius: 4px; }
#retry-round { grid-column: 2; justify-self: start; padding: 10px 16px; }
.modal-card, .drawer aside { background: #151e17; border-color: #687453; border-radius: 7px; }
.drawer aside { border-radius: 0; }
body.no-motion *, body.no-motion *::after { animation: none !important; transition: none !important; }
@media (max-width: 1000px) {
  .stage { grid-template-columns: 160px minmax(0, 1fr) 100px; gap: 14px; }
  .action-dock { grid-template-columns: 160px minmax(0, 1fr) 100px; column-gap: 14px; }
  .create-layout { gap: 30px; }
  .class-portrait { margin-top: -120px; padding-inline: 18px; }
}
@media (max-width: 860px) {
  .app { padding: 20px 22px 32px; }
  header { margin-bottom: 20px; padding-bottom: 16px; }
  .subtitle { display: none; }
  .sound-toggle { top: 27px; right: 22px; }
  .creation-intro { margin: 26px 0; }
  .creation-intro h2 { font-size: 38px; }
  .create-layout { grid-template-columns: minmax(0, 1fr) 240px; gap: 18px; }
  #create-form { padding: 22px; }
  .class-portrait { order: initial; margin: 0; border-radius: 80px 80px 6px 6px; }
  .class-portrait img { width: 180px; }
  body.in-play .app { height: 100dvh; min-height: 0; overflow: hidden; padding: 16px 18px 0; }
  body.in-play { overflow: hidden; }
  body.in-play header { margin-bottom: 12px; }
  body.in-play .stage { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); gap: 10px; flex: 1; min-height: 0; align-items: stretch; }
  .party-panel { order: 0; overflow: hidden; }
  .party-panel > .section-caption { display: none; }
  .party-col { flex-direction: row; overflow-x: auto; gap: 8px; }
  .hero-card { flex: 0 0 170px; padding: 9px; }
  .hero-card .avatar { width: 28px; height: 28px; }
  .hero-card .who strong { font-size: 15px; }
  .hero-card .hp-line { margin-top: 4px; }
  .hero-card .status { margin-top: 2px; }
  .side-rail { order: 1; display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 8px; overflow: visible; }
  .side-rail .rail-button { padding: 8px 12px; width: auto; }
  .die-window, .turn-window { padding: 6px 10px; display: flex; gap: 8px; align-items: center; }
  .die-window { order: 0; }
  .die-note { display: none; }
  .die-face, .turn-count { font: 19px var(--story); margin: 0; }
  .scene { order: 2; min-height: 0; }
  .adventure { padding-bottom: 10px; }
  .adventure h2 { font-size: 23px; }
  .adventure .location { padding-right: 120px; }
  #new-adventure { position: absolute; right: 0; bottom: 8px; padding: 2px; }
  .journal-heading { padding: 10px 18px; font-size: 9px; }
  #log, body.in-play #log { height: auto; min-height: 0; padding: 18px 20px 24px; font-size: 17px; }
  .action-dock { grid-template-columns: minmax(0, 1fr); padding: 12px 0; }
  .dock-line, .action-dock .hint, #retry-round { grid-column: 1; }
  .action-dock input { padding: 12px; font-size: 14px; }
  .action-dock button { padding: 12px; min-width: 90px; }
}
@media (max-width: 580px) {
  #backdrop.landing .backdrop-layer { background-position: 85% center; }
  .class-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .class-card { padding: 10px 8px; grid-template-columns: 24px minmax(0, 1fr); gap: 0 6px; }
  .class-card .avatar { width: 24px; height: 24px; }
  .class-card strong { font-size: 12px; }
  .brand-subtitle { font-size: 8px; max-width: 100px; line-height: 1.6; }
  .create-layout { display: flex; flex-direction: column; }
  #create-form { width: 100%; }
  .class-portrait { width: 100%; display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 0 18px; padding: 18px; border-radius: 6px; }
  .class-portrait > .eyebrow { display: none; }
  .portrait-frame { grid-row: span 2; border: 0; align-self: start; }
  .class-portrait img { width: 108px; }
  .class-portrait #class-portrait-name { margin: 0 0 12px; font-size: 24px; }
  #class-details { font-size: 11px; }
  #class-details .class-hp { text-align: left; }
  .side-rail { grid-template-columns: auto auto 1fr auto; gap: 5px; }
  .side-rail .ghost-button { font-size: 8px; letter-spacing: 0; }
  .side-rail .rail-button { font-size: 9px; padding: 8px; }
  .die-window, .turn-window { padding: 6px; gap: 5px; }
  .rail-caption { font-size: 8px; }
  .dock-line { gap: 7px; }
  .creation-intro h2 { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
/* Workspace: party and chat / story / dice and chronicle. */
body.in-play .app { max-width: 1600px; }
body.in-play .stage { grid-template-columns: 240px minmax(0, 1fr) 220px; gap: 20px; }
body.in-play .action-dock { grid-template-columns: 240px minmax(0, 1fr) 220px; column-gap: 20px; }
.party-panel { display: flex; flex-direction: column; overflow: hidden; }
.party-panel > .section-caption { flex: none; }
.party-col { overflow-y: auto; flex: 0 1 auto; max-height: 44%; }
.chat-panel, .chronicle-panel { background: #131d16e8; border: 1px solid #74815d55; border-radius: 6px; padding: 14px; min-height: 0; display: flex; flex-direction: column; }
.chat-panel { margin-top: 18px; flex: 1; min-height: 210px; }
.chat-panel h2, .chronicle-panel h2 { font: 11px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 10px; }
.panel-help { font: 11px/1.6 var(--ui); color: var(--muted); margin: 6px 0 12px; }
#chat-messages, #chronicle { overflow: auto; scrollbar-color: #526046 #141b15; scrollbar-width: thin; overflow-wrap: anywhere; min-height: 0; flex: 1; }
#chat-messages { font: 13px/1.65 var(--ui); }
#chat-messages p { margin: 0 0 12px; white-space: pre-wrap; }
#chat-messages strong { color: #d6b77c; }
#chat-form { margin: 12px 0 0; padding: 0; width: 100%; max-width: none; }
#chat-form label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#chat-input { width: 100%; margin: 0 0 8px; padding: 10px; font-size: 12px; }
#chat-form button { width: 100%; padding: 9px; font-size: 11px; }
#chat-error { font: 11px/1.4 var(--ui); color: #efa69e; margin: 6px 0 0; }
#chat-error:empty { display: none; }
.side-rail { display: flex; flex-direction: column; overflow: hidden; }
.side-rail .die-window { order: 0; flex: none; }
.side-rail .chronicle-panel { order: 1; flex: 1; min-height: 160px; }
.side-rail .turn-window { order: 2; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.side-rail #recovery-button { order: 3; flex: none; }
#chronicle { font: 14px/1.65 var(--story); }
#chronicle p { margin: 0 0 12px; padding-bottom: 10px; border-bottom: 1px solid #74815d20; }
#chronicle .round-title { color: var(--accent); font: 10px var(--ui); margin-top: 14px; border: 0; }
#profile-card { width: min(900px, 100%); max-height: 90dvh; padding: 26px; scrollbar-color: #526046 #141b15; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.profile-section { min-width: 0; padding: 18px; background: #101912; border: 1px solid #74815d35; border-radius: 5px; }
.profile-section h3 { margin: 0 0 14px; color: var(--accent); font: 11px var(--ui); letter-spacing: .12em; text-transform: uppercase; }
.profile-section p { line-height: 1.6; margin: 0 0 8px; }
.profile-health { color: #a7d9ae; }
.profile-wide { grid-column: 1 / -1; }
.stats-scroll { overflow: auto; }
.check-table { width: 100%; border-collapse: collapse; font: 13px/1.6 var(--ui); }
.check-table th { color: #b3bea8; font-size: 10px; text-align: left; font-weight: normal; }
.check-table td, .check-table th { padding: 10px 12px; border-bottom: 1px solid #74815d35; vertical-align: top; }
.check-table td:nth-child(3) { color: var(--accent); font-weight: 600; white-space: nowrap; }
.check-table td:last-child { color: #b3bea8; }
.check-table + p, .stats-scroll + p { margin-top: 14px; }
.inventory-slots { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 0; margin: 12px 0 18px; }
.inventory-slots li { display: flex; flex-direction: column; gap: 10px; min-height: 90px; padding: 12px; border: 1px solid #78836360; border-radius: 4px; font: 13px/1.5 var(--ui); overflow-wrap: anywhere; }
.inventory-slots .occupied { background: #263022; }
.inventory-slots .empty { border-style: dashed; color: #8b9882; }
.slot-number { color: #a99b78; font: 10px var(--ui); }
@media (min-width: 861px) and (max-width: 1150px) {
  body.in-play .stage, body.in-play .action-dock { grid-template-columns: 190px minmax(0, 1fr) 180px; gap: 12px; }
  #log { padding-inline: 20px; }
}
@media (max-width: 860px) {
  body.in-play { overflow: auto; }
  body.in-play .app { height: auto; min-height: 100dvh; overflow: visible; }
  body.in-play .stage { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; grid-template-areas: 'party' 'scene' 'tools' 'chat'; }
  .party-panel { display: contents; }
  .party-col { grid-area: party; max-height: none; overflow-x: auto; }
  .scene { grid-area: scene; }
  #log, body.in-play #log { height: 48dvh; min-height: 260px; flex: none; }
  .side-rail { grid-area: tools; display: grid; grid-template-columns: 110px minmax(0, 1fr); grid-template-rows: auto auto auto; gap: 10px; }
  .side-rail .die-window { grid-column: 1; grid-row: 1; display: block; }
  .side-rail .die-note { display: block; }
  .side-rail .die-face { font-size: 30px; }
  .side-rail .chronicle-panel { grid-column: 2; grid-row: 1 / 4; height: 210px; }
  .side-rail .turn-window { grid-column: 1; grid-row: 2; padding: 8px; }
  .side-rail #recovery-button { grid-column: 1; grid-row: 3; }
  .chat-panel { grid-area: chat; height: 270px; margin: 0; }
  body.in-play .action-dock { grid-template-columns: minmax(0, 1fr); }
  .profile-grid { grid-template-columns: minmax(0, 1fr); }
  #profile-card { padding: 16px; }
  .profile-section { padding: 12px; }
  .inventory-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .check-table { min-width: 520px; }
}
.room-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; max-width: 950px; }
.room-forms form { padding: 24px; border: 1px solid #74815d55; background: #131d16ed; border-radius: 6px; margin: 0; max-width: none; }
.room-forms h2 { font: 26px var(--story); margin: 0 0 24px; }
#room-error { color: #efa69e; }
#room-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 12px; font: 11px var(--ui); color: var(--accent); }
#room-toolbar a { color: var(--muted); }
#room-toolbar button { font-size: 10px; }
.room-identity, .room-expiry-help { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.room-expiry-help { position: relative; }
#room-expiry-button { display: none; }
body.in-play #room-toolbar { flex: none; }
@media (max-width: 650px) { .room-forms { grid-template-columns: minmax(0, 1fr); } }
/* Room administration lives in a scrollable dialog, outside the action dock. */
#creator-menu-open[hidden], .game-menu-dialog [hidden] { display: none !important; }
#host-controls { display: flex; flex-direction: column; gap: 8px; }
#host-controls > div { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; border-top: 1px solid #74815d44; padding-top: 10px; }
.game-menu-dialog { width: min(620px, calc(100vw - 32px)); max-width: none; max-height: min(80dvh, 720px); box-sizing: border-box; overflow-y: auto; padding: 22px; border: 1px solid #a18b56; border-radius: 8px; background: #172118; color: #f0eee7; }
.game-menu-dialog::backdrop { background: #000b; }
.game-menu-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding-bottom: 8px; background: #172118; }
.game-menu-head h2 { margin: 0; font: 26px/1.2 var(--story); }
.game-menu-head form { flex: none; }
.game-menu-head button { padding: 4px 0; }
.game-menu-dialog h3 { margin: 18px 0 10px; color: var(--accent); font: 12px var(--ui); letter-spacing: .1em; text-transform: uppercase; }
.game-menu-dialog h4 { margin: 0; font: 18px var(--story); }
#recovery-controls { display: grid; gap: 10px; }
.creator-player-controls { display: grid; gap: 9px; padding: 12px; border: 1px solid #74815d55; border-radius: 6px; background: #101a13; }
.creator-player-controls > button { justify-self: start; }
.creator-player-controls label { display: flex; align-items: flex-start; gap: 8px; font: 13px/1.4 var(--ui); }
.creator-player-controls input { width: auto; flex: none; margin: 2px 0 0; }

/* Playtest fixes: distinguish authored actions without recolouring outcomes. */
#log .quote { border-left-color: var(--hero-color, #536447); }
#log .quote-name { color: var(--hero-color, #d0d9c3); }
.modal { z-index: 40; }
#profile-card h2 { min-width: 0; overflow-wrap: anywhere; }
.action-dock label.secret-action { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; display: flex; align-items: center; gap: 6px; flex: none; font-size: 12px; }
.action-dock .secret-action input { width: 18px; height: 18px; flex: none; padding: 0; margin: 0; }
@media (max-width: 860px) {
  .stage > *, .party-col, .side-rail, .chat-panel { min-width: 0; }
  .party-col { width: 100%; }
  body.in-play .action-dock { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  #host-controls { overflow-wrap: anywhere; }
  #room-toolbar { overflow-wrap: anywhere; }
  body.in-play #room-toolbar .room-identity { display: none; }
  body.in-play #room-toolbar #creator-menu-open { font-size: 0; }
  body.in-play #room-toolbar #creator-menu-open::after { content: "Меню"; font-size: 10px; }
  input, select, .action-dock input, #chat-input { font-size: 16px; }
  button, .ghost-button, .side-rail .ghost-button { min-height: 44px; }
  .sound-panel { max-height: 70dvh; overflow-y: auto; max-width: calc(100vw - 24px); }
}
@media (max-width: 420px) {
  .app, body.in-play .app { padding-left: 12px; padding-right: 12px; }
  header { padding-right: 48px; gap: 8px; }
  header h1 { gap: 8px; font-size: 17px; }
  .sound-toggle { right: 12px; }
  .room-forms form, #create-form { padding: 18px 14px; }
  #log { padding-left: 14px; padding-right: 14px; }
  .dock-line { flex-wrap: wrap; }
  .action-dock input { flex: 1 1 100%; }
  .action-dock button { width: 100%; }
  .adventure .location { padding-right: 0; }
  #new-adventure { position: static; }
}
/* Server-assigned identity colors and paragraph attribution. */
.hero-card { position: relative; }
.hero-color-swatch { position: absolute; top: 10px; right: 10px; width: 10px; height: 10px; border-radius: 1px; border: 1px solid #ffffff55; }
#log .game-master { color: #f0eee7; }
#log .game-master.hero-paragraph { color: var(--hero-color); border-left: 2px solid var(--hero-color); padding-left: 14px; }
#hero-code-dialog, #recovery-dialog { background: #172118; color: #f0eee7; border: 1px solid #a18b56; border-radius: 8px; max-width: min(540px, calc(100vw - 32px)); padding: 24px; }
#hero-code-dialog::backdrop, #recovery-dialog::backdrop { background: #000b; }
#new-hero-code, #recovery-code { width: 100%; box-sizing: border-box; font-family: monospace; overflow-wrap: anywhere; }
.enemy-stats { color: #f1c5b7; padding: 12px; border: 1px solid #825b4d; background: #271e1a; }
.enemy-stats span { white-space: nowrap; }
.combat-event { color: #d5c4b3; font-size: .85rem; }

/* The rule is also available by keyboard focus and touch. */
.secret-rule { position: relative; display: inline-flex; align-items: center; }
.secret-rule-button { width: 1.5rem; height: 1.5rem; padding: 0; border-radius: 50%; border: 1px solid #bda16c; background: transparent; color: #e1c78a; cursor: help; }
#secret-rule-tooltip { display: none; position: absolute; bottom: calc(100% + 10px); right: 0; z-index: 20; width: min(320px, 75vw); padding: 14px; border: 1px solid #bda16c; border-radius: 6px; background: #152019; color: #eee9da; font: 14px/1.5 sans-serif; box-shadow: 0 8px 30px #0008; }
.secret-rule:hover #secret-rule-tooltip, .secret-rule:focus-within #secret-rule-tooltip { display: block; }
.hero-location { font-size: .8rem; color: #c6c8b7; overflow-wrap: anywhere; }
.action-dock .secret-rule { flex: 0 0 auto; }
.action-dock .secret-rule .secret-rule-button { display: inline-flex; align-items: center; justify-content: center; width: 24px; min-width: 24px; height: 24px; min-height: 24px; padding: 0; border-radius: 50%; line-height: 1; }

/* Desktop play layout. The phone keeps its existing tabs and panels. */
#room-toolbar #desktop-recovery-button, #desktop-round, #desktop-chat-toggle { display: none !important; }
@media (min-width: 861px) {
  body.in-play header { min-height: 62px; padding-bottom: 28px; margin-bottom: 8px; }
  body.in-play header .subtitle { display: none; }
  body.in-play #room-toolbar {
    position: absolute;
    top: 20px;
    left: 300px;
    right: clamp(80px, calc((100vw - 1180px) / 2), 210px);
    z-index: 2;
    flex-wrap: nowrap;
    gap: 8px;
    margin: 0;
    white-space: nowrap;
  }
  body.in-play #room-toolbar .room-identity { flex: 0 1 320px; margin-right: auto; }
  body.in-play #room-toolbar #room-invite { margin-left: auto; }
  body.in-play #room-toolbar #room-name-label {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    font: 18px/1.2 var(--story);
  }
  body.in-play #room-toolbar button, body.in-play #room-toolbar a {
    flex: none;
    padding: 5px 7px;
    font-size: 10px;
    line-height: 1.2;
  }
  body.in-play #room-toolbar #desktop-recovery-button:not([hidden]),
  body.in-play #room-toolbar #desktop-round:not([hidden]) { display: inline-flex !important; }
  body.in-play #room-toolbar #desktop-round { align-items: center; color: var(--accent); font: 12px var(--ui); }
  body.in-play #room-toolbar #room-expiry-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    min-width: 20px;
    height: 20px;
    min-height: 20px;
    padding: 0;
    border: 1px solid #bda16c;
    border-radius: 50%;
    background: transparent;
    color: #e1c78a;
    font: 12px/1 var(--ui);
    cursor: help;
  }
  body.in-play #room-toolbar #room-expiry {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;
    width: 240px;
    margin: 0;
    padding: 11px 13px;
    white-space: normal;
    border: 1px solid #bda16c;
    border-radius: 6px;
    background: #152019;
    color: #eee9da;
    font: 12px/1.4 var(--ui);
    box-shadow: 0 8px 30px #0008;
  }
  body.in-play #room-toolbar .room-expiry-help:hover #room-expiry,
  body.in-play #room-toolbar .room-expiry-help:focus-within #room-expiry { display: block; }
  body.in-play #hero-code-notice { display: none; }
  body.in-play #game-screen .party-panel { overflow: visible; }
  body.in-play #game-screen .party-col { flex: 1 1 auto; max-height: none; min-height: 0; }
  body.in-play #game-screen .scene,
  body.in-play #game-screen .side-rail { padding-top: 29px; }
  body.in-play #game-screen #adventure-banner { display: none; }
  body.in-play #game-screen .side-rail #recovery-button,
  body.in-play #game-screen .side-rail .turn-window { display: none; }
  body.in-play #log .beat { gap: 2px; }
  body.in-play #log .beat > .game-master,
  body.in-play #log .game-master.hero-paragraph { margin: 0 0 5px; line-height: 1.65; }
  body.in-play #game-screen .chat-panel { display: none; }
  body.in-play #game-screen.desktop-chat-open .chat-panel {
    position: fixed;
    right: 24px;
    bottom: 185px;
    z-index: 25;
    display: flex;
    width: min(340px, calc(100vw - 32px));
    height: min(420px, calc(100dvh - 240px));
    min-height: 0;
    margin: 0;
    box-shadow: 0 18px 55px #0009;
  }
  body.in-play #game-screen #desktop-chat-toggle {
    position: fixed;
    right: 24px;
    bottom: 132px;
    z-index: 25;
    display: block !important;
    min-width: 130px;
    padding: 10px 15px;
    border: 1px solid #bda16c;
    border-radius: 5px;
    background: #19251ced;
    color: var(--accent);
  }
}
@media (min-width: 861px) and (max-width: 1240px) {
  body.in-play #room-toolbar { left: 285px; right: 80px; gap: 5px; }
  body.in-play #room-toolbar .room-identity {
    position: absolute;
    top: 30px;
    left: 0;
    width: min(280px, 45vw);
    margin: 0;
  }
  body.in-play #room-toolbar #room-name-label { font-size: 17px; }
  body.in-play #room-toolbar button, body.in-play #room-toolbar a { padding: 5px 4px; font-size: 9px; }
  body.in-play #room-toolbar #creator-menu-open { font-size: 0; }
  body.in-play #room-toolbar #creator-menu-open::after { content: "Меню"; font-size: 9px; }
}
