html { scrollbar-gutter: stable; }
main:has(#room:not([hidden])) { max-width: 1480px; }
.room-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.room-top h2 { margin: 0; }
.room-list-heading { margin: 20px 0 8px; }
#roomList { margin: 0; padding: 0; list-style: none; }
.room-list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.room-list-row button { flex: 0 0 auto; }
.room-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.hud { position: sticky; top: 0; z-index: 5; display: grid; box-shadow: 0 4px 10px #10090b80; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 0 0 10px; background: var(--line); border: 1px solid var(--line); }
.hud div { padding: 7px 11px; background: #351719; }
.hud span { color: var(--muted); font-size: 12px; }
.hud div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; }
.hud strong { color: var(--ink); font-size: clamp(16px, 3vw, 24px); font-variant-numeric: tabular-nums; }
.hud #cost { color: #f0c66a; }
.hud .danger { color: #ff9b84; }
.lanes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.lanes span { padding: 5px 9px; border-left: 3px solid var(--sector); background: #351719; }
.battle-map { position: relative; width: min(100%, calc(100dvh - 48px)); margin-inline: auto; overflow: hidden; border: 1px solid #88423a; background: #10090b; }
#arena { display: block; width: 100%; height: auto; aspect-ratio: 1; cursor: crosshair; touch-action: pan-y; }
#arena:active { user-select: none; }
#arena:focus-visible { outline-offset: -3px; }
.map-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 0 0 8px; }
.map-actions button { padding: 5px 8px; background: #40191cec; font-variant-numeric: tabular-nums; }
.map-actions button[aria-pressed='true'] { border-color: #ffc400; color: #ffd46b; }
.room-tools { align-items: center; }
#inspector { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.prisoner-actions { --slot: clamp(30px, 9vw, 56px); display: grid; grid-template-columns: repeat(3, var(--slot)); gap: 3px; align-self: start; }
.command-slot { height: var(--slot); border: 1px solid var(--line); background: #230c10; }
.command-slot button { position: relative; display: grid; place-items: center; width: 100%; height: 100%; padding: 3px; margin: 0; color: #ffd46b; font-size: 21px; background: linear-gradient(145deg, #8D1714, #410404); }
.command-slot button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px #ffd46b; }
.command-slot kbd { position: absolute; right: 3px; bottom: 0; font-size: 10px; }
.rally img { display: block; width: min(75%, 32px); filter: url(#rally-yellow); }
@media (max-width: 540px) {
  #inspector { grid-template-columns: minmax(0, 1fr) auto; }
  #inspector .selection-info { grid-template-columns: minmax(0, 1fr); }
}
.room-tools h2 { margin-right: 8px; }
.room-tools button, #ticketOpen, .sell { padding: 5px 10px; font-size: 13px; }
#ticketOpen, .sell { margin-top: 8px; }
.draw-option .primary { padding: 5px 15px; font-size: 14px; display: block; min-width: 64px; text-align: center; }
#draw-low, #mission-1 { background: #fff; border-color: #fff; }
#draw-mid, #mission-2 { background: #82d69c; border-color: #82d69c; }
#draw-high, #mission-3 { background: #7fbdf1; border-color: #7fbdf1; }
#mission-4 { background: #c5a7f3; border-color: #c5a7f3; }
.mission-heading { margin: 12px 0 6px; }
#missions { display: flex; gap: 6px; }
.mission-button { min-width: 42px; padding: 5px 9px; color: #211416; text-align: center; }
.mission-button { position: relative; isolation: isolate; overflow: hidden; }
.mission-button span { position: relative; }
.mission-button.cooling { opacity: 1; }
.mission-button.cooling::before {
  content: ''; position: absolute; inset: 0 0 0 var(--charged, 0%);
  background: #15090cc9; transition: left .24s linear; pointer-events: none;
}
.mission-button.cooling span { color: #fff3e8; text-shadow: 0 1px 2px #19090c, 0 0 3px #19090c; }
#outcomeReason:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .mission-button.cooling::before { transition: none; } }
#outcomeDialog { text-align: center; width: min(440px, 90vw); border: 2px solid #e8b64d; }
#outcomeTitle { font-size: clamp(38px, 10vw, 66px); color: #ffd46b; margin-bottom: 20px; }
.outcome-actions { justify-content: center; }
#otherLanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; max-width: min(330px, 100%); }
#otherLanes button { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; background: url('/assets/battle/bus.png') center bottom / 100% auto no-repeat; opacity: .45; z-index: -1; }
body { isolation: isolate; }

.face { position: relative; display: inline-block; width: 36px; height: 36px; flex: 0 0 36px; vertical-align: middle; overflow: hidden; border-radius: 4px; background: #432729; margin-right: 6px; }
.face img { position: absolute; max-width: none; }
#recipeDialog, #ticketDialog { width: min(760px, 93vw); max-width: 93vw; max-height: 80vh; padding: 0 16px 16px; }
.dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; background: var(--panel); padding: 12px 0; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; }
#recipeDialog[open] { display: flex; flex-direction: column; overflow: hidden; }
#recipeNav { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 0; }
#recipeNav button { padding: 4px 8px; font-size: 13px; }
#recipeBook { overflow-y: auto; min-height: 0; padding-right: 6px; }
#recipeBook section { margin: 0; padding: 6px 0 12px; }
#recipeBook h3 { margin: 0; }
.book-row { padding: 9px 0; border-bottom: 1px solid var(--line); }
.materials, #ticketOptions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.materials { font-size: 13px; color: var(--muted); }
#ticketOptions button { text-align: left; }
#announcements { position: fixed; z-index: 8; top: 12px; left: 50%; transform: translateX(-50%); width: min(700px, 92vw); pointer-events: none; }
.notice { margin-bottom: 8px; padding: 14px 20px; border: 1px solid #b68254; background: #2b1014f5; box-shadow: 0 3px 16px #0008; font-size: clamp(22px, 5vw, 30px); font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.selection-box { position: absolute; pointer-events: none; border: 1px solid #ffdc8c; background: #f5cc7f28; }
.battle-map { margin-bottom: 12px; }
.commands { display: grid; grid-template-columns: minmax(220px, .85fr) minmax(0, 1.5fr); gap: 10px; }
.commands .panel { min-width: 0; padding: 12px; }
.draws { display: flex; flex-wrap: wrap; gap: 6px; }
.draws button { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px; text-align: left; }
.draws button span { font-size: 12px; font-weight: 400; }
#drawResult { margin: 8px 0 0; font-size: 26px; min-height: 1.4em; }
.selection-info { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; }
.unit-portrait { position: relative; width: 104px; height: 112px; overflow: hidden; border-radius: 4px; background: #3e2020; }
.unit-portrait img { position: absolute; max-width: none; }
.selection-info h4 { margin: 0 0 3px; }
.selection-info p { margin: 0 0 5px; }
.selection-info dl { display: flex; flex-wrap: wrap; gap: 3px 12px; margin: 0; font-size: 13px; }
.selection-info dl div { display: flex; gap: 6px; }
.selection-info dt { color: var(--muted); }
.selection-info dd { margin: 0; }
.prisoner-detail { height: 174px; overflow-y: auto; scrollbar-gutter: stable; }
.recipes { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); align-content: start; gap: 6px; height: 160px; overflow-y: auto; scrollbar-gutter: stable; overscroll-behavior-y: contain; }
.recipes .recipe { min-width: 0; }
.recipes .recipe button { width: 100%; }
.recipe-materials { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.recipe { position: relative; max-width: 100%; }
.recipe button { min-height: 52px; padding: 8px 12px; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.recipe [aria-disabled="true"] { opacity: .65; }
.recipe .tooltip { display: none; position: absolute; bottom: calc(100% + 4px); left: 0; z-index: 2; width: max-content; max-width: min(340px, 75vw); padding: 7px 9px; background: #241014; border: 1px solid #885d4d; color: var(--ink); font-size: 12px; }
.recipe:hover .tooltip, .recipe:focus-within .tooltip { display: block; }
@media(max-width: 760px) {
  header, main { padding: 12px; }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hud div { padding: 3px 8px; }
  .hud span { font-size: 10px; }
  .commands { grid-template-columns: minmax(0, 1fr); }
  .prisoner-detail { height: 218px; }
}
