/* Shared palace surfaces: ink, crimson, aged metal, restrained jade feedback. */
:root { --hub-ink: #19171c; --hub-raised: #211e25; --hub-line: #bda17a45; --hub-muted: #c3b9ae; --hub-gold: #d4b789; --hub-text: #f3ede3; --hub-red: #a12a40; }
body .hub-dialog { box-sizing: border-box; width: min(880px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); border: 1px solid #bfa071; border-radius: 4px; background: var(--hub-ink); color: var(--hub-text); padding: 0; box-shadow: 0 24px 80px #000b; font: 14px/1.5 system-ui,sans-serif; letter-spacing: 0; color-scheme: dark; }
.hub-dialog::backdrop { background: #0a090eb8; backdrop-filter: blur(4px); }
.hub-dialog[open] { display: flex; flex-direction: column; }
.hub-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 24px; border-bottom: 1px solid var(--hub-line); flex: none; }
.hub-heading h2 { margin: 0; font-size: 22px; font-family: "Songti SC",serif; color: var(--hub-text); letter-spacing: 0; }
body .hub-dialog button, body .hub-dialog select, body .hub-dialog textarea, body .hub-support button, body .hub-settings-grid button { color: var(--hub-text); background: var(--hub-raised); border: 1px solid #a78d695f; border-radius: 3px; box-shadow: none; min-height: 40px; padding: 8px 12px; font: inherit; letter-spacing: 0; }
.hub-command { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.hub-command svg { width: 18px; height: 18px; flex: none; }
.hub-heading button { width: 38px; min-height: 38px; padding: 8px; flex: none; }
.hub-heading button span:empty { display: none; }
body .hub-dialog button:hover:not(:disabled), body .hub-support button:hover:not(:disabled), body .hub-settings-grid button:hover:not(:disabled) { border-color: var(--hub-gold); background: #34252e; transform: none; color: var(--hub-text); }
.hub-dialog :focus-visible, .hub-settings-grid :focus-visible, .hub-support :focus-visible { outline: 2px solid var(--hub-gold); outline-offset: 2px; }
body .hub-dialog .hub-primary { background: var(--hub-red); border-color: #d57782; padding-inline: 28px; }
.hub-dialog button:disabled { opacity: .5; cursor: not-allowed; }
.hub-dialog select { min-width: 0; max-width: 100%; }
body.theme-feijin .hub-dialog :is(select,textarea) { background: #211e25; background-image: none; color: #f3ede3; }
.hub-footer { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--hub-line); flex: none; }
.hub-footer output { flex: 1; min-width: 0; font-size: 12px; color: #edbaae; overflow-wrap: anywhere; }
.practice-body { overflow: auto; min-height: 0; padding: 20px 24px; }
.practice-matchup { display: grid; grid-template-columns: minmax(0,1fr) 60px minmax(0,1fr); align-items: start; }
.practice-seat { display: flex; flex-direction: column; align-items: center; min-width: 0; text-align: center; gap: 8px; }
.practice-seat img { width: 100%; height: 200px; object-fit: contain; }
.practice-seat h3 { font-size: 19px; line-height: 1.4; margin: 0; min-height: 30px; overflow-wrap: anywhere; }
.practice-seat :is(small,p) { color: var(--hub-muted); margin: 0; font-size: 12px; }
.practice-seat label { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 10px; align-items: center; width: 100%; font-size: 12px; }
.practice-versus { align-self: center; text-align: center; font: italic 25px Georgia,serif; color: var(--hub-gold); }
.practice-config { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-block: 1px solid var(--hub-line); padding: 14px 0; margin-top: 18px; }
.practice-config label { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.practice-config p { margin: 0; color: var(--hub-muted); font-size: 12px; }
.practice-roster summary { cursor: pointer; color: var(--hub-gold); padding: 14px 0; }
.practice-roster > div { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
.practice-roster h4 { margin: 0 0 10px; font-size: 13px; }
body .practice-roster button { display: block; width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--hub-line); border-radius: 0; min-height: 34px; font-size: 12px; }
.hub-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 24px; flex: none; }
.hub-toolbar small { margin-right: auto; color: var(--hub-muted); }
.archive-totals { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; padding: 0 24px 16px; border-bottom: 1px solid var(--hub-line); flex: none; }
.archive-totals div { display: flex; align-items: baseline; gap: 10px; }
.archive-totals strong { font: 28px Georgia,serif; color: var(--hub-gold); font-variant-numeric: tabular-nums; }
.archive-totals span { font-size: 12px; color: var(--hub-muted); }
#matchArchive { width: min(1040px,calc(100vw - 32px)); height: min(730px,calc(100dvh - 32px)); }
.archive-layout { display: grid; grid-template-columns: minmax(220px, .9fr) minmax(0,1.2fr); flex: 1; min-height: 0; }
.match-list, .match-detail { overflow: auto; scrollbar-gutter: stable; padding: 16px 22px; min-width: 0; }
.match-detail { border-left: 1px solid var(--hub-line); }
body .hub-dialog .match-row { width: 100%; display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 3px 12px; padding: 14px 12px; margin-bottom: 8px; text-align: left; background: transparent; border: 1px solid transparent; border-bottom-color: var(--hub-line); }
.match-row strong { grid-row: 1/3; align-self: center; color: #dbb4ac; }
.match-row[data-result='player'] strong { color: #a8d0c1; }
.match-row[data-result='draw'] strong { color: #d7c6a4; }
.match-row > span:empty { display: none; }
.match-row small { color: var(--hub-muted); }
.match-row span { overflow-wrap: anywhere; }
body .hub-dialog .match-row[aria-pressed='true'] { background: #34232c; border-color: #c0a17199; }
.match-detail h3 { font-size: 20px; margin: 8px 0; overflow-wrap: anywhere; }
.match-detail h4 { border-top: 1px solid var(--hub-line); padding-top: 16px; font-size: 13px; }
.match-detail :is(p,small) { color: var(--hub-muted); }
.match-log { list-style: none; margin: 0; padding: 0; }
.match-log li { padding: 10px 0; border-bottom: 1px solid var(--hub-line); font-size: 12px; overflow-wrap: anywhere; line-height: 1.65; }
.hub-notice { display: block; font-size: 12px; color: #eab9a9; margin: 0 24px; }
.hub-notice:empty { display: none; }
.hub-empty { color: var(--hub-muted); text-align: center; padding: 30px 8px; }
#matchExport, #clearMatchArchive, #restartMatchDialog { width: min(560px,calc(100vw - 28px)); }
#matchExport textarea { resize: vertical; min-height: 130px; height: 300px; margin: 20px; box-sizing: border-box; font-size: 12px; }
#matchExport > button { margin: 0 20px 16px; }
#clearMatchArchive p, #restartMatchDialog p { padding: 14px 24px; margin: 0; }
.match-save-status { display: block; font-size: 12px; color: #b4c9bb; margin-top: 8px; }
body #introOverlay.rebel-home .rebel-footer .hub-command span { font-family: inherit; font-size: inherit; }
body #introOverlay.rebel-home .rebel-footer .hub-command:hover { transform: none; }
body #settingsOverlay .settings-panel { width: min(780px,calc(100vw - 28px)); max-height: calc(100dvh - 28px); display: flex; flex-direction: column; background: var(--hub-ink); padding: 20px 24px; }
.hub-settings-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 24px; overflow: auto; min-height: 0; }
.hub-settings-grid > fieldset { margin: 12px 0; border: 0; padding: 0; min-width: 0; }
.hub-settings-grid > fieldset + fieldset { border-left: 1px solid var(--hub-line); padding-left: 24px; }
.hub-settings-grid legend { font-size: 14px; color: var(--hub-gold); padding: 0 0 12px; }
body .settings-panel .hub-settings-grid label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; min-height: 42px; margin: 0; }
.hub-settings-grid .sound-preference, .hub-settings-grid .salon-preferences { background: none; margin: 0; padding: 0; border: 0; }
.hub-settings-grid input[type='checkbox'] { width: 18px; height: 18px; flex: none; accent-color: #b6354b; }
.hub-settings-grid input[type='range'] { min-width: 30px; width: 100%; accent-color: #c7a977; }
body #settingsOverlay .settings-panel .hub-volume { display: grid; grid-template-columns: 56px minmax(0,1fr) 36px; }
.hub-volume output { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.hub-display-settings .battle-reading-settings { margin: 8px 0 0; padding: 10px 0 0; }
.hub-display-settings .battle-reading-settings legend { font-size: 12px; padding: 0 8px 0 0; }
.hub-support { display: flex; gap: 10px; border-top: 1px solid var(--hub-line); padding-top: 16px; margin-top: 12px; flex-wrap: wrap; }
body .hub-support button { font-size: 13px; }
body #settingsOverlay.rebel-dialog .hub-support { flex: none; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
body #settingsOverlay.rebel-dialog .hub-support button { width: auto; margin: 0; min-height: 36px; text-align: center; font-size: 12px; }
body #settingsOverlay.rebel-dialog :is(.sound-preference,.salon-preferences) { padding: 0; background: transparent; }
body #settingsOverlay.rebel-dialog :is(.sound-preference,.salon-preferences) label { min-height: 44px; padding: 0; font-size: 13px; }
body #settingsOverlay.rebel-dialog input[type='checkbox'] { width: 40px; min-width: 40px; height: 22px; transform: none; border-radius: 12px; flex: none; }
body #settingsOverlay.rebel-dialog input[type='checkbox']::after { inset: 3px auto 3px 3px; width: 14px; border-radius: 50%; }
body #settingsOverlay.rebel-dialog input[type='checkbox']:checked::after { translate: 18px 0; }
body #settingsOverlay.rebel-dialog .library-header { flex: none; padding: 0 0 12px; margin: 0; min-height: 40px; }
body #settingsOverlay.rebel-dialog .library-header::after { content: none; }
body #settingsOverlay.rebel-dialog .library-header h2 { font-size: 22px; text-shadow: none; margin: 0; }
body #settingsOverlay.rebel-dialog .library-header .eyebrow { display: none; }
body :is(#settingsOverlay,#guideOverlay) .library-header button { width: 36px; height: 36px; min-height: 36px; padding: 8px; border: 1px solid #a78d695f; background: #211e25; color: var(--hub-text); transform: none; clip-path: none; box-shadow: none; border-radius: 3px; }
body :is(#settingsOverlay,#guideOverlay) .library-header button svg { width: 18px; height: 18px; }
body #settingsOverlay .settings-panel::before, body #settingsOverlay .settings-panel::after { content: none; }
body #settingsOverlay .rebel-more[hidden] { display: none; }
body .guide-panel { display: flex; flex-direction: column; width: min(960px,calc(100vw - 28px)); height: min(760px,calc(100dvh - 28px)); padding: 22px; background: var(--hub-ink); }
.rule-search { flex: none; box-sizing: border-box; min-height: 42px; margin: 14px 0; width: 100%; padding: 8px 12px; background: #211e25; color: var(--hub-text); border: 1px solid #a78d6970; border-radius: 3px; font: 14px system-ui,sans-serif; }
.rulebook-content { overflow: auto; min-height: 0; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 24px; align-content: start; }
.rulebook-content section { padding: 14px 0; border-bottom: 1px solid var(--hub-line); }
.rulebook-content h3 { font-size: 15px; color: var(--hub-gold); margin: 0 0 8px; }
.rulebook-content p { margin: 0; font-size: 13px; line-height: 1.85; color: #e0d7cb; }
/* Saved decks should read as real artwork, not bright placeholder tiles. */
body #libraryOverlay.archive-surface #savedDeckList { grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 18px; padding: 18px 12px 18px 0; background: none; border-top: 1px solid var(--hub-line); }
body #libraryOverlay.archive-surface .saved-deck { border: 1px solid #a88b634f; border-radius: 4px; overflow: hidden; background: #211d24; box-shadow: none; }
body #libraryOverlay.archive-surface .saved-deck.is-selected { border-color: #c1a478; outline: none; box-shadow: inset 3px 0 #c1a478; }
body #libraryOverlay.archive-surface .saved-deck .saved-deck-cover { background: #201c23; color: #f4ecdf; border: 0; padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 12px; }
body #libraryOverlay.archive-surface.deck-collection-mode .saved-deck .saved-deck-cover:not(:disabled):is(:hover,:focus-visible) { background: #2b222a; color: #fff2dd; box-shadow: none; translate: none; transform: none; }
body #libraryOverlay.archive-surface .saved-deck .saved-deck-cover:focus-visible { outline-offset: -4px; }
body #libraryOverlay.archive-surface .deck-artwork { height: 180px; width: 100%; display: grid; place-items: center; background: transparent; }
body #libraryOverlay.archive-surface .deck-artwork img { height: 180px; width: 100%; object-fit: contain; filter: drop-shadow(0 6px 10px #0007); }
body #libraryOverlay.archive-surface .saved-deck-cover > span { font-size: 16px; color: inherit; align-self: flex-start; }
body #libraryOverlay.archive-surface .saved-deck-meta { padding: 0 16px 12px; }
body #libraryOverlay.archive-surface .deck-organization { padding-inline: 16px; }
body #libraryOverlay.archive-surface .saved-deck-actions { border-top: 1px solid var(--hub-line); }
body #libraryOverlay.archive-surface .saved-deck-actions button { background: transparent; border: 0; min-height: 42px; }
body #libraryOverlay.archive-surface .saved-deck-actions button:hover:not(:disabled) { background: #39252c; color: #f6e9d4; }
body #libraryOverlay.archive-surface .deck-collection-layout { grid-template-columns: minmax(0,1fr) 310px; }
body #libraryOverlay.archive-surface #savedDeckDetail { border-left-color: var(--hub-line); padding-left: 20px; }
body #libraryOverlay.archive-surface #deckPresetGrid { background: #242027; color: #f4ecdf; border-top: 1px solid var(--hub-line); }
body #libraryOverlay.archive-surface .workshop-preset :is(h3,p,small), body #libraryOverlay.archive-surface .preset-size { color: #ddd1c0; }
body #libraryOverlay.archive-surface .workshop-preset { background: none; border-color: var(--hub-line); }
body :is(#libraryOverlay,#collectionEditor).archive-surface { --archive-paper: #e9e6e2; }
@media (max-width: 1000px) { body #libraryOverlay.archive-surface .deck-collection-layout { grid-template-columns: minmax(0,1fr) 240px; } body #libraryOverlay.archive-surface #savedDeckList { grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap: 12px; } }
@media (max-width: 580px) {
  body #libraryOverlay.archive-surface .deck-collection-layout { grid-template-columns: minmax(0,1fr); }
  .hub-heading { padding: 12px 16px; } .hub-heading h2 { font-size: 19px; }
  .hub-toolbar { padding: 12px 16px; gap: 8px; } .hub-toolbar small { width: calc(100% - 160px); font-size: 11px; }
  .archive-totals { padding: 0 16px 12px; gap: 8px; } .archive-totals div { gap: 5px; } .archive-totals strong { font-size: 22px; }
  .archive-layout { display: flex; flex-direction: column; overflow: auto; } .match-list { max-height: 200px; flex: none; } .match-detail { overflow: visible; border-left: 0; border-top: 1px solid var(--hub-line); }
  .hub-settings-grid { grid-template-columns: minmax(0,1fr); gap: 0; } .hub-settings-grid > fieldset + fieldset { border-left: 0; padding-left: 0; border-top: 1px solid var(--hub-line); }
  .rulebook-content { grid-template-columns: minmax(0,1fr); }
  .practice-body { padding: 14px; } .practice-matchup { grid-template-columns: minmax(0,1fr) 30px minmax(0,1fr); }
  .practice-seat img { height: 125px; } .practice-seat h3 { font-size: 16px; } .practice-seat label { display: grid; grid-template-columns: minmax(0,1fr); }
  .practice-config { flex-wrap: wrap; gap: 8px; } .practice-config p { font-size: 11px; }
  .practice-roster > div { grid-template-columns: minmax(0,1fr); }
  .hub-footer { padding: 12px 16px; } .hub-footer button { flex: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
  body .hub-dialog { max-height: calc(100dvh - 12px); } #matchArchive { height: calc(100dvh - 12px); }
  .hub-heading { padding: 8px 16px; } .hub-heading h2 { font-size: 18px; } .hub-heading button { min-height: 30px; height: 30px; width: 30px; padding: 5px; }
  .hub-toolbar { padding: 6px 16px; } .hub-toolbar button, .hub-toolbar select { min-height: 30px; padding: 4px 8px; font-size: 12px; }
  .archive-totals { padding: 4px 16px 8px; } .archive-totals strong { font-size: 20px; }
  .practice-body { padding: 10px 18px; } .practice-seat img { height: 100px; } .practice-seat h3 { font-size: 16px; } .practice-config { margin-top: 10px; padding: 8px 0; }
  .hub-footer { padding: 8px 18px; } .hub-footer button { min-height: 34px; font-size: 12px; }
  body #settingsOverlay .settings-panel { max-height: calc(100dvh - 12px); padding: 10px 16px; } .hub-settings-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body #libraryOverlay.archive-surface .deck-artwork, body #libraryOverlay.archive-surface .deck-artwork img { height: 94px; }
  body #libraryOverlay.archive-surface .saved-deck .saved-deck-cover { padding: 8px; gap: 6px; }
  body #libraryOverlay.archive-surface #savedDeckList { grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); }
}
@media (prefers-reduced-motion: reduce) { .hub-dialog::backdrop { backdrop-filter: none; } }

/* Preparation uses the cover's graphic language, without changing combat surfaces. */
body .hub-dialog.preparation-dialog {
  --hub-ink: #131415; --hub-raised: #222424; --hub-line: #f0e5d12b;
  --hub-muted: #b5b1a9; --hub-text: #f6eee0; --hub-red: #b6162f;
  width: min(960px,calc(100vw - 40px)); max-height: calc(100dvh - 40px);
  border: 1px solid #70685a; border-top: 3px solid #b6162f; border-radius: 0;
  background: var(--hub-ink); box-shadow: 0 24px 80px #0009;
  opacity: 0; transform: translateY(14px);
  transition: opacity 180ms ease, transform 180ms ease, display 180ms allow-discrete, overlay 180ms allow-discrete;
}
body .preparation-dialog[open] { opacity: 1; transform: none; }
.preparation-dialog::backdrop {
  background: #080909b3; backdrop-filter: none; opacity: 0;
  transition: opacity 180ms ease, display 180ms allow-discrete, overlay 180ms allow-discrete;
}
.preparation-dialog[open]::backdrop { opacity: 1; }
@starting-style {
  body .preparation-dialog[open] { opacity: 0; transform: translateY(14px); }
  .preparation-dialog[open]::backdrop { opacity: 0; }
}
.preparation-dialog .hub-heading { padding: 24px 32px 20px; border-bottom-color: var(--hub-line); gap: 24px; }
.preparation-title { min-width: 0; flex: 1; }
.preparation-kicker { display: block; margin-bottom: 6px; color: var(--hub-muted); font-size: 11px; line-height: 1.3; }
.preparation-dialog .hub-heading h2 { font: 800 36px/1.2 'Songti SC','STSong',serif; color: var(--hub-text); }
body .preparation-dialog .hub-heading > button {
  width: 44px; height: 44px; min-height: 44px; padding: 11px; border: 0;
  border-radius: 0; background: transparent; color: var(--hub-text);
}
body .preparation-dialog .hub-heading > button:hover { background: #b6162f; }
.preparation-dialog :focus-visible { outline: 2px solid #f6eee0; outline-offset: -3px; }
.preparation-caravan { width: 124px; height: 54px; object-fit: contain; }
body:has(.preparation-dialog[open]) #introOverlay .rebel-art { transform: none; transition: none; }
body:has(.preparation-dialog[open]) #introOverlay .rebel-atmosphere i { animation-play-state: paused; }

#merchantModeDialog .merchant-entry-body { display: grid; grid-template-columns: minmax(0,1.12fr) minmax(0,1fr); gap: 40px; min-height: 0; overflow: auto; padding: 24px 32px; }
.merchant-entry-art { position: relative; isolation: isolate; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.merchant-entry-art::before { content: ''; position: absolute; z-index: -1; inset: 16% -2% 24%; background: #a51229; clip-path: polygon(0 35%,100% 0,94% 73%,4% 100%); }
.merchant-entry-goods { display: flex; align-items: center; height: 194px; width: 100%; }
.merchant-entry-goods i { display: block; width: 33.333%; aspect-ratio: 1; background: url('./assets/ui/merchant/goods-atlas-v1.webp') 0 center / 300% 100% no-repeat; }
.merchant-entry-goods [data-goods='spell'] { background-position: 50% center; transform: translateY(-10px); }
.merchant-entry-goods [data-goods='troop'] { background-position: 100% center; }
.merchant-entry-pool { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 0 0; }
.merchant-entry-pool strong { color: var(--hub-text); font: 600 16px/1.4 'Songti SC',serif; }
.merchant-entry-pool span { color: var(--hub-muted); font-size: 12px; }
.merchant-entry-rules { display: grid; grid-template-rows: repeat(3,minmax(0,1fr)); margin: 0; }
.merchant-entry-rules > div { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--hub-line); padding: 10px 0; }
.merchant-entry-rules > div:last-child { border: 0; }
.merchant-entry-rules dt { color: #d3cbbd; font-size: 14px; }
.merchant-entry-rules dd { display: flex; align-items: center; gap: 12px; min-width: 116px; margin: 0; }
.merchant-entry-rules dd > strong { min-width: 54px; color: var(--hub-text); font: 500 40px/1 Georgia,serif; font-variant-numeric: tabular-nums; }
.merchant-entry-rules dd > span { color: var(--hub-text); font-size: 13px; }
.merchant-entry-rules small { display: block; margin-top: 3px; color: var(--hub-muted); font-size: 11px; white-space: nowrap; }
.merchant-entry-loadout { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 16px 32px; border-top: 1px solid var(--hub-line); }
.merchant-entry-loadout > div { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.merchant-entry-loadout :is(small,span) { color: var(--hub-muted); font-size: 12px; white-space: nowrap; }
.merchant-entry-loadout strong { min-width: 0; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; }
body .preparation-dialog .merchant-entry-loadout button { flex: none; background: transparent; border: 0; border-radius: 0; padding: 4px 0 4px 12px; min-height: 44px; font-size: 13px; color: #e0d5c1; }
body .preparation-dialog .merchant-entry-loadout button:hover { color: #fff7e7; background: transparent; text-decoration: underline; text-underline-offset: 4px; }
.preparation-dialog .hub-footer { padding: 18px 32px 24px; border-top-color: var(--hub-line); }
.merchant-entry-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
body .preparation-dialog .preparation-action {
  --action-fill: #262828; position: relative; isolation: isolate; display: grid;
  grid-template-columns: 24px minmax(0,1fr) 20px; align-items: center; gap: 14px;
  min-height: 64px; padding: 12px 32px; border: 0; border-radius: 0; box-shadow: none;
  background: transparent; color: #f6eee0; text-align: left; cursor: pointer;
  font: 700 20px/1.3 'Songti SC','STSong',serif; letter-spacing: 0; touch-action: manipulation;
}
.preparation-action::before { content: ''; position: absolute; z-index: -1; inset: 0; background: var(--action-fill); clip-path: polygon(4% 0,100% 0,96% 100%,0 100%); transition: background 140ms ease; }
body .preparation-dialog :is(#merchantOnlineButton,#practiceStart) { --action-fill: #b6162f; }
body .preparation-dialog .preparation-action:hover { --action-fill: #8f1d2e; background: transparent; color: #fff7e7; }
body .preparation-dialog :is(#merchantOnlineButton,#practiceStart):hover { --action-fill: #d01a36; }
.preparation-action svg { width: 22px; height: 22px; }
.preparation-action svg:last-child { width: 18px; transition: transform 140ms ease; }
.preparation-action:hover svg:last-child { transform: translateX(4px); }
.preparation-dialog .preparation-action:focus-visible { outline: 0; }
.preparation-action:focus-visible > span { text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 2px; }

#practiceDialog .practice-body { padding: 24px 32px 12px; }
#practiceDialog .practice-matchup { grid-template-columns: minmax(0,1fr) 80px minmax(0,1fr); }
#practiceDialog .practice-seat { gap: 10px; }
#practiceDialog .practice-seat > small { align-self: flex-start; color: #dbd0be; padding-left: 10px; border-left: 3px solid #b6162f; font-size: 13px; }
.practice-portrait { display: grid; place-items: center; width: 100%; max-width: 230px; height: 180px; margin: 0; overflow: hidden; background: #232525; clip-path: polygon(12% 0,100% 0,88% 100%,0 100%); }
#practiceDialog .practice-portrait img { width: 100%; height: 180px; object-fit: contain; }
#practiceDialog .practice-portrait img[data-cutout='true'] { object-fit: cover; object-position: center top; }
#practiceDialog .practice-seat h3 { min-height: 28px; font: 700 20px/1.4 'Songti SC',serif; color: var(--hub-text); }
#practiceDialog .practice-versus { font: italic 600 30px/1 Georgia,serif; color: #d42a3e; }
body #practiceDialog select { border: 0; border-bottom: 1px solid #d6cab86b; border-radius: 0; background: #232525; color: #f6eee0; min-height: 44px; padding: 8px 12px; }
body #practiceDialog [data-practice-change] button { border: 0; border-radius: 0; background: transparent; color: #ded2bf; font-size: 13px; min-height: 44px; padding: 4px 10px; }
body #practiceDialog [data-practice-change] button:hover { background: #292b2b; }
#practiceDialog .practice-config { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px 24px; padding: 18px 0; margin-top: 20px; }
#practiceDialog .practice-config label { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 16px; font-size: 13px; }
#practiceDialog .practice-config p { grid-column: 1 / -1; font-size: 12px; color: #b5b1a9; }
#practiceDialog .practice-roster summary { color: #d7c7aa; padding: 12px 0; }
#practiceDialog #practiceStart { min-width: 230px; }

@media (max-width: 640px) and (min-height: 521px) {
  body .hub-dialog.preparation-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); }
  .preparation-dialog .hub-heading { padding: 20px; gap: 12px; }
  .preparation-dialog .hub-heading h2 { font-size: 28px; }
  .preparation-caravan { display: none; }
  #merchantModeDialog .merchant-entry-body { grid-template-columns: minmax(0,1fr); gap: 18px; padding: 12px 20px 16px; }
  .merchant-entry-goods { height: 156px; }
  .merchant-entry-pool { gap: 8px; }
  .merchant-entry-pool strong { font-size: 15px; }
  .merchant-entry-pool span { font-size: 11px; }
  .merchant-entry-rules { grid-template-columns: repeat(3,minmax(0,1fr)); grid-template-rows: none; gap: 10px; }
  .merchant-entry-rules > div { flex-direction: column; align-items: flex-start; justify-content: start; gap: 8px; padding: 8px 0; border: 0; }
  .merchant-entry-rules dt { font-size: 12px; }
  .merchant-entry-rules dd { flex-wrap: wrap; gap: 8px; min-width: 0; }
  .merchant-entry-rules dd > strong { min-width: 0; font-size: 32px; }
  .merchant-entry-rules dd > span { font-size: 11px; }
  .merchant-entry-rules small { font-size: 10px; white-space: normal; }
  .merchant-entry-loadout { padding: 12px 20px; gap: 12px; }
  .merchant-entry-loadout > div { display: grid; gap: 3px; }
  .merchant-entry-loadout strong { max-width: none; }
  .merchant-entry-loadout :is(small,span) { font-size: 11px; }
  .preparation-dialog .hub-footer { padding: 16px 20px 20px; gap: 8px; }
  body .preparation-dialog .preparation-action { grid-template-columns: 18px minmax(0,1fr) 14px; min-height: 54px; gap: 6px; padding: 10px 16px; font-size: 17px; }
  .preparation-action svg { width: 18px; height: 18px; }
  .preparation-action svg:last-child { width: 14px; }
  #practiceDialog .practice-body { padding: 18px 20px 8px; }
  #practiceDialog .practice-matchup { grid-template-columns: minmax(0,1fr) 32px minmax(0,1fr); }
  #practiceDialog .practice-versus { font-size: 20px; }
  .practice-portrait, #practiceDialog .practice-portrait img { height: 140px; }
  #practiceDialog .practice-seat h3 { font-size: 16px; }
  #practiceDialog .practice-seat label { grid-template-columns: minmax(0,1fr); gap: 6px; }
  #practiceDialog .practice-config { gap: 12px; }
  #practiceDialog .practice-config label { grid-template-columns: minmax(0,1fr); gap: 6px; }
  #practiceDialog #practiceStart { min-width: 186px; }
}
@media (min-width: 641px) and (min-height: 521px) and (max-height: 760px) {
  #practiceDialog .hub-heading { padding: 16px 24px; }
  #practiceDialog .practice-body { padding: 16px 24px 8px; }
  #practiceDialog .practice-seat { gap: 8px; }
  #practiceDialog .practice-portrait, #practiceDialog .practice-portrait img { height: 132px; }
  #practiceDialog .practice-config { margin-top: 12px; padding: 12px 0; gap: 8px 24px; }
  #practiceDialog .practice-roster summary { padding: 8px 0; }
  #practiceDialog .hub-footer { padding: 12px 24px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  body .hub-dialog.preparation-dialog { width: min(880px,calc(100vw - 24px)); max-height: calc(100dvh - 16px); }
  .preparation-dialog .hub-heading { padding: 8px 22px; gap: 16px; }
  .preparation-dialog .hub-heading h2 { font-size: 26px; }
  .preparation-kicker { font-size: 10px; margin-bottom: 3px; }
  .preparation-caravan { width: 88px; height: 34px; }
  #merchantModeDialog .merchant-entry-body { padding: 12px 22px; gap: 28px; }
  .merchant-entry-goods { height: 112px; }
  .merchant-entry-goods i { max-width: 104px; }
  .merchant-entry-pool { flex-wrap: wrap; gap: 3px; padding-top: 4px; }
  .merchant-entry-pool strong { font-size: 13px; }
  .merchant-entry-pool span { font-size: 10px; }
  .merchant-entry-rules > div { padding: 4px 0; gap: 10px; }
  .merchant-entry-rules dt { font-size: 12px; }
  .merchant-entry-rules dd { min-width: 100px; gap: 8px; }
  .merchant-entry-rules dd > strong { min-width: 36px; font-size: 28px; }
  .merchant-entry-rules dd > span { font-size: 11px; }
  .merchant-entry-rules small { font-size: 10px; margin-top: 0; }
  .merchant-entry-loadout { padding: 4px 22px; gap: 10px; }
  .merchant-entry-loadout > div { gap: 10px; }
  .merchant-entry-loadout strong { max-width: 160px; font-size: 13px; }
  .merchant-entry-loadout :is(small,span) { font-size: 10px; }
  body .preparation-dialog .merchant-entry-loadout button { min-height: 44px; font-size: 12px; }
  .preparation-dialog .hub-footer { padding: 8px 22px; }
  body .preparation-dialog .preparation-action { min-height: 44px; padding: 8px 22px; font-size: 17px; }
  .preparation-action svg { width: 18px; height: 18px; }
  #practiceDialog .practice-body { padding: 6px 22px 0; }
  #practiceDialog .practice-matchup { grid-template-columns: minmax(0,1fr) 50px minmax(0,1fr); }
  #practiceDialog .practice-seat { display: grid; grid-template-columns: 94px minmax(0,1fr); grid-template-rows: 18px auto auto auto; gap: 3px 10px; align-items: center; text-align: left; }
  #practiceDialog .practice-seat > small { grid-column: 1 / -1; font-size: 11px; }
  #practiceDialog .practice-portrait { grid-column: 1; grid-row: 2 / 5; }
  #practiceDialog .practice-seat :is(h3,p,[data-practice-change],label) { grid-column: 2; }
  #practiceDialog .practice-seat h3 { grid-row: 2; }
  #practiceDialog .practice-seat p { grid-row: 3; }
  #practiceDialog [data-practice-change] { grid-row: 4; }
  #practiceDialog .practice-seat:has([data-practice-enemy-art]) p { grid-row: 4; }
  .practice-portrait, #practiceDialog .practice-portrait img { height: 90px; }
  #practiceDialog .practice-seat h3 { font-size: 16px; min-height: 23px; }
  #practiceDialog .practice-seat label { grid-template-columns: minmax(0,1fr); gap: 3px; font-size: 11px; }
  body #practiceDialog select { min-height: 36px; padding: 5px 8px; font-size: 12px; }
  body #practiceDialog [data-practice-change] button { min-height: 32px; font-size: 11px; }
  #practiceDialog .practice-config { margin-top: 6px; padding: 8px 0; gap: 6px 20px; }
  #practiceDialog .practice-config label { font-size: 11px; gap: 10px; }
  #practiceDialog .practice-config p { font-size: 10px; }
  #practiceDialog .practice-roster summary { padding: 7px 0; font-size: 11px; }
  #practiceDialog #practiceStart { min-width: 188px; }
}
@media (max-height: 360px) and (orientation: landscape) {
  .preparation-dialog .hub-heading { padding-block: 6px; }
  .preparation-dialog .hub-heading h2 { font-size: 23px; }
  #merchantModeDialog .merchant-entry-body { padding-block: 6px; gap: 24px; }
  .merchant-entry-goods { height: 102px; }
  .merchant-entry-pool { display: none; }
  .merchant-entry-rules > div { padding-block: 3px; }
  .merchant-entry-loadout { padding-block: 2px; }
  .preparation-dialog .hub-footer { padding-block: 6px; }
  #practiceDialog .hub-heading, #practiceDialog .hub-footer { padding-block: 4px; }
  #practiceDialog .practice-body { padding-top: 4px; }
  #practiceDialog .practice-seat { grid-template-columns: 82px minmax(0,1fr); gap: 2px 8px; }
  .practice-portrait, #practiceDialog .practice-portrait img { height: 82px; }
  #practiceDialog .practice-config { margin-top: 6px; padding-block: 6px; gap: 4px 16px; }
  #practiceDialog .practice-config p { display: none; }
  #practiceDialog .practice-roster summary { padding-block: 7px; min-height: 32px; box-sizing: border-box; }
}
.salon-reduced-motion .hub-dialog.preparation-dialog, .salon-reduced-motion .preparation-dialog::backdrop,
.salon-reduced-motion .preparation-action::before, .salon-reduced-motion .preparation-action svg:last-child { transition: none; }
@media (prefers-reduced-motion: reduce) {
  body .hub-dialog.preparation-dialog, .preparation-dialog::backdrop, .preparation-action::before, .preparation-action svg:last-child { transition: none; }
}
