:root {
  --bg: #f2f2f2;
  --bg-elev: #ffffff;
  --line: #d9d9d9;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --brand: #1a3a5c;
  --brand-deep: #0f2740;
  --brand-soft: #e8eef4;
  --neg: #d23939;
  --pos: #0d7a45;
  --topbar-offset: 4.6rem;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Noto Sans JP", "Helvetica Neue", Arial, sans-serif;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: #fff;
  color: var(--brand);
  font-weight: 800;
  padding: 0.4rem 0.7rem;
  z-index: 50;
}

.skip:focus { top: 0.5rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--brand);
  border-bottom: 4px solid var(--brand-deep);
  padding: 0.4rem 1rem;
}

.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: #fff;
  text-decoration: none;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.brand-logo {
  height: 56px;
  width: auto;
  display: block;
}

.menu-btn {
  appearance: none;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: transparent;
  color: #fff;
  padding: 0;
  cursor: pointer;
}

.menu-icon {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 18px;
}

.menu-icon span {
  display: block;
  height: 2px;
  background: #fff;
}

.nav-drawer { position: fixed; inset: 0; z-index: 40; }
.nav-drawer[hidden] { display: none; }

.nav-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  border: 0;
  padding: 0;
  cursor: pointer;
}

.nav-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(320px, 86vw);
  height: 100%;
  background: #fff;
  padding: 1.25rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.nav-panel a {
  display: block;
  padding: 0.9rem 0.75rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
}

.nav-panel a[aria-current="page"],
.nav-panel a:hover { background: var(--brand-soft); }

