:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #181c24;
  --surface-3: #20252f;
  --line: #2d333e;
  --line-strong: #414958;
  --text: #f1f3f5;
  --muted: #969eaa;
  --accent: #d8b85b;
  --accent-strong: #f1d176;
  --teal: #4fc6b1;
  --danger: #e56565;
  --cost-1: rgb(175, 175, 175);
  --cost-2: rgb(28, 195, 152);
  --cost-3: rgb(7, 165, 241);
  --cost-4: rgb(213, 105, 230);
  --cost-5: rgb(255, 183, 1);
  --cost-7: rgb(255, 183, 1);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(82, 101, 129, 0.18), transparent 36%),
    var(--bg);
  background-size: 32px 32px, 32px 32px, auto, auto;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sim-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 64px;
  display: grid;
  grid-template-columns: 250px 1fr 250px;
  align-items: center;
  gap: 20px;
  padding: 8px max(20px, calc((100vw - 1500px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(11, 13, 18, 0.92);
  backdrop-filter: blur(18px);
}

.sim-brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.sim-brand-mark { width: 36px; height: 36px; display: grid; place-items: center; color: #15130b; background: var(--accent); font-weight: 900; border-radius: 4px; }
.sim-brand strong, .sim-brand small { display: block; }
.sim-brand strong { font-size: 15px; }
.sim-brand small { margin-top: 1px; color: var(--muted); font-size: 9px; font-weight: 700; }

.season-switcher { display: flex; align-items: center; justify-content: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.season-switcher::-webkit-scrollbar { display: none; }
.season-button { min-width: 72px; min-height: 36px; padding: 7px 13px; border: 1px solid transparent; border-radius: 4px; color: var(--muted); background: transparent; cursor: pointer; white-space: nowrap; }
.season-button:hover { color: var(--text); background: var(--surface-2); }
.season-button.is-active { color: #17140b; border-color: var(--accent); background: var(--accent); font-weight: 800; }
.season-button small { display: block; font-size: 8px; opacity: 0.7; }

.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); cursor: pointer; }
.icon-button svg { width: 17px; height: 17px; }
.icon-button:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-3); }
.icon-button:disabled { opacity: 0.35; cursor: default; }
.icon-button.danger:hover { color: #fff; border-color: var(--danger); background: #4a2025; }
.icon-button.small { width: 28px; height: 28px; }

.sim-shell { width: min(1500px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 64px; }
.sim-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.eyebrow, .panel-kicker { margin: 0 0 5px; color: var(--accent); font-size: 10px; line-height: 1; font-weight: 800; letter-spacing: 0.12em; }
.sim-heading h1 { margin: 0; font-size: 30px; line-height: 1.15; }
.sim-heading p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.text-button, .primary-button { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 12px; border-radius: 4px; cursor: pointer; }
.text-button { border: 1px solid var(--line); background: var(--surface-2); }
.text-button:hover { border-color: var(--line-strong); background: var(--surface-3); }
.text-button svg { width: 15px; height: 15px; }
.primary-button { border: 1px solid var(--accent); color: #17140b; background: var(--accent); font-weight: 800; }

.toggle-control { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.toggle-control input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-control span { width: 36px; height: 20px; position: relative; border: 1px solid var(--line-strong); border-radius: 20px; background: var(--surface-3); }
.toggle-control span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform 120ms ease, background 120ms ease; }
.toggle-control input:checked + span { border-color: #8c793f; background: #453d25; }
.toggle-control input:checked + span::after { transform: translateX(16px); background: var(--accent); }

.workspace { display: grid; grid-template-columns: 220px minmax(640px, 1fr) 248px; gap: 12px; align-items: stretch; }
.tool-panel, .board-stage { border: 1px solid var(--line); border-radius: 6px; background: rgba(18, 21, 28, 0.96); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22); }
.trait-rail, .item-rail { min-height: 554px; padding: 16px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.panel-title-row h2, .roster-toolbar h2 { margin: 0; font-size: 16px; line-height: 1.2; }
.panel-count { min-width: 28px; height: 24px; display: grid; place-items: center; padding: 0 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 12px; }

.trait-summary { margin-top: 12px; display: flex; flex-direction: column; gap: 2px; max-height: 490px; overflow-y: auto; scrollbar-width: thin; }
.trait-row { min-height: 43px; display: grid; grid-template-columns: 36px 28px minmax(0, 1fr); align-items: center; gap: 6px; padding: 3px 2px; }
.trait-badge { grid-column: 1; grid-row: 1; width: 36px; height: 36px; position: relative; display: grid; place-items: center; }
.trait-badge-frame { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.trait-badge-icon { position: relative; z-index: 1; width: 18px; height: 18px; object-fit: contain; filter: brightness(0); opacity: .76; }
.trait-copy { grid-column: 3; grid-row: 1; min-width: 0; }
.trait-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e5e8ec; font-size: 13px; line-height: 1.2; }
.trait-copy small { display: block; margin-top: 2px; color: #a1a7b0; font-size: 11px; line-height: 1.15; }
.trait-count { grid-column: 2; grid-row: 1; min-width: 24px; height: 24px; display: grid; place-items: center; padding: 0 5px; border-radius: 4px; color: #f1f3f5; background: #343943; font-weight: 700; font-size: 12px; }

.board-stage { min-width: 0; container-type: inline-size; padding: 14px 16px 12px; background: linear-gradient(180deg, rgba(24, 28, 36, 0.98), rgba(12, 15, 21, 0.98)); }
.board-toolbar { min-height: 38px; display: flex; align-items: center; gap: 14px; }
.board-stat { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.board-stat svg { width: 16px; height: 16px; color: var(--teal); }
.board-stat strong { color: var(--text); font-size: 15px; }
.gold-stat img { width: 17px; height: 17px; object-fit: contain; }
.gold-stat span { margin-left: 2px; }
.board-hint { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: #747d8a; font-size: 11px; }
.board-hint svg { width: 14px; height: 14px; }

.hex-board-wrap { width: 100%; min-width: 0; display: grid; place-items: center; overflow: visible; padding: 6px 0 10px; }
.hex-board { --hex-w: min(105px, calc(13.333cqw - 6.933px)); --hex-h: calc(var(--hex-w) * 1.14); --hex-gap: 8px; --col-step: calc(var(--hex-w) + var(--hex-gap)); --row-step: calc(var(--hex-h) * .78); width: calc(var(--col-step) * 6.5 + var(--hex-w)); max-width: 100%; height: calc(var(--row-step) * 3 + var(--hex-h)); position: relative; }
.hex-cell { position: absolute; width: var(--hex-w); height: var(--hex-h); padding: 0; border: 0; background: transparent; cursor: pointer; }
.hex-cell.has-unit { z-index: 2; }
.hex-cell.has-items { z-index: 20; }
.hex-cell.has-unit:hover { z-index: 30; }
.hex-cell:nth-child(n+8):nth-child(-n+14), .hex-cell:nth-child(n+22):nth-child(-n+28) { transform: translateX(calc(var(--col-step) / 2)); }
.hex-cell:nth-child(-n+7) { top: 0; }
.hex-cell:nth-child(n+8):nth-child(-n+14) { top: var(--row-step); }
.hex-cell:nth-child(n+15):nth-child(-n+21) { top: calc(var(--row-step) * 2); }
.hex-cell:nth-child(n+22) { top: calc(var(--row-step) * 3); }
.hex-cell:nth-child(7n+1) { left: 0; }
.hex-cell:nth-child(7n+2) { left: var(--col-step); }
.hex-cell:nth-child(7n+3) { left: calc(var(--col-step) * 2); }
.hex-cell:nth-child(7n+4) { left: calc(var(--col-step) * 3); }
.hex-cell:nth-child(7n+5) { left: calc(var(--col-step) * 4); }
.hex-cell:nth-child(7n+6) { left: calc(var(--col-step) * 5); }
.hex-cell:nth-child(7n+7) { left: calc(var(--col-step) * 6); }
.hex-floor, .unit-portrait { position: absolute; inset: 2px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.hex-floor { background: #303641; }
.hex-floor::after { content: ""; position: absolute; inset: 2px; clip-path: inherit; background: linear-gradient(145deg, #1d222b, #11151c); }
.hex-cell:hover .hex-floor { background: #5d6675; }
.hex-cell.is-drop-target .hex-floor { background: var(--accent); }
.unit-portrait { inset: 0; z-index: 1; padding: 3px; background: var(--unit-color); filter: drop-shadow(0 5px 8px rgba(0,0,0,.46)); }
.unit-portrait-image { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); clip-path: inherit; object-fit: cover; }
.unit-portrait::after { content: ""; position: absolute; z-index: 1; inset: 3px; clip-path: inherit; background: linear-gradient(transparent 42%, rgba(0,0,0,.82)); }
.unit-name { position: absolute; z-index: 3; left: 12px; right: 12px; bottom: 12px; overflow: hidden; color: #fff; font-size: 11px; font-weight: 700; text-align: center; text-shadow: 0 1px 3px #000; white-space: nowrap; text-overflow: ellipsis; }
.hex-board.hide-names .unit-name { display: none; }
.unit-items { position: absolute; z-index: 40; top: 10px; left: 50%; display: flex; gap: 2px; transform: translateX(-50%); pointer-events: auto; }
.unit-item { width: 25px; height: 25px; padding: 0; border: 1px solid #c6a84f; border-radius: 3px; background: #111; overflow: hidden; cursor: help; box-shadow: 0 2px 5px #000; }
.unit-item img { width: 100%; height: 100%; object-fit: cover; }
.unlock-mark { position: absolute; z-index: 41; right: -1px; bottom: 18px; width: 18px; height: 18px; padding: 0; border: 0; background: transparent; }
.unlock-mark img { width: 100%; height: 100%; object-fit: contain; }

.board-footer { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--line); }
.component-summary-wrap { min-width: 0; display: flex; align-items: center; gap: 10px; }
.footer-label { color: var(--muted); font-size: 11px; white-space: nowrap; }
.component-summary { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.component-stack { position: relative; width: 31px; height: 31px; }
.component-stack img { width: 100%; height: 100%; object-fit: cover; border: 1px solid var(--line-strong); border-radius: 3px; }
.component-stack b { position: absolute; right: -4px; bottom: -4px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; color: #fff; background: #111820; font-size: 9px; line-height: 15px; text-align: center; }
.selected-help { max-width: 240px; color: var(--accent-strong); font-size: 10px; text-align: right; }
.selected-help[hidden] { display: none; }
.muted { color: var(--muted); font-size: 11px; }

.item-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; margin: 12px 0 9px; }
.item-tab { min-width: 0; padding: 6px 2px; border: 1px solid transparent; border-radius: 3px; color: var(--muted); background: var(--surface-3); font-size: 11px; cursor: pointer; }
.item-tab:hover { color: var(--text); }
.item-tab.is-active { color: #17140b; border-color: var(--accent); background: var(--accent); font-weight: 800; }
.search-field { min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px; background: #0e1117; }
.search-field:focus-within { border-color: var(--accent); }
.search-field svg { flex: 0 0 auto; width: 15px; height: 15px; color: var(--muted); }
.search-field input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 12px; }
.search-field input::placeholder { color: #68717e; }
.compact-search { min-height: 32px; }
.item-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-top: 10px; max-height: 428px; overflow-y: auto; scrollbar-width: thin; }
.item-button { aspect-ratio: 1; position: relative; padding: 0; border: 1px solid var(--line); border-radius: 3px; background: #0c0f14; overflow: hidden; cursor: grab; }
.item-button img { width: 100%; height: 100%; object-fit: cover; }
.item-button:hover, .item-button.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.item-button.is-selected::after { content: ""; position: absolute; inset: 0; background: rgba(216,184,91,.18); }

.roster-panel { margin-top: 12px; padding: 16px; }
.roster-toolbar { display: grid; grid-template-columns: 150px minmax(220px, 360px) minmax(220px, 300px) 1fr; align-items: center; gap: 12px; }
.hero-search kbd { padding: 1px 5px; border: 1px solid var(--line); border-radius: 3px; color: #77808d; background: var(--surface-2); font-size: 10px; }
.cost-filters { display: flex; justify-content: flex-end; gap: 4px; flex-wrap: wrap; }
.cost-filter { min-width: 32px; height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); background: var(--surface-2); font-size: 11px; cursor: pointer; }
.cost-filter:hover { border-color: var(--line-strong); color: var(--text); }
.cost-filter.is-active { color: #111; border-color: var(--filter-color, var(--accent)); background: var(--filter-color, var(--accent)); font-weight: 800; }
.trait-picker { width: 100%; min-height: 38px; position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 32px; align-items: center; gap: 2px; margin: 0; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: #0e1117; }
.trait-picker:focus-within, .trait-picker.is-open { border-color: var(--accent); }
.trait-picker.is-filtering { border-color: #8c793f; background: #17170f; }
.trait-picker-trigger { min-width: 0; height: 36px; display: grid; grid-template-columns: 24px minmax(0, 1fr) 16px; align-items: center; gap: 8px; padding: 0 4px 0 9px; border: 0; color: var(--text); background: transparent; cursor: pointer; text-align: left; }
.trait-filter-current-icon { width: 22px; height: 22px; display: grid; place-items: center; }
.trait-filter-current-icon img { width: 19px; height: 19px; object-fit: contain; filter: brightness(0) invert(1); opacity: .88; }
.trait-filter-current-icon svg, .trait-picker-chevron { width: 15px; height: 15px; color: var(--muted); }
.trait-filter-current-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.trait-picker.is-open .trait-picker-chevron { transform: rotate(180deg); }
.trait-filter-menu { position: absolute; z-index: 40; top: calc(100% + 5px); left: -1px; width: max(100%, 260px); max-height: 360px; padding: 5px; border: 1px solid var(--line-strong); border-radius: 4px; background: #202020; box-shadow: 0 16px 34px rgba(0,0,0,.58); overflow-y: auto; scrollbar-width: thin; }
.trait-filter-menu[hidden] { display: none; }
.trait-filter-group { padding-top: 4px; border-top: 1px solid #343434; }
.trait-filter-group-label { display: block; padding: 7px 8px 4px; color: #7f858e; font-size: 10px; font-weight: 700; }
.trait-filter-option { width: 100%; min-height: 38px; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 5px 8px; border: 0; border-radius: 3px; color: #d8dbe0; background: transparent; cursor: pointer; text-align: left; }
.trait-filter-option:hover, .trait-filter-option.is-selected { color: #fff; background: #303030; }
.trait-filter-option small { min-width: 22px; color: #898f99; font-size: 10px; text-align: right; }
.trait-option-icon { width: 24px; height: 24px; display: grid; place-items: center; }
.trait-option-icon img { width: 20px; height: 20px; object-fit: contain; filter: brightness(0) invert(1); opacity: .84; }
.trait-option-icon svg { width: 18px; height: 18px; }
.trait-filter-clear { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 3px; color: var(--muted); background: transparent; cursor: pointer; }
.trait-filter-clear:hover { color: var(--text); background: var(--surface-3); }
.trait-filter-clear[hidden] { display: none; }
.trait-filter-clear svg { width: 14px; height: 14px; }
.hero-groups { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.hero-cost-group { display: grid; grid-template-columns: 80px 1fr; gap: 12px; align-items: start; }
.cost-heading { min-height: 54px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.cost-dot { width: 8px; height: 30px; border-radius: 2px; background: var(--cost-color); }
.cost-heading strong { display: block; color: var(--text); font-size: 14px; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.hero-button { min-width: 0; position: relative; padding: 0; border: 2px solid var(--hero-color); border-radius: 3px; background: #0c0f14; overflow: hidden; cursor: pointer; transition: opacity 100ms ease, filter 100ms ease; }
.hero-button::before { content: ""; display: block; padding-top: 100%; }
.hero-button img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-button span { position: absolute; z-index: 2; inset: auto 0 0; padding: 13px 2px 3px; overflow: hidden; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.92)); font-size: 10px; text-align: center; white-space: nowrap; text-overflow: ellipsis; }
.hero-button .hero-unlock { inset: 3px 3px auto auto; width: 16px; height: 16px; padding: 2px; border-radius: 50%; background: #121722; }
.hero-button.is-dimmed { opacity: .2; filter: grayscale(.9); }
.hero-button:hover { z-index: 2; opacity: 1; filter: none; box-shadow: 0 0 0 2px rgba(255,255,255,.8); }
.hero-button.is-dimmed:hover { opacity: .35; filter: grayscale(.75); box-shadow: 0 0 0 1px var(--line-strong); }
.empty-state { padding: 34px 12px; color: var(--muted); font-size: 12px; text-align: center; }
.empty-state.compact { padding: 24px 8px; }

.detail-popover { position: fixed; z-index: 100; width: min(390px, calc(100vw - 24px)); max-height: min(620px, calc(100vh - 24px)); border: 1px solid #525966; border-radius: 5px; background: #12151a; box-shadow: 0 18px 48px rgba(0,0,0,.62); overflow: auto; pointer-events: none; }
.detail-popover[hidden] { display: none; }
.hero-detail-cover { min-height: 155px; position: relative; padding: 16px; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(90deg, rgba(8,10,14,.95), rgba(8,10,14,.15)), var(--splash) center/cover no-repeat; }
.hero-detail-cover h3 { margin: 0; font-size: 25px; text-shadow: 0 2px 6px #000; }
.hero-detail-traits { display: flex; flex-direction: column; gap: 5px; }
.hero-detail-traits span { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; }
.hero-detail-traits img { width: 18px; height: 18px; object-fit: contain; filter: brightness(0) invert(1); }
.hero-detail-cost { position: absolute; right: 14px; bottom: 12px; display: flex; align-items: center; gap: 5px; font-weight: 800; }
.hero-detail-cost img { width: 17px; height: 17px; }
.hero-detail-body { padding: 15px; }
.skill-heading { display: grid; grid-template-columns: 34px 1fr auto; gap: 9px; align-items: center; }
.skill-heading img { width: 34px; height: 34px; border-radius: 3px; object-fit: cover; }
.skill-heading strong { font-size: 15px; }
.mana { color: #65bce7; font-size: 11px; }
.skill-description { margin: 12px 0 0; color: #c4c9d0; font-size: 12px; line-height: 1.75; white-space: pre-line; }
.skill-values { display: grid; gap: 5px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.skill-value { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.unlock-box { display: flex; gap: 10px; margin-top: 14px; padding: 11px; border: 1px solid #6e5b25; border-radius: 4px; background: #252318; }
.unlock-box img { flex: 0 0 auto; width: 24px; height: 24px; object-fit: contain; }
.unlock-box strong { display: block; color: var(--accent-strong); font-size: 12px; }
.unlock-box p { margin: 4px 0 0; color: #c4c0b4; font-size: 11px; line-height: 1.55; }
.item-detail { padding: 16px; }
.item-detail-heading { display: grid; grid-template-columns: 48px 1fr; gap: 11px; align-items: center; }
.item-detail-heading > img { width: 48px; height: 48px; border: 1px solid var(--line-strong); border-radius: 4px; object-fit: cover; }
.item-detail h3 { margin: 0; font-size: 18px; }
.item-recipe { display: flex; align-items: center; gap: 7px; margin-top: 7px; }
.item-recipe img { width: 25px; height: 25px; border-radius: 3px; object-fit: cover; }
.item-recipe b { color: var(--muted); }
.item-stats { margin: 12px 0 0; color: #68bde6; font-size: 12px; }
.item-description { margin: 9px 0 0; color: #c4c9d0; font-size: 12px; line-height: 1.65; }

.toast { position: fixed; z-index: 120; left: 50%; bottom: 28px; min-width: 160px; max-width: calc(100vw - 32px); padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--text); background: #20252d; box-shadow: 0 8px 24px #0008; font-size: 12px; text-align: center; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity 130ms ease, transform 130ms ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.code-dialog { width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); background: var(--surface); }
.code-dialog::backdrop, .export-image-dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(3px); }
.code-dialog form { padding: 18px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-heading h2 { margin: 0; font-size: 19px; }
.code-dialog p { color: var(--muted); font-size: 12px; }
.code-dialog textarea { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 4px; resize: vertical; color: var(--text); background: #0d1015; font-family: ui-monospace, Consolas, monospace; font-size: 11px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.export-image-dialog { width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); background: var(--surface); }
.export-image-dialog form { padding: 18px; }
.export-image-dialog h2 { margin: 0; font-size: 19px; }
.export-image-option { min-height: 64px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); cursor: pointer; }
.export-image-option:first-of-type { margin-top: 18px; }
.export-image-option strong, .export-image-option small { display: block; }
.export-image-option strong { font-size: 13px; }
.export-image-option small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.export-image-option input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 38px; height: 22px; position: relative; border: 1px solid var(--line-strong); border-radius: 12px; background: #292e37; }
.toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform 120ms ease; }
.export-image-option input:checked + .toggle-track { border-color: #8c793f; background: #453d25; }
.export-image-option input:checked + .toggle-track::after { transform: translateX(16px); background: var(--accent); }

.lineup-image-capture { position: fixed; z-index: -10; top: 0; left: -20000px; width: max-content; min-height: 574px; display: flex; align-items: stretch; gap: 24px; padding: 20px; color: var(--text); background: #0d101a; }
.lineup-image-capture.is-transparent { background: transparent; }
.lineup-image-traits { width: 244px; height: 534px; flex: 0 0 244px; padding: 16px 14px; border-radius: 6px; background: #232329; overflow: hidden; }
.lineup-image-trait-title { padding: 2px 2px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.lineup-image-trait-title span, .lineup-image-trait-title strong { display: block; }
.lineup-image-trait-title span { color: var(--accent); font-size: 9px; font-weight: 800; }
.lineup-image-trait-title strong { margin-top: 3px; font-size: 15px; }
.lineup-image-traits .trait-summary { max-height: 458px; gap: 0; overflow: hidden; }
.lineup-image-traits .trait-row { min-height: 55px; grid-template-columns: 42px 30px minmax(0, 1fr); gap: 7px; }
.lineup-image-traits .trait-badge { width: 42px; height: 42px; }
.lineup-image-traits .trait-badge-icon { width: 21px; height: 21px; }
.lineup-image-traits .trait-copy strong { font-size: 14px; }
.lineup-image-traits .trait-copy small { font-size: 12px; }
.lineup-image-board { width: 1098px; min-height: 534px; display: grid; place-items: center; }
.lineup-image-board .hex-board { --hex-w: 140px; --hex-h: calc(var(--hex-w) * 1.14); --hex-gap: 8px; }
.lineup-image-board .unit-name { bottom: 15px; font-size: 15px; }
.lineup-image-board .unit-item { width: 30px; height: 30px; }
.lineup-image-board .unit-items { top: 14px; }
.lineup-image-board .unlock-mark { right: -1px; bottom: 23px; width: 23px; height: 23px; }

@container (max-width: 700px) {
  .hex-board { --hex-w: min(94px, calc(13.333cqw - 4.333px)); --hex-gap: 5px; }
}

@container (max-width: 480px) {
  .hex-board { --hex-w: calc(13.333cqw - 2.6px); --hex-gap: 3px; }
}

@media (max-width: 1220px) {
  .sim-topbar { grid-template-columns: 210px 1fr auto; }
  .workspace { grid-template-columns: 190px minmax(600px, 1fr); }
  .item-rail { grid-column: 1 / -1; min-height: auto; }
  .item-rail .panel-title-row { display: none; }
  .item-rail { display: grid; grid-template-columns: 320px minmax(220px, 1fr) 1fr; align-items: start; gap: 12px; }
  .item-tabs { margin: 0; }
  .item-grid { grid-template-columns: repeat(auto-fill, 34px); max-height: 110px; margin: 0; }
}

@media (max-width: 900px) {
  .sim-topbar { position: static; grid-template-columns: 1fr auto; padding: 9px 14px; }
  .season-switcher { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; padding-top: 3px; }
  .sim-shell { width: min(100% - 20px, 760px); padding-top: 20px; }
  .sim-heading { align-items: flex-start; }
  .sim-heading h1 { font-size: 25px; }
  .workspace { display: flex; flex-direction: column; }
  .board-stage { order: 1; }
  .trait-rail { order: 2; min-height: auto; }
  .item-rail { order: 3; }
  .trait-summary { display: grid; grid-template-columns: 1fr; max-height: 280px; }
  .trait-rail .panel-title-row { padding-bottom: 9px; }
  .item-rail { display: block; }
  .item-rail .panel-title-row { display: flex; }
  .item-tabs { margin-top: 12px; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); max-height: 220px; margin-top: 10px; }
  .roster-toolbar { grid-template-columns: 1fr 1fr; }
  .trait-picker { grid-column: 1; }
  .cost-filters { grid-column: 1 / -1; justify-content: flex-start; }
  .hero-cost-group { grid-template-columns: 58px 1fr; }
}

@media (max-width: 600px) {
  .sim-brand small, .top-actions #exportImageButton, .top-actions #shareButton { display: none; }
  .sim-topbar { min-height: 56px; }
  .sim-heading { display: block; }
  .heading-actions { justify-content: flex-start; margin-top: 14px; }
  .board-stage { padding: 10px 6px 9px; }
  .board-toolbar { padding: 0 5px; }
  .board-hint { display: none; }
  .hex-board { flex: 0 0 auto; }
  .unit-name { left: 7px; right: 7px; bottom: 7px; font-size: 8px; }
  .unit-items { top: 4px; gap: 1px; }
  .unit-item { width: 17px; height: 17px; }
  .unlock-mark { right: -1px; bottom: 9px; width: 14px; height: 14px; }
  .board-footer { align-items: flex-start; }
  .selected-help { display: none; }
  .component-summary-wrap { align-items: flex-start; }
  .roster-panel { padding: 12px; }
  .roster-toolbar { display: flex; align-items: stretch; flex-direction: column; gap: 10px; }
  .hero-search { width: 100%; }
  .hero-cost-group { display: block; }
  .cost-heading { min-height: 28px; }
  .cost-dot { width: 26px; height: 4px; }
  .cost-heading strong { display: inline; margin-right: 4px; }
  .hero-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .hero-button span { font-size: 8px; }
  .trait-summary { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
