/* app/lib/theme.dart の AppColors と対応する（色は値をそのまま移植）。 */
:root {
  --paper: #FDFBF6;
  --surface: #FFFFFF;
  --surface-muted: #F2EFE6;
  --outline: #DED7C4;
  --line-soft: #DED7C48C;
  --ink: #231F18;
  --ink-muted: #6F6A5C;
  --felt: #1F5C4C;
  --felt-light: #DCEAE4;
  --gold: #A9822E;
  --positive: #1E8E5A;
  --negative: #C5372A;
  --warn-surface: #FBEEDC;
  --warn-on: #8A5D12;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17140F;
    --surface: #201C15;
    --surface-muted: #2A2519;
    --outline: #3C3526;
    --line-soft: #3C352680;
    --ink: #F2EEE4;
    --ink-muted: #A8A18E;
    --felt: #4C9C82;
    --felt-light: #1E332C;
    --gold: #D3AE5E;
    --positive: #4FBE8B;
    --negative: #E2695A;
    --warn-surface: #3A2E17;
    --warn-on: #E0B876;
  }
}
:root[data-theme="dark"] {
  --paper: #17140F; --surface: #201C15; --surface-muted: #2A2519;
  --outline: #3C3526; --line-soft: #3C352680; --ink: #F2EEE4;
  --ink-muted: #A8A18E; --felt: #4C9C82; --felt-light: #1E332C;
  --gold: #D3AE5E; --positive: #4FBE8B; --negative: #E2695A;
  --warn-surface: #3A2E17; --warn-on: #E0B876;
}
:root[data-theme="light"] {
  --paper: #FDFBF6; --surface: #FFFFFF; --surface-muted: #F2EFE6;
  --outline: #DED7C4; --line-soft: #DED7C48C; --ink: #231F18;
  --ink-muted: #6F6A5C; --felt: #1F5C4C; --felt-light: #DCEAE4;
  --gold: #A9822E; --positive: #1E8E5A; --negative: #C5372A;
  --warn-surface: #FBEEDC; --warn-on: #8A5D12;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ── 状態メッセージ（読み込み中・エラー） ── */
.status-message {
  margin-top: 25vh;
  text-align: center;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.6;
}
.retry-button {
  display: block;
  margin: 16px auto 0;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--outline);
  background: transparent;
  color: var(--felt);
  cursor: pointer;
}
.retry-button:focus-visible {
  outline: 2px solid var(--felt);
  outline-offset: 2px;
}

/* ── ヘッダー ── */
header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 18px;
}
.table-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.2px;
  text-wrap: balance;
}
.table-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--ink-muted);
}
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  max-width: 220px;
  text-wrap: pretty;
}
.chip .dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.chip--live { background: var(--surface-muted); color: var(--ink-muted); }
.chip--stale { background: var(--warn-surface); color: var(--warn-on); white-space: normal; }
.chip--done { background: var(--surface-muted); color: var(--ink-muted); }

/* ── ルールバー ── */
.rule-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 9px 12px;
  background: var(--surface-muted);
  border-radius: 10px;
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.4;
}
.rule-bar b { color: var(--ink); font-weight: 700; }

/* ── テーブル共通 ── */
.table-scroll {
  overflow-x: auto;
  margin-top: 14px;
  border-radius: 12px;
}
table.sheet {
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
  min-width: 460px;
}
table.sheet th, table.sheet td {
  font-variant-numeric: tabular-nums;
}
table.sheet thead th {
  background: var(--surface-muted);
  border-bottom: 1px solid var(--outline);
  padding: 7px 2px;
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
}
table.sheet thead th:first-child {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  width: 34px;
}
table.sheet tbody th {
  background: var(--surface-muted);
  border-right: 1px solid var(--line-soft);
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 8px 4px;
}
table.sheet tbody td {
  border-top: 1px solid var(--line-soft);
  border-left: 1px solid var(--line-soft);
  text-align: center;
  vertical-align: top;
  padding: 8px 2px 9px;
}
.cell {
  position: relative;
  padding-top: 10px;
}
.cell .rank {
  position: absolute;
  top: -4px;
  left: 1px;
  font-size: 9.5px;
  font-weight: 700;
  color: color-mix(in srgb, var(--ink-muted) 65%, transparent);
}
.cell .rank.top { color: var(--gold); }
.cell .badges {
  position: absolute;
  top: -5px;
  right: 1px;
  display: flex;
  gap: 2px;
}
.badge {
  display: flex;
  align-items: center;
}
.badge svg { display: block; }
.badge--yakitori { color: var(--gold); }
.badge--tobi { color: var(--negative); }
.cell .raw {
  font-size: 10.5px;
  color: var(--ink-muted);
  line-height: 1.2;
}
.cell .pt {
  margin-top: 1px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.2;
}
.pt.pos, .final.pos { color: var(--positive); }
.pt.neg, .final.neg { color: var(--negative); }
.pt.zero, .final.zero { color: var(--ink-muted); }

tfoot th, tfoot td {
  background: var(--felt-light);
  border-top: 1.5px solid var(--felt) !important;
  padding: 9px 2px;
}
tfoot th {
  font-size: 11px;
  font-weight: 700;
  color: var(--felt);
  text-align: center;
}
tfoot .final-label { font-size: 10.5px; }
tfoot td .total {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
tfoot td .games-count {
  margin-top: 2px;
  font-size: 9.5px;
  color: var(--ink-muted);
}
tfoot td .final {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.settlement { margin-top: 14px; }
.settlement-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  margin: 0 0 6px 2px;
}
table.settlement-table td {
  font-size: 13px;
  padding: 7px 4px;
}

footer.updated {
  margin-top: 16px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-muted);
}
