:root {
  color-scheme: light;
  --bg: #f3f5f0;
  --panel: #ffffff;
  --ink: #16231f;
  --muted: #65736d;
  --line: #dce3dd;
  --brand: #1f6f5b;
  --brand-dark: #174f43;
  --accent: #d99a2b;
  --danger: #b84a3a;
  --good: #177d4f;
  --shadow: 0 12px 28px rgba(27, 43, 38, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 96px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 16px;
}

.top-actions,
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions .status-pill {
  padding-inline: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.08;
}

h2 {
  font-size: 17px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--brand-dark);
  font-size: 22px;
  box-shadow: var(--shadow);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.tab,
.mini-tab {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.active,
.mini-tab.active {
  background: var(--brand);
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 2px 10px;
}

.section-head.spaced {
  margin-top: 24px;
}

.section-head.compact-head {
  margin-top: 12px;
}

.status-pill,
.hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 111, 91, 0.14);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--brand);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 0.7fr 1fr;
  gap: 10px;
}

.player-list,
.score-list,
.pair-list,
.leaderboard {
  display: grid;
  gap: 10px;
}

.player-card,
.score-card,
.pair-card,
.leader-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.player-card {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  padding: 12px;
}

.badge {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #e8f1ed;
  color: var(--brand-dark);
  font-weight: 900;
}

.player-card .field {
  margin: 0;
}

.handicap-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.mini-tab {
  border: 1px solid var(--line);
  background: #fff;
}

.matrix {
  display: grid;
  gap: 8px;
}

.matrix-row {
  display: grid;
  grid-template-columns: 76px 72px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.matrix-row strong {
  font-size: 13px;
}

.matrix-row input {
  min-height: 40px;
  text-align: center;
}

.taker-button {
  min-height: 40px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
}

.hole-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 46px;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  scrollbar-width: none;
}

.hole-strip::-webkit-scrollbar {
  display: none;
}

.hole-btn {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.hole-btn.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.score-card {
  padding: 12px;
}

.score-head,
.pair-head,
.leader-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.score-head {
  margin-bottom: 12px;
}

.score-name {
  font-weight: 900;
}

.score-total {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
}

.honor-name {
  color: #1265c7;
}

.score-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 96px;
  gap: 10px;
  align-items: end;
}

.score-input-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 6px;
}

.sign-button {
  min-height: 46px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 950;
}

.sign-button.active {
  border-color: #e0ad23;
  background: #fff1a8;
  color: #4d3400;
}

.toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f6;
}

.toggle button {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.toggle button.active {
  background: var(--accent);
  color: #2c1b00;
}

.sticky-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(100%, 520px);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(243, 245, 240, 0.92);
  backdrop-filter: blur(10px);
}

.primary,
.secondary {
  min-height: 48px;
  border-radius: 8px;
  font-weight: 900;
}

.primary {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand-dark);
}

.secondary:disabled {
  color: #a6b0aa;
  background: #f5f7f4;
}

.small-action {
  min-height: 34px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
}

.club-detail-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.club-detail-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.club-detail-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.club-detail-head strong {
  display: block;
  font-size: 15px;
}

.club-detail-head span,
.nine-chip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.nine-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.nine-chip {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: #f7f9f6;
}

.nine-chip button {
  min-height: 32px;
  border: 1px solid var(--brand);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
}

