:root {
  color-scheme: light;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  background: #f4f2e9;
  color: #17382f;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid #c99238; outline-offset: 3px; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 95% 0%, #e2e9dd 0, transparent 35%),
    #f4f2e9;
}

.shell { max-width: 760px; margin: 0 auto; padding: 0 18px; }
.site-header { display: flex; align-items: center; gap: 11px; padding: 22px 0 25px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border: 1px solid #295b4b;
  border-radius: 50%;
  color: #b58439;
  font-size: 32px;
  line-height: 1;
}
.eyebrow {
  margin: 0 0 6px;
  color: #688175;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .19em;
}
.site-header .eyebrow { margin-bottom: 1px; font-size: 9px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, serif; font-size: 20px; letter-spacing: .06em; }
.brand-dot { color: #bf863a; }
h2 { font-size: clamp(27px, 7vw, 42px); line-height: 1.35; letter-spacing: -.04em; }
h3 { margin-bottom: 0; font-size: 21px; letter-spacing: -.04em; }

.hero {
  overflow: hidden;
  position: relative;
  padding: 31px 25px 27px;
  border-radius: 26px;
  background: linear-gradient(135deg, #174b3d, #0d3029 75%);
  color: #fffdf3;
  box-shadow: 0 20px 45px #153a2d24;
}
.hero::after {
  position: absolute;
  right: -62px;
  top: -86px;
  width: 245px;
  height: 245px;
  border: 1px solid #ffffff25;
  border-radius: 50%;
  box-shadow: 0 0 0 35px #ffffff09, 0 0 0 70px #ffffff08;
  content: "";
  pointer-events: none;
}
.hero .eyebrow { color: #b8cebd; }
.hero-medals { display: flex; flex-wrap: wrap; gap: 7px; }
.medal-key {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid #ffffff3b;
  border-radius: 9px;
  background: #ffffff13;
  font-size: 12px;
  font-weight: 700;
}
.medal-key strong { font-family: Georgia, serif; font-size: 17px; }
.medal-key.gold { color: #f6d388; }
.medal-key.silver { color: #e5ebea; }
.medal-key.bronze { color: #e7b29a; }
.medal-key.iron { color: #d1d8d3; }

.panel {
  margin-top: 18px;
  padding: 24px 20px;
  border: 1px solid #e2e6d9;
  border-radius: 22px;
  background: #fffef9;
  box-shadow: 0 9px 25px #1d3e2910;
}
.section-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.section-number {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  height: 38px;
  border-radius: 11px;
  background: #e7eee4;
  color: #35634c;
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 700;
}
.field-group { margin: 0 0 23px; padding: 0; border: 0; }
.field-group > label, .field-group legend {
  display: block;
  margin-bottom: 10px;
  color: #28483b;
  font-size: 13px;
  font-weight: 800;
}
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; opacity: 0; }
.segmented span {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid #d6dfd4;
  border-radius: 12px;
  background: #f7f9f3;
  font-weight: 800;
}
.segmented input:checked + span { border-color: #1b5c43; background: #e2eee3; color: #14513b; }
.segmented input:focus-visible + span { outline: 3px solid #c99238; outline-offset: 3px; }
select, .name-grid input, .point-grid input, .rule-points input {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid #ccd9ce;
  border-radius: 11px;
  background: #fff;
  color: #153b2d;
  font-size: 16px;
}
.name-grid { display: grid; gap: 11px; }
.name-grid label, .point-grid label { color: #607268; font-size: 12px; font-weight: 700; }
.name-grid input, .point-grid input { display: block; margin-top: 6px; }
.rule-settings { margin: 0 0 23px; border-top: 1px solid #e6e9e0; padding-top: 17px; }
.rule-settings summary { color: #2a614b; font-size: 13px; font-weight: 800; cursor: pointer; }
.rule-settings p { margin: 12px 0; color: #65776d; font-size: 12px; line-height: 1.6; }
.point-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.point-grid input { padding: 8px; text-align: center; }
.local-rules { display: grid; gap: 10px; margin-top: 14px; }
.rule-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #e3e9df;
  border-radius: 11px;
}
.rule-toggle { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 700; line-height: 1.4; }
.rule-toggle input { flex: 0 0 auto; width: 18px; height: 18px; accent-color: #1d5b41; }
.rule-points { color: #607268; font-size: 11px; font-weight: 700; }
.rule-points input { min-height: 38px; margin-top: 3px; padding: 5px; text-align: center; }
.form-error { margin-bottom: 15px; color: #a4372d; font-size: 13px; font-weight: 700; }
.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 17px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 800;
}
.primary-button { border: 1px solid #1d5b41; background: #1d5b41; color: #fff; }
.primary-button:hover { background: #154a36; }
.primary-button:disabled { opacity: .65; }
.setup-panel > .primary-button { width: 100%; }
.secondary-button { border: 1px solid #cdd9cd; background: #fffef9; color: #2e5a45; }
.secondary-button:disabled { opacity: .5; }
.rule-note { display: flex; gap: 11px; padding: 19px 7px 7px; color: #5f7267; }
.rule-note p { margin: 0; font-size: 12px; line-height: 1.7; }
.note-symbol {
  display: grid;
  place-items: center;
  flex: 0 0 19px;
  height: 19px;
  border: 1px solid #a5b9a9;
  border-radius: 50%;
  font: italic 13px Georgia, serif;
}

.round-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 10px; }
.round-heading h2 { margin: 0; font-size: 23px; }
.text-button { min-height: 44px; padding: 5px; border: 0; background: transparent; color: #416c55; font-size: 12px; font-weight: 800; text-decoration: underline; text-underline-offset: 4px; }
.hole-score-summary {
  margin-top: 16px;
}
.hole-score-summary-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 7px;
}
.hole-score-summary-heading h3 { font-size: 16px; }
.hole-score-scroll {
  overflow-x: auto;
  border: 1px solid #d6e2d7;
  border-radius: 11px;
  background: #fffef9;
  scrollbar-width: thin;
}
.hole-score-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: #17382f;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.hole-score-table th, .hole-score-table td {
  height: 25px;
  padding: 4px 5px;
  border-right: 1px solid #e3e9df;
  border-bottom: 1px solid #e3e9df;
  text-align: center;
  white-space: nowrap;
}
.hole-score-table tr > :last-child { border-right: 0; }
.hole-score-table tbody tr:last-child > * { border-bottom: 0; }
.hole-score-table thead th { background: #e8f0e6; color: #315a43; }
.hole-score-table thead th:not(.hole-score-player):not(.hole-score-total),
.hole-score-table tbody td:not(.hole-score-total) { min-width: 34px; }
.hole-score-table .hole-score-player {
  position: sticky;
  z-index: 1;
  left: 0;
  width: 74px;
  min-width: 74px;
  max-width: 74px;
  overflow: hidden;
  background: #fffef9;
  box-shadow: 1px 0 #d6e2d7;
  text-align: left;
  text-overflow: ellipsis;
}
.hole-score-table thead .hole-score-player { background: #e8f0e6; }
.hole-score-table .hole-score-total {
  position: sticky;
  z-index: 1;
  right: 0;
  min-width: 56px;
  background: #eef4ec;
  box-shadow: -1px 0 #d6e2d7;
  font-weight: 800;
}
.hole-score-table thead .hole-score-total { background: #e8f0e6; }
.score-section {
  margin-top: 12px;
  padding: 12px 15px;
  border-radius: 13px;
  background: #153d31;
  color: #fffdf7;
}
.score-section > summary { cursor: pointer; font-size: 13px; font-weight: 800; }
.save-status { color: #607268; font-size: 10px; text-align: right; }
.scoreboard { display: grid; gap: 6px; margin-top: 10px; }
.score-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid #ffffff21;
  border-radius: 9px;
  background: #ffffff10;
}
.score-name { overflow: hidden; font-size: 14px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.score-earned { display: none; }
.score-final { min-width: 66px; color: #f2cc82; font: bold 22px Georgia, serif; text-align: right; }
.score-final.negative { color: #d7e4dc; }
.score-details { margin-top: 12px; border-top: 1px solid #ffffff2b; padding-top: 11px; }
.score-details summary { color: #d9e7d9; font-size: 12px; font-weight: 700; cursor: pointer; }
.detail-line { margin: 10px 0 0; color: #d2e1d4; font-size: 11px; line-height: 1.7; }

.hole-section { margin-top: 0; }
.hole-list { display: flex; gap: 7px; overflow-x: auto; padding: 2px 1px 7px; scrollbar-width: thin; }
.hole-tab {
  flex: 0 0 40px;
  height: 40px;
  border: 1px solid #d4dfd3;
  border-radius: 10px;
  background: #fffef9;
  color: #456756;
  font: bold 14px Georgia, serif;
}
.hole-tab.complete::after { content: "•"; display: block; margin-top: -5px; color: #bd8d42; font: 16px sans-serif; }
.hole-tab.active { border-color: #1d5b41; background: #1d5b41; color: #fff; }
.hole-tab.active::after { color: #f3d08b; }
.record-help { margin: 2px 0 7px; color: #62776b; font-size: 12px; }
.hole-card { padding: 10px 12px; border: 1px solid #e2e6d9; border-radius: 16px; background: #fffef9; }
.hole-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hole-card-head .eyebrow { display: none; }
.hole-card-head h4 { margin: 0; font: bold 18px Georgia, serif; }
.hole-state { padding: 4px 8px; border-radius: 30px; background: #eef2e8; color: #55715d; font-size: 10px; font-weight: 800; }
.hole-state.complete { background: #deebdc; color: #2c694a; }
.hole-help { display: none; }
.par3-button {
  min-height: 36px;
  margin-top: 7px;
  margin-bottom: 2px;
  padding: 5px 10px;
  border: 1px solid #cdd9cd;
  border-radius: 10px;
  background: #f8faf5;
  color: #315a43;
  font-size: 12px;
  font-weight: 800;
}
.par3-button.selected { border-color: #1d5b41; background: #e2eee3; }
.player-card { padding: 8px 0; border-top: 1px solid #e9ede5; }
.player-card:first-of-type { margin-top: 7px; }
.player-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.player-card-name { overflow: hidden; font-size: 14px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.player-card-points { display: none; }
.medal-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.medal-buttons.three { grid-template-columns: repeat(3, 1fr); }
.medal-buttons.with-diamond { grid-template-columns: repeat(auto-fit, minmax(48px, 1fr)); }
.medal-button {
  min-height: 44px;
  padding: 4px 2px;
  border: 1px solid #dbe2d9;
  border-radius: 9px;
  background: #f8faf5;
  color: #314b3e;
  font-size: 12px;
  font-weight: 800;
}
.medal-button small { display: block; font-size: 10px; font-weight: 700; }
.medal-button.gold.selected { border-color: #b58630; background: #fff0cb; color: #75500d; }
.medal-button.silver.selected { border-color: #849493; background: #e8efed; color: #3d5552; }
.medal-button.bronze.selected { border-color: #b87960; background: #f9e4d9; color: #794630; }
.medal-button.iron.selected { border-color: #6c8075; background: #e5e9e3; color: #405249; }
.medal-button.diamond.selected { border-color: #55739b; background: #e5eef9; color: #294d78; }
.medal-button:disabled { opacity: .43; }
.event-buttons { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.event-button {
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid #dbe2d9;
  border-radius: 9px;
  background: #f8faf5;
  color: #314b3e;
  font-size: 11px;
  font-weight: 700;
}
.event-button small { margin-left: 3px; font-size: 10px; }
.event-button.selected { border-color: #1d5b41; background: #e2eee3; color: #14513b; }
.hole-footnote { display: none; }
.bottom-actions {
  position: sticky;
  z-index: 3;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(105px, 1fr) minmax(0, 2fr);
  gap: 9px;
  margin: 10px -18px 0;
  padding: 8px 18px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid #e4e8de;
  background: #f4f2e9f5;
  backdrop-filter: blur(12px);
}
.bottom-actions .primary-button, .bottom-actions .secondary-button { min-height: 46px; }
.site-footer { padding: 31px 0 25px; color: #86988a; font: bold 10px Georgia, serif; letter-spacing: .12em; text-align: center; }
.site-footer span { padding: 0 5px; color: #bd8d42; }
.toast {
  position: fixed;
  z-index: 10;
  right: 18px;
  bottom: calc(85px + env(safe-area-inset-bottom));
  left: 18px;
  max-width: 420px;
  margin: auto;
  padding: 12px 16px;
  border-radius: 12px;
  background: #173d30;
  box-shadow: 0 12px 30px #102a1e45;
  color: #fff;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (min-width: 620px) {
  .shell { padding: 0 25px; }
  .hero { padding: 42px 38px; }
  .panel { padding: 28px 32px; }
  .name-grid { grid-template-columns: 1fr 1fr; }
  .bottom-actions { margin-right: -25px; margin-left: -25px; padding-right: 25px; padding-left: 25px; }
}
