:root {
  color-scheme: light;
  --bg: #fbfbf9;
  --panel: #ffffff;
  --ink: #232323;
  --body: #3c3c3c;
  --muted: #707070;
  --faint: #9b9b96;
  --line: #e5e3dd;
  --line-strong: #d5d2ca;
  --blue: #3f6f9f;
  --blue-soft: #4a79ab;
  --red: #a85c5c;
  --red-soft: #b26b6b;
  --green: #5a9e6d;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(40, 35, 25, 0.04), 0 12px 32px rgba(40, 35, 25, 0.05);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--body);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- header */

.site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 28px 0;
}

.wordmark {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-decoration: none;
  text-transform: uppercase;
}

.tagline {
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.header-spacer {
  margin-left: auto;
}

.header-link {
  padding-bottom: 1px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
}

.header-link:hover {
  color: var(--ink);
}

.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 28px 30px;
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-align: center;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------ page */

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 26px 28px 80px;
}

.page.narrow {
  max-width: 720px;
}

.intro,
.hero {
  text-align: center;
}

.intro {
  margin-bottom: 26px;
}

h1 {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: clamp(28px, 4.4vw, 44px);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.1;
  text-wrap: balance;
}

.lede {
  max-width: 560px;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 15px;
  text-wrap: balance;
}

.not-found {
  padding-top: 12vh;
}

.not-found .btn {
  margin-top: 18px;
}

/* ----------------------------------------------------------------- gauge */

.gauge {
  width: 100%;
  max-width: 900px;
  margin: 18px auto 0;
}

.gauge svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.band {
  stroke: var(--bg);
  stroke-width: 3;
  stroke-linejoin: round;
}

.gauge-outline {
  fill: none;
  stroke: #c9c6bf;
  stroke-width: 2;
}

.gauge-baseline {
  fill: none;
  stroke: #d8d5ce;
  stroke-width: 2;
}

.gauge-notch {
  fill: var(--bg);
  stroke: #dcd9d2;
  stroke-width: 2;
}

.band-label {
  font-family: var(--font);
  font-size: 20px;
  font-weight: 750;
  letter-spacing: 1.7px;
  text-anchor: middle;
  dominant-baseline: central;
}

.band-label.left {
  fill: var(--blue-soft);
}

.band-label.right {
  fill: var(--red-soft);
}

.band-label.tossup {
  fill: #5d5d5d;
}

.needle {
  transform-box: view-box;
  transform-origin: 500px 480px;
}

