:root {
  --green: #0A6E3C;
  --green-deep: #06422A;
  --ink: #03291A;
  --royal: #2350C8;
  --royal-light: #6E9BFF;
  --white: #FFFFFF;
  --mist: rgba(255, 255, 255, 0.78);
  --faint: rgba(255, 255, 255, 0.14);
  --board: #0B0F0E;
  --led: #4DFF8A;
  --amber: #FFB21E;
  --red: #E5383B;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--green-deep);
  color: var(--white);
  font-family: var(--body);
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#safe-probe {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

button { font: inherit; color: inherit; }

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

/* ---- Screens ---- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top, 0px) + 22px) 16px calc(env(safe-area-inset-bottom, 0px) + 28px);
}

.screen.is-active { display: block; }

body.is-racing .screen { display: none; }

.wrap {
  max-width: 460px;
  margin: 0 auto;
}

/* Poolside tiles in club green */
.screen--title {
  background-color: var(--green);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.075) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -1px -1px;
}

.screen--plain { background: var(--green-deep); }

.club {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.club__anchor { width: 22px; height: 22px; }

/* The wordmark sits on a pool-floor lane line, T and all */
.wordmark {
  position: relative;
  margin: 0;
  padding-left: 30px;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(64px, 25vw, 132px);
  line-height: 0.8;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.wordmark span { display: block; }

.wordmark::before,
.wordmark::after {
  content: "";
  position: absolute;
  background: var(--royal);
}

.wordmark::before { left: 6px; top: 4px; bottom: 2px; width: 12px; }
.wordmark::after { left: -4px; bottom: 2px; width: 32px; height: 12px; }

.event-line {
  margin: 14px 0 22px 30px;
  font-weight: 600;
  font-size: 18px;
  color: var(--mist);
}

.panel {
  background: rgba(3, 41, 26, 0.38);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 22px;
}

.label {
  display: block;
  margin: 0 0 8px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mist);
}

.label--section { margin-top: 4px; }

.panel .label + .kit-row,
.panel .error + .label,
.panel .input + .label { margin-top: 16px; }

.input {
  width: 100%;
  height: 54px;
  padding: 0 14px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.input::placeholder { color: rgba(3, 41, 26, 0.35); }
.input:focus { outline: none; border-color: var(--royal); }

.error {
  margin: 8px 0 0;
  color: #FFD2D2;
  font-weight: 600;
  font-size: 15px;
}

.kit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
}

.segmented button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] { background: var(--white); color: var(--ink); }

.skins { display: flex; gap: 8px; }

.skins button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25) inset;
  cursor: pointer;
}

.skins button[aria-pressed="true"] { border-color: var(--white); }

/* Meets read like a heat sheet, with a lane line marking your choice */
.meets {
  display: grid;
  gap: 6px;
  margin-bottom: 22px;
}

.meet {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 12px;
  width: 100%;
  min-height: 60px;
  padding: 10px 14px 10px 12px;
  border: 0;
  border-left: 6px solid transparent;
  border-radius: 4px 12px 12px 4px;
  background: rgba(3, 41, 26, 0.38);
  text-align: left;
  cursor: pointer;
}

.meet[aria-pressed="true"] {
  border-left-color: var(--royal);
  background: rgba(255, 255, 255, 0.16);
}

.meet:disabled { cursor: not-allowed; opacity: 0.55; }

.meet__name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 24px;
  line-height: 1;
  text-transform: uppercase;
}

.meet__where {
  grid-column: 1;
  font-size: 15px;
  color: var(--mist);
}

.meet__qt {
  grid-row: 1 / span 2;
  grid-column: 2;
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--mist);
}

.meet__qt b { display: block; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }

/* ---- Buttons ---- */

.btn {
  display: block;
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 12px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn--primary { background: var(--white); color: var(--green-deep); }
.btn--primary:disabled { background: rgba(255, 255, 255, 0.35); color: rgba(3, 41, 26, 0.6); cursor: wait; }
.btn--ghost { background: transparent; color: var(--white); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55) inset; font-size: 20px; min-height: 50px; }
.btn + .btn { margin-top: 10px; }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.pb-line {
  margin: 18px 0 0;
  text-align: center;
  font-weight: 600;
  color: var(--mist);
  font-variant-numeric: tabular-nums;
}

