:root {
  color-scheme: light;
  --page:           #f9f9f7;
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --accent:         #2a78d6;
  --accent-track:   #e6eefb;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:           #0d0d0d;
    --surface-1:      #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
    --accent:         #3987e5;
    --accent-track:   #24344a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:           #0d0d0d;
  --surface-1:      #1a1a19;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --grid:           #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);
  --accent:         #3987e5;
  --accent-track:   #24344a;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

/* ---- main page ---- */
header.main-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 2px;
}
header.main-header p {
  margin: 0 0 20px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.round-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.round-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.round-card:hover {
  border-color: var(--accent);
}

.round-card .thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--accent-track);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.round-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.round-card .thumb .placeholder {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0 8px;
}
.round-card .logo-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.15s ease;
}
.round-card:hover .logo-badge {
  transform: translateY(-2px) scale(1.04);
}
.round-card .logo-badge img {
  width: 78%;
  height: 78%;
  object-fit: contain;
  display: block;
}

.round-card .body {
  padding: 12px 14px 14px;
}
.round-card .round-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin: 0 0 4px;
}
.round-card .opponent {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.round-card dl {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.round-card dl div {
  display: flex;
  gap: 6px;
  padding: 2px 0;
}
.round-card dl dt {
  flex: none;
  width: 34px;
  color: var(--text-muted);
}
.round-card dl dd {
  margin: 0;
}

/* ---- round page ---- */
.back-link {
  display: inline-block;
  font-size: 0.82rem;
  margin-bottom: 16px;
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.round-header .round-number {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 2px;
}
.round-header h1 {
  font-size: 1.3rem;
  margin: 0 0 14px;
}
.round-header .opponent-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}
.round-header .opponent-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 50%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  padding: 3px;
}
.round-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 20px;
  font-size: 0.85rem;
}
.round-meta > div {
  display: flex;
  gap: 10px;
}
.round-meta dt {
  flex: none;
  width: 44px;
  color: var(--text-muted);
}
.round-meta dd {
  margin: 0;
  color: var(--text-primary);
}

.round-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 20px;
  border-bottom: 1px solid var(--border);
}
.round-tab {
  display: inline-block;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.round-tab:hover { color: var(--text-primary); }
.round-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.recent-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 20px;
}
.recent-tab {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.recent-tab:hover { color: var(--text-primary); border-color: var(--text-muted); }
.recent-tab.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.phase-panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.phase-panel-title {
  margin: 0;
  padding: 10px 14px;
  background: #1a1a19;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}
.phase-panel-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px;
}
.phase-radar-frame {
  position: relative;
  width: 460px;
  max-width: 100%;
  min-height: 220px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.phase-radar-frame .phase-radar-svg {
  width: 100%;
  height: auto;
  display: block;
}
.phase-radar-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.playtype-tables {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
  align-content: start;
}
.playtype-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.playtype-table caption {
  text-align: left;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 0 0 6px;
}
.playtype-table th {
  text-align: right;
  font-weight: 600;
  color: var(--text-muted);
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.playtype-table th:first-child { text-align: left; }
.playtype-table td {
  text-align: right;
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.playtype-table tbody tr:nth-child(even) { background: var(--page); }
.playtype-table td.pt-name {
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}
.playtype-table td.pt-rank {
  color: var(--text-primary);
  font-weight: 600;
  border-radius: 4px;
}

.playtype-table td.pt-clickable {
  cursor: pointer;
  color: var(--accent);
}
.playtype-table td.pt-clickable:hover { text-decoration: underline; }
.playtype-table td.pt-clickable .pt-caret {
  display: inline-block;
  font-size: 0.65rem;
  transition: transform 0.15s ease;
  color: var(--text-muted);
}
.playtype-table td.pt-clickable.is-active {
  color: var(--text-primary);
}
.playtype-table td.pt-clickable.is-active .pt-caret {
  transform: rotate(90deg);
}
.playtype-table tr:has(td.pt-clickable.is-active) {
  background: var(--accent-track);
}

.personnel-panel { display: none; }
.personnel-panel.is-open {
  display: block;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.personnel-panel-title {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.personnel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.personnel-table th {
  text-align: right;
  font-weight: 600;
  color: var(--text-muted);
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
}
.personnel-table th:first-child { text-align: left; }
.personnel-table td {
  text-align: right;
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.personnel-table tbody tr:nth-child(even) { background: var(--page); }
.personnel-table td.pn-name {
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}

.content-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}
.content-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.content-card-title {
  margin: 0;
  padding: 10px 14px;
  background: #1a1a19;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}
.content-card-body {
  padding: 12px 16px;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-primary);
}
.content-card-body p { margin: 0 0 10px; }
.content-card-body p:last-child { margin-bottom: 0; }
.content-card-group { padding-bottom: 14px; }
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  padding: 14px 14px 0;
}
.content-grid .content-card { border-radius: 10px; }

.png-frame-section { margin-top: 8px; }
.png-frame {
  position: relative;
  min-height: 320px;
  border: 1px dashed var(--baseline);
  border-radius: 12px;
  background: var(--surface-1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.png-frame img {
  width: 100%;
  height: auto;
  display: block;
}
.png-frame.has-image .png-frame-empty { display: none; }
.png-frame-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}
.png-frame-empty span {
  font-size: 0.72rem;
  word-break: break-all;
  padding: 0 12px;
}
