:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1b2430;
  --text: #f3f6fb;
  --muted: #9aa7b8;
  --line: #2a3442;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic UI",
    sans-serif;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  width: calc(100% - 24px);
  margin: 0 auto;
  padding: 24px 0 18px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 18px;
  width: calc(100% - 24px);
  margin: 0 auto;
  padding-bottom: 32px;
}

.side-panel {
  align-self: start;
  position: sticky;
  top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.brand-block {
  display: grid;
  gap: 6px;
  margin-bottom: 24px;
}

.brand-block strong {
  font-size: 20px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav button {
  height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.side-nav button.active {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.workspace {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
}

.eyebrow,
.muted {
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 16px;
}

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

.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.calendar-toolbar > button {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.date-calendar {
  display: flex;
  flex: 1;
  gap: 8px;
  overflow-x: auto;
}

.date-chip {
  display: grid;
  gap: 2px;
  min-width: 76px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: left;
}

.date-chip strong {
  color: var(--text);
  font-size: 14px;
}

.date-chip.active {
  border-color: #64748b;
  background: var(--panel-2);
}

.game-card {
  display: grid;
  grid-template-columns: 1fr 116px;
  gap: 14px;
  align-items: center;
  min-height: 180px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.game-copy {
  display: grid;
  gap: 12px;
}

.game-meta,
.game-row,
.game-probability {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.game-meta {
  color: var(--muted);
  font-size: 12px;
}

.game-row strong {
  font-size: 16px;
}

.game-row > div {
  display: grid;
  gap: 3px;
}

.subline {
  color: var(--muted);
  font-size: 12px;
}

.player-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.player-link:hover {
  color: #8fc2ff;
}

.game-score {
  font-size: 24px;
  font-weight: 700;
}

.game-probability {
  color: var(--muted);
  font-size: 12px;
}

.count-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.count-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.count-group b {
  color: var(--muted);
  font-size: 12px;
}

.count-group span {
  display: inline-flex;
  gap: 4px;
}

.count-group i {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
}

.count-group i.b.active {
  border-color: #16a34a;
  background: #22c55e;
}

.count-group i.s.active {
  border-color: #eab308;
  background: #facc15;
}

.count-group i.o.active {
  border-color: #dc2626;
  background: #ef4444;
}

.pie-wrap {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.pie {
  display: grid;
  place-items: center;
  width: 104px;
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
}

.pie::after {
  content: "";
  width: 68px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--panel);
}

.pie-label {
  position: absolute;
  z-index: 1;
  display: grid;
  justify-items: center;
  font-size: 12px;
}

.pie-label strong {
  font-size: 18px;
}

.impact-dialog {
  width: min(1120px, calc(100% - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.impact-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.impact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.impact-header button {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
}

.impact-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.impact-tabs button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.impact-tabs button.active {
  border-color: #64748b;
  background: var(--panel-2);
  color: var(--text);
}

.impact-list {
  display: grid;
}

.impact-chart-wrap {
  padding: 18px;
}

.impact-chart {
  width: 100%;
  height: 450px;
  display: block;
}

.impact-chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.impact-chart-center {
  stroke: #ffffff;
  stroke-width: 1.5;
}

.impact-chart-label {
  fill: var(--muted);
  font-size: 11px;
}

.impact-annotation text {
  font-size: 15px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--panel);
  stroke-width: 5px;
  stroke-linejoin: round;
}

.impact-annotation path {
  opacity: 0.82;
}

.impact-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

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

.impact-rank {
  color: var(--muted);
  font-size: 13px;
}

.impact-copy {
  display: grid;
  gap: 4px;
}

.impact-player-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.impact-copy strong .impact-player-link,
.impact-copy > strong.impact-player-link {
  font-weight: inherit;
}

.impact-player-link:hover {
  color: #8fc2ff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.impact-copy span {
  color: var(--muted);
  font-size: 12px;
}

.impact-delta {
  font-size: 18px;
  font-weight: 700;
}

.stats-header {
  margin-bottom: 16px;
}

.embedded-app {
  width: 100%;
  min-height: calc(100vh - 154px);
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.standings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.standings-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.standings-panel h3 {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.standings-table {
  display: grid;
}

.standings-row {
  display: grid;
  grid-template-columns: 42px 1fr repeat(4, 56px);
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

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

.standings-row.header {
  color: var(--muted);
  font-size: 12px;
}

.standings-row strong {
  font-size: 14px;
}

@media (max-width: 900px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

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

  .games-grid {
    grid-template-columns: 1fr;
  }

  .standings-grid {
    grid-template-columns: 1fr;
  }
}