.nav-external {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.external-icon { width: 1.05rem; height: 1.05rem; }

.nav-close {
  align-self: flex-end;
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.hero { margin-bottom: 1rem; }

.sec-title {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  margin: 0;
}

.sec-title .en {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.sec-title .ja {
  font-size: clamp(1.35rem, 4vw, 1.8rem);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.hero-lead,
.back,
.entry-note,
.total-line,
.diff-hint {
  color: var(--muted);
  line-height: 1.6;
}

.back { margin: 0 0 0.6rem; }
.back a { color: var(--ink); font-weight: 800; }

.month-switch {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.month-switch a,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 2px solid var(--brand);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font: inherit;
}

.btn.primary {
  width: 100%;
  background: var(--brand);
  color: #fff;
  margin-top: 0.8rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn.ghost { background: #fff; }
.btn.danger {
  border-color: var(--neg);
  color: var(--neg);
  background: #fff;
}

.calendar {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
  table-layout: fixed;
}

.calendar th {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 0.2rem;
}

.calendar td { padding: 0; }

.day {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-height: 44px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  border: 2px solid transparent;
  position: relative;
}

.day.outside { color: #b5b5b5; background: transparent; }
.day.is-today { border-color: var(--brand); }
.day.has-score {
  padding-bottom: 7px;
}

.day.has-score::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--neg);
}

.sheets {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  margin: 0 0 1rem;
  padding-bottom: 0.2rem;
}

.sheets a {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0.35rem 0.75rem;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  border: 2px solid var(--line);
}

.sheets a[aria-current="page"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.badge {
  min-width: 1.2rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--ink);
  font-size: 0.75rem;
  text-align: center;
}

.sheets a[aria-current="page"] .badge {
  background: #fff;
}

.stack { display: flex; flex-direction: column; gap: 1rem; }

.ranking { margin: 0; }

.ranking .sec-title { margin: 0 0 0.7rem; }

.standings {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
}

.standings-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.standings-row:last-child { border-bottom: 0; }
.standings-row:nth-child(odd) { background: #f4f7fb; }

.place {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 900;
  color: #fff;
  background: var(--brand);
}

.place-1 { background: var(--brand-deep); }
.place-2 { background: #24507a; }
.place-3 { background: #4d7399; }

.standing-person {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.standing-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--brand);
  background: var(--brand-soft);
  flex-shrink: 0;
}

.standing-name {
  font-size: 1.05rem;
  font-weight: 900;
  border-left: 4px solid var(--member);
  padding-left: 0.4rem;
}

.standing-total {
  font-size: 1.25rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.day-totals {
  background: #fff;
  border: 1px solid var(--line);
  padding: 0.4rem 0.7rem 0.7rem;
}

.totals-wrap { overflow-x: auto; }

.totals {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.totals th,
.totals td {
  padding: 0.45rem 0.35rem;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}

.totals th:first-child,
.totals td:first-child { text-align: left; }

.totals thead th {
  font-size: 0.75rem;
  color: var(--muted);
}

.totals tbody th { font-size: 0.95rem; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  padding: 0.9rem;
}

.card h2 {
  margin: 0 0 0.7rem;
  font-size: 1.05rem;
}

.banner.error {
  background: #fdecec;
  border-left: 4px solid var(--neg);
  color: #8a1f1f;
  padding: 0.7rem 0.8rem;
  margin: 0 0 0.7rem;
  font-weight: 700;
}

.diffbar {
  position: sticky;
  top: var(--topbar-offset);
  z-index: 5;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  background: var(--brand);
  color: #fff;
  padding: 0.28rem 0.7rem;
  margin-bottom: 0.9rem;
}

.diffbar .label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #cfcfcf;
}

.diffbar .value {
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.diffbar .pos { color: #8dffb0; }
.diffbar .neg { color: #ff9a9a; }

.diff-hint { margin: 0 0 0.8rem; font-size: 0.86rem; }
.diff-hint:empty { display: none; }

.players { display: flex; flex-direction: column; gap: 0.45rem; }

.player {
  display: grid;
  grid-template-columns: 40px minmax(4.5rem, 0.8fr) minmax(6rem, 1fr);
  gap: 0.55rem;
  align-items: center;
}

.player.locked { grid-template-columns: 3rem 40px minmax(4.5rem, 1fr) auto; }
.player.locked.absent { opacity: 0.55; }

.player img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 50%;
  background: var(--brand-soft);
}

.who {
  font-weight: 900;
  border-left: 4px solid var(--member);
  padding-left: 0.4rem;
}

.amount {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 0;
}

.sign {
  display: flex;
  flex: 0 0 auto;
}

.sign-opt {
  display: grid;
}

.sign-opt input {
  grid-area: 1 / 1;
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  min-height: 48px;
  margin: 0;
  border-radius: 0;
  opacity: 0;
  cursor: pointer;
}

.sign-opt span {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: #fff;
  font-weight: 900;
  font-size: 1.25rem;
  pointer-events: none;
}

.sign-opt:first-child span { border-right-width: 1px; }
.sign-opt:last-child span { border-left-width: 1px; }

.sign-opt input:checked + .plus {
  background: var(--pos);
  border-color: var(--pos);
  color: #fff;
}

.sign-opt input:checked + .minus {
  background: var(--neg);
  border-color: var(--neg);
  color: #fff;
}

.sign-opt input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.rate-form {
  background: #fff;
  border: 1px solid var(--line);
  padding: 0.75rem 0.9rem;
}

.rate {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
}

.rate .times {
  font-size: 1.25rem;
  font-weight: 900;
}

.rate input {
  width: 6.5rem;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: #fff;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  text-align: right;
  padding: 0.3rem 0.6rem;
}

.rate input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

.player input[data-points] {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 2px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 0.3rem 0.6rem;
}

.player input[data-points]:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.player input[data-points].bad { border-color: var(--neg); background: #fff6f6; }

.rank {
  font-weight: 900;
  font-size: 0.85rem;
  text-align: center;
}

.rank-1 { color: #8a6a00; }
.rank-2 { color: #555; }
.rank-3 { color: #8a4b2f; }

.pts {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  text-align: right;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); font-weight: 700; }

.note {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.8rem;
  font-weight: 800;
}

.note textarea {
  width: 100%;
  border: 2px solid var(--line);
  font: inherit;
  font-weight: 500;
  padding: 0.55rem 0.65rem;
  resize: vertical;
}

.total-line { margin: 0.7rem 0 0; font-weight: 800; }
.entry-note { margin: 0.35rem 0 0; white-space: pre-wrap; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.add-wrap { margin: 0; }
.add-wrap .btn { width: 100%; }

footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 520px) {
  .brand-name { font-size: 1.05rem; letter-spacing: 0.08em; }
  .standings-row { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 0.5rem; padding: 0.7rem; }
  .place { width: 36px; height: 36px; font-size: 1rem; }
  .standing-photo { width: 40px; height: 40px; }
  .standing-name { font-size: 0.95rem; }
  .standing-total { font-size: 1.05rem; }
  .player { grid-template-columns: 36px 4.2rem minmax(0, 1fr); }
  .player.locked { grid-template-columns: 2.4rem 36px 4.2rem minmax(0, 1fr); }
  .player img { width: 36px; height: 36px; }
}
