:root {
  color-scheme: light dark;
  --paper: #f4f0e6;
  --paper-deep: #e8e0d0;
  --ink: #16231d;
  --muted: #536158;
  --line: #b8b3a7;
  --line-strong: #68736c;
  --turf: #176b45;
  --turf-deep: #0f4b31;
  --turf-soft: #d9e8df;
  --wood: #d8b782;
  --warning: #8a4b12;
  --danger: #9d2d24;
  --white: #fffdf7;
  --shadow: 0 18px 45px rgb(29 48 38 / 10%);
  --radius: 14px;
  --page: min(1180px, calc(100% - 32px));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(
      to bottom,
      color-mix(in srgb, var(--ink) 5%, transparent) 1px,
      transparent 1px
    ),
    var(--paper);
  background-size: 100% 96px;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
.link-button {
  min-height: 44px;
}

button {
  color: inherit;
}

a {
  color: var(--turf-deep);
  text-underline-offset: 0.18em;
}

:focus-visible {
  outline: 3px solid var(--turf);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
}

.header-inner {
  width: var(--page);
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand svg {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
}

.brand rect {
  fill: var(--wood);
  stroke: var(--ink);
  stroke-width: 2;
}

.brand circle {
  fill: var(--ink);
}

.brand path {
  fill: none;
  stroke: var(--turf);
  stroke-linecap: round;
  stroke-width: 2.5;
}

.site-header nav,
.site-footer nav {
  display: flex;
  gap: 20px;
}

.site-header nav a,
.site-footer nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.hero {
  width: var(--page);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 70px) 0 56px;
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(520px, 1.35fr);
  align-items: start;
  gap: clamp(28px, 5vw, 72px);
}

.hero-copy {
  min-width: 0;
}

.kicker,
.method-label {
  margin: 0 0 8px;
  color: var(--turf-deep);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
.metric-answer,
.measurement-readout strong,
.method-card > strong {
  letter-spacing: -0.035em;
}

h1 {
  max-width: 650px;
  margin-bottom: 8px;
  font-size: clamp(2.25rem, 5.2vw, 4.9rem);
  line-height: 0.98;
}

#hero-distance,
.metric-answer,
.diagram-topline strong,
.measurement-readout strong,
.method-card > strong,
td,
dd,
output {
  font-variant-numeric: tabular-nums;
}

.metric-answer {
  min-height: 34px;
  margin-bottom: 10px;
  color: var(--turf-deep);
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  font-weight: 800;
}

.answer-detail {
  max-width: 38rem;
  margin-bottom: 24px;
  color: var(--muted);
}

.answer-detail strong {
  color: var(--ink);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.tool-controls {
  display: grid;
  gap: 14px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.mode-grid button,
.unit-picker button,
.measurement-button {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 82%, var(--white));
  cursor: pointer;
}

.mode-grid button {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 9px;
  text-align: left;
}

.mode-grid button strong,
.mode-grid button span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-grid button strong {
  font-size: 0.86rem;
}

.mode-grid button span {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.mode-grid button[aria-pressed="true"],
.unit-picker button[aria-pressed="true"] {
  border-color: var(--turf);
  background: var(--turf-soft);
  color: var(--turf-deep);
  box-shadow: inset 0 0 0 1px var(--turf);
}

.unit-picker div {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-width: 190px;
}

.unit-picker button {
  padding: 6px 16px;
}

.unit-picker button:first-child {
  border-radius: 8px 0 0 8px;
}

.unit-picker button:last-child {
  margin-left: -1px;
  border-radius: 0 8px 8px 0;
}

.conditional-control {
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: color-mix(in srgb, var(--paper) 82%, var(--white));
}

.conditional-control label {
  display: block;
  font-weight: 750;
}

.conditional-control p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

#youth-distance {
  width: 100%;
  min-height: 44px;
  accent-color: var(--turf);
}

.fit-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.fit-fields label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.fit-fields label em {
  font-weight: 500;
}

input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
}

.primary-button,
.secondary-button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--turf-deep);
  background: var(--turf-deep);
  color: var(--white);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
}

