:root {
  color-scheme: light;
  --bg: #eee4d0;
  --panel: #fbf4df;
  --paper: #fbf4df;
  --paper-2: #f4e8ce;
  --ink: #172018;
  --muted: #706856;
  --line: #cdbf9d;
  --ledger-line: #9fb6bd;
  --green: #1e4f34;
  --green-2: #17371f;
  --red: #b3272b;
  --blue: #1c5b9e;
  --brass: #c69a3c;
  --focus: #d9aa48;
  --book-font: "Bree Serif", Georgia, "Times New Roman", serif;
  --score-font: "Playwrite NZ Basic", "Bradley Hand", cursive;
  --title-font: var(--book-font);
  --shadow: 0 16px 36px rgba(56, 43, 24, 0.16);
}

@font-face {
  font-display: swap;
  font-family: "Bree Serif";
  font-style: normal;
  font-weight: 400;
  src: url("fonts/bree-serif-v18-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-display: swap;
  font-family: "Bree Serif";
  font-style: normal;
  font-weight: 400;
  src: url("fonts/bree-serif-v18-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-display: swap;
  font-family: "Playwrite NZ Basic";
  font-style: normal;
  font-weight: 100 400;
  src: url("fonts/playwrite-nz-basic-v1.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 22px 18px, rgba(121, 92, 47, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(90deg, rgba(91, 72, 40, 0.08) 1px, transparent 1px),
    linear-gradient(var(--bg), var(--bg));
  background-size: 38px 38px, 100% 100%, 100% 100%;
  color: var(--ink);
  font: 15px/1.45 var(--book-font);
}

a {
  color: inherit;
}

.topbar {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 30%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 7px),
    var(--green-2);
  border-bottom: 3px solid #0f2415;
  box-shadow: inset 0 -1px rgba(255, 255, 255, 0.12), 0 4px 12px rgba(23, 32, 24, 0.18);
  color: #fdf6e5;
  display: flex;
  justify-content: space-between;
  min-height: 62px;
  padding: 0 20px;
}

.brand {
  font-family: var(--title-font);
  font-size: 21px;
  font-weight: 800;
  text-decoration: none;
}

.topbar nav {
  display: flex;
  gap: 14px;
}

.topbar nav a {
  border-radius: 6px;
  color: #fdf6e5;
  padding: 8px 10px;
  text-decoration: none;
}

.topbar nav a:hover {
  background: rgba(255, 255, 255, 0.14);
}

.app-shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px 18px 48px;
}

.band {
  background:
    linear-gradient(90deg, rgba(168, 137, 82, 0.12) 38px, transparent 38px 39px, rgba(159, 182, 189, 0.18) 39px 40px, transparent 40px),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(159, 182, 189, 0.22) 31px 32px),
    var(--paper);
  border: 1px solid #bcae8d;
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  padding: 18px;
}

.hero {
  align-items: center;
  background:
    linear-gradient(90deg, rgba(30, 79, 52, 0.12) 18px, transparent 18px),
    radial-gradient(circle at 72% 36%, rgba(30, 79, 52, 0.1), transparent 28%),
    var(--paper);
  border: 1px solid #bcae8d;
  border-radius: 10px;
  box-shadow: var(--shadow);
  color: var(--ink);
  display: grid;
  min-height: 300px;
  padding: 30px;
}

.hero h1,
.band h1,
.band h2,
.band h3 {
  letter-spacing: 0;
  margin: 0 0 12px;
}

.hero h1 {
  color: var(--green-2);
  font-family: var(--score-font);
  font-size: clamp(50px, 9vw, 92px);
  font-weight: 400;
  line-height: 0.9;
  margin-bottom: 28px;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 10px;
}

.hero form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 540px;
}

.cover-panel {
  max-width: 560px;
}

.cover-subtitle,
.book-kicker {
  color: var(--green-2);
  font-weight: 850;
  letter-spacing: 0.18em;
  margin: 0 0 22px;
  text-transform: uppercase;
}

.book-kicker {
  font-size: 12px;
  margin-bottom: 5px;
}

.code-entry-field {
  display: grid;
  gap: 6px;
  min-width: min(260px, 100%);
}

.code-entry-field span {
  color: #3d3320;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.code-entry-field input {
  border-color: #9f8450;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 252, 241, 0.6);
  font-family: var(--score-font);
  font-size: 34px;
  letter-spacing: 0.28em;
  min-height: 70px;
  text-align: center;
  text-transform: uppercase;
}

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

.toolbar .left,
.toolbar .right {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

input,
select,
textarea,
button {
  font: inherit;
  touch-action: manipulation;
}

input,
select,
textarea {
  background: rgba(255, 252, 241, 0.92);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(242, 184, 75, 0.55);
  outline-offset: 1px;
}

button {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent),
    var(--green);
  border: 1px solid #12321f;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  color: #fff8e9;
  cursor: pointer;
  min-height: 40px;
  padding: 9px 13px;
}

button.secondary {
  background: rgba(255, 252, 241, 0.82);
  border-color: #8b784f;
  color: var(--green);
}

button.danger {
  background: var(--red);
  border-color: var(--red);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.auth-status {
  color: var(--muted);
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.error-text {
  background: #fff1f0;
  border: 1px solid #f4b4ad;
  border-radius: 6px;
  color: var(--red);
  margin: 0;
  padding: 10px;
}

.tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  margin: 10px 0 16px;
  overflow-x: auto;
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--muted);
  min-height: 42px;
}

.tab.active {
  border-bottom-color: var(--green-2);
  color: var(--ink);
}

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.admin-layout {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  max-width: 100%;
  min-width: 0;
}

.admin-layout > .card {
  min-width: 0;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.admin-editor {
  max-width: 100%;
  min-width: 0;
}

.admin-login {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
}

.login-card {
  align-content: start;
  display: grid;
  gap: 12px;
}

.tournament-list {
  display: grid;
  gap: 8px;
}

.list-button {
  align-items: flex-start;
  display: grid;
  gap: 2px;
  justify-items: start;
  text-align: left;
  width: 100%;
}

.list-button small {
  color: var(--muted);
  font-size: 12px;
}

.admin-sections {
  display: grid;
  gap: 14px;
  max-width: 100%;
  min-width: 0;
}

.admin-section,
.admin-subsection {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 14px;
}

.admin-subsection {
  margin-top: 10px;
}

.section-heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-heading h3,
.section-heading h4 {
  margin: 0;
}

.team-player-card {
  display: grid;
  gap: 10px;
}

.team-player-header {
  align-items: center;
  display: flex;
  gap: 10px;
}

.team-player-header h4 {
  margin: 0;
}

.team-swatch {
  background: var(--team-color);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 auto;
  height: 20px;
  width: 20px;
}

.player-slot-table {
  min-width: 640px;
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
  max-width: 100%;
  min-width: 0;
}

.basics-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}

.form-grid.tight {
  flex: 1;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  min-width: 0;
}

.field {
  color: #344054;
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 5px;
}

.checkbox-field {
  align-content: end;
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 64px;
}

.compact-input {
  max-width: 86px;
}

.color-input {
  height: 44px;
  max-width: 72px;
  min-width: 64px;
  padding: 4px;
  width: 72px;
}

.check-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.check-pill {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-flex;
  gap: 6px;
  padding: 7px 9px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.skins-player-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}

.skins-player-row {
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(90px, 130px);
  padding: 8px;
}

.code-link {
  color: var(--green);
  display: inline-block;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.advanced-json .editor {
  margin-top: 10px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 720px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f2f4f7;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

td.number,
th.number {
  text-align: right;
}

.score-input {
  max-width: 54px;
  min-height: 36px;
  padding: 6px;
  text-align: center;
}

.leaderboard-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.leaderboard-entry {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: 34px 1fr auto auto;
  padding: 8px 0;
}

.tournament-page {
  display: grid;
  gap: 14px;
  margin-left: auto;
  margin-right: auto;
  max-width: 760px;
  overflow: hidden;
  position: relative;
}

.tournament-header {
  align-items: start;
  position: relative;
}

.tournament-title-row {
  align-items: start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.tournament-header-actions {
  align-items: start;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.tournament-header h1 {
  color: var(--green-2);
  flex: 1 1 auto;
  font-family: var(--title-font);
  font-size: clamp(34px, 7vw, 56px);
  letter-spacing: 0.01em;
  line-height: 1.02;
  margin-bottom: 8px;
  min-width: 0;
}

.group-unlock {
  background: rgba(255, 252, 241, 0.72);
  border: 1px solid #d3c5a4;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px;
}

.group-options {
  justify-self: end;
  position: relative;
}

.group-menu-button {
  background: rgba(255, 252, 241, 0.9);
  border-color: #2b5b3d;
  color: var(--green);
  font-size: 20px;
  line-height: 1;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
}

.group-options-menu {
  background: var(--paper);
  border: 1px solid #bcae8d;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(56, 43, 24, 0.18);
  min-width: 160px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
}

.group-options-item {
  background: transparent;
  border-color: transparent;
  color: var(--ink);
  justify-content: start;
  min-height: 40px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.group-options-item:hover {
  background: rgba(198, 154, 60, 0.13);
}

.mobile-nav {
  background: #d9bf82;
  border: 1px solid #ad8950;
  border-radius: 8px 8px 4px 4px;
  display: grid;
  gap: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  padding: 5px 5px 0;
}

.mobile-nav-button {
  background: #ead6aa;
  border-color: #b89b62;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  color: #2c2214;
  font-family: var(--title-font);
  font-size: 16px;
  min-width: 0;
  white-space: nowrap;
}

.mobile-nav-button.active {
  background: var(--paper);
  border-color: #9f8450;
  box-shadow: inset 0 -3px var(--red);
  color: var(--ink);
}

.round-strip {
  align-items: stretch;
  background:
    repeating-linear-gradient(0deg, transparent 0 24px, rgba(159, 182, 189, 0.18) 24px 25px),
    rgba(255, 252, 241, 0.72);
  border: 1px solid #c9ba98;
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  padding: 6px;
}

.round-chip {
  background: #efe0ba;
  border: 1px solid #ad8950;
  border-radius: 6px;
  box-shadow: inset 0 -2px rgba(132, 102, 54, 0.12);
  color: #2c2214;
  display: grid;
  font-family: var(--title-font);
  gap: 1px;
  justify-items: center;
  min-height: 48px;
  padding: 7px 8px;
}

.round-chip.active {
  background: var(--paper);
  box-shadow: inset 0 -3px var(--red);
  color: var(--ink);
}

.round-chip small {
  color: #6f6657;
  font-family: var(--body-font);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.round-chip.final small {
  color: #8d6d2d;
}

.round-chip.open small {
  color: var(--green);
}

.view-heading,
.mobile-card-heading {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.view-heading h2,
.mobile-card h3 {
  color: var(--green-2);
  font-family: var(--title-font);
  margin: 0;
}

.view-heading > div,
.mobile-card-heading > div,
.leaderboard-game-card > div {
  min-width: 0;
}

.view-heading .muted {
  overflow-wrap: anywhere;
}

.mobile-list,
.scorecard-view {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}

.mobile-card {
  background:
    linear-gradient(90deg, rgba(168, 137, 82, 0.08) 28px, transparent 28px 29px),
    repeating-linear-gradient(0deg, transparent 0 34px, rgba(159, 182, 189, 0.2) 34px 35px),
    rgba(255, 252, 241, 0.9);
  border: 1px solid #c9ba98;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(56, 43, 24, 0.08);
  min-width: 0;
  padding: 14px;
}

.leaderboard-card {
  display: grid;
  gap: 8px;
}

.leaderboard-game-card {
  align-items: center;
  color: inherit;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 112px;
  text-align: left;
  width: 100%;
}

.leaderboard-game-card h3,
.leaderboard-game-card p {
  margin: 0;
}

.leaderboard-game-meta {
  align-items: center;
  color: var(--muted);
  display: grid;
  gap: 2px;
  justify-items: end;
}

.leaderboard-game-meta strong {
  color: var(--red);
  font-family: var(--score-font);
  font-size: 25px;
  font-weight: 400;
  line-height: 1.25;
  text-align: right;
}

.leaderboard-table {
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
  width: 100%;
}

.leaderboard-table th,
.leaderboard-table td {
  border-bottom: 1px solid rgba(159, 182, 189, 0.62);
  padding: 12px 6px;
  text-align: left;
}

.leaderboard-table th {
  background: rgba(234, 214, 170, 0.58);
  color: #2e3b33;
  font-size: 13px;
  font-weight: 800;
}

.leaderboard-table th:nth-child(1),
.leaderboard-table td:nth-child(1),
.leaderboard-table th:nth-child(4),
.leaderboard-table td:nth-child(4) {
  width: 48px;
}

.leaderboard-table th:nth-child(3),
.leaderboard-table td:nth-child(3) {
  width: 62px;
}

.leaderboard-table th:nth-child(1),
.leaderboard-table td:nth-child(1),
.leaderboard-table th:nth-child(3),
.leaderboard-table td:nth-child(3),
.leaderboard-table th:nth-child(4),
.leaderboard-table td:nth-child(4) {
  text-align: center;
  white-space: nowrap;
}

.leaderboard-table tr:last-child td {
  border-bottom: 0;
}

.leaderboard-table.individual-breakdown-table {
  table-layout: auto;
}

.individual-breakdown-table th,
.individual-breakdown-table td {
  padding: 10px 4px;
}

.individual-breakdown-table th:nth-child(n),
.individual-breakdown-table td:nth-child(n) {
  text-align: left;
  width: auto;
}

.individual-breakdown-table th:first-child,
.individual-breakdown-table td:first-child {
  text-align: center;
  width: 36px;
}

.individual-breakdown-table th:nth-child(2),
.individual-breakdown-table td:nth-child(2) {
  width: 34%;
}

.individual-breakdown-table th:nth-child(n+3),
.individual-breakdown-table td:nth-child(n+3) {
  text-align: center;
  white-space: nowrap;
  width: 52px;
}

.individual-breakdown-table .leaderboard-entry-button {
  font-size: 22px;
}

.leaderboard-rank {
  color: var(--green-2);
  font-family: var(--score-font);
  font-size: 22px;
  font-weight: 400;
}

.leaderboard-entry-button {
  background: transparent;
  border-color: transparent;
  color: var(--green);
  font-family: var(--score-font);
  font-size: 25px;
  font-weight: 400;
  line-height: 1.1;
  max-width: 100%;
  min-height: 38px;
  overflow: hidden;
  padding: 4px 0;
  text-align: left;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
}

.leaderboard-entry-button:hover {
  text-decoration: underline;
}

.leaderboard-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
  min-height: 58px;
  padding: 10px 0 0;
}

.rank,
.score-pill {
  align-items: center;
  background: rgba(255, 248, 226, 0.92);
  border: 1px solid rgba(198, 154, 60, 0.5);
  border-radius: 999px;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 34px;
  min-width: 34px;
  padding: 4px 8px;
}

.score-pill {
  background: #fff6dc;
  color: #775000;
}

.readonly-scorecard-modal {
  background:
    linear-gradient(90deg, rgba(168, 137, 82, 0.08) 34px, transparent 34px 35px),
    repeating-linear-gradient(0deg, transparent 0 33px, rgba(159, 182, 189, 0.2) 33px 34px),
    var(--paper);
  border: 1px solid #bcae8d;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(36, 28, 17, 0.3);
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px;
  width: min(960px, calc(100vw - 24px));
}

.readonly-scorecard-modal h2 {
  margin: 0;
}

.compact-action {
  min-height: 34px;
  padding: 6px 9px;
}

.group-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: end;
}

.scorecard-toolbar {
  align-items: center;
  background: rgba(255, 252, 241, 0.66);
  border: 1px solid #d3c5a4;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.scorecard-toolbar h2 {
  color: var(--green-2);
  font-family: var(--title-font);
  margin: 0;
}

.scorecard-readonly-note {
  background:
    linear-gradient(90deg, rgba(198, 154, 60, 0.12), transparent 46%),
    rgba(255, 252, 241, 0.72);
  border: 1px solid #d3c5a4;
  border-radius: 8px;
  color: #5f5a4d;
  font-weight: 650;
  margin: 0;
  padding: 10px 12px;
}

.golf-scorecard-wrap {
  background: var(--paper);
  border: 1px solid #bcae8d;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 252, 241, 0.56);
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.scorecard-legend {
  align-items: center;
  color: #5f5a4d;
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 650;
  gap: 8px 14px;
  padding: 0 4px;
}

.scorecard-legend-item {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}

.scorecard-legend-mark {
  color: #8d6d2d;
  font-weight: 850;
  line-height: 1;
}

.scorecard-legend-swatch {
  border: 1px solid rgba(179, 39, 43, 0.24);
  border-radius: 2px;
  display: inline-block;
  height: 13px;
  width: 18px;
}

.scorecard-legend-red-ball {
  background: rgba(179, 39, 43, 0.11);
}

.golf-scorecard {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 900px;
  width: 100%;
}

.golf-scorecard th,
.golf-scorecard td {
  border-bottom: 1px solid rgba(159, 182, 189, 0.64);
  border-right: 1px solid rgba(159, 182, 189, 0.64);
  height: 42px;
  min-width: 42px;
  padding: 6px 7px;
  text-align: center;
}

.golf-scorecard .scorecard-plus-col {
  background: #f1e0b9;
  border-left: 2px solid #9f8450;
  border-right: 0;
  min-width: 58px;
  position: sticky;
  right: 0;
  text-align: center;
  width: 58px;
  z-index: 3;
}

.golf-scorecard .scorecard-name-col {
  background: rgba(255, 252, 241, 0.96);
  left: 0;
  max-width: 92px;
  min-width: 72px;
  overflow: hidden;
  padding-left: 10px;
  padding-right: 10px;
  position: sticky;
  text-align: left;
  white-space: nowrap;
  width: 72px;
  z-index: 2;
}

.golf-scorecard thead th {
  background: rgba(30, 79, 52, 0.1);
  color: #23352a;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.golf-scorecard thead .scorecard-plus-col {
  background: #e8d09a;
  z-index: 5;
}

.golf-scorecard thead .scorecard-name-col {
  z-index: 4;
}

.golf-scorecard tbody .scorecard-name-col {
  color: #243226;
  font-weight: 800;
}

.golf-scorecard tbody .scorecard-name-col > span {
  display: block;
  font-family: var(--score-font);
  font-size: 17px;
  font-weight: 400;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.golf-scorecard tbody .scorecard-name-col small {
  color: var(--muted);
  display: block;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
}

.golf-scorecard tbody .scorecard-plus-col {
  color: var(--green);
  font-family: var(--score-font);
  font-size: 16px;
  font-weight: 400;
}

.scorecard-player-score-cell {
  position: relative;
}

.golf-scorecard td.scorecard-red-ball {
  background: rgba(179, 39, 43, 0.11);
}

.scorecard-score {
  align-items: center;
  display: inline-flex;
  font-family: var(--score-font);
  font-size: 17px;
  font-weight: 400;
  justify-content: center;
  line-height: 1;
  min-height: 26px;
  min-width: 26px;
  position: relative;
  z-index: 1;
}

.scorecard-has-strokes .scorecard-score {
  transform: translateX(-3px);
}

.scorecard-score::before,
.scorecard-score::after {
  content: "";
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-6deg);
}

.scorecard-strokes {
  color: #8d6d2d;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  position: absolute;
  right: 4px;
  top: 3px;
  z-index: 4;
}

.scorecard-mark-circle .scorecard-score::before,
.scorecard-mark-double-circle .scorecard-score::before,
.scorecard-mark-double-circle .scorecard-score::after {
  border: 2px solid var(--red);
  border-radius: 999px;
  height: 29px;
  transform: translate(-50%, -50%);
  width: 29px;
}

.scorecard-mark-double-circle .scorecard-score::after {
  height: 34px;
  width: 34px;
}

.scorecard-mark-square .scorecard-score::before {
  border: 2px solid var(--blue);
  border-radius: 2px;
  height: 24px;
  transform: translate(-50%, -50%);
  width: 24px;
}

.scorecard-mark-over .scorecard-score::before {
  transform: translate(-50%, -50%);
}

.scorecard-over-marker {
  bottom: 2px;
  color: var(--blue);
  font-size: 9px;
  font-weight: 850;
  line-height: 1;
  position: absolute;
  right: 4px;
  z-index: 3;
}

.golf-scorecard tr:last-child th,
.golf-scorecard tr:last-child td {
  border-bottom: 0;
}

.scorecard-meta-row th,
.scorecard-meta-row td {
  background: rgba(255, 252, 241, 0.58);
  color: #344034;
  font-size: 13px;
  font-weight: 750;
}

.scorecard-summary-cell {
  background: rgba(234, 214, 170, 0.52);
  font-weight: 850;
}

.modal-backdrop {
  align-items: end;
  background: rgba(19, 26, 19, 0.64);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 20;
}

.score-entry-modal,
.confirm-modal {
  background:
    linear-gradient(rgba(159, 182, 189, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(159, 182, 189, 0.22) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  border: 1px solid #bcae8d;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(36, 28, 17, 0.34);
  display: grid;
  gap: 18px;
  max-width: 440px;
  padding: 18px;
  width: min(100%, 440px);
}

.score-entry-modal h2,
.score-entry-modal p,
.confirm-modal h2,
.confirm-modal p {
  margin: 0;
}

.score-entry-modal h2 {
  font-family: var(--score-font);
  font-size: 42px;
  font-weight: 400;
  line-height: 1;
}

.confirm-modal {
  align-content: start;
}

.confirm-modal h2 {
  color: var(--green-2);
  font-family: var(--title-font);
  font-size: 32px;
}

.exit-code-display {
  background: rgba(255, 252, 241, 0.84);
  border: 1px solid #bcae8d;
  border-radius: 6px;
  color: var(--green-2);
  font-family: var(--score-font);
  font-size: 34px;
  font-weight: 400;
  letter-spacing: 0.16em;
  padding: 10px 12px;
  text-align: center;
}

.modal-topline,
.score-entry-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.modal-topline {
  color: #5f563f;
  font-weight: 700;
}

.icon-button {
  align-items: center;
  background: rgba(255, 252, 241, 0.9);
  border-color: #bcae8d;
  color: var(--ink);
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 36px;
  min-width: 36px;
  padding: 0;
}

.score-entry-input-row {
  display: grid;
  gap: 14px;
  grid-template-columns: 74px minmax(0, 1fr) 74px;
  align-items: center;
}

.score-step {
  background: #efe3c7;
  border-color: #9f8450;
  box-shadow: 0 4px 0 #cab98d;
  color: #211a12;
  font-size: 34px;
  font-weight: 800;
  min-height: 74px;
  padding: 0;
}

.score-entry-input {
  background: transparent;
  border: 0;
  color: #1f211d;
  font-family: var(--score-font);
  font-size: 76px;
  font-weight: 400;
  line-height: 1;
  min-height: 86px;
  padding: 6px;
  text-align: center;
}

.score-entry-actions button {
  flex: 1;
  min-height: 48px;
}

.group-card {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  padding: 0;
}

.group-accordion-trigger {
  align-items: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: inherit;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  min-height: 74px;
  padding: 14px;
  text-align: left;
  width: 100%;
}

.group-accordion-trigger:hover {
  background: rgba(198, 154, 60, 0.1);
}

.group-accordion-trigger strong {
  color: var(--green-2);
  display: block;
  font-family: var(--title-font);
  font-size: 22px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-accordion-trigger small {
  color: var(--muted);
  display: block;
  font-weight: 700;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-accordion-meta {
  color: var(--muted);
  font-weight: 850;
  white-space: nowrap;
}

.group-accordion-icon {
  align-items: center;
  border: 1px solid #9f8450;
  border-radius: 999px;
  color: var(--green);
  display: inline-flex;
  font-size: 18px;
  font-weight: 850;
  height: 28px;
  justify-content: center;
  line-height: 1;
  width: 28px;
}

.group-accordion-panel {
  border-top: 1px solid rgba(159, 182, 189, 0.46);
  min-width: 0;
  padding: 0 12px 12px;
}

.read-score-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.read-score-chip {
  background: rgba(255, 252, 241, 0.78);
  border: 1px solid rgba(159, 182, 189, 0.64);
  border-radius: 6px;
  display: grid;
  gap: 2px;
  min-height: 46px;
  padding: 5px;
  text-align: center;
}

.read-score-chip span {
  color: var(--muted);
  font-size: 12px;
}

.editor {
  min-height: 560px;
  width: 100%;
}

#adminPage {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

#adminPage.band {
  background: #fff;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(21, 35, 50, 0.08);
}

#adminPage .admin-section,
#adminPage .admin-subsection {
  background: #fff;
}

#adminPage input,
#adminPage select,
#adminPage textarea {
  background: #fff;
  border-color: #d9dee7;
  border-radius: 6px;
  max-width: 100%;
  width: 100%;
}

#adminPage button {
  background: #245b42;
  border-color: #245b42;
  box-shadow: none;
  color: #fff;
}

#adminPage button.secondary {
  background: #fff;
  border-color: #245b42;
  color: #245b42;
}

#adminPage button.danger {
  background: var(--red);
  border-color: var(--red);
}

#adminPage input[type="checkbox"],
#adminPage input[type="color"] {
  width: auto;
}

#adminPage td input,
#adminPage td select {
  min-width: 0;
}

#adminPage td input.color-input {
  cursor: pointer;
  min-width: 72px;
  width: 72px;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

.color-input::-moz-color-swatch {
  border: 0;
  border-radius: 4px;
}

.toast {
  background: #1b1f24;
  border-radius: 8px;
  bottom: 18px;
  color: #fff;
  left: 50%;
  max-width: calc(100vw - 28px);
  padding: 12px 14px;
  position: fixed;
  transform: translateX(-50%);
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 12px;
  }

  .app-shell {
    padding: 16px 12px 36px;
  }

  .hero {
    min-height: 260px;
    padding: 20px;
  }

  .hero form,
  .hero input,
  .hero button {
    width: 100%;
  }

  .tournament-page {
    border-radius: 0;
    margin-left: -12px;
    margin-right: -12px;
    padding: 14px 12px;
  }

  .group-unlock {
    grid-template-columns: 1fr;
  }

  .view-heading,
  .mobile-card-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .view-heading button {
    width: 100%;
  }

  .leaderboard-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
  }

  .leaderboard-row .compact-action,
  .leaderboard-row .group-choice {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .leaderboard-row .group-choice button {
    flex: 1 1 130px;
  }

  .leaderboard-game-card {
    align-items: stretch;
    flex-direction: column;
  }

  .leaderboard-game-meta {
    grid-auto-flow: column;
    justify-content: space-between;
    justify-items: start;
  }

  .scorecard-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .scorecard-toolbar button {
    width: 100%;
  }

  .golf-scorecard {
    min-width: 820px;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .score-entry-modal {
    max-width: none;
    padding: 16px;
  }

  .readonly-scorecard-modal {
    max-height: calc(100vh - 20px);
    padding: 12px;
    width: calc(100vw - 20px);
  }

  .score-entry-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .score-entry-actions button {
    width: 100%;
  }

  .read-score-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-login {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .topbar {
    padding: 0 10px;
  }

  .brand {
    flex: 0 0 auto;
    font-size: 16px;
    white-space: nowrap;
  }

  .topbar nav {
    gap: 4px;
  }

  .topbar nav a {
    font-size: 13px;
    padding: 6px 5px;
  }

  .topbar nav a[href="/"] {
    display: none;
  }

  .mobile-nav-button {
    font-size: 12px;
    min-width: 0;
    padding-left: 3px;
    padding-right: 3px;
  }

  .score-entry-input-row {
    gap: 8px;
    grid-template-columns: 58px minmax(78px, 1fr) 58px;
  }

  .score-step {
    font-size: 28px;
    min-height: 58px;
  }

  .score-entry-input {
    font-size: 62px;
    min-height: 74px;
    padding: 2px;
  }
}