.pb-line strong { color: var(--white); font-family: var(--display); font-size: 24px; font-weight: 800; }

/* ---- How to race ---- */

.screen-title {
  margin: 0 0 18px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 54px;
  line-height: 0.9;
  text-transform: uppercase;
}

.steps {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 12px 0 12px 46px;
  border-top: 1px solid var(--faint);
  line-height: 1.35;
  color: var(--mist);
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 12px;
  width: 32px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 30px;
  line-height: 1;
  color: var(--led);
}

.steps strong {
  display: block;
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  text-transform: uppercase;
  color: var(--white);
}

.keys { color: var(--mist); font-size: 15px; margin: 0 0 18px; }

kbd {
  display: inline-block;
  min-width: 26px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.16);
  font-family: var(--body);
  font-weight: 700;
  text-align: center;
}

/* ---- Marshalling card ---- */

.eyebrow {
  margin: 0 0 10px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--led);
}

.card {
  background: #FBFCF8;
  color: var(--ink);
  border-radius: 6px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card__head {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green);
}

.card__race {
  margin: 6px 0 12px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 40px;
  line-height: 0.95;
  text-transform: uppercase;
}

.card__grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  margin-bottom: 12px;
}

.card__grid div { padding: 8px 0; }
.card__grid div + div { padding-left: 12px; border-left: 1px solid rgba(3, 41, 26, 0.25); }
.card__grid span { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(3, 41, 26, 0.6); }
.card__grid strong { font-family: var(--display); font-weight: 900; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }

.sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.sheet th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(3, 41, 26, 0.6);
  padding: 4px 0;
}

.sheet td { padding: 5px 0; border-top: 1px solid rgba(3, 41, 26, 0.12); }
.sheet td:first-child, .sheet th:first-child { width: 48px; }
.sheet td:last-child, .sheet th:last-child { text-align: right; }
.sheet tr.is-you td { font-weight: 700; color: var(--green); }

.queue { margin: 20px 0 16px; }

.queue__bar {
  height: 6px;
  border-radius: 3px;
  background: var(--faint);
  overflow: hidden;
}

.queue__bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--led);
}

.queue__status {
  margin: 10px 0 0;
  font-weight: 600;
  font-size: 18px;
}

/* ---- Results ---- */

.board {
  padding: 8px;
  border-radius: 6px;
  background: #1D2422;
  box-shadow: 0 0 0 1px #000 inset, 0 12px 30px rgba(0, 0, 0, 0.35);
}

#scoreboard { display: block; width: 100%; }

.banner {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--led);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 900;
  font-size: 24px;
  line-height: 1.05;
  text-transform: uppercase;
}

.banner small {
  display: block;
  font-family: var(--body);
  font-weight: 600;
  font-size: 15px;
  text-transform: none;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 16px 0;
  background: var(--faint);
  border-radius: 12px;
  overflow: hidden;
}

.stats div { padding: 10px 12px; background: var(--green-deep); }
.stats dt { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mist); }
.stats dd { margin: 2px 0 0; font-family: var(--display); font-weight: 800; font-size: 26px; font-variant-numeric: tabular-nums; }

.tip {
  margin: 0 0 18px;
  padding: 12px 14px 12px 16px;
  border-left: 6px solid var(--royal);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 2px 10px 10px 2px;
}

.tip p { margin: 0; font-size: 18px; line-height: 1.35; }

/* ---- In-race quit button ---- */

.quit {
  position: fixed;
  z-index: 5;
  top: calc(env(safe-area-inset-top, 0px) + 4px);
  right: 6px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  font-size: 26px;
  line-height: 1;
  display: none;
  cursor: pointer;
}