.hero-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-status,
.form-message {
  min-height: 1.5em;
  margin: 6px 0 0;
  color: var(--turf-deep);
  font-size: 0.82rem;
}

.form-message[data-error="true"] {
  color: var(--danger);
}

.visualizer-shell {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgb(23 107 69 / 7%) 1px, transparent 1px),
    linear-gradient(rgb(23 107 69 / 7%) 1px, transparent 1px),
    color-mix(in srgb, var(--paper) 72%, var(--white));
  background-size: 24px 24px;
  box-shadow: var(--shadow);
}

.diagram-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.diagram-topline div span,
.diagram-topline div strong {
  display: block;
}

.diagram-topline div span {
  color: var(--muted);
  font-size: 0.75rem;
}

.diagram-topline div strong {
  font-size: 1.15rem;
}

.switch {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.switch input {
  width: 20px;
  height: 20px;
  accent-color: var(--turf);
}

.diagram-frame {
  width: 100%;
  aspect-ratio: 2.25 / 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper) 94%, var(--white));
}

.diagram-frame svg {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 1;
  transition: opacity 160ms ease;
}

.diagram-frame.is-updating svg {
  opacity: 0.35;
}

.court-boundary {
  fill: rgb(23 107 69 / 3%);
  stroke: var(--line-strong);
  stroke-dasharray: 8 5;
}

.space-boundary {
  fill: none;
  stroke: var(--warning);
  stroke-width: 2;
  stroke-dasharray: 13 4 3 4;
}

.board-shape {
  fill: var(--wood);
  stroke: var(--ink);
  stroke-width: 2;
}

.board-hole {
  fill: var(--ink);
}

.pitch-box {
  fill: none;
  stroke: var(--turf);
  stroke-width: 1.4;
  stroke-dasharray: 6 4;
}

.foul-line {
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-dasharray: 2 5;
}

.measure-line {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.measure-line[data-kind="front"] {
  stroke: var(--turf);
}

.measure-line[data-kind="back"] {
  stroke-dasharray: 12 5;
}

.measure-line[data-kind="holes"] {
  stroke-dasharray: 3 4;
}

.measure-line[data-kind="foul-hole"] {
  stroke-dasharray: 12 4 2 4;
}

.measure-line:not(.is-active) {
  opacity: 0.52;
}

.measure-line.is-secondary[hidden] {
  display: none;
}

.measure-end {
  fill: var(--paper);
  stroke: currentColor;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.measure-label {
  fill: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  font-weight: 750;
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 5px;
  stroke-linejoin: round;
}

.measurement-controls {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.measurement-button {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 7px;
  text-align: left;
}

.measurement-button span,
.measurement-button strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.measurement-button span {
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
}

.measurement-button strong {
  font-size: 0.72rem;
}

.measurement-button.is-active {
  border-color: var(--turf);
  background: var(--turf-soft);
}

.measurement-readout {
  min-height: 82px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.measurement-readout > span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.measurement-readout strong {
  display: block;
  font-size: 1.1rem;
}

.measurement-readout p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.fit-result {
  width: var(--page);
  margin: -20px auto 54px;
  padding: 24px;
  border-top: 3px solid var(--turf);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--turf-soft) 38%, var(--paper));
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 28px;
}

.fit-result h2 {
  margin-bottom: 8px;
}

.fit-result dl,
.derived-block dl,
.print-sheet dl {
  margin: 0;
}

.fit-result dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fit-result dl div,
.derived-block dl div {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
}

dd {
  margin: 2px 0 0;
  font-weight: 800;
}

.fit-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section {
  width: var(--page);
  margin: 0 auto;
  padding: clamp(52px, 7vw, 96px) 0;
  border-top: 1px solid var(--line);
}

.section-heading {
  max-width: 680px;
  margin-bottom: 30px;
}

.section-heading h2 {
  margin-bottom: 10px;
  font-size: clamp(1.9rem, 4vw, 3.4rem);
  line-height: 1.05;
}

.section-heading > p:last-child {
  color: var(--muted);
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.method-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--paper) 82%, var(--white));
}

