:root {
  --page: #eef1f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --surface-blue: #f1f6ff;
  --ink: #1d2d44;
  --muted: #7b899d;
  --line: #dce3ec;
  --line-strong: #c5d0de;
  --navy: #203451;
  --navy-light: #2c476c;
  --blue: #3474d3;
  --blue-dark: #245bab;
  --blue-soft: #e9f1ff;
  --win: #299363;
  --win-soft: #e7f6ee;
  --loss: #d85862;
  --loss-soft: #fff0f1;
  --draw: #7e8b9e;
  --draw-soft: #f0f2f5;
  --shadow: 0 2px 8px rgba(32, 52, 81, 0.06);
  --content-width: 1080px;
  --tap-size: 40px;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--blue-dark);
}

a:hover,
a:focus-visible {
  color: var(--blue);
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2,
h3,
h4 {
  line-height: 1.35;
}

h1 {
  margin-bottom: 0;
  font-size: 1rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

h3 {
  margin-bottom: 6px;
  font-size: 0.95rem;
}

p {
  margin-bottom: 8px;
}

button,
input {
  box-sizing: border-box;
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Header */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 3px solid var(--blue);
  background: var(--navy);
}

.app-header-inner {
  display: flex;
  align-items: center;
  width: min(100% - 40px, var(--content-width));
  min-height: 58px;
  margin: 0 auto;
}

.app-brand {
  color: #fff;
  text-decoration: none;
}

.app-brand-copy {
  display: flex;
  align-items: center;
  line-height: 1;
}

.app-brand-copy strong {
  color: #fff;
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-brand-copy small,
.app-header-context {
  display: none;
}

/* Search */

.main-content {
  width: min(100% - 40px, var(--content-width));
  min-width: 0;
  margin: 0 auto;
  padding: 18px 0 44px;
}

.search-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-panel h1 {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 800;
}

.search-form {
  display: flex;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}

.search-form > label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.search-controls {
  display: flex;
  align-items: stretch;
  gap: 7px;
  width: min(100%, 600px);
  min-width: 0;
}

.search-controls input[type="text"] {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: var(--tap-size);
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(29, 45, 68, 0.04);
}

.search-controls input[type="text"]::placeholder {
  color: #9aa6b6;
}

.search-controls input[type="text"]:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(52, 116, 211, 0.14);
  outline-offset: 0;
}

.btn-primary,
.btn-secondary,
.segbtn {
  min-height: var(--tap-size);
  padding: 6px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--ink);
  white-space: nowrap;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.btn-primary {
  min-width: 64px;
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
  color: #fff;
  transform: translateY(-1px);
}

.btn-secondary:hover,
.btn-secondary:focus-visible,
.segbtn:hover,
.segbtn:focus-visible {
  border-color: #a9c2e8;
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.search-description,
.search-hint {
  display: none;
}

/* Notices */

.banner,
.loading-indicator {
  margin: 12px 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.banner p:last-child {
  margin-bottom: 0;
}

.banner--error {
  border-color: #e5b5b9;
  background: var(--loss-soft);
  color: #9e3138;
}

.banner--notice {
  border-color: #b9cfee;
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.banner--warn {
  border-color: #e0c879;
  background: #fff8df;
  color: #735b09;
}

.loading-indicator {
  color: var(--muted);
}

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 5px;
  border: 2px solid #c8d0db;
  border-top-color: var(--blue);
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Shared sections */

.card {
  min-width: 0;
  margin: 12px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  margin-bottom: 13px;
}

.section-header > div {
  min-width: 0;
}

.section-header h2 {
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 800;
}

.section-header .muted {
  margin: 3px 0 0;
}

.section-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.muted {
  color: var(--muted);
  font-size: 0.78rem;
}

.section-collapse {
  display: grid;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  line-height: 0;
}

.section-collapse:hover,
.section-collapse:focus-visible {
  border-color: #a9c2e8;
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.section-collapse-mark {
  position: relative;
  display: block;
  width: 9px;
  height: 9px;
  color: currentColor;
  font-size: 0;
}

.section-collapse-mark::before {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(45deg);
}

.section-collapse[aria-expanded="true"] .section-collapse-mark::before {
  top: 3px;
  transform: rotate(225deg);
}

/* Player */

.player-card {
  overflow: hidden;
  padding: 0;
}

.player-card-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding: 17px 18px;
  background: linear-gradient(110deg, var(--navy), #2d4e78);
  color: #fff;
}

.player-identity {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px 10px;
  min-width: 0;
}

.player-name {
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-tag {
  color: #c9d8f1;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.78rem;
}

.player-card-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
}

.player-card-main .btn-secondary,
.player-card-main .section-collapse {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.player-card-main .btn-secondary:hover,
.player-card-main .btn-secondary:focus-visible,
.player-card-main .section-collapse:hover,
.player-card-main .section-collapse:focus-visible {
  border-color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.player-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.stat {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  padding: 13px 12px 12px 0;
  border-right: 1px solid var(--line);
}

.stat:not(:first-child) {
  padding-left: 12px;
}

.stat:last-child {
  border-right: 0;
}

.stat-label,
.tile-label,
.insight-label {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.stat-value {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 800;
}

.stat-value--with-icon {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.player-clan-badge {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  object-fit: contain;
}

.player-badge-section {
  margin: 0 18px;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--line);
}

.player-badge-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
}

.player-badges {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.player-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
}

.player-badge-art {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.player-badge-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player-badge-icon--fallback {
  display: grid;
  place-items: center;
  border: 1px solid #d2b66e;
  border-radius: 50%;
  background: #fff6d8;
  color: #946a1c;
  font-weight: 800;
}

.player-badge-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.player-badge-copy strong,
.player-badge-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-badge-copy strong {
  color: var(--ink);
  font-size: 0.72rem;
}

.player-badge-copy span {
  color: var(--muted);
  font-size: 0.65rem;
}

.tracking-info {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 16px;
  padding: 9px 18px 12px;
  color: var(--muted);
  font-size: 0.69rem;
}

.refresh-message {
  margin: 0;
  padding: 0 18px 12px;
  color: var(--blue-dark);
  font-size: 0.76rem;
}

/* Quota and filters */

.quota-section,
.filter-section {
  background: #fbfcfe;
}

.quota-section .section-header,
.filter-section .section-header {
  margin-bottom: 8px;
}

.quota-bar-wrap {
  margin: 3px 0 6px;
}

.quota-bar-track {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4eaf2;
}

.quota-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 0.25s ease;
}

.quota-bar--warn {
  background: var(--loss);
}

.quota-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.filters-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px 16px;
}

.filter-group,
.sort-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.segbtn {
  min-height: 32px;
  padding: 4px 11px;
  font-size: 0.77rem;
}

.segbtn.is-active {
  border-color: #a9c2e8;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-weight: 800;
}

/* Summary */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.tile {
  display: flex;
  min-width: 0;
  min-height: 74px;
  flex-direction: column;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
}

.tile-value {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 800;
}

.tile-value--xl {
  color: var(--blue);
  font-size: 1.55rem;
  line-height: 1.15;
}

.tile-note {
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.3;
}

.summary-insight {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 17px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #cfe0fa;
  border-radius: 4px;
  background: var(--surface-blue);
}

.summary-insight-form {
  display: flex;
  align-items: center;
  gap: 9px;
}

.recent-form {
  display: flex;
  gap: 4px;
}

.form-pill {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  font-size: 0.66rem;
  font-weight: 800;
}

.form-win {
  background: var(--win-soft);
  color: var(--win);
}

.form-loss {
  background: var(--loss-soft);
  color: var(--loss);
}

.form-draw {
  background: var(--draw-soft);
  color: var(--draw);
}

.summary-insight-copy p {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Opponent cards */

.opponent-card-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.opponent-card-kpi {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
}

.opponent-card-kpi-value {
  color: var(--blue);
  font-size: 1.32rem;
  line-height: 1.2;
}

.opponent-card-list {
  display: flex;
  flex-direction: column;
  margin-top: 9px;
}

.opponent-card-row {
  display: grid;
  grid-template-columns: 25px 38px minmax(0, 1fr) 50px;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.opponent-card-row:last-child {
  border-bottom: 0;
}

.opponent-card-rank {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.opponent-card-icon-wrap {
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #edf2f8;
}

.opponent-card-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.opponent-card-icon--empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.75rem;
}

.opponent-card-main {
  min-width: 0;
}

.opponent-card-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  margin-bottom: 4px;
}

.opponent-card-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opponent-card-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.69rem;
}

.opponent-card-bar-wrap,
.winrate-bar-wrap,
.rank-bar-wrap,
.opponent-analysis-bar-wrap {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4eaf2;
}

.opponent-card-bar,
.winrate-bar,
.rank-bar,
.opponent-analysis-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.opponent-card-level {
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

/* Battle history */

.battle-list,
.deck-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.battle-item {
  display: block;
  margin: 7px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.battle-item:first-child {
  margin-top: 0;
}

.battle-item:last-child {
  margin-bottom: 0;
}

.battle-details > summary {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto 68px 17px;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 11px;
  cursor: pointer;
  list-style: none;
}

.battle-details > summary::-webkit-details-marker {
  display: none;
}

.battle-details > summary:hover {
  background: var(--surface-soft);
}

.battle-summary-result {
  display: inline-flex;
  justify-content: center;
  width: fit-content;
  min-width: 53px;
  padding: 3px 7px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 800;
}

.battle-summary-result.result-win {
  background: var(--win-soft);
  color: var(--win);
}

.battle-summary-result.result-loss {
  background: var(--loss-soft);
  color: var(--loss);
}

.battle-summary-result.result-draw {
  background: var(--draw-soft);
  color: var(--draw);
}

.battle-summary-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.battle-summary-main strong,
.battle-summary-main small,
.battle-summary-time {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-summary-main strong {
  color: var(--ink);
  font-size: 0.84rem;
}

.battle-summary-main small,
.battle-summary-time {
  color: var(--muted);
  font-size: 0.7rem;
}

.battle-summary-score {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--ink);
  font-size: 1rem;
  white-space: nowrap;
}

.battle-summary-score strong:first-child {
  color: var(--blue);
}

.battle-summary-score strong:nth-of-type(2) {
  color: var(--loss);
}

.battle-summary-time {
  text-align: right;
}

.battle-summary-mark {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 0.16s ease;
}

.battle-details[open] .battle-summary-mark {
  transform: rotate(180deg);
}

.battle-details-content {
  padding: 0 11px 11px;
  border-top: 1px solid var(--line);
}

.battle-detail-meta,
.battle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 13px;
  color: var(--muted);
  font-size: 0.7rem;
}

.battle-detail-meta {
  padding: 8px 1px 0;
}

.battle-meta {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.battle-matchup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 10px 0 11px;
}

.battle-side {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-top-width: 3px;
  border-radius: 4px;
  background: #fbfcfe;
}

.battle-side--self {
  border-top-color: var(--blue);
}

.battle-side--opponent {
  border-top-color: var(--loss);
}

.battle-side-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 7px;
  min-width: 0;
}

.battle-side-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-side-heading span {
  flex: 0 0 auto;
  overflow: hidden;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.65rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 7px;
}

.battle-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 2px;
  border: 1px solid #ccd6e3;
  border-radius: 4px;
  background: #edf2f8;
}

.battle-card-icon {
  display: block;
  width: 100%;
  aspect-ratio: 0.78;
  border-radius: 3px;
  background: #e6ecf3;
  object-fit: contain;
}

.battle-card-icon--empty {
  display: grid;
  place-items: center;
  min-height: 40px;
  color: var(--muted);
  font-size: 0.85rem;
}

.battle-card-level {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 0 3px;
  border-radius: 2px;
  background: rgba(29, 45, 68, 0.9);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.35;
}

.battle-card-evolution {
  position: absolute;
  top: 3px;
  left: 3px;
  padding: 0 3px;
  border-radius: 2px;
  background: #6b429e;
  color: #fff;
  font-size: 0.52rem;
  font-weight: 800;
  line-height: 1.35;
}

.battle-card-name {
  display: none;
}

.battle-cards-empty {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.battle-versus {
  align-self: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.result-win .battle-summary-result {
  color: var(--win);
}

.result-loss .battle-summary-result {
  color: var(--loss);
}

.result-draw .battle-summary-result {
  color: var(--draw);
}

#loadMoreBtn {
  width: 100%;
  margin-top: 10px;
}

/* Opponent archetypes */

.opponent-analysis-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.opponent-analysis-row {
  display: grid;
  grid-template-columns: 24px 145px minmax(0, 1fr) 60px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-soft);
}

.opponent-analysis-row--good {
  border-left-color: var(--win);
}

.opponent-analysis-row--bad {
  border-left-color: var(--loss);
}

.opponent-analysis-rank {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-align: center;
}

.opponent-analysis-cards {
  display: flex;
  min-width: 0;
  gap: 4px;
}

.opponent-analysis-card-icon {
  display: block;
  width: 29px;
  height: 36px;
  border: 1px solid #cdd7e5;
  border-radius: 3px;
  background: #edf2f8;
  object-fit: contain;
}

.opponent-analysis-card-empty {
  color: var(--muted);
  font-size: 0.7rem;
}

.opponent-analysis-main {
  min-width: 0;
}

.opponent-analysis-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.opponent-analysis-heading strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opponent-analysis-badge {
  flex: 0 0 auto;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.62rem;
  font-weight: 800;
}

.opponent-analysis-badge--good {
  background: var(--win-soft);
  color: var(--win);
}

.opponent-analysis-badge--bad {
  background: var(--loss-soft);
  color: var(--loss);
}

.opponent-analysis-badge--neutral {
  background: var(--draw-soft);
  color: var(--muted);
}

.opponent-analysis-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.68rem;
}

.opponent-analysis-bar-wrap {
  margin-top: 4px;
}

.opponent-analysis-winrate {
  font-size: 0.96rem;
  text-align: right;
  white-space: nowrap;
}

.wr-good {
  color: var(--win);
}

.wr-bad {
  color: var(--loss);
}

.wr-neutral {
  color: var(--ink);
}

/* Deck archive */

.archive-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.archive-panel > summary {
  position: relative;
  padding: 11px 40px 11px 14px;
  color: var(--blue-dark);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  list-style: none;
}

.archive-panel > summary::-webkit-details-marker {
  display: none;
}

.archive-panel > summary::after {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: translateY(-70%) rotate(45deg);
}

.archive-panel[open] > summary::after {
  transform: translateY(-20%) rotate(225deg);
}

.archive-panel > summary:hover {
  background: var(--surface-soft);
}

.archive-panel .card {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.deck-item {
  border-bottom: 1px solid var(--line);
}

.deck-item:last-child {
  border-bottom: 0;
}

.deck-item-header {
  display: block;
  width: 100%;
  padding: 9px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.deck-item-header:hover,
.deck-item-header:focus-visible {
  background: var(--surface-soft);
}

.deck-cards {
  margin-bottom: 3px;
}

.chip {
  color: var(--blue-dark);
  font-size: 0.78rem;
}

.chip:not(:last-child)::after {
  color: var(--muted);
  content: " / ";
}

.deck-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  color: var(--muted);
  font-size: 0.7rem;
}

.deck-archetype {
  color: var(--ink);
  font-weight: 800;
}

.winrate-bar-wrap {
  position: relative;
  margin-top: 6px;
}

.winrate-label {
  position: absolute;
  right: 0;
  bottom: 7px;
  color: var(--muted);
  font-size: 0.68rem;
}

.deck-matchups {
  padding: 0 0 10px 12px;
}

/* Tables */

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.data-table,
.mini-table,
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.data-table th,
.data-table td,
.mini-table th,
.mini-table td,
.matrix-table th,
.matrix-table td {
  padding: 6px 8px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th,
.mini-table th,
.matrix-table th {
  background: #f1f4f8;
  color: var(--ink);
  font-weight: 800;
}

.matrix-table {
  min-width: 620px;
}

.matrix-cell {
  text-align: center !important;
}

.matrix-cell--empty {
  color: var(--muted);
}

.mc-wr,
.mc-n {
  display: block;
}

.mc-wr {
  font-weight: 800;
}

.mc-n {
  color: var(--muted);
  font-size: 0.66rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.plans-container {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 9px;
}

.plan-card {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.plan-card h4 {
  margin-bottom: 2px;
  color: var(--blue-dark);
}

.plan-limit {
  margin-bottom: 3px;
  font-weight: 800;
}

.plan-card ul {
  margin: 0;
  padding-left: 1.1em;
  color: var(--muted);
  font-size: 0.72rem;
}

.app-footer {
  width: min(100% - 40px, var(--content-width));
  margin: 0 auto;
  padding: 10px 0 28px;
  color: var(--muted);
  font-size: 0.68rem;
}

@media (max-width: 820px) {
  .main-content,
  .app-header-inner,
  .app-footer {
    width: min(100% - 28px, var(--content-width));
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .opponent-analysis-row {
    grid-template-columns: 22px 116px minmax(0, 1fr) 58px;
    gap: 8px;
  }
}

@media (max-width: 680px) {
  .app-header-inner {
    min-height: 52px;
  }

  .main-content {
    padding-top: 12px;
  }

  .search-panel {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
    padding: 12px;
  }

  .search-form,
  .search-controls {
    width: 100%;
  }

  .card {
    padding: 13px;
  }

  .player-card {
    padding: 0;
  }

  .player-card-main {
    padding: 14px 13px;
  }

  .player-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0 13px;
  }

  .stat:nth-child(2) {
    border-right: 0;
  }

  .stat:nth-child(3),
  .stat:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .stat:nth-child(3) {
    padding-left: 0;
  }

  .player-badge-section {
    margin: 0 13px;
  }

  .tracking-info {
    padding-right: 13px;
    padding-left: 13px;
  }

  .refresh-message {
    padding-right: 13px;
    padding-left: 13px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-insight {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .summary-insight-copy p {
    white-space: normal;
  }

  .opponent-analysis-row {
    grid-template-columns: 20px 104px minmax(0, 1fr) 53px;
    gap: 6px;
    padding: 8px 7px;
  }

  .opponent-analysis-card-icon {
    width: 25px;
    height: 32px;
  }

  .opponent-analysis-cards {
    gap: 3px;
  }

  .opponent-analysis-heading {
    gap: 4px;
  }

  .opponent-analysis-badge {
    padding: 1px 4px;
    font-size: 0.58rem;
  }

  .opponent-analysis-winrate {
    font-size: 0.86rem;
  }

  .battle-details > summary {
    grid-template-columns: 58px minmax(0, 1fr) auto 16px;
    gap: 7px;
    padding: 8px;
  }

  .battle-summary-result {
    grid-column: 1;
    grid-row: 1;
    min-width: 48px;
  }

  .battle-summary-main {
    grid-column: 2;
    grid-row: 1;
  }

  .battle-summary-score {
    grid-column: 3;
    grid-row: 1;
  }

  .battle-summary-mark {
    grid-column: 4;
    grid-row: 1;
  }

  .battle-summary-time {
    grid-column: 2;
    grid-row: 2;
    text-align: left;
  }

  .battle-details-content {
    padding-right: 8px;
    padding-left: 8px;
  }

  .battle-matchup {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .battle-versus {
    padding: 0;
  }

  .plans-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .main-content,
  .app-header-inner,
  .app-footer {
    width: min(100% - 20px, var(--content-width));
  }

  .app-brand-copy strong {
    font-size: 1rem;
  }

  .player-name {
    max-width: 45vw;
    font-size: 1.1rem;
  }

  .player-card-actions {
    gap: 5px;
  }

  .player-card-main .btn-secondary {
    min-height: 34px;
    padding: 4px 10px;
  }

  .section-collapse {
    width: 26px;
    height: 26px;
  }

  .opponent-card-row {
    grid-template-columns: 22px 34px minmax(0, 1fr) 45px;
    gap: 7px;
  }

  .opponent-card-icon-wrap {
    width: 34px;
    height: 34px;
  }

  .opponent-card-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
  }

  .opponent-card-heading span {
    font-size: 0.64rem;
  }

  .player-badges {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .battle-card-grid {
    gap: 3px;
  }

  .battle-card {
    padding: 1px;
  }

  .battle-card-level {
    right: 2px;
    bottom: 2px;
    font-size: 0.52rem;
  }

  .battle-card-evolution {
    top: 2px;
    left: 2px;
    font-size: 0.48rem;
  }
}

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