:root {
  --ink: #142016;
  --cream: #f4f7ef;
  --muted: #3e5344;
  --leaf: #1f6b3a;
  --leaf-deep: #123822;
  --gold: #e6b23c;
  --line: rgba(20, 32, 22, 0.14);
  --water: #1a86a8;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0f2418;
  color: var(--ink);
}

body {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  min-height: 100dvh;
}

button, input, .sans { font-family: "Avenir Next", "Segoe UI", sans-serif; }

button, input { color: inherit; }

button {
  background: #fff;
  border: 1px solid rgba(20, 32, 22, 0.18);
  border-radius: 12px;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 1rem;
}

button.primary {
  background: var(--leaf);
  border-color: #174f2b;
  color: var(--cream);
  font-size: 1.05rem;
}

button:active { transform: translateY(1px); }

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

input {
  width: 100%;
  background: #fff;
  border: 1px solid rgba(20, 32, 22, 0.2);
  border-radius: 12px;
  min-height: 48px;
  padding: 0 12px;
  font-size: 1.05rem;
}

.boot { padding: 24px; color: var(--cream); }

.home {
  max-width: 460px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

body:not(.playing) {
  background:
    radial-gradient(circle at 12% -10%, #e7f6c8, transparent 42%),
    linear-gradient(180deg, #9dcc73 0%, #3f8d49 42%, #1d5a34 100%);
}

.home.gate { display: flex; flex-direction: column; justify-content: center; }

.eyebrow {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.78rem;
  color: #174f2b;
}

.home h1 {
  font-weight: 600;
  font-size: 2.7rem;
  letter-spacing: 0.02em;
  margin: 4px 0 0;
  color: var(--leaf-deep);
}

.lede { margin: 6px 0 18px; line-height: 1.4; color: #1c3b28; }

.home .lede { margin-bottom: 2px; }

.grip {
  margin: 0 0 18px;
  font-weight: 650;
  color: #14331f;
}

.hint { margin: 2px 0 0; color: #3d5c45; font-size: 0.9rem; }

.card {
  background: rgba(244, 247, 239, 0.94);
  border-radius: 16px;
  padding: 14px;
  margin: 12px 0;
  box-shadow: 0 10px 30px rgba(12, 40, 20, 0.12);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.stats strong {
  display: block;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 1.35rem;
  color: #1d6b34;
}

.stats span {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stats .stat-hit {
  background: transparent;
  border: 0;
  min-height: 0;
  padding: 4px;
  border-radius: 12px;
  width: 100%;
  font: inherit;
}

.stats .stat-hit strong {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.home .card-table th,
.home .card-table td { padding: 8px 10px 8px 0; }

.ace-line {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  min-height: 0;
  padding: 6px 0;
  text-align: left;
  color: inherit;
  font: inherit;
}

.board-aces {
  margin: 14px 0 4px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.95rem;
}

.round-status {
  display: block;
  color: var(--muted);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tr.pick { cursor: pointer; }

tr.pick:hover td,
tr.pick:focus td { background: rgba(29, 107, 52, 0.08); }

.stack { display: flex; flex-direction: column; gap: 8px; }

.how { color: #24382c; line-height: 1.45; font-size: 0.98rem; }

.how p { margin: 0 0 8px; }

.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  align-items: center;
  margin-top: 8px;
}

.quiet {
  background: transparent;
  border: 0;
  color: #245033;
  min-height: 36px;
  padding: 0;
}

.error { color: #9c2f24; min-height: 1.2em; }

.bag-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.mold {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border-radius: 999px;
  padding: 4px 8px 4px 4px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.78rem;
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.2);
}

.brand { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; }

.play {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto auto;
  background: #12321f;
  touch-action: none;
  color: var(--cream);
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  background: linear-gradient(#1a5633, #14482b);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hole-kicker {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.hole-name { font-size: 1.15rem; line-height: 1.1; }

.meta {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.82rem;
  color: #d5e6d4;
  margin-top: 2px;
}

.blurb {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #c5dcc4;
  font-size: 0.78rem;
  margin-top: 2px;
}

.hud-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.scorebig {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 1.4rem;
  color: var(--gold);
  line-height: 1;
}

.dots { display: flex; gap: 4px; }

.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid #d5e6d4;
}

.dots i.on { background: var(--gold); border-color: var(--gold); }

.hud-buttons { display: flex; gap: 6px; }

.hud-buttons button {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 0.78rem;
  background: transparent;
  color: var(--cream);
  border-color: rgba(255, 255, 255, 0.25);
}

.stage { position: relative; min-height: 0; background: #1a4a2c; }

canvas { width: 100%; height: 100%; display: block; background: #1b4d2e; }

.log {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 8px;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: #fff;
}

.bag {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 0;
  background: #102818;
}

.disc-label {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #d5e6d4;
}

select#disc {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid #d7ead6;
  background: #f4f7ef;
  color: #142016;
  font: 600 0.95rem "Avenir Next", "Segoe UI", sans-serif;
  padding: 8px 10px;
}

.kinds, .molds, .releases { display: flex; gap: 6px; }

.kinds button, .releases button, .molds button {
  flex: 1;
  min-height: 36px;
  padding: 6px 4px;
  background: #1a3a26;
  color: #d7ead6;
  border-color: #2d5a3d;
  font-size: 0.82rem;
}

.kinds button.on, .releases button.on, .molds button.on {
  background: #f4f7ef;
  color: var(--ink);
  border-color: #f4f7ef;
}

.molds button { font-size: 0.78rem; }

.molds button small {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.deck {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 10px;
  align-items: end;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: #102818;
}

.stick {
  position: relative;
  width: 148px;
  height: 148px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #2f6a40, #1a3d26 70%);
  border: 1px solid #6ea36a;
  touch-action: none;
}

.stick .knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: #efe7d4;
  border: 1px solid #c8b89a;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.stick span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  text-align: center;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d5ead0;
  pointer-events: none;
}

.throw-col { display: flex; flex-direction: column; gap: 8px; }

.power-wrap { display: flex; flex-direction: column; gap: 4px; }

.power-wrap span {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d5ead0;
  text-align: center;
}

.power {
  height: 8px;
  border-radius: 99px;
  background: #1a3a26;
  overflow: hidden;
}

.power i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7dcea0, #f2c84b);
}

#throw {
  min-height: 64px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--gold);
  color: #1a2410;
  border-color: #a97d16;
}

#throw:disabled { opacity: 0.45; }

.veil {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(8, 24, 14, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  overflow: hidden;
  touch-action: pan-y;
}

.veil.hidden { display: none; }

.sheet {
  width: min(460px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  border-radius: 16px;
  padding: 16px;
  margin-top: auto;
  touch-action: pan-y;
}

.sheet.card-sheet { height: 100%; }

.sheet-scroll {
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: none;
  padding-top: 12px;
}

.sheet h2 { margin: 0 0 6px; font-size: 1.7rem; }

.sheet p { margin: 0 0 12px; line-height: 1.4; color: #314638; }

.card-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.82rem;
  margin-bottom: 12px;
}

.card-table th {
  text-align: left;
  color: #5c6f62;
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--cream);
}
.card-table td { padding: 3px 0; border-top: 1px solid rgba(20, 32, 22, 0.08); }
.card-table td.num, .card-table th.num { text-align: right; }

@media (max-width: 380px) {
  .stick { width: 124px; height: 124px; }
  .home h1 { font-size: 2.2rem; }
  .kinds button, .molds button { font-size: 0.72rem; }
}

@media (min-width: 800px) {
  .play {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }
}

.admin-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
}

.admin-wrap h1 {
  font-weight: 600;
  font-size: 2.4rem;
  letter-spacing: 0.02em;
  margin: 4px 0 0;
  color: var(--leaf-deep);
}

.admin-wrap h2 {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 1.05rem;
  font-weight: 650;
  margin: 0 0 6px;
}

.admin-wrap .lede { max-width: 40rem; }

.admin-wrap .stats {
  margin-top: 4px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 640px) {
  .admin-wrap .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

.admin-wrap .card-table { width: 100%; font-size: 0.95rem; }

.admin-wrap .card-table th,
.admin-wrap .card-table td {
  padding: 8px 18px 8px 0;
  white-space: nowrap;
}

.admin-wrap .card-table td.name { white-space: normal; }

.hidden { display: none; }

.count-link {
  background: transparent;
  border: 0;
  min-height: 0;
  padding: 0;
  color: #1d6b34;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.trash {
  background: transparent;
  border: 0;
  min-height: 0;
  padding: 4px;
  color: #8a3b32;
  line-height: 0;
}

.trash-cell { width: 1%; text-align: right; }

a.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--leaf);
  border: 1px solid #174f2b;
  color: var(--cream);
  text-decoration: none;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 1.05rem;
}
