:root {
  --ink: #17202b;
  --ink-soft: #344054;
  --muted: #667085;
  --line: #d8dee7;
  --line-soft: #e9edf2;
  --surface: #ffffff;
  --surface-alt: #f7f9fb;
  --page: #eef1f4;
  --blue: #215fbe;
  --blue-dark: #174b99;
  --teal: #177466;
  --green: #18794e;
  --amber: #9b6300;
  --red: #b42336;
  --red-dark: #8f1c2b;
  --focus: #91b7ed;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body { margin: 0; color: var(--ink); background: var(--page); font: 14px/1.45 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button, input, select, dialog { color: inherit; }
button { min-height: 36px; padding: 0 13px; border: 1px solid #cbd3dd; border-radius: 5px; background: var(--surface); cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled) { border-color: #9cabbc; background: #f8fafc; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 52%, transparent); outline-offset: 1px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { border-color: var(--blue); color: #fff; background: var(--blue); }
button.primary:hover:not(:disabled) { border-color: var(--blue-dark); background: var(--blue-dark); }
button.danger { border-color: var(--red); color: #fff; background: var(--red); }
button.danger:hover:not(:disabled) { border-color: var(--red-dark); background: var(--red-dark); }
button.danger-outline { border-color: #d6a4ab; color: var(--red); background: transparent; }
button.danger-outline:hover:not(:disabled) { border-color: var(--red); background: #fff5f6; }
button.compact { min-height: 32px; padding-inline: 11px; font-size: 13px; }
button.text-button { min-height: auto; padding: 2px 0; border: 0; color: var(--blue); background: transparent; }
button.text-button:hover:not(:disabled) { border: 0; color: var(--blue-dark); background: transparent; }
.full-button { width: 100%; }
input, select { width: 100%; min-width: 0; min-height: 36px; padding: 6px 9px; border: 1px solid #cbd3dd; border-radius: 4px; background: var(--surface); }
input[type="checkbox"] { width: 16px; min-height: 16px; height: 16px; margin: 0; accent-color: var(--blue); }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
h1, h2, h3, h4, p, dl, dd, ol { margin: 0; }
h1 { font-size: 22px; line-height: 1.2; }
h2 { font-size: 18px; line-height: 1.25; }
h3 { font-size: 14px; line-height: 1.3; }
h4 { font-size: 12px; color: var(--muted); text-transform: uppercase; }
code { font: 12px ui-monospace, Consolas, monospace; }
[hidden] { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 22px; min-height: 64px; padding: 10px max(20px, calc((100% - 1440px) / 2)); border-bottom: 1px solid #2f3b49; color: #fff; background: #18222e; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 5px; color: #18222e; background: #e5bc55; font-weight: 800; }
.brand > span:last-child { display: grid; }
.brand strong { font-size: 15px; }
.brand small { color: #aeb8c6; font-size: 11px; }
.environment { display: flex; align-items: center; gap: 7px; color: #c8d1dc; font-size: 12px; }
.environment code { color: #fff; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #35b37e; box-shadow: 0 0 0 3px rgba(53, 179, 126, .14); }
.status-dot.idle { background: #98a2b3; box-shadow: none; }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 3px rgba(180, 35, 54, .12); }
.session-tools { display: flex; align-items: end; gap: 8px; margin-left: auto; }
.session-tools button { min-height: 34px; color: #e7ecf2; border-color: #526071; background: transparent; }
.session-tools button:hover:not(:disabled) { border-color: #8593a3; background: #233140; }
.session-tools .danger-outline { color: #ffb8c2; border-color: #80515a; }
.quick-account { display: flex; align-items: center; gap: 7px; color: #aeb8c6; }
.quick-account select { width: 190px; min-height: 34px; color: #fff; border-color: #526071; background: #222f3d; }

main { width: min(1440px, calc(100% - 32px)); margin: 20px auto 42px; }
.login-shell { width: min(1040px, 100%); margin: 38px auto; background: var(--surface); border: 1px solid var(--line); }
.login-heading { padding: 26px 28px 22px; border-bottom: 1px solid var(--line); }
.login-heading h1 { margin-top: 4px; font-size: 25px; }
.eyebrow { color: var(--teal); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.account-manager { background: var(--surface); }
.account-columns { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); min-height: 310px; }
.account-list-section, .account-action-section { padding: 24px 28px; }
.account-list-section { border-right: 1px solid var(--line); }
.account-action-section { display: grid; align-content: start; gap: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; }
.account-rows { display: grid; gap: 8px; margin-top: 14px; }
.account-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px; border: 1px solid var(--line-soft); border-left: 3px solid transparent; background: var(--surface-alt); }
.account-row.active { border-left-color: var(--teal); background: #f3faf8; }
.account-row strong, .account-row small { display: block; }
.account-row small { margin-top: 2px; color: var(--muted); }
.account-row-actions { display: flex; gap: 6px; }
.account-row-actions button { min-height: 30px; padding-inline: 9px; font-size: 12px; }
.form-stack { display: grid; gap: 13px; }
.server-form { padding-top: 18px; border-top: 1px solid var(--line); }
.account-summary { padding: 9px 11px; border-left: 3px solid var(--teal); color: var(--ink-soft); background: #f1f7f6; font-size: 12px; }

.identity-band { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 98px; padding: 18px 22px; border: 1px solid var(--line); border-bottom: 0; background: var(--surface); }
.identity-main { display: flex; align-items: center; gap: 13px; min-width: 220px; }
.player-initial { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; border-radius: 6px; color: #fff; background: var(--teal); font-size: 20px; font-weight: 700; }
.identity-main h1 { margin-top: 2px; }
.identity-main div > p:last-child { margin-top: 3px; color: var(--muted); font-size: 12px; }
.identity-stats { display: grid; grid-template-columns: repeat(4, minmax(100px, auto)); gap: 0; }
.identity-stats > div { min-width: 110px; padding: 4px 20px; border-left: 1px solid var(--line); }
.identity-stats dt { color: var(--muted); font-size: 11px; }
.identity-stats dd { margin-top: 4px; font-size: 14px; font-weight: 700; }
.identity-stats dd, .metric strong, .detail-grid dd { min-width: 0; overflow-wrap: anywhere; }
.state-label { display: inline-flex; align-items: center; min-height: 23px; padding: 2px 8px; border-radius: 999px; color: var(--ink-soft); background: #edf1f5; font-size: 11px; font-weight: 600; }
.state-label.success { color: var(--green); background: #e9f6ef; }
.state-label.warning { color: var(--amber); background: #fff5db; }
.state-label.error { color: var(--red); background: #fff0f2; }

.workbench { display: grid; grid-template-columns: 176px minmax(0, 1fr); align-items: start; border: 1px solid var(--line); background: var(--surface); }
.side-nav { position: sticky; top: 84px; display: grid; align-content: start; min-height: calc(100vh - 106px); padding: 12px 8px; border-right: 1px solid var(--line); background: #f7f9fb; }
.nav-item { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 8px; min-height: 43px; padding: 0 10px; border: 0; border-radius: 4px; color: var(--ink-soft); text-align: left; background: transparent; }
.nav-item > span { color: #98a2b3; font: 10px ui-monospace, Consolas, monospace; }
.nav-item:hover:not(:disabled) { border: 0; color: var(--ink); background: #e9edf2; }
.nav-item.active { color: #fff; background: #263a50; }
.nav-item.active > span { color: #b9c7d6; }
.count-badge { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; color: #fff; background: var(--red); font-size: 10px; }
.content-area { min-width: 0; }
.view { min-height: 720px; padding: 22px 24px 30px; }
.view-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 44px; margin-bottom: 18px; }
.view-heading h2 { margin-top: 3px; font-size: 21px; }
.metric-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface-alt); }
.metric { min-height: 86px; padding: 14px 16px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 11px; }
.metric strong { display: block; margin-top: 7px; overflow: hidden; font-size: 19px; text-overflow: ellipsis; white-space: nowrap; }
.metric small { display: block; margin-top: 3px; color: var(--muted); }
.quick-start { margin-top: 16px; padding: 14px; border: 1px solid #b9d7cd; background: #f4faf8; }
.quick-start .section-head > div p { margin-top: 3px; color: var(--muted); font-size: 11px; }
.quick-start-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.quick-start-button { display: grid; justify-items: start; align-content: center; gap: 3px; min-height: 64px; padding: 10px 13px; border-color: #83b8a8; text-align: left; background: var(--surface); }
.quick-start-button:hover:not(:disabled) { border-color: var(--teal); background: #f6fcfa; }
.quick-start-button strong { color: var(--teal); font-size: 14px; }
.quick-start-button small { max-width: 100%; overflow-wrap: anywhere; color: var(--muted); white-space: normal; }
.quick-start-button.is-busy { justify-items: center; color: var(--teal); }
.quick-action-stage { min-height: 29px; margin-top: 9px; padding: 6px 9px; border-left: 3px solid var(--teal); color: var(--ink-soft); background: rgba(255, 255, 255, .72); font-size: 12px; }
.quick-action-stage.error { border-left-color: var(--red); color: var(--red); background: #fff5f6; }
.section-block { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 12px; border-top: 1px solid var(--line-soft); border-left: 1px solid var(--line-soft); }
.detail-grid > div { min-height: 65px; padding: 11px 12px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.detail-grid dt { color: var(--muted); font-size: 11px; }
.detail-grid dd { margin-top: 5px; overflow-wrap: anywhere; font-weight: 600; }
.wealth-grid dd { color: var(--teal); font-size: 16px; }
.status-line { margin-top: 12px; padding: 11px 12px; border-left: 3px solid #98a2b3; background: var(--surface-alt); }
.muted { color: var(--muted); font-size: 12px; }

.control-band { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; gap: 10px; padding: 14px; border: 1px solid var(--line); background: var(--surface-alt); }
.toolbar { display: flex; align-items: end; gap: 10px; min-height: 58px; margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line); background: var(--surface-alt); }
.capacity { margin-right: auto; color: var(--ink-soft); font-weight: 700; white-space: nowrap; }
.search-field { display: flex; align-items: center; gap: 7px; }
.search-field input { width: 210px; }
.level-filter { display: flex; align-items: center; gap: 7px; }
.level-filter select { width: 112px; }
.inline-control, .switch-control { display: flex; align-items: center; gap: 7px; min-height: 36px; color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.escort-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--line); }
.escort-details > div { min-width: 0; padding: 9px 10px; background: var(--surface); }
.escort-details small, .escort-details strong { display: block; }
.escort-details small { color: var(--muted); font-size: 11px; }
.escort-details strong { margin-top: 2px; overflow-wrap: anywhere; font-size: 13px; }
.stretch-actions > button { flex: 1 1 0; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); }
.tall-table { max-height: 630px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 9px 11px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #f5f7f9; font-size: 11px; font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
tbody tr.selected { background: #edf5ff; }
td { font-size: 12px; }
td strong { display: block; color: var(--ink); font-size: 13px; }
td small { display: block; margin-top: 2px; color: var(--muted); }
.check-column { width: 40px; text-align: center; }
.check-column input { vertical-align: middle; }
.action-column { width: 100px; }
.table-action { min-height: 28px; padding-inline: 9px; font-size: 11px; }
.inventory-amount-control { display: grid; grid-template-columns: 64px auto; align-items: center; gap: 5px; min-width: 112px; }
.inventory-amount-control input { min-height: 28px; height: 28px; padding: 3px 6px; }
.inventory-amount-control .table-action { min-width: 43px; padding-inline: 7px; }
.quality { font-weight: 600; }
.quality-0, .quality-1 { color: var(--ink-soft); }
.quality-2 { color: var(--green); }
.quality-3 { color: var(--blue); }
.quality-4, .quality-5 { color: #8a4da2; }
.quality-6 { color: var(--amber); }
.empty-cell { padding: 34px 16px; color: var(--muted); text-align: center; }

.lineup-section { margin-top: 0; padding-top: 0; border-top: 0; }
.illustration-summon-section { margin-top: 0; padding-top: 0; border-top: 0; }
.illustration-toolbar { margin-top: 12px; }
.illustration-summon-table { max-height: 360px; }
.illustration-summon-table table { min-width: 720px; }
.illustration-count-input { width: 76px; min-height: 28px; height: 28px; padding: 3px 6px; }
.lineup-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 12px; }
.lineup-editor > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; padding: 12px; border: 1px solid var(--line); background: var(--surface-alt); }
.lineup-editor h4 { grid-column: 1 / -1; }

.automation-monitor { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(180px, .7fr) auto; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); background: #f7f9fb; }
.automation-monitor > div { display: grid; grid-template-columns: 13px 1fr; align-items: center; column-gap: 7px; }
.automation-monitor small { grid-column: 2; color: var(--muted); }
progress { width: 100%; height: 8px; accent-color: var(--teal); }
.combat-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px; }
.operation-section { display: grid; align-content: start; gap: 12px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.combat-layout .operation-section:nth-child(odd) { padding-right: 22px; border-right: 1px solid var(--line); }
.wide-operation { grid-column: 1 / -1; padding-right: 0 !important; border-right: 0 !important; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.form-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.draw-settings { display: grid; grid-template-columns: minmax(95px, .7fr) minmax(130px, 1fr) minmax(95px, .7fr); align-items: end; gap: 9px; padding: 10px; border-left: 3px solid #bac4d0; background: #f6f8fa; }
.compact-settings input[type="number"] { min-height: 33px; }
.advanced-settings { margin: 0; padding: 0; border: 1px solid var(--line); background: var(--surface-alt); }
.advanced-settings summary { display: flex; align-items: center; min-height: 36px; padding: 7px 10px; color: var(--ink-soft); background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.advanced-settings summary:hover { color: var(--blue); background: #f1f4f7; }
.advanced-settings[open] summary { border-bottom: 1px solid var(--line); }
.advanced-settings-body { display: grid; gap: 10px; padding: 10px; }
.advanced-settings .draw-settings { padding: 0 0 0 9px; background: transparent; }
.option-line { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.option-at-bottom { align-self: end; }
.action-row { display: flex; gap: 8px; }
.action-row > button { flex: 1; }
.inline-summary { min-height: 34px; padding: 8px 10px; color: var(--muted); background: var(--surface-alt); font-size: 12px; }
.treasure-maze-status { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; border: 1px solid #b9d7cd; background: #b9d7cd; }
.treasure-maze-status > div { min-width: 0; padding: 9px 10px; background: #f4faf8; }
.treasure-maze-status small, .treasure-maze-status strong { display: block; }
.treasure-maze-status small { color: var(--muted); font-size: 11px; }
.treasure-maze-status strong { margin-top: 2px; overflow-wrap: anywhere; font-size: 13px; }
.treasure-maze-status .treasure-maze-empty { grid-column: 1 / -1; color: var(--muted); text-align: center; background: var(--surface-alt); }

.task-actions { display: grid; grid-template-columns: 1.2fr 1.2fr .8fr; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.task-actions .operation-section { padding: 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.reward-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.reward-item { display: grid; gap: 3px; min-width: 150px; padding: 9px 10px; border: 1px solid var(--line); background: var(--surface-alt); }
.reward-item strong { font-size: 12px; }
.reward-item small { color: var(--muted); }
.reward-item.ready { border-color: #8bc4ae; background: #eff9f4; }
.reward-item.received { opacity: .62; }

.log-filters { display: flex; gap: 7px; margin-bottom: 10px; }
.filter-chip { min-height: 29px; padding-inline: 12px; border-radius: 15px; font-size: 11px; }
.filter-chip.active { color: #fff; border-color: #34485e; background: #34485e; }
.log-list { display: grid; gap: 9px; padding: 0; list-style: none; }
.log-entry { border: 1px solid var(--line); border-left: 3px solid var(--green); background: var(--surface); }
.log-entry.error { border-left-color: var(--red); }
.log-entry[hidden] { display: none; }
.log-entry-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.log-entry-head time { color: var(--muted); font-size: 11px; }
.log-entry-body { padding: 10px 12px; }
.result-status { font-weight: 700; }
.result-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.result-group { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 8px 9px; background: var(--surface-alt); }
.result-group b { width: 100%; color: var(--muted); font-size: 11px; }
.result-group span { font-size: 12px; }
.result-group.gain strong, .result-group.pet strong, .result-group.currency strong { color: var(--green); }
.result-group.loss strong { color: var(--red); }
.result-notes { display: grid; gap: 3px; margin-top: 8px; color: var(--muted); font-size: 11px; }
details { margin-top: 9px; border-top: 1px solid var(--line-soft); padding-top: 7px; }
details summary { color: var(--blue); font-size: 11px; cursor: pointer; }
pre { max-height: 260px; margin: 8px 0 0; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: #465669; font: 11px/1.5 ui-monospace, Consolas, monospace; }
.empty-state { padding: 30px 14px; color: var(--muted); text-align: center; }

.confirm-dialog { width: min(460px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 7px; box-shadow: 0 20px 65px rgba(16, 24, 40, .28); }
.confirm-dialog::backdrop { background: rgba(15, 23, 33, .58); }
.confirm-dialog form { padding: 20px; }
.confirm-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.confirm-dialog p { margin: 13px 0; color: var(--ink-soft); }
.dialog-close { width: 32px; min-height: 32px; padding: 0; border: 0; font-size: 23px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
body.game-loading-active { overflow: hidden; }
.game-loading { position: fixed; inset: 0; z-index: 1000; display: grid; grid-template-rows: auto 1fr; min-width: 320px; min-height: 100dvh; padding: 24px clamp(20px, 4vw, 64px); color: #f5f7fa; background: #111a24; }
.game-loading-brand { display: flex; align-items: center; gap: 11px; font-size: 14px; }
.game-loading-brand > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 5px; color: #18222e; background: #e5bc55; font-weight: 800; }
.game-loading-brand strong { font-size: 15px; }
.game-loading-center { align-self: center; justify-self: center; display: grid; justify-items: center; width: min(520px, 100%); padding-bottom: 72px; text-align: center; }
.game-loading-spinner { position: relative; width: 72px; height: 72px; margin-bottom: 28px; animation: game-loading-rotate 1.5s linear infinite; }
.game-loading-spinner i { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #e5bc55; }
.game-loading-spinner i:nth-child(1) { top: 0; left: 25px; }
.game-loading-spinner i:nth-child(2) { top: 25px; right: 0; background: #46a697; }
.game-loading-spinner i:nth-child(3) { bottom: 0; left: 25px; background: #5a8ed8; }
.game-loading-spinner i:nth-child(4) { top: 25px; left: 0; background: #d46a78; }
.game-loading-center p { font-size: 24px; font-weight: 750; }
.game-loading-center small { min-height: 22px; margin-top: 9px; color: #b8c3cf; font-size: 13px; }
.game-loading-track { width: 100%; height: 5px; margin-top: 28px; overflow: hidden; background: #344252; }
.game-loading-track span { display: block; width: 0; height: 100%; background: #46a697; transition: width .22s ease; }
.game-loading-center output { margin-top: 10px; color: #d8e0e8; font: 12px ui-monospace, Consolas, monospace; }
@keyframes game-loading-rotate { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .game-loading-spinner { animation: none; }
  .game-loading-track span { transition: none; }
}
#toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: min(440px, calc(100% - 40px)); padding: 11px 14px; border-radius: 5px; color: #fff; background: #1f2d3b; box-shadow: 0 10px 30px rgba(16, 24, 40, .2); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: var(--red); }

@media (max-width: 1100px) {
  .environment { display: none; }
  .identity-stats { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
  .identity-stats > div:nth-child(3) { border-top: 1px solid var(--line); }
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(n+4) { border-top: 1px solid var(--line); }
  .detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .task-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-actions .operation-section:last-child { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  main { width: min(100% - 20px, 1440px); margin-top: 10px; }
  .topbar { position: static; flex-wrap: wrap; gap: 10px; padding: 10px; }
  .session-tools { width: 100%; margin-left: 0; overflow-x: auto; }
  .quick-account { flex: 1 0 220px; }
  .quick-account select { width: 100%; }
  .login-shell { margin: 10px auto; }
  .login-heading { padding: 20px; }
  .account-columns { grid-template-columns: 1fr; }
  .account-list-section, .account-action-section { padding: 18px; }
  .account-list-section { border-right: 0; border-bottom: 1px solid var(--line); }
  .identity-band { align-items: flex-start; flex-direction: column; border-bottom: 1px solid var(--line); }
  .identity-stats { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .identity-stats > div { min-width: 0; padding-inline: 10px; }
  .identity-stats > div:first-child { border-left: 0; }
  .identity-stats > div:nth-child(3) { border-top: 0; }
  .workbench { display: block; }
  .side-nav { position: sticky; top: 0; z-index: 10; display: flex; min-height: 0; padding: 7px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-item { flex: 0 0 auto; display: flex; min-height: 37px; padding-inline: 11px; }
  .nav-item > span { display: none; }
  .view { min-height: 600px; padding: 18px 16px 24px; }
  .control-band { grid-template-columns: 1fr 1fr; }
  .control-band button { width: 100%; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .capacity { width: 100%; }
  .search-field { flex: 1 1 220px; }
  .search-field input { width: 100%; }
  .level-filter { flex: 0 1 150px; }
  .level-filter select { width: 100%; }
  .combat-layout { grid-template-columns: 1fr; }
  .combat-layout .operation-section:nth-child(odd) { padding-right: 0; border-right: 0; }
  .wide-operation { grid-column: auto; }
  .task-actions { grid-template-columns: 1fr; }
  .task-actions .operation-section:last-child { grid-column: auto; }
  .automation-monitor { grid-template-columns: 1fr auto; }
  .automation-monitor progress { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 560px) {
  .game-loading { padding: 18px; }
  .game-loading-center { padding-bottom: 36px; }
  .game-loading-center p { font-size: 21px; }
  main { width: 100%; margin: 0 auto 24px; }
  .brand small { display: none; }
  .session-tools { flex-wrap: wrap; overflow: visible; }
  .session-tools button { flex: 1 1 auto; padding-inline: 9px; }
  .quick-account { flex: 1 1 100%; }
  .quick-account > span { white-space: nowrap; }
  .login-shell, .identity-band, .workbench { border-left: 0; border-right: 0; }
  .account-row { grid-template-columns: 1fr; }
  .account-row-actions { justify-content: flex-start; }
  .identity-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .identity-stats > div:nth-child(3) { border-top: 1px solid var(--line); }
  .identity-stats > div:nth-child(odd) { border-left: 0; }
  .view-heading { align-items: flex-start; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric strong { font-size: 22px; }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-child(3) { border-right: 1px solid var(--line); }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .quick-start-actions { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .treasure-maze-status { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-band, .form-grid, .form-grid.three-columns, .draw-settings { grid-template-columns: 1fr; }
  .lineup-editor { grid-template-columns: 1fr; }
  .lineup-editor > div { grid-template-columns: 1fr; }
  .result-groups { grid-template-columns: 1fr; }
  .action-row { flex-wrap: wrap; }
  .action-row > button { flex: 1 1 120px; }
}
