:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --card: #ffffff;
  --panel: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --border: #dbe1e8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --danger: #b42318;
  --positive: #16794b;
  --negative: #b42318;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(980px, calc(100% - 24px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.section-head,
.section-title-row,
.calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar { margin-bottom: 20px; }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 800; letter-spacing: .1em; color: var(--accent); }
h1 { margin: 0; font-size: clamp(26px, 5vw, 38px); line-height: 1.2; }
h2 { margin: 0; font-size: 20px; }
p { margin: 0; }
.subtext, .section-head p, .section-title-row p { margin-top: 5px; color: var(--muted); font-size: 14px; }

.panel,
.match-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel { padding: 18px; margin-bottom: 16px; }
.section-head { margin-bottom: 14px; }
.section-head.compact { align-items: flex-start; }

.btn {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 800;
  white-space: nowrap;
}
.btn-primary { color: #fff; background: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-danger-outline { background: transparent; border-color: #f0b4ae; color: var(--danger); }
.btn-large { min-width: 180px; }

.source-input,
.copy-box,
.text-input,
.select-input,
.amount-input,
.score-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.source-input:focus,
.copy-box:focus,
.text-input:focus,
.select-input:focus,
.amount-input:focus,
.score-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.source-input { min-height: 250px; padding: 13px; resize: vertical; }
.bulk-bet-input {
  width: 100%;
  min-height: 190px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
  resize: vertical;
  font: inherit;
  line-height: 1.65;
}
.bulk-bet-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.bulk-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 9px;
}
.bulk-hint span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #1e40af;
  font-size: 12px;
  font-weight: 800;
}
.bulk-note { margin-top: 8px; color: var(--muted); font-size: 12px; }
.copy-box { min-height: 126px; padding: 13px; resize: none; line-height: 1.8; background: var(--panel); }
.text-input, .select-input, .amount-input, .score-input { min-height: 44px; padding: 9px 11px; }

.message { min-height: 20px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.message.error { color: var(--danger); }
.message.success { color: var(--positive); }

.name-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.name-grid label { font-size: 13px; font-weight: 700; color: var(--muted); }
.name-grid input { margin-top: 5px; color: var(--text); font-size: 16px; }

.match-meta {
  margin: 6px 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-weight: 700;
}
.section-title-row { margin: 20px 0 12px; }
.matches { display: grid; gap: 14px; }
.match-card { padding: 18px; }

.match-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
}
.team { min-width: 0; overflow-wrap: anywhere; }
.handicap-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 7px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  vertical-align: 2px;
}
.vs { color: var(--muted); font-size: 13px; font-weight: 800; }

.score-area {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: center;
  gap: 8px;
  margin: 18px 0;
  padding: 14px;
  border-radius: 12px;
  background: var(--panel);
}
.score-label { width: 110px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.score-label span { display: block; min-height: 20px; overflow-wrap: anywhere; }
.score-input { margin-top: 5px; text-align: center; color: var(--text); font-size: 18px; font-weight: 800; }
.score-dash { padding-bottom: 10px; font-weight: 900; }
.match-judge { min-width: 180px; padding-bottom: 10px; color: var(--muted); font-size: 13px; font-weight: 700; }

.bet-header,
.bettor-row {
  display: grid;
  grid-template-columns: 120px minmax(150px, 1fr) 180px 190px;
  align-items: center;
  gap: 10px;
}
.bet-header { padding: 0 10px 7px; color: var(--muted); font-size: 12px; font-weight: 800; }
.bettor-row { padding: 10px; border-top: 1px solid var(--border); }
.bettor-name { font-weight: 900; overflow-wrap: anywhere; }
.amount-wrap { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 7px; }
.amount-wrap b { color: var(--muted); font-size: 12px; }
.bet-result { text-align: right; font-weight: 900; }
.bet-result.positive { color: var(--positive); }
.bet-result.negative { color: var(--negative); }
.mobile-label > span { display: none; }

.calc-row { margin: 16px 0 20px; }
.auto-save { color: var(--muted); font-size: 12px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.summary-card { padding: 14px; border-radius: 12px; background: var(--panel); }
.summary-name { color: var(--muted); font-size: 13px; font-weight: 800; }
.summary-value { margin-top: 3px; font-size: 26px; font-weight: 900; }
.summary-value.positive, .grand-total strong.positive { color: var(--positive); }
.summary-value.negative, .grand-total strong.negative { color: var(--negative); }
.summary-count { margin-top: 3px; color: var(--muted); font-size: 11px; }
.grand-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-weight: 800;
}
.grand-total strong { font-size: 30px; }

.rules-note {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 12px 4px;
  color: var(--muted);
  font-size: 12px;
}
.rules-note strong { color: var(--text); }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 16px, 980px); padding-top: 18px; }
  .topbar, .section-head, .section-title-row, .calc-row { align-items: stretch; flex-direction: column; }
  .topbar .btn, .section-head .btn, .section-title-row .btn, .calc-row .btn { width: 100%; }
  .name-grid, .summary-grid { grid-template-columns: 1fr; }
  .match-card { padding: 14px; }
  .match-title { font-size: 16px; gap: 7px; }
  .score-area { justify-content: flex-start; }
  .match-judge { width: 100%; padding: 4px 0 0; }
  .desktop-only { display: none; }
  .bettor-row { grid-template-columns: 1fr; gap: 9px; padding: 13px 0; }
  .bettor-row:first-child { border-top: 0; }
  .bettor-name { font-size: 17px; }
  .mobile-label > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 800; }
  .bet-result { text-align: left; padding: 7px 10px; border-radius: 8px; background: var(--panel); }
  .grand-total { align-items: flex-start; flex-direction: column; }
}

.fixed-member {
  display: flex;
  min-height: 54px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}
.fixed-member span {
  font-size: 12px;
  color: var(--muted);
}
.fixed-member strong {
  font-size: 16px;
}