body.is-racing .quit { display: block; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---- Accounts ---- */

.row .btn + .btn { margin-top: 0; }
.row--tight { margin-top: 12px; }

.btn--small { min-height: 48px; font-size: 22px; }
.btn--inline { display: inline-block; width: auto; padding: 0 18px; }

.account {
  margin-bottom: 16px;
  padding: 14px 16px 16px;
  border-left: 6px solid var(--royal);
  border-radius: 4px 14px 14px 4px;
  background: rgba(3, 41, 26, 0.38);
}

.account__lead {
  margin: 0;
  color: var(--mist);
  line-height: 1.35;
}

.account__lead strong {
  display: block;
  margin-bottom: 2px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 26px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--white);
}

.account__who .label { margin-bottom: 2px; }

.account__who strong {
  display: block;
  font-family: var(--display);
  font-weight: 800;
  font-size: 26px;
  line-height: 1.05;
  text-transform: uppercase;
}

.account__meta { display: block; font-size: 15px; color: var(--mist); font-variant-numeric: tabular-nums; }

.intro {
  margin: 0 0 20px;
  font-size: 18px;
  line-height: 1.4;
  color: var(--mist);
}

.form .field { margin-bottom: 16px; }

.form label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 16px;
}

.optional { font-weight: 500; color: var(--mist); }

.input.input--form {
  height: 52px;
  font-family: var(--body);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0;
  text-transform: none;
}

.input[aria-invalid="true"] { border-color: var(--red); }

.field__hint { margin: 6px 0 0; font-size: 14px; color: var(--mist); }

.field__error { margin: 6px 0 0; font-weight: 600; font-size: 15px; color: #FFD2D2; }

.password { position: relative; }
.password .input { padding-right: 76px; }

.password__show {
  position: absolute;
  top: 6px;
  right: 6px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(3, 41, 26, 0.08);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

.form__error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 6px solid var(--red);
  border-radius: 2px 10px 10px 2px;
  background: rgba(229, 56, 59, 0.18);
  font-weight: 600;
  line-height: 1.35;
}

.switch { margin: 16px 0; text-align: center; color: var(--mist); }

.link {
  min-height: 44px;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--white);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.saved { margin: 12px 0 0; font-weight: 600; color: var(--mist); }
.saved.is-ok { color: var(--led); }

/* ---- Leaderboards ---- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.account__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
}

.tabs button {
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-family: var(--display);
  font-weight: 800;
  font-size: 19px;
  text-transform: uppercase;
  cursor: pointer;
}

.tabs button[aria-selected="true"] { background: var(--white); color: var(--green-deep); }

/* The board reads like the poolside scoreboard: amber on black, you in green */
.lb {
  min-height: 180px;
  margin-bottom: 18px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--board);
  box-shadow: 0 0 0 8px #1D2422, 0 12px 30px rgba(0, 0, 0, 0.35);
  margin-top: 8px;
}

.lb__table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--display);
  font-weight: 800;
  font-size: 24px;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255, 178, 30, 0.45);
}

.lb__table td { padding: 7px 0; border-top: 1px solid #1B2421; }
.lb__table tr:first-child td { border-top: 0; }
.lb__place { width: 40px; }
.lb__time { text-align: right; }

.lb__table .is-me { color: var(--led); text-shadow: 0 0 10px rgba(77, 255, 138, 0.55); }

.lb__you {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--led);
  color: var(--board);
  font-size: 14px;
  vertical-align: 3px;
  text-shadow: none;
}

.lb__gap td { padding: 0; color: #4A5551; text-align: center; letter-spacing: 0.3em; text-shadow: none; }

.lb__status {
  margin: 0;
  padding: 18px 4px;
  color: var(--mist);
  font-size: 17px;
  line-height: 1.4;
}

.lb__status:empty { display: none; }

.toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  cursor: pointer;
}

.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.toggle__track {
  position: relative;
  width: 52px;
  height: 32px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.15s;
}

.toggle__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--white);
  transition: transform 0.15s;
}

.toggle input:checked + .toggle__track { background: var(--led); }
.toggle input:checked + .toggle__track::after { transform: translateX(20px); }
.toggle input:focus-visible + .toggle__track { outline: 3px solid var(--royal-light); outline-offset: 3px; }

.toggle__text { font-size: 15px; line-height: 1.35; color: var(--mist); }
.toggle__text strong { display: block; font-size: 17px; color: var(--white); }