.limit-note {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.course-editor {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.course-hole-grid {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.course-hole-row {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  align-items: end;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: #f7f9f6;
}

.course-hole-row strong {
  align-self: center;
}

.course-hole-row label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.course-hole-row input {
  min-height: 38px;
  text-align: center;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.source-note {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.leader-card {
  padding: 13px 14px;
}

.leader-card strong {
  font-size: 16px;
}

.leader-card span:not(.amount) {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.manual-field {
  display: grid;
  grid-template-columns: minmax(86px, auto) 146px;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.manual-input-row {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 6px;
}

.manual-field input {
  min-height: 38px;
  text-align: center;
}

.sign-button.manual-sign {
  min-height: 38px;
  font-size: 11px;
}

.amount {
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.achievement-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 999px;
  background: #fff3c7;
  color: #7a4d00;
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  vertical-align: middle;
}

.achievement-badge.hio {
  min-width: 28px;
  background: #e8f1ff;
  color: #1265c7;
}

.amount.win {
  color: var(--good);
}

.amount.lose {
  color: var(--danger);
}

.win {
  color: var(--good);
}

.lose {
  color: var(--danger);
}

.pair-card {
  padding: 12px;
}

.pair-head {
  margin-bottom: 10px;
}

.pair-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.mini-stat {
  padding: 8px;
  border-radius: 8px;
  background: #f7f9f6;
}

.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mini-stat strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.report-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.report-doc {
  padding: 14px;
}

.report-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.report-title span,
.report-split {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.report-doc h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}

.report-doc h4 {
  margin: 14px 0 8px;
  font-size: 14px;
}

.one-page-report h3 {
  margin: 10px 0 5px;
}

.one-page-report .report-table {
  font-size: 10px;
}

.one-page-report .report-table th,
.one-page-report .report-table td {
  padding: 5px;
}

.table-scroll {
  overflow-x: auto;
}

.report-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 12px;
}

.score-summary {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.live-score-table {
  width: 100%;
  min-width: 580px;
  border-collapse: collapse;
  font-size: 12px;
}

.live-score-table th,
.live-score-table td {
  padding: 8px;
  border: 1px solid var(--line);
  text-align: center;
}

.live-score-table th {
  background: #edf3ef;
  color: var(--brand-dark);
  font-weight: 900;
}

.live-score-table button {
  min-width: 32px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 900;
}

.live-score-table .active-row td {
  background: #fff7e8;
}

.live-score-table td.negative-score,
.report-table td.negative-score {
  background: #fff1a8 !important;
  color: #4d3400;
  font-weight: 950;
}

.live-score-table .active-row button {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.live-score-table tfoot th {
  background: #f7f9f6;
}

.report-table.compact {
  min-width: 420px;
}

.report-table th,
.report-table td {
  padding: 7px 8px;
  border: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
}

.report-table th {
  background: #edf3ef;
  color: var(--brand-dark);
  font-weight: 900;
}

.report-table td:first-child,
.report-table th:first-child {
  font-weight: 900;
}

.report-split {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 8px 0 2px;
}

.report-summary {
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-bottom: 10px;
}

@media (max-width: 380px) {
  .grid-2,
  .filter-grid,
  .score-controls,
  .pair-grid,
  .action-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 6mm;
  }

  body {
    background: #fff;
  }

  body * {
    visibility: hidden;
  }

  #printReport,
  #printReport * {
    visibility: visible;
  }

  #printReport {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    border: 0;
    box-shadow: none;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .report-doc {
    padding: 0;
  }

  .report-doc.one-page-report {
    font-size: 7px;
    line-height: 1.1;
  }

  .report-title {
    margin-bottom: 4px;
  }

  .report-title h2 {
    font-size: 13px;
    line-height: 1;
  }

  .report-title span,
  .report-split,
  .eyebrow {
    font-size: 7px;
  }

  .report-summary {
    margin-bottom: 4px;
  }

  .report-doc h3 {
    margin: 4px 0 2px;
    font-size: 8px;
    line-height: 1;
  }

  .table-scroll {
    overflow: visible;
  }

  .report-table,
  .report-table.compact {
    min-width: 0;
    font-size: 6.8px;
  }

  .report-table th,
  .report-table td {
    padding: 1.8px 2.2px;
    line-height: 1.08;
  }

  .pair-report {
    break-inside: avoid;
  }

  .achievement-badge {
    font-size: 6px;
  }

  .achievement-badge.hio {
    padding: 0 2px;
  }
}