.method-card svg {
  width: 100%;
  height: 72px;
  margin-bottom: 16px;
  fill: none;
  stroke: var(--turf-deep);
  stroke-width: 2.2;
}

.method-card h3 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.method-card p {
  color: var(--muted);
}

.method-card > strong {
  display: block;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--turf-deep);
}

.method-card input {
  width: 82px;
  display: inline-block;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 84%, var(--white));
}

table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  text-align: left;
}

caption {
  padding: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: left;
}

th,
td {
  padding: 14px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

thead th {
  background: color-mix(in srgb, var(--turf-soft) 58%, var(--paper));
  color: var(--turf-deep);
  font-size: 0.75rem;
  text-transform: uppercase;
}

tbody th {
  width: 160px;
}

td {
  color: var(--muted);
  font-size: 0.9rem;
}

.swipe-hint {
  display: none;
  color: var(--muted);
  font-size: 0.78rem;
}

.derived-block {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: 30px;
}

.derived-block h3 {
  font-size: 1.5rem;
}

.methodology-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
}

.methodology-grid h3 {
  margin-bottom: 6px;
  color: var(--turf-deep);
}

.methodology-grid p,
.truth-note,
.independence {
  color: var(--muted);
}

.truth-note {
  max-width: 880px;
  margin: 36px 0 24px;
  padding-left: 16px;
  border-left: 4px solid var(--warning);
}

.source-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.source-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.source-list span {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.faq-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 46px;
}