.needle-body {
  fill: url(#needle-fill);
}

.needle-pivot {
  fill: #3d3d3d;
}

.gauge-ends {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: -10px;
  padding: 0 1%;
}

.end {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.end-right {
  align-items: flex-end;
  text-align: right;
}

.end-name {
  max-width: 26ch;
  overflow: hidden;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.end-pct {
  font-size: clamp(22px, 3.2vw, 32px);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.end.is-left .end-name,
.end.is-left .end-pct {
  color: var(--blue);
}

.end.is-right .end-name,
.end.is-right .end-pct {
  color: var(--red);
}

.end.is-left .end-name,
.end.is-right .end-name {
  opacity: 0.78;
}

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.status-sep {
  color: var(--line-strong);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(90, 158, 109, 0.14);
  animation: breathe 2.6s ease-in-out infinite;
}

.status-dot.is-offline {
  background: #b08a5a;
  box-shadow: 0 0 0 3px rgba(176, 138, 90, 0.14);
  animation: none;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ----------------------------------------------------------------- cards */

.card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

/* ----------------------------------------------------------------- forms */

.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field > label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fefefd;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: transparent;
  outline: 2px solid #9a9a9a;
}

input::placeholder {
  color: #b3b0a8;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.form-error {
  margin: 0;
  color: #a13d3d;
  font-size: 13.5px;
}

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    opacity 0.15s ease;
}

.btn:hover {
  background: #000;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn.secondary {
  border-color: var(--line);
  background: #f3f2ee;
  color: var(--ink);
}

.btn.secondary:hover {
  background: #eae8e2;
}

.btn.danger {
  height: 40px;
  border-color: #e3cccc;
  background: #fff;
  color: #a13d3d;
}

.btn.danger:hover {
  background: #fdf3f3;
}

/* ------------------------------------------------------------------ copy */

.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-row input {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- notice */

.notice {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.notice strong {
  color: #8a5a2b;
  font-weight: 650;
}

/* --------------------------------------------------------------- preview */

.preview {
  margin-top: 48px;
  text-align: center;
}

.preview-eyebrow {
  margin: 0;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.preview-title {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.preview-note {
  min-height: 1.2em;
  max-width: 480px;
  margin: 6px auto 0;
  color: var(--muted);
  font-size: 13.5px;
}

.preview .gauge {
  max-width: 620px;
  margin-top: 10px;
}

/* ----------------------------------------------------------------- admin */

.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 680px;
  margin: 26px auto 0;
  text-align: center;
}

.readout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.readout-value {
  color: var(--ink);
  font-size: 34px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.readout-suffix {
  color: var(--muted);
  font-size: 13px;
}

.readout-suffix span {
  color: var(--blue);
  font-weight: 650;
}

.readout.is-right .readout-suffix span {
  color: var(--red);
}

.drag-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-wrap: balance;
}

.gauge.is-interactive svg {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.gauge.is-interactive svg:focus-visible {
  border-radius: 12px;
  outline: 2px solid #8f8f8f;
  outline-offset: 8px;
}

.needle-hit {
  stroke: transparent;
  stroke-width: 110;
  stroke-linecap: round;
}

.gauge.is-interactive .needle-hit {
  cursor: grab;
}

.gauge.is-interactive.is-dragging .needle-hit {
  cursor: grabbing;
}

.save-status {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.save-status.is-error {
  color: #a13d3d;
}

.save-status.is-ok {
  color: #4c7d5c;
}

.share {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 680px;
  margin: 18px auto 0;
}

.danger-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------ admin sharing */

.admin-mode-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto 18px;
  padding: 10px 14px;
  border: 1px solid #f0d7b8;
  border-radius: 12px;
  background: #fff7ed;
  color: #7a4b1a;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
}

.admin-mode-banner p {
  margin: 0;
}

.admin-mode-banner strong {
  color: #8a3d2b;
}

.admin-mode-lock {
  flex: 0 0 auto;
  color: #a85c5c;
}

.hero-share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.btn.share-cta {
  background: var(--blue);
}

.btn.share-cta:hover {
  background: #2f5b85;
}

.private-admin {
  margin-top: 4px;
}

.private-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ecd3b8;
  border-radius: 12px;
  background: #fffaf2;
  color: #7a4b1a;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.private-toggle:hover {
  background: #fff4e6;
}

.private-toggle-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lock-icon {
  color: #a85c5c;
}

.private-toggle-chevron {
  color: #a85c5c;
  transition: transform 0.15s ease;
}

.private-toggle[aria-expanded="true"] .private-toggle-chevron {
  transform: rotate(180deg);
}

.private-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  padding: 14px;
  border: 1px solid #f0d7b8;
  border-radius: 12px;
  background: #fffaf2;
}

.private-panel[hidden] {
  display: none;
}

.private-warning {
  margin: 0;
  color: #7a4b1a;
  font-size: 12.5px;
  line-height: 1.45;
}

.private-warning strong {
  color: #8a3d2b;
}

.text-button {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: #a13d3d;
  font: inherit;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.text-button:hover {
  color: #7f2c2c;
}

.text-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.private-panel .save-status {
  text-align: left;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 720px) {
  .site-header {
    padding: 20px 18px 0;
  }

  .site-footer {
    padding: 0 18px 24px;
  }

  .page {
    padding: 20px 18px 64px;
  }

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

  .copy-row {
    flex-wrap: wrap;
  }

  .copy-row input {
    flex: 1 0 100%;
  }

  .band-label {
    font-size: 30px;
    letter-spacing: 2.2px;
  }

  .gauge {
    margin-top: 10px;
  }

  .gauge-ends {
    padding: 0 0.5%;
    margin-top: -2px;
  }

  .end-name {
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  .end-pct {
    font-size: 22px;
  }

  .card {
    padding: 18px;
  }

  .controls {
    margin-top: 20px;
  }

  .readout-value {
    font-size: 30px;
  }

  .admin-mode-banner {
    align-items: flex-start;
  }

  .hero-share {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-share .btn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .band-label {
    font-size: 33px;
    letter-spacing: 2.4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
