
    :root {
      --bg: #080909;
      --panel: rgba(9, 10, 10, .72);
      --border: rgba(113, 113, 122, .48);
      --border-soft: rgba(113, 113, 122, .23);
      --text: #f4f4f5;
      --muted: #a1a1aa;
      --gold: #f2c744;
      --cyan: #54d9f0;
      --green: #4ade80;
      --orange: #ff7f24;
      --red: #f87171;
      --surface: #171719;
      --surface-hover: #23231f;
      --surface-sunken: #131315;
      --slot: #202023;
      --panel-solid: #0e0f10;
      --radius: 12px;
    }

    * { box-sizing: border-box; }
    html { background: var(--bg); }
    body {
      min-width: 320px;
      min-height: 100vh;
      margin: 0;
      color: var(--text);
      background:
        radial-gradient(circle at 11% 20%, rgba(5, 57, 39, .34), transparent 28rem),
        radial-gradient(circle at 87% 5%, rgba(75, 24, 11, .36), transparent 31rem),
        var(--bg);
      font: 14px/1.35 Inter, "Noto Sans KR", system-ui, sans-serif;
    }

    .page {
      width: min(1180px, calc(100% - 48px));
      margin: 0 auto;
      padding: 36px 0 64px;
    }

    .viewer-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 24px; border-bottom: 1px solid var(--border-soft); }
    .viewer-tabs { display: flex; gap: 8px; }
    .viewer-tab { padding: 10px 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-weight: 700; }
    .viewer-tab:hover, .viewer-tab:focus-visible { color: var(--text); outline: none; }
    .viewer-tab.active { border-bottom-color: var(--gold); color: var(--gold); }

    :where(button, summary, select, input):focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

    .field-box {
      min-height: 36px;
      padding: 6px 10px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background-color: var(--surface);
      color: var(--text);
      font: inherit;
      font-size: 13px;
    }

    .picker-field {
      appearance: none;
      padding-right: 30px;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23a1a1aa'/%3E%3C/svg%3E");
      background-position: right 11px center;
      background-repeat: no-repeat;
      background-size: 10px 6px;
      cursor: pointer;
    }

    .leaderboard-view { display: grid; gap: 18px; }
    .leaderboard-view[hidden] { display: none; }
    .leaderboard-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
    .leaderboard-head h2 { margin: 0; font-size: 20px; }
    #leaderboard-filter { min-width: 104px; }
    .leaderboard-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
    .leaderboard-table { width: 100%; border-collapse: collapse; text-align: left; }
    .leaderboard-table th, .leaderboard-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
    .leaderboard-table th { color: var(--muted); font-size: 12px; font-weight: 700; }
    .leaderboard-table tbody tr:last-child td { border-bottom: 0; }
    .leaderboard-table .speed { color: var(--green); font-weight: 800; }
    .leaderboard-empty { margin: 0; padding: 28px 16px; border: 1px dashed var(--border-soft); border-radius: var(--radius); color: var(--muted); text-align: center; }
    .defense-filter-view { display: grid; gap: 18px; }
    .defense-filter-view[hidden] { display: none; }
    .defense-filter-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
    .defense-filter-head h2 { margin: 0; font-size: 20px; }
    .defense-filter-count { color: var(--muted); font-size: 12px; }
    .defense-filter-controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .defense-filter-label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
    .defense-unit-filter { min-width: 0; }
    .defense-unit-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .defense-unit-slot { display: flex; position: relative; align-items: center; gap: 6px; min-width: 0; }
    .defense-unit-input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
    .defense-unit-input[readonly] { cursor: pointer; }
    .defense-unit-clear { flex: none; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font: inherit; }
    .defense-unit-options { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0; max-height: 260px; overflow: auto; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-sunken); box-shadow: 0 18px 44px rgba(0, 0, 0, .55); }
    .defense-unit-options[hidden] { display: none; }
    .defense-unit-option { display: flex; width: 100%; padding: 7px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; font: inherit; text-align: left; }
    .defense-unit-option:hover, .defense-unit-option:focus-visible, .defense-unit-option.selected { background: #2f2a16; outline: none; }
    .defense-guild-filter { width: 100%; }
    .defense-record-grid { display: grid; gap: 24px; }
    .defense-record-card { min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
    .defense-record-owner { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
    .defense-record-owner strong { color: var(--text); }
    .defense-record-units { margin: 0; }
    .defense-group-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .defense-group { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
    .defense-group-line { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; min-height: 44px; padding: 10px 14px; cursor: pointer; list-style: none; }
    .defense-group-line::-webkit-details-marker { display: none; }
    .defense-group-units { display: flex; flex: 1; min-width: 0; align-items: center; gap: 6px; color: var(--text); font-weight: 600; }
    .defense-group-names { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .defense-group-missed { flex: none; padding: 1px 6px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 11px; font-style: normal; font-weight: 400; }
    .defense-group-guild, .defense-group-grade, .defense-group-count { flex: none; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
    .defense-group-guild { width: 122px; }
    .defense-group-grade { width: 30px; text-align: right; }
    .defense-group-count { width: 104px; font-variant-numeric: tabular-nums; text-align: right; }
    .defense-group[open] > .defense-group-line { border-bottom: 1px solid var(--border-soft); }
    .defense-build-list { display: grid; gap: 2px; padding: 8px 10px 10px; }
    .defense-build { display: grid; grid-template-columns: 96px repeat(3, minmax(0, 1fr)); gap: 4px 10px; align-items: center; width: 100%; padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; font: inherit; text-align: left; }
    .defense-build:hover, .defense-build:focus-visible { background: var(--surface-hover); outline: none; }
    .defense-build-owner { display: flex; align-items: center; gap: 4px; min-width: 0; color: var(--muted); font-size: 12px; }
    .defense-build-merged { flex: none; color: var(--muted); font-size: 11px; font-style: normal; }
    .defense-build-owner strong { min-width: 0; overflow: hidden; color: var(--cyan); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
    .defense-build-unit { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1.4fr); gap: 6px; min-width: 0; }
    .defense-build-unit > span { min-width: 0; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
    .defense-build-name { color: var(--text); font-weight: 600; }
    .defense-build-set, .defense-build-style, .defense-build-artifacts { color: var(--muted); }
    .defense-build-artifacts { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; }
    .defense-build-artifacts > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .defense-build-artifacts i { padding: 0 3px; color: var(--border); font-style: normal; }
    .defense-build-past { display: grid; gap: 2px; min-width: 0; margin: 0 0 10px 8px; padding-left: 6px; border-left: 2px solid #3a3a34; }
    .defense-build-past > summary { padding: 6px 8px; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 12px; list-style: none; }
    .defense-build-past > summary::-webkit-details-marker { display: none; }
    .defense-build-past > summary:hover, .defense-build-past > summary:focus-visible { background: var(--surface-hover); outline: none; }
    @media (max-width: 900px) {
      .defense-build { grid-template-columns: minmax(0, 1fr); gap: 2px; }
      .defense-build-owner { padding-bottom: 2px; }
    }
    .deck-modal[hidden] { display: none; }
    .deck-modal { position: fixed; z-index: 40; inset: 0; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 24px 12px; background: rgba(0, 0, 0, 0.66); }
    .deck-modal-panel { position: relative; width: min(1180px, 100%); padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel-solid); }
    .deck-modal-close { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; }
    .deck-modal .defense-record-card { padding: 0; border: 0; border-radius: 0; background: transparent; }

    .replay-switcher { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 14px; }
    .replay-switcher label, .switcher-label { flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
    .replay-switcher .picker-field { flex: 0 1 auto; width: min(100%, 640px); min-width: 0; }
    .segmented { display: inline-flex; gap: 2px; max-width: 100%; overflow-x: auto; padding: 3px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface-sunken); }
    .seg { flex: none; padding: 6px 14px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; }
    .seg:hover { color: var(--text); }
    .seg.active { background: var(--slot); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
    .match-tabs { margin-bottom: 14px; }
    #match-summary-base-filter { width: auto; }
    .battle-loss-filter { position: relative; display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); cursor: pointer; font-size: 12px; user-select: none; }
    .battle-loss-filter input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
    .battle-loss-filter:hover { color: var(--text); }
    .battle-loss-filter:has(input:checked) { border-color: var(--gold); background: rgba(242, 199, 68, .1); color: var(--gold); }
    .battle-loss-filter:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
    .battle-filters { display: flex; flex-wrap: wrap; gap: 8px; }
    #battle-list { display: grid; gap: 10px; }
    .battle-record { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 0; }
    .battle-record > summary { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 14px; cursor: pointer; list-style: none; }
    .battle-record > summary::-webkit-details-marker { display: none; }
    .battle-line { flex: 1; min-width: 0; overflow-wrap: anywhere; }
    .battle-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
    .battle-summary { display: grid; gap: 2px; min-width: 0; }
    .battle-build { display: grid; grid-template-columns: 96px repeat(3, minmax(0, 1fr)); gap: 4px 10px; align-items: center; min-width: 0; padding: 5px 0; }
    .battle-build-side { flex: none; color: var(--muted); font-size: 11px; font-style: normal; }
    .battle-build-owner { display: flex; align-items: center; gap: 4px; min-width: 0; font-size: 12px; }
    .battle-build-owner strong { min-width: 0; overflow: hidden; color: var(--cyan); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
    .battle-cards-toggle { justify-self: start; padding: 4px 0; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
    .battle-cards-toggle::before { margin-right: 6px; content: '\25B8'; }
    .battle-cards-toggle[aria-expanded="true"]::before { content: '\25BE'; }
    .battle-cards-toggle:hover, .battle-cards-toggle:focus-visible { color: var(--text); outline: none; }
    .battle-cards { min-width: 0; padding-top: 6px; }
    @media (max-width: 900px) { .battle-build { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
    .battle-record[open] .battle-detail { padding: 0 14px 14px; }
    .battle-line .result { font-weight: 800; }
    .battle-line .result.win { color: var(--green); }
    .battle-line .result.lose { color: var(--red); }
    .battle-line .wizard { color: var(--cyan); }
    .battle-line .deck { color: var(--text); font-weight: 600; }
    .battle-line .vs { margin: 0 5px; color: var(--muted); }
    .battle-line .no-replay { color: var(--muted); }
    .loss-feedback-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 14px; }
    .loss-feedback-status { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; text-align: right; }
    .loss-feedback-copy { min-height: 36px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--gold); color: #211900; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
    .loss-feedback-copy:disabled { opacity: .4; cursor: default; }
    #loss-feedback-list { display: grid; gap: 10px; }
    .loss-case { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
    .loss-case-head { padding: 12px 14px 4px; overflow-wrap: anywhere; }
    .loss-case-head .battle-line { display: block; }
    .loss-case-tabs { margin: 0 14px; }
    .loss-tab-count { margin-left: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
    .loss-case-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; padding: 12px 14px 14px; }
    .loss-memo { width: 100%; }
    .loss-rec-limit { margin: 0; color: var(--muted); font-size: 12px; }
    .loss-rec-row { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 10px; align-items: start; }
    .loss-rec-row + .loss-rec-row { padding-top: 12px; border-top: 1px dashed var(--border-soft); }
    .loss-rec-label { padding-top: 12px; color: var(--muted); font-size: 12px; font-weight: 700; }
    .loss-rec-label small { display: block; font-size: 11px; font-weight: 400; }
    .loss-rec-list { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
    .loss-rec { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px 5px 6px; border: 1px solid var(--gold); border-radius: 10px; background: rgba(242, 199, 68, .1); color: var(--gold); font: inherit; font-weight: 800; cursor: pointer; }
    .loss-rec[aria-pressed="false"] { border-color: var(--border); background: transparent; color: var(--muted); }
    .loss-rec[aria-pressed="mixed"] { border-style: dashed; }
    .loss-rec[aria-pressed="mixed"] .loss-trio { filter: blur(2px) grayscale(1); }
    .loss-rec[aria-pressed="false"] .loss-trio { filter: grayscale(1); opacity: .45; }
    .loss-rec[aria-disabled="true"] { cursor: not-allowed; opacity: .5; }
    .loss-rec-rank { width: 16px; font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
    .loss-rec-pick { display: grid; justify-items: center; gap: 3px; }
    .loss-trio { display: inline-flex; gap: 2px; }
    .loss-trio .unit-portrait { width: 34px; height: 34px; border-radius: 6px; }
    .loss-rec-stat { font-size: 11px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
    .loss-rec-more, .loss-retry { padding: 8px 10px; border: 1px dashed var(--border); border-radius: 10px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
    .loss-rec-none { color: var(--muted); font-size: 12px; }
    .loss-sheet-title { margin: 22px 0 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
    .loss-sheet-scroll { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 12px; }
    #loss-sheet { display: block; width: 100%; min-width: 720px; }

    .team-block { margin-bottom: 30px; }

    .team-title {
      display: flex;
      flex-wrap: wrap;
      align-items: baseline;
      gap: 4px 8px;
      margin-bottom: 14px;
      padding-bottom: 9px;
      border-bottom: 1px solid var(--border-soft);
    }

    .team-title h2 { margin: 0; font-size: 16px; }
    .defense-opening { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
    .defense-opening > span:first-child { color: var(--gold); }
    .action-sequence { display: flex; flex-wrap: wrap; gap: 8px 6px; margin: 0; padding: 0; list-style: none; }
    .action-sequence li { display: grid; justify-items: center; gap: 3px; }
    .action-skill.estimated { color: var(--gold); }
    .action-more button { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 10px; background: var(--slot); color: var(--text); font-size: 18px; line-height: 1; cursor: pointer; }
    .action-sequence li.action-raw { align-self: center; overflow-wrap: anywhere; font-size: 11px; }
    .action-face { position: relative; display: block; }
    .action-sequence li[data-side="attack"] .action-face > .unit-portrait { border-color: var(--gold); }
    .action-target { position: absolute; left: -4px; bottom: -4px; }
    .action-target .unit-portrait { width: 20px; height: 20px; border: 1px solid var(--text); border-radius: 50%; box-shadow: 0 0 0 1.5px var(--bg); }
    .action-skill { position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center; min-width: 18px; height: 13px; border: 1px solid var(--border); border-radius: 2px; background: var(--surface-sunken); color: var(--text); font-size: 10px; line-height: 1; }
    .team-owner { color: var(--muted); font-size: 12px; }

    .team-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 16px;
    }

    .leaderboard-card.unit-card {
      position: relative;
      min-width: 0;
      overflow: visible;
      padding: 18px;
      border: 1px solid var(--border);
      border-radius: 16px;
      background: var(--panel);
      box-shadow: 0 18px 44px rgba(0, 0, 0, .24);
    }

    .team-grid > .leaderboard-card {
      display: grid;
      grid-row: span 3;
      grid-template-rows: subgrid;
      row-gap: 0;
    }

    .team-grid > .leaderboard-card.empty-slot > * { grid-row: 1 / -1; }

    .unit-info-row {
      container-type: inline-size;
      display: grid;
      grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
      gap: clamp(8px, 2.4cqi, 16px);
      align-items: start;
    }

    .unit-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 13px; }
    .unit-portrait { display: block; width: 44px; height: 44px; border: 1px solid var(--border-soft); border-radius: 10px; background: #202023; object-fit: cover; }
    .unit-heading .unit-portrait { width: 58px; height: 58px; border: 1px solid rgba(161, 161, 170, .7); border-radius: 6px; background: #242427; }
    .unit-portrait-split { position: relative; overflow: hidden; flex: none; }
    .unit-portrait-split .portrait-half { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
    .unit-portrait-split .portrait-half.orig { clip-path: polygon(0 0, 0 100%, 100% 100%); }
    .unit-portrait-split .portrait-half.collab { clip-path: polygon(0 0, 100% 0, 100% 100%); }

    .unit-heading h3 { margin: 0; font-size: 20px; line-height: 1.1; }
    .unit-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }

    .stat-block { display: grid; justify-content: start; gap: clamp(3px, .9cqi, 4px) clamp(4px, 1.4cqi, 6px); grid-template-columns: minmax(0, max-content) minmax(0, max-content) minmax(0, max-content); }
    .stat-row { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; font-size: clamp(11px, 3.9cqi, 13px); }
    .stat-row > span:first-child { word-break: keep-all; }
    .stat-row .base, .stat-row .additional { white-space: nowrap; }
    .stat-row .base { text-align: right; }
    .stat-row .additional { margin: 0; color: var(--green); text-align: left; }
    .stat-row.final-only .base { grid-column: 2; color: #f4f4f5; }
    .stat-row .base.capped { color: #f87171; }

    .effect-block { display: grid; align-content: start; gap: clamp(4px, 1.1cqi, 6px); font-size: clamp(10px, 3.2cqi, 12.5px); }
    .effect-line { display: flex; justify-content: space-between; gap: 8px; }
    .effect-line .label { min-width: 0; color: #e4e4e7; }
    .effect-line .value { color: #e4e4e7; font-weight: 700; text-align: right; }
    .effect-line.relic-line { padding-bottom: 4px; border-bottom: 1px solid var(--border-soft); }
    .effect-line.relic-line .label { color: var(--cyan); font-weight: 800; }
    .effect-line.relic-line .value { color: var(--cyan); }

    .spec-missing { margin: 0; color: var(--muted); font-size: 12px; }
    .leaderboard-card.no-spec .equipment-grid { margin-top: 18px; }

    .equipment-grid {
      display: grid;
      width: min(100%, 252px);
      grid-template-columns: repeat(3, 1fr);
      gap: 7px;
      margin: 30px auto 0;
    }

    .equipment-tile {
      position: relative;
      aspect-ratio: 1;
      display: grid;
      min-height: 0;
      place-items: center;
      overflow: hidden;
      padding: 0;
      border: 1px solid rgba(101, 74, 15, .65);
      border-radius: 8px;
      background: #2d1c04;
      cursor: pointer;
    }

    .equipment-tile:hover, .equipment-tile:focus-visible { transform: translateY(-1px); border-color: #eabf42; outline: none; }
    .equipment-tile.selected { border-color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.68), 0 0 20px rgba(242,199,68,.2); }
    .equipment-tile img { position: absolute; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
    .equipment-tile img.tile-artifact-body, .equipment-tile img.tile-relic,
    .equipment-tile img.tile-rune-body { color: #f2c744; font-size: 10px; }
    .equipment-tile.artifact { background: #2b1803; }
    .equipment-tile.relic { background: #251904; }
    .equipment-tile.rune { background: #251904; }
    .equipment-tile.empty { border-color: rgba(113, 113, 122, .35); background: #131315; cursor: default; }
    .equipment-tile img.tile-empty { width: 74%; height: 74%; opacity: .34; }
    .equipment-tile img.tile-rune-body { width: 68%; height: 68%; }
    .equipment-tile img.tile-rune-body.ancient {
      filter: drop-shadow(0 0 4px rgba(255, 255, 255, .95)) drop-shadow(0 0 10px rgba(255, 255, 255, .6));
    }
    .equipment-tile img.tile-rune-symbol {
      width: 34%;
      height: 34%;
      filter: sepia(1) saturate(8) hue-rotate(-14deg) brightness(1.1);
    }
    .equipment-tile img.tile-rune-symbol.rune-slot-1 { transform: translate(-1%, 10%); }
    .equipment-tile img.tile-rune-symbol.rune-slot-2 { transform: translate(-4%, -1%); }
    .equipment-tile img.tile-rune-symbol.rune-slot-3 { transform: translate(-4%, -1%); }
    .equipment-tile img.tile-rune-symbol.rune-slot-4 { transform: translate(-1%, -12%); }
    .equipment-tile img.tile-rune-symbol.rune-slot-5 { transform: translate(1%, -1%); }
    .equipment-tile img.tile-rune-symbol.rune-slot-6 { transform: translate(0, -1%); }

    .equipment-tile img.tile-rune-symbol.rune-set-energy { width: 34.4%; height: 34.4%; }
    .equipment-tile img.tile-rune-symbol.rune-set-guard { width: 29.5%; height: 29.5%; }
    .equipment-tile img.tile-rune-symbol.rune-set-swift { width: 35.7%; height: 35.7%; }
    .equipment-tile img.tile-rune-symbol.rune-set-blade { width: 32.4%; height: 32.4%; }
    .equipment-tile img.tile-rune-symbol.rune-set-rage { width: 32.9%; height: 32.9%; }
    .equipment-tile img.tile-rune-symbol.rune-set-focus { width: 32.7%; height: 32.7%; }
    .equipment-tile img.tile-rune-symbol.rune-set-endure { width: 31.3%; height: 31.3%; }
    .equipment-tile img.tile-rune-symbol.rune-set-fatal { width: 33.9%; height: 33.9%; }
    .equipment-tile img.tile-rune-symbol.rune-set-despair { width: 34.3%; height: 34.3%; }
    .equipment-tile img.tile-rune-symbol.rune-set-vampire { width: 30.8%; height: 30.8%; }
    .equipment-tile img.tile-rune-symbol.rune-set-violent { width: 35.2%; height: 35.2%; }
    .equipment-tile img.tile-rune-symbol.rune-set-nemesis { width: 36.8%; height: 36.8%; }
    .equipment-tile img.tile-rune-symbol.rune-set-will { width: 34.3%; height: 34.3%; }
    .equipment-tile img.tile-rune-symbol.rune-set-shield { width: 34.8%; height: 34.8%; }
    .equipment-tile img.tile-rune-symbol.rune-set-revenge { width: 31.4%; height: 31.4%; }
    .equipment-tile img.tile-rune-symbol.rune-set-destroy { width: 33.0%; height: 33.0%; }
    .equipment-tile img.tile-rune-symbol.rune-set-fight { width: 34.4%; height: 34.4%; }
    .equipment-tile img.tile-rune-symbol.rune-set-determination { width: 30.9%; height: 30.9%; }
    .equipment-tile img.tile-rune-symbol.rune-set-enhance { width: 36.5%; height: 36.5%; }
    .equipment-tile img.tile-rune-symbol.rune-set-accuracy { width: 34.3%; height: 34.3%; }
    .equipment-tile img.tile-rune-symbol.rune-set-tolerance { width: 35.0%; height: 35.0%; }
    .equipment-tile img.tile-rune-symbol.rune-set-seal { width: 33.3%; height: 33.3%; }
    .equipment-tile img.tile-rune-symbol.rune-set-intangible { width: 34.0%; height: 34.0%; }
    .equipment-tile img.tile-artifact-body { width: 77%; height: 77%; }
    .equipment-tile img.tile-artifact-symbol { width: 32%; height: 32%; }
    .equipment-tile img.tile-relic { width: 69%; height: 69%; }
    .equipment-tile .tile-upgrade { position: absolute; right: 3px; bottom: 2px; color: var(--text); font-size: 9px; font-weight: 700; text-shadow: 0 1px 2px #000, 0 0 3px #000; pointer-events: none; }

    .reference-popup[hidden] { display: none; }
    .reference-popup {
      position: fixed;
      z-index: 50;
      inset: auto;
      display: block;
      width: auto;
      padding: 0;
      border: 0;
      border-radius: 0;
      background: transparent;
      box-shadow: none;
    }
    .reference-popup-panel {
      width: min(240px, calc(100vw - 24px));
      min-height: 180px;
      margin-left: 20px;
      padding: 16px;
      border: 1px solid #52525b;
      border-radius: 16px;
      background: rgba(9, 9, 11, .8);
      box-shadow: 0 24px 70px rgba(0, 0, 0, .78);
      color: #f4f4f5;
      font-weight: 600;
    }
    .reference-popup-close {
      float: right;
      margin: -7px -5px 0 0;
      border: 0;
      background: transparent;
      color: #a1a1aa;
      cursor: pointer;
      font-size: 18px;
      line-height: 1;
    }
    .reference-rune-button {
      display: block;
      width: 100%;
      padding: 0;
      border: 0;
      background: transparent;
      color: inherit;
      text-align: left;
      cursor: pointer;
    }
    .reference-rune-head { display: flex; align-items: flex-start; gap: 12px; }
    .reference-rune-icon { position: relative; width: 50px; height: 50px; flex: 0 0 auto; }
    .reference-rune-icon img { position: absolute; object-fit: contain; }
    .reference-rune-icon .body { top: 2px; left: 2px; width: 46px; height: 46px; }
    .reference-rune-icon .set {
      top: 13px;
      left: 13px;
      width: 24px;
      height: 24px;
      filter: sepia(1) saturate(8) hue-rotate(-14deg) brightness(1.1);
    }
    .reference-head-text { display: block; min-width: 0; }
    .reference-popup-title { display: block; padding-top: 3px; font-size: 18px; line-height: 1.2; }
    .reference-prefix { display: flex; gap: 8px; margin: 4px 0 0; color: #d4d4d8; font-size: 13px; line-height: 1.2; }
    .reference-prefix .value { color: #fff; }
    .reference-popup-row { display: grid; grid-template-columns: 5.5em auto; gap: 0 10px; margin-top: 7px; padding-left: 2px; font-size: 14px; line-height: 1.25; }
    .reference-popup-row .label { color: #d4d4d8; }
    .reference-popup-row .value { color: #fff; }
    .reference-popup-row .grind, .reference-popup-row .value.special, .reference-effect.converted, .reference-rotate { color: var(--orange); }
    .reference-artifact-descriptor { margin-top: 4px; color: rgba(228, 228, 231, .8); font-size: 14px; }
    .reference-effect { margin-top: 7px; font-size: 14px; line-height: 1.25; }
    .reference-effect .value { color: #fff; }
    .reference-enchanted { width: 13px; height: 13px; margin-left: 4px; vertical-align: -2px; }

    @media (max-width: 1040px) {
      .page { width: min(920px, calc(100% - 32px)); }
      .team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (max-width: 720px) { .team-grid, .defense-record-grid { grid-template-columns: 1fr; } .reference-popup-panel { margin-left: 0; } }
    @media (max-width: 640px) {
      .leaderboard-head h2, .defense-filter-head h2 { font-size: 17px; }
      .team-title h2 { font-size: 14px; }
      .viewer-tab { font-size: 13px; }
      .seg { padding: 5px 10px; font-size: 12px; }
      .field-box { min-height: 32px; font-size: 12px; }
      .loss-feedback-copy { min-height: 32px; font-size: 12px; }
      .defense-group-units { font-size: 12px; }
      .leaderboard-table th, .leaderboard-table td { padding: 8px 10px; }
      .leaderboard-table td { font-size: 13px; }
      .leaderboard-empty { padding: 20px 12px; font-size: 13px; }
      .loss-case-tabs { margin: 0 10px; }
      .page { width: min(100% - 20px, 560px); padding-top: 24px; }
      .defense-unit-slots { grid-template-columns: 1fr; }
      .defense-group-line { gap: 8px; min-height: 40px; padding: 8px 10px; }
      .defense-group-guild, .defense-group-grade, .defense-group-count { width: auto; max-width: 96px; font-size: 11px; }
      .defense-group-missed { padding: 0 5px; font-size: 10px; }
      .viewer-top { gap: 6px; }
      .viewer-tabs { min-width: 0; overflow-x: auto; }
      .viewer-tab { padding: 10px 8px; }
      .viewer-logout { padding: 6px 8px; font-size: 11px; }
      .battle-record > summary { gap: 8px; min-height: 40px; padding: 8px 10px; }
      .battle-line { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
      .battle-line .vs { margin: 0 3px; }
      .loss-rec-row { grid-template-columns: 1fr; gap: 4px; }
      .loss-rec-label { padding-top: 0; }
      .defense-build-list { padding: 6px 4px 8px; }
      .deck-modal { padding: 12px 6px; }
      .deck-modal-panel { padding: 14px 8px; }
    }
    .access-gate { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
    .access-gate[hidden] { display: none; }
    #viewer-app[hidden] { display: none; }
    .access-card { width: min(100%, 360px); padding: 28px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); box-shadow: 0 18px 44px rgba(0, 0, 0, .24); }
    .access-card h1 { margin: 0; font-size: 22px; }
    .access-card p { margin: 8px 0 18px; color: var(--muted); }
    .access-card form { display: grid; gap: 10px; }
    .access-card input, .access-card button { min-height: 42px; border-radius: 8px; font: inherit; }
    .access-card input { width: 100%; padding: 0 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
    .access-card button { border: 0; background: var(--gold); color: #211900; font-weight: 800; cursor: pointer; }
    .access-message { min-height: 18px; margin: 0; color: #fda4af; font-size: 12px; }
    .viewer-logout { flex: none; margin-bottom: 8px; min-height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; font: inherit; font-size: 12px; }
    .leaderboard-card.empty-slot { display: grid; place-items: center; min-height: 220px; border-style: dashed; color: var(--muted); }
  
/* The build prepends the replay viewer's canonical stylesheet. */
[hidden],
#notice:empty,
.message:empty {
  display: none;
}
.viewer-tab {
  white-space: nowrap;
  flex: none;
}
#guides {
  display: grid;
  gap: 10px;
}
#controls,
.field,
.scroller,
.toolbar,
.original {
  min-width: 0;
  max-width: 100%;
}
.detail .toolbar,
.actions,
.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}
.detail .toolbar .field {
  max-width: min(100%, 400px);
}
.field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}
.field .field-box {
  width: 100%;
  min-width: 0;
}
.field-box {
  max-width: 100%;
}
.card .field {
  margin: 6px 0;
}
.actions > button,
.toolbar > button,
.detail > button,
.message button,
#guides > button {
  width: fit-content;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
button.primary {
  border-color: var(--gold);
  background: var(--gold);
  color: #211900;
  font-weight: 800;
}
button:disabled {
  opacity: 0.48;
  cursor: default;
}
button:not(:disabled):is(.toolbar > button, .actions > button):hover {
  border-color: var(--gold);
}
.detail h3:not(.unit-heading h3),
.detail h4 {
  margin: 12px 0 8px;
}
.battle-detail .team-title {
  margin: 26px 0 14px;
}
.battle-detail .scroller > .team-title:first-child {
  margin-top: 0;
}
.scroller {
  overflow-x: auto;
  scrollbar-color: var(--border) transparent;
}
.scroller .team-grid {
  margin: 0 0 2px;
}
.team-grid > .guide-card,
.team-grid > .choice-card {
  display: block;
  grid-row: auto;
}
.guide-card.editable .unit-info-row {
  grid-template-columns: 1fr;
}
.guide-card .effect-line .label {
  flex: none;
  white-space: nowrap;
}
.guide-card .stat-row .additional {
  overflow-wrap: anywhere;
  white-space: normal;
}
.editable .stat-block {
  grid-template-columns: max-content max-content minmax(0, 9em);
  align-items: center;
}
.editable .stat-row {
  align-items: center;
}
.editable .stat-row .stat-input {
  width: 100%;
  min-height: 26px;
  padding: 2px 6px;
  color: var(--green);
  text-align: right;
}
.editable .stat-row.final-only .stat-input {
  color: var(--text);
}
.editable .stat-row.final-only .base {
  grid-column: 3;
}
.guide-render {
  max-width: 866px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: #0a0705;
}
.guide-render iframe {
  display: block;
  width: 866px;
  height: 760px;
  border: 0;
  transform-origin: top left;
}
.scroller[data-comparison] .team-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 930px;
}
.card details,
.unit-note,
.gear-line,
.summary-note,
.message {
  margin: 6px 0;
  font-size: 13px;
}
.card details > summary,
.original summary {
  cursor: pointer;
  color: var(--muted);
}
.unit-note {
  white-space: pre-line;
  overflow-wrap: anywhere;
  color: var(--muted);
}
.gear-line {
  overflow-wrap: anywhere;
}
.gear-line b {
  font-weight: 500;
  color: var(--muted);
  margin-right: 6px;
}
.status-line,
.result-note,
.minor,
.count,
.tag,
.load,
.foot {
  color: var(--muted);
  font-size: 12px;
}
.tag,
.count {
  flex: none;
}
.tag.confirmed,
.tag.pass {
  color: var(--green);
}
.tag.progress,
.tag.unknown {
  color: var(--gold);
}
.tag.fail,
.error,
.field-error {
  color: var(--red);
}
.wizard {
  color: var(--cyan);
}
.empty,
.load {
  text-align: center;
}
.detail .empty,
.load,
#notice {
  margin: 0;
}
.empty {
  padding: 20px 12px;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius);
  color: var(--muted);
}
#notice {
  color: var(--gold);
}
.team-grid > .leaderboard-card:has(> .card-foot) {
  grid-row: span 4;
}
.card-foot {
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}
.card-foot > :first-child {
  margin-top: 0;
}
@media (min-width: 901px) {
  .defense-build {
    grid-template-columns: 150px repeat(3, minmax(0, 1fr));
  }
}
.defense-build-owner .tag {
  margin: 0 8px 0 auto;
}
.defense-record-owner .defense-build-owner {
  gap: 8px;
  font-size: 13px;
}
.defense-record-owner .tag {
  margin: 0;
}
.defense-group-units .deck-portraits {
  flex: none;
}
.battle-detail > .defense-group-list {
  padding-top: 2px;
}
input[type='checkbox'],
input[type='radio'] {
  accent-color: var(--gold);
}
.choice {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.choice:has(:checked) {
  color: var(--gold);
}
.card fieldset {
  padding: 0;
  margin: 8px 0;
  border: 0;
}
.card legend {
  margin: 5px 0;
  font-size: 12px;
}
.original .team-grid {
  margin-top: 8px;
}
.skip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  transform: translateY(-150%);
  padding: 6px;
  color: var(--gold);
  background: var(--bg);
}
.skip:focus {
  transform: none;
}
@media (max-width: 640px) {
  .battle-record[open] .battle-detail {
    padding-right: 8px;
    padding-left: 8px;
  }
  .detail .toolbar {
    align-items: stretch;
  }
  .battle-filters {
    gap: 5px;
  }
  .scroller[data-comparison] .team-grid {
    gap: 8px;
  }
}

.filter-count {
  margin-left: 5px;
  font-variant-numeric: tabular-nums;
}

.deck-portraits {
  align-items: center;
  gap: 5px;
}
.deck-slot {
  position: relative;
  display: inline-flex;
}
.deck-slot .unit-portrait {
  display: grid;
  place-items: center;
}
.deck-slot:has(.deck-leader) .unit-portrait {
  border-color: var(--gold);
}
.deck-leader {
  position: absolute;
  left: -2px;
  bottom: -2px;
  padding: 0 3px;
  border-radius: 3px;
  background: var(--gold);
  color: #211900;
  font:
    800 9px/12px system-ui,
    sans-serif;
}
.guide > summary > .tag,
.match > summary > .count {
  margin-left: auto;
}

.source-picker {
  max-width: 100%;
}
.source-decks {
  display: flex;
  align-items: center;
  gap: 6px;
}
.source-decks:not(:empty) {
  margin-top: 6px;
}
.source-decks .unit-portrait {
  width: 27px;
  height: 27px;
}

.card textarea.field-box {
  resize: vertical;
}
.note-review:not(:empty) {
  margin: 8px 0;
  padding: 8px;
  border-left: 2px solid var(--gold);
  background: var(--surface);
  font-size: 12px;
}
.note-review strong {
  color: var(--gold);
}
.note-review p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}
