:root {
  color-scheme: dark;
  --bg: #061a15;
  --panel: rgba(12, 48, 38, 0.94);
  --panel-2: rgba(4, 30, 24, 0.92);
  --line: rgba(226, 239, 232, 0.13);
  --gold: #f2ce75;
  --blue: #84c6ff;
  --text: #f5faf7;
  --muted: #a9c2b7;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  -webkit-text-size-adjust: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0, rgba(42, 126, 92, 0.32), transparent 38%),
    linear-gradient(145deg, #0b3026, var(--bg) 55%);
}

.stats-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
  min-height: calc(76px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(3, 22, 17, 0.9);
  backdrop-filter: blur(16px);
}

.stats-header > div { display: flex; flex-direction: column; min-width: 0; }
.stats-header strong { color: var(--gold); font-size: 29px; line-height: 1.2; }
.stats-header span { overflow: hidden; color: #c2d5cc; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }

.back-link {
  display: grid;
  min-height: 54px;
  place-items: center;
  border: 1px solid rgba(242, 206, 117, 0.4);
  border-radius: 10px;
  padding: 10px 17px;
  color: var(--gold);
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
}

.stats-main {
  display: grid;
  gap: 22px;
  width: min(1180px, calc(100% - max(24px, env(safe-area-inset-left)) - max(24px, env(safe-area-inset-right))));
  margin: 18px auto 42px;
}

.intro-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, var(--panel), var(--panel-2));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

.intro-card {
  padding: 18px 20px;
}

.intro-card div { display: flex; flex-direction: column; }
.intro-card span { color: #c2d5cc; font-size: 18px; }
.intro-card strong { color: var(--blue); font-size: 23px; }

.panel { min-width: 0; padding: 22px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.section-heading span { color: var(--blue); font-size: 16px; font-weight: 800; letter-spacing: 0.1em; }
.section-heading h1,
.section-heading h2 { margin: 3px 0 0; color: var(--gold); font-size: 32px; line-height: 1.25; word-break: keep-all; }
.section-heading small { color: #d2e1da; font-size: 16px; white-space: nowrap; }

.table-scroll { width: 100%; max-width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 6px; font-size: 18px; line-height: 1.3; text-align: center; white-space: normal; overflow-wrap: anywhere; }
th { color: #d2e1da; background: rgba(1, 21, 16, 0.8); font-size: 17px; }
th + th, td + td { border-left: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; background: #0b3227; }
tbody tr:last-child td { border-bottom: 0; }
.player-name { color: var(--gold); font-weight: 900; }
.rate-good td:not(:first-child) { color: #8ee3b4; }
.rate-risk td:not(:first-child) { color: #ffaaa3; }

.breakdown-comparison-list { display: grid; gap: 14px; }
.breakdown-card { min-width: 0; border: 1px solid var(--line); border-radius: 11px; padding: 16px; background: rgba(1, 24, 18, 0.5); }
.breakdown-card > strong { display: block; margin-bottom: 12px; color: var(--gold); font-size: 23px; }
.comparison-matrix th:first-child,
.comparison-matrix td:first-child { width: 28%; }
.comparison-matrix th:not(:first-child),
.comparison-matrix td:not(:first-child) { width: 18%; text-align: center; }
.metric-name { color: #fff3c6; font-weight: 850; }
.empty { color: #d0dfd8; font-size: 19px; }

.yaku-table th:first-child, .yaku-table td:first-child { width: 11%; text-align: center; }
.yaku-table th:nth-child(2), .yaku-table td:nth-child(2) { width: 25%; text-align: left; }
.yaku-table th:nth-child(n + 3), .yaku-table td:nth-child(n + 3) { width: 16%; text-align: center; }
.han-badge { color: var(--blue); font-weight: 900; }
.yakuman { color: #ffb987; }

@media (orientation: landscape) and (max-height: 500px) {
  .stats-header { min-height: calc(70px + env(safe-area-inset-top)); }
  .stats-main { margin-top: 16px; gap: 16px; }
  .intro-card { padding: 16px 18px; }
  .panel { padding: 18px; }
}

@media (max-width: 640px) {
  .stats-main { width: calc(100% - 12px); gap: 12px; margin-top: 10px; }
  .intro-card,
  .panel { padding: 10px; }
  .section-heading { display: block; }
  .section-heading h1,
  .section-heading h2 { font-size: 25px; }
  .section-heading small { display: block; margin-top: 8px; white-space: normal; }
  .breakdown-card { padding: 7px; }
  .breakdown-card > strong { margin-bottom: 7px; font-size: 19px; }
  th, td { padding: 8px 3px; font-size: 14px; line-height: 1.25; }
  th { font-size: 13px; }
  .comparison-matrix th:first-child,
  .comparison-matrix td:first-child { width: 32%; font-size: 14px; }
  .comparison-matrix th:not(:first-child),
  .comparison-matrix td:not(:first-child) { width: 17%; }
  .yaku-table th:first-child, .yaku-table td:first-child { width: 11%; }
  .yaku-table th:nth-child(2), .yaku-table td:nth-child(2) { width: 29%; }
  .yaku-table th:nth-child(n + 3), .yaku-table td:nth-child(n + 3) { width: 15%; }
  .empty { font-size: 14px; }
}
