:root {
  --green: #1d9e75;
  --green-dark: #0f6e56;
  --green-light: #e1f5ee;
  --ink: #1a1a19;
  --muted: #6b6a66;
  --line: #e5e3dc;
  --surface: #ffffff;
  --bg: #f7f6f2;
  --danger: #b42318;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
               "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
.view { min-height: 100vh; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); font-size: 13px; margin: 8px 0; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.7; margin-top: 16px; }
code { background: #eeece5; padding: 1px 4px; border-radius: 4px; font-size: 12px; }

/* ログイン */
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 48px 20px;
  padding: 28px 22px;
}
.brand { text-align: center; margin-bottom: 26px; }
.brand-tile, .tile-mini {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green); color: #fff; font-weight: 700; border-radius: 10px;
}
.brand-tile { width: 52px; height: 52px; font-size: 26px; margin-bottom: 10px; }
.tile-mini { width: 26px; height: 26px; font-size: 14px; border-radius: 6px; }
.brand h1 { font-size: 20px; margin: 6px 0 2px; }
.brand p { margin: 0; font-size: 13px; }

.field-label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.input {
  width: 100%; padding: 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink);
}
.input:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }

.btn {
  border: none; border-radius: 8px; padding: 12px 16px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:active { background: var(--green-dark); }
.btn-block { width: 100%; margin-top: 14px; }
.btn-ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; color: var(--muted); cursor: pointer;
}

/* トップバー */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 8px;
}
.topbar-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.groupbar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px 10px;
}
.groupbar-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.group-select {
  flex: 1; padding: 8px 10px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--green); border-radius: 8px;
  background: var(--green-light); color: var(--green-dark);
}

/* タブ */
.tabs {
  display: flex; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 9;
}
.tab {
  flex: 1; padding: 12px 0; border: none; background: transparent;
  font-size: 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--green); border-bottom-color: var(--green); font-weight: 600; }

.content { padding: 16px 16px 40px; }
.section-title { font-size: 16px; margin: 4px 0 12px; }
.sub-title { font-size: 14px; margin: 20px 0 8px; }
.group-name { color: var(--green-dark); font-weight: 600; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card-list { margin-bottom: 12px; }

/* 対戦カード */
.game-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
}
.game-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
}
.game-venue { font-weight: 600; color: var(--ink); font-size: 14px; }
.score-line {
  display: flex; justify-content: space-between;
  padding: 3px 0; font-size: 13px; border-top: 1px solid #f0eee8;
}
.score-line.rank-1 { color: var(--green-dark); font-weight: 700; }
.score-line .rank { width: 24px; }
.score-line .name { flex: 1; }
.score-line .pts { font-variant-numeric: tabular-nums; }

/* 記録フォーム */
.score-row {
  display: grid; grid-template-columns: 1fr 90px 56px; gap: 6px;
  margin-bottom: 8px; align-items: center;
}
.score-row select, .score-row input {
  padding: 10px 8px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
  width: 100%;
}
.sum-line { text-align: right; font-size: 13px; margin: 10px 0; color: var(--muted); }
.sum-line.ok b { color: var(--green); }
.sum-line.bad b { color: var(--danger); }

/* 集計 */
.segmented {
  display: flex; background: #eeece5; border-radius: 8px; padding: 3px; margin-bottom: 14px;
}
.seg {
  flex: 1; padding: 8px; border: none; background: transparent;
  border-radius: 6px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.seg.active { background: #fff; color: var(--ink); font-weight: 600; }

.stat-row {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 8px;
  align-items: center; padding: 8px 0; border-top: 1px solid #f0eee8; font-size: 13px;
}
.stat-row:first-child { border-top: none; }
.stat-rank { color: var(--muted); }
.stat-name { font-weight: 600; }
.stat-num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.total-card { background: var(--green-light); border-color: var(--green); }
.total-card .stat-num { color: var(--green-dark); }

/* トースト */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 13px; z-index: 100;
  max-width: 90vw; text-align: center;
}

@media (min-width: 600px) {
  .content { padding-left: 24px; padding-right: 24px; }
}