.faq-item {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.faq-item h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.faq-item p {
  margin-bottom: 0;
  color: var(--muted);
}

.site-footer {
  width: var(--page);
  margin: 0 auto;
  padding: 36px 0;
  border-top: 2px solid var(--ink);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 30px;
}

.site-footer p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.site-footer > p {
  grid-column: 1 / -1;
}

dialog {
  width: min(760px, calc(100% - 24px));
  max-height: min(760px, calc(100dvh - 24px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 100px rgb(0 0 0 / 35%);
}

dialog::backdrop {
  background: rgb(10 20 15 / 68%);
}

.dialog-shell {
  padding: 22px;
}

.dialog-topline {
  position: sticky;
  top: -22px;
  z-index: 1;
  margin: -22px -22px 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-topline span {
  font-weight: 800;
}

.dialog-topline button {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
}

.dialog-tabs {
  display: inline-flex;
  gap: 6px;
}

.dialog-tabs button {
  min-height: 36px;
  padding: 4px 10px;
}

.dialog-tabs button[aria-pressed="true"] {
  border-color: var(--turf);
  background: var(--turf-soft);
}

[data-legal-document] {
  max-width: 660px;
}

[data-legal-document] header {
  margin-bottom: 32px;
}

[data-legal-document] section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

[data-legal-document] p {
  color: var(--muted);
}

.legal-main {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 96px;
}

.not-found-page main {
  width: min(660px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-content: center;
}

.not-found-page h1 {
  font-size: clamp(3rem, 9vw, 6rem);
}

.error-code {
  color: var(--turf);
  font-family: ui-monospace, monospace;
  font-size: 1.2rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.noscript-note {
  position: fixed;
  right: 12px;
  bottom: 12px;
  max-width: 420px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--warning);
  background: var(--paper);
}

.print-sheet {
  display: none;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .visualizer-shell {
    max-width: 720px;
  }

  .fit-result {
    margin-top: 0;
  }
}

@media (max-width: 720px) {
  :root {
    --page: min(100% - 28px, 620px);
  }

  .site-header nav {
    display: none;
  }

  .header-inner {
    min-height: 56px;
  }

  .hero {
    padding-top: 24px;
    gap: 26px;
  }

  h1 {
    font-size: clamp(2rem, 11.5vw, 3.4rem);
  }

  .mode-grid {
    grid-template-columns: 1fr 1fr;
  }

  .mode-grid button:last-child {
    grid-column: 1 / -1;
  }

  .visualizer-shell {
    padding: 12px;
  }

  .diagram-frame {
    aspect-ratio: 0.68 / 1;
    max-height: 650px;
  }

  .measurement-controls {
    grid-template-columns: 1fr 1fr;
  }

  .fit-result {
    grid-template-columns: 1fr;
  }

  .fit-result dl,
  .fit-fields {
    grid-template-columns: 1fr 1fr;
  }

  .method-grid,
  .methodology-grid,
  .faq-list {
    grid-template-columns: 1fr;
  }

  .derived-block {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .swipe-hint {
    display: block;
  }

  .source-list li {
    display: block;
  }

  .source-list span {
    display: block;
    margin-top: 4px;
    text-align: left;
  }

  .site-footer {
    grid-template-columns: 1fr;
  }

  .site-footer > p {
    grid-column: auto;
  }
}

@media (max-width: 380px) {
  :root {
    --page: calc(100% - 24px);
  }

  .hero {
    padding-top: 18px;
  }

  .kicker {
    margin-bottom: 5px;
  }

  h1 {
    font-size: 2.08rem;
  }

  .answer-detail {
    margin-bottom: 16px;
    font-size: 0.88rem;
  }

  .mode-grid button {
    padding: 7px 8px;
  }

  .hero-actions .primary-button,
  .hero-actions .secondary-button {
    flex: 1 1 calc(50% - 8px);
  }

  .hero-actions button:last-of-type {
    flex-basis: 100%;
  }

  .fit-fields {
    grid-template-columns: 1fr;
  }

  .diagram-topline {
    align-items: flex-start;
  }

  .switch {
    max-width: 130px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15211c;
    --paper-deep: #1c2c24;
    --ink: #f3eee1;
    --muted: #b8c2bb;
    --line: #415047;
    --line-strong: #748178;
    --turf: #62c58f;
    --turf-deep: #84d8a8;
    --turf-soft: #233d30;
    --wood: #aa7f4f;
    --warning: #e9a052;
    --danger: #ff8d83;
    --white: #202f27;
    --shadow: 0 18px 45px rgb(0 0 0 / 30%);
  }
}

@media (forced-colors: active) {
  .measure-line,
  .court-boundary,
  .space-boundary,
  .pitch-box,
  .foul-line,
  .board-shape {
    stroke: CanvasText;
  }

  .board-shape,
  .board-hole {
    fill: Canvas;
  }

  .measurement-button.is-active,
  .mode-grid button[aria-pressed="true"],
  .unit-picker button[aria-pressed="true"] {
    border: 3px solid Highlight;
  }
}

@media print {
  @page {
    size: letter;
    margin: 0.35in;
  }

  html,
  body {
    background: white !important;
    color: black !important;
  }

  body > :not(.print-sheet) {
    display: none !important;
  }

  .print-sheet {
    display: block !important;
    color: black;
    font-size: 9.5pt;
  }

  .print-sheet header {
    padding-bottom: 8px;
    border-bottom: 2px solid black;
  }

  .print-sheet h2 {
    margin-bottom: 2px;
    font-size: 24pt;
  }

  #print-diagram {
    height: 3.5in;
    margin: 0.15in 0;
  }

  #print-diagram svg {
    width: 100%;
    height: 100%;
  }

  .print-sheet dl {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 0.25in;
  }

  .print-sheet dl div {
    padding: 5px 0;
    border-bottom: 1px solid #999;
  }

  .print-sheet p {
    margin-top: 0.15in;
    font-size: 8pt;
  }
}
