.p03-page { max-width: 1080px; padding-bottom: 48px; }
.p03-title-row { margin-bottom: 16px; }
.p03-title-row h1 { margin: 0; }
.p03-panel { min-width: 0; }
.p03-section-heading { margin: 0 0 16px; }
.p03-section-heading h2, .p03-opponent-search h2 { margin: 0; font-size: 16px; }
.p03-manage { font-size: 13px; }
.p03-own-picker { max-width: 360px; margin-bottom: 16px; }
.p03-own-picker[hidden] { display: none; }
.p03-own-information { padding-bottom: 24px; }
.p03-role-content { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 16px; min-width: 0; }
.p03-portrait-wrap { position: relative; display: grid; place-items: center; width: 72px; height: 72px; overflow: hidden; border-radius: 6px; background: var(--surface-muted); }
.p03-portrait-blue { background: var(--blue-soft); }
.p03-portrait-red { background: var(--red-soft); }
.p03-portrait { width: 72px; height: 72px; object-fit: cover; object-position: center; }
.p03-portrait[hidden] { display: none; }
.p03-portrait-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-muted); font-size: 20px; font-weight: 700; }
.p03-portrait-wrap:has(.p03-portrait:not([hidden])) .p03-portrait-fallback { display: none; }
.p03-role-details { display: grid; justify-items: start; gap: 6px; min-width: 0; }
.p03-role-name { max-width: 100%; overflow-wrap: anywhere; font-size: 16px; font-weight: 650; }
.p03-role-detail { color: var(--ink-muted); font-size: 13px; overflow-wrap: anywhere; }
.p03-opponent-search { position: relative; padding: 24px 0; border-top: 1px solid var(--line); }
.p03-opponent-search h2 { margin-bottom: 14px; }
.p03-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.p03-search-row .search-field { min-width: 0; min-height: 46px; }
.p03-search-row input { min-width: 0; }
.p03-search-row .search-field button { width: 44px; flex: none; }
.p03-search-row .search-field button[hidden] { display: none; }
.p03-random { min-width: 88px; min-height: 46px; }
.p03-random[aria-pressed="true"] { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.p03-search-results { margin-top: 12px; }
.p03-search-results[hidden] { display: none; }
.p03-opponent-results { display: grid; gap: 6px; min-width: 0; }
.p03-search-status { color: var(--ink-muted); font-size: 12px; padding: 2px 0 4px; }
.p03-result-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); text-align: left; }
.p03-result-option:hover, .p03-result-option[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); }
.p03-result-name { min-width: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 600; }
.p03-search-results > button { margin-top: 10px; }
.p03-search-empty { margin: 0; padding: 8px 0; color: var(--ink-muted); font-size: 13px; }
.p03-confirmation { padding-top: 24px; border-top: 1px solid var(--line); }
.p03-config-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.p03-config-side { display: grid; gap: 8px; align-content: start; min-width: 0; min-height: 102px; padding-bottom: 16px; }
.p03-config-label { color: var(--ink-muted); font-size: 13px; }
.p03-config-side strong { overflow-wrap: anywhere; font-size: 16px; font-weight: 650; }
.p03-config-detail { color: var(--ink-muted); overflow-wrap: anywhere; font-size: 13px; min-height: 20px; }
.p03-feedback { min-height: 20px; margin: 8px 0; color: var(--ink-muted); font-size: 13px; overflow-wrap: anywhere; }
.p03-start { width: 100%; min-height: 48px; white-space: normal; padding: 12px 16px; }
.p03-task { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; padding: 20px 0; border-top: 1px solid var(--line); }
.p03-task[hidden] { display: none; }
.p03-task p { flex-basis: 100%; margin: 0; overflow-wrap: anywhere; }
.p03-task code { font-size: 11px; }
.p03-task-result { width: 100%; min-width: 0; }
.p03-match-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .7fr) auto; align-items: center; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.p03-match-main { min-width: 0; }
.p03-match-labels { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.p03-match-main h3 { margin: 0; overflow-wrap: anywhere; font-size: 15px; }
.p03-match-participants { margin: 4px 0 0; color: var(--ink-muted); font-size: 12px; overflow-wrap: anywhere; }
.p03-match-facts { display: flex; flex-wrap: wrap; gap: 6px 15px; font-size: 12px; font-variant-numeric: tabular-nums; }
.p03-match-facts strong { color: var(--ink); font-weight: 650; }
.p03-match-link { justify-self: end; }

.battle-view { max-width: 1320px; padding-top: 20px; padding-bottom: 28px; }
.battle-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.battle-heading-actions { display: flex; flex: none; gap: 8px; }
.battle-heading h1 { margin: 4px 0 0; font-size: 22px; }
.battle-matchup { display: grid; grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr); align-items: center; gap: 16px; padding-bottom: 18px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.battle-participant { display: flex; align-items: center; gap: 12px; min-width: 0; }
.battle-participant-b { flex-direction: row-reverse; text-align: right; }
.battle-participant img, .battle-portrait-placeholder { flex: none; width: 56px; height: 56px; object-fit: cover; object-position: center; background: var(--blue-soft); border-radius: 4px; }
.battle-participant-b img, .battle-participant-b .battle-portrait-placeholder { background: var(--red-soft); }
.battle-participant > div { display: grid; gap: 4px; min-width: 0; }
.battle-participant strong { font-size: 15px; overflow-wrap: anywhere; }
.battle-participant span { color: var(--ink-muted); font-size: 12px; }
.battle-vs { color: var(--ink-muted); text-align: center; font-size: 13px; font-weight: 650; }
.battle-player-host { width: 100%; min-width: 0; }
.battle-after { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.battle-after:empty { display: none; }
.battle-preparation { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: #10251b55; }
.battle-preparation-inner { position: relative; display: grid; justify-items: center; gap: 16px; width: min(440px, 100%); min-height: 256px; max-height: calc(100svh - 40px); overflow-y: auto; padding: 32px 28px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); box-shadow: 0 12px 48px #14221b20; text-align: center; }
.battle-preparation-close { position: absolute; top: 10px; right: 10px; }
.battle-versus { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--green); border-radius: 4px; color: var(--green); font-size: 15px; font-weight: 700; }
.battle-preparation h2 { margin: 0; font-size: 20px; }
.battle-preparation p { margin: 0; min-height: 36px; overflow-wrap: anywhere; }
.battle-preparation progress { width: 100%; height: 8px; accent-color: var(--green); }
.battle-settlement { display: grid; gap: 20px; }
.battle-winner { display: flex; align-items: center; gap: 18px; padding: 4px 0 22px; border-bottom: 1px solid var(--line); }
.battle-winner > div { min-width: 0; }
.battle-winner img { flex: none; width: 72px; height: 72px; object-fit: cover; object-position: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.battle-winner h3 { margin: 6px 0; font-size: 26px; overflow-wrap: anywhere; }
.battle-winner p { margin: 0; color: var(--ink-muted); }
.battle-statistics-section h3, .battle-ladder-section h3, .battle-share-links h3 { margin: 0 0 12px; font-size: 14px; font-weight: 650; }
.battle-statistics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.battle-statistics > div { min-width: 0; min-height: 94px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: #f5f7f6; box-shadow: 0 2px 0 #e7ece9; }
.battle-statistics > div:has(.team-a-text) { border-color: #d2e0f1; background: #f0f5fc; box-shadow: 0 2px 0 #e0e9f5; }
.battle-statistics > div:has(.team-b-text) { border-color: #eed9d5; background: #fcf3f1; box-shadow: 0 2px 0 #f3e4e0; }
.battle-statistics dt { color: var(--ink-muted); font-size: 12px; }
.battle-statistics dd { display: flex; align-items: baseline; gap: 5px; margin: 8px 0 0; font-size: 24px; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.battle-stat-unit { flex: none; font-size: 12px; font-weight: 500; color: var(--ink-muted); }
.battle-ladder-list { display: grid; margin: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.battle-ladder-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) 54px; align-items: center; gap: 4px 16px; padding: 16px; }
.battle-ladder-row + .battle-ladder-row { border-top: 1px solid var(--line); }
.battle-ladder-row[data-rating-tone="gain"] { background: #f2f9f5; }
.battle-ladder-player { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.battle-ladder-player img { flex: none; width: 36px; height: 36px; object-fit: cover; object-position: center; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.battle-ladder-player span { min-width: 0; }
.battle-ladder-row dd { min-width: 0; margin: 0; }
.battle-ladder-transition { display: flex; align-items: center; gap: 12px; font-variant-numeric: tabular-nums; }
.battle-ladder-stage { display: grid; gap: 3px; min-width: 0; max-width: calc((100% - 36px) / 2); overflow-wrap: anywhere; }
.battle-ladder-stage > span { color: var(--ink-muted); font-size: 11px; }
.battle-ladder-stage strong { font-size: 15px; font-weight: 550; color: var(--ink-muted); }
.battle-ladder-after strong { color: var(--ink); font-weight: 700; }
.battle-ladder-arrow { flex: none; color: #87958e; font-size: 16px; }
.battle-ladder-delta { text-align: right; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
[data-rating-tone="gain"] .battle-ladder-delta { color: var(--green); }
[data-rating-tone="loss"] .battle-ladder-delta { color: var(--red); }
[data-rating-tone="unchanged"] .battle-ladder-delta { color: var(--ink-muted); }
.battle-ladder-note { grid-column: 2 / -1; color: var(--ink-muted); font-size: 11px; overflow-wrap: anywhere; }
.battle-share-links { display: grid; gap: 14px; min-width: 0; }
.battle-share-links h3 { margin-bottom: 0; }
.battle-share-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-top: 6px; }
.battle-share-row a { display: block; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.battle-share-row button { white-space: nowrap; }
.battle-settlement [data-share-feedback] { min-height: 18px; margin: 0; }

@media (max-width: 720px) {
  .p03-match-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .p03-match-main { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .battle-view { width: calc(100% - 28px); padding-top: 16px; }
  .battle-heading { align-items: flex-start; }
  .battle-heading h1 { font-size: 20px; }
  .battle-heading-actions > button { flex: none; padding-inline: 10px; }
  .battle-matchup { grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); gap: 8px; }
  .battle-participant { gap: 8px; align-items: flex-start; }
  .battle-participant img, .battle-portrait-placeholder { width: 40px; height: 40px; }
  .battle-participant strong { font-size: 13px; }
  .battle-participant span { font-size: 11px; }
  .battle-statistics { gap: 8px; }
  .battle-statistics > div { min-height: 82px; padding: 12px 9px; }
  .battle-statistics dt { font-size: 11px; }
  .battle-statistics dd { gap: 2px; font-size: 20px; }
  .battle-stat-unit { font-size: 10px; }
  .battle-ladder-row { grid-template-columns: minmax(0, 1fr) 54px; gap: 10px; padding: 14px; }
  .battle-ladder-player { grid-column: 1; grid-row: 1; }
  .battle-ladder-delta { grid-column: 2; grid-row: 1; }
  .battle-ladder-transition { grid-column: 1 / -1; grid-row: 2; padding-left: 46px; }
  .battle-ladder-note { grid-column: 1 / -1; padding-left: 46px; }
  .battle-share-row { grid-template-columns: minmax(0, 1fr); }
  .battle-share-row button { justify-self: end; }
  .p03-config-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .p03-config-side { min-height: 0; padding-bottom: 8px; }
  .p03-config-side + .p03-config-side { padding-top: 16px; border-top: 1px solid var(--line); }
  .p03-role-content { gap: 12px; }
  .p03-random { min-width: 76px; }
  .p03-match-row { grid-template-columns: minmax(0, 1fr); }
  .p03-match-main { grid-column: auto; }
  .p03-match-link { justify-self: stretch; }
}

body:has(.battle-view:not([hidden])) .site-header-inner { width: calc(100% - 32px); }
body:has(.battle-view:not([hidden])) { overflow: hidden; }
.battle-view:not([hidden]) { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) auto; grid-template-rows: 44px minmax(0, 1fr); gap: 8px 16px; width: calc(100% - 32px); max-width: none; height: calc(100svh - 61px); min-height: 0; padding: 8px 0; }
.battle-heading { display: contents; }
.battle-heading > div:first-child { grid-column: 1; grid-row: 1; min-width: 0; }
.battle-heading [data-battle-phase] { display: none; }
.battle-heading h1 { margin: 0; font-size: 18px; white-space: nowrap; }
.battle-heading-actions { grid-column: 3; grid-row: 1; align-items: center; gap: 8px; }
.battle-heading-actions > .button { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.battle-matchup { grid-column: 2; grid-row: 1; justify-self: center; width: min(100%, 600px); grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); gap: 10px; padding: 0; margin: 0; border: 0; }
.battle-participant { gap: 8px; align-items: center; }
.battle-participant img, .battle-portrait-placeholder { width: 32px; height: 32px; }
.battle-participant > div { gap: 1px; }
.battle-participant strong { overflow: hidden; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.battle-participant > div > span { overflow: hidden; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.battle-player-host { grid-column: 1/-1; grid-row: 2; height: 100%; min-height: 0; }
.battle-player-host > div { height: 100%; min-height: 0; }
.battle-after { grid-column: 1/-1; grid-row: 3; margin: 0; }
.battle-after:not(:has(> :not([hidden]))) { display: none; }
@media (max-width: 900px) {
  body:has(.battle-view:not([hidden])) { overflow-x: hidden; overflow-y: auto; }
  body:has(.battle-view:not([hidden])) .site-header-inner { width: calc(100% - 24px); }
  .battle-view:not([hidden]) { --battle-board-limit: max(160px, calc(100svh - 280px)); display: flex; flex-direction: column; gap: 10px; width: calc(100% - 24px); height: auto; min-height: 0; padding: 10px 0 calc(72px + env(safe-area-inset-bottom)); }
  .battle-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
  .battle-heading h1 { font-size: 18px; }
  .battle-heading-actions { flex-wrap: wrap; max-width: 100%; gap: 6px; margin-left: auto; }
  .battle-matchup { flex: none; width: 100%; gap: 8px; }
  .battle-participant strong { font-size: 13px; }
  .battle-participant span { font-size: 10px; }
  .battle-player-host, .battle-player-host > div { height: auto; }
  .battle-after { margin: 0; }
}
@media (max-width: 400px) {
  .battle-view:not([hidden]) { --battle-board-limit: max(160px, calc(100svh - 360px)); }
}
