/* Minigolf — the page around the hole. The hole is a canvas (render.js);
   the HUD, the face-to-face seats, the cards and the sheets are DOM on top.
   Light and dark follow the system. */

:root {
  --round: "SF Pro Rounded", ui-rounded, "Nunito", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
  --spring: cubic-bezier(0.25, 0.85, 0.3, 1.15);
  --flip: 0rad;
  --face-rot: 0rad;
  --face-base: 0rad;
  color-scheme: light;
  --bg-a: #eef3e6;
  --bg-b: #cfdcc0;
  --ink: #1d2a1b;
  --ink-soft: #566552;
  --paper: #fffdf7;
  --paper-2: #f0efe4;
  --glass: rgba(255, 253, 245, 0.86);
  --line: rgba(30, 50, 20, 0.13);
  --accent: #2c8a3c;
  --accent-ink: #1f6e2e;
  --accent-soft: rgba(44, 138, 60, 0.22);
  --flagred: #d8452f;
  --btn-bg: rgba(255, 255, 255, 0.66);
  --btn-hover: rgba(255, 255, 255, 0.95);
  --btn-line: rgba(30, 50, 20, 0.15);
  --primary-a: #3aa04b;
  --primary-b: #227a33;
  --primary-line: #1b6229;
  --primary-ink: #ffffff;
  --danger-a: #e0573f;
  --danger-b: #b8381f;
  --backdrop: rgba(18, 28, 14, 0.4);
  --toast: rgba(22, 32, 20, 0.92);
  --scrim-top: rgba(238, 243, 230, 0.9);
  --scrim-bottom: rgba(207, 220, 192, 0.6);
  --card-paper: #fbf6e6;
  --card-line: rgba(120, 90, 40, 0.22);
  --card-ink: #2b2417;
  --ca-accent: #2c8a3c; /* the accounts SDK's sheets and chip */
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-a: #12211f;
    --bg-b: #070d0d;
    --ink: #eaf3e6;
    --ink-soft: rgba(234, 243, 230, 0.66);
    --paper: #16231f;
    --paper-2: #1f302a;
    --glass: rgba(18, 30, 26, 0.86);
    --line: rgba(190, 230, 190, 0.14);
    --accent: #6fd480;
    --accent-ink: #8be39a;
    --accent-soft: rgba(111, 212, 128, 0.22);
    --btn-bg: rgba(255, 255, 255, 0.07);
    --btn-hover: rgba(255, 255, 255, 0.13);
    --btn-line: rgba(190, 230, 190, 0.18);
    --primary-a: #43a956;
    --primary-b: #2a7b39;
    --primary-line: #1f5c2b;
    --backdrop: rgba(0, 4, 2, 0.6);
    --toast: rgba(32, 48, 40, 0.95);
    --scrim-top: rgba(10, 18, 16, 0.88);
    --scrim-bottom: rgba(6, 12, 10, 0.6);
    --card-paper: #2a2619;
    --card-line: rgba(240, 220, 170, 0.18);
    --card-ink: #f3ead2;
    --ca-accent: #6fd480;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  font-family: var(--sans);
  color: var(--ink);
  background: linear-gradient(165deg, var(--bg-a), var(--bg-b)) fixed;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }

/* --------------------------------------------------------------- stage */
.stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ----------------------------------------------------------------- HUD */
.hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.hud-bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(env(safe-area-inset-top) + 6px) calc(env(safe-area-inset-right) + 8px) 4px calc(env(safe-area-inset-left) + 8px);
  pointer-events: none;
}
.hud-bar > * { pointer-events: auto; }
.icon-btn.glassy {
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px -8px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.hole-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  padding: 5px 14px;
  margin: 0 auto;
  max-width: 340px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px -8px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.hole-info b { font: 700 15px var(--round); letter-spacing: 0.01em; white-space: nowrap; }
.hole-info span { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.players {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 8px);
  max-width: 100%;
  pointer-events: auto;
}
.pchip {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 6px 10px 6px 7px;
  border-radius: 999px;
  background: var(--glass);
  border: 1.5px solid var(--line);
  box-shadow: 0 4px 14px -8px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s var(--spring), opacity 0.3s;
  opacity: 0.78;
}
.pchip .pt { display: flex; flex-direction: column; line-height: 1.12; min-width: 0; }
.pchip b { font: 700 13.5px var(--round); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9em; }
.pchip small { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pchip.active {
  opacity: 1;
  border-color: var(--pc);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--pc) 35%, transparent), 0 6px 18px -6px color-mix(in oklab, var(--pc) 70%, black);
  transform: translateY(-2px) scale(1.04);
}
@media (max-width: 420px) {
  .pchip { padding: 5px 8px 5px 6px; gap: 5px; }
  .pchip b { font-size: 12.5px; max-width: 5.5em; }
  .pchip small { font-size: 10.5px; }
  .players { gap: 4px; padding-left: 4px; padding-right: 4px; }
}
/* landscape: the players line up on the left, the bar keeps to the top */
.hud.land .players {
  left: 0;
  top: 56px;
  bottom: auto;
  transform: none;
  flex-direction: column;
  padding: 4px 6px 4px calc(env(safe-area-inset-left) + 8px);
  width: min(160px, 24vw);
}
.hud.land .pchip { border-radius: 16px; }
.hud.land .pchip.active { transform: translateX(3px) scale(1.03); }
.hud.land .hole-info { max-width: 300px; }

/* the ball of each player: a colour and a mark of its own */
.emblem {
  --c: #e4513c;
  position: relative;
  flex: 0 0 auto;
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 42%), radial-gradient(circle at 60% 65%, var(--c), color-mix(in oklab, var(--c) 70%, black) 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 -1px 2px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.emblem::after { content: ""; position: absolute; inset: 0; border-radius: 50%; }
.emblem.e0 { --c: #e4513c; }
.emblem.e0::after { background: linear-gradient(transparent 41%, rgba(255, 255, 255, 0.95) 41% 59%, transparent 59%); }
.emblem.e1 { --c: #2f86e0; }
.emblem.e1::after { background: radial-gradient(circle at 50% 18%, #fff 0 17%, transparent 18%), radial-gradient(circle at 50% 82%, #fff 0 17%, transparent 18%); }
.emblem.e2 { --c: #f0b429; }
.emblem.e2::after { background: radial-gradient(circle at 26% 50%, #fff 0 12%, transparent 13%), radial-gradient(circle at 74% 50%, #fff 0 12%, transparent 13%), radial-gradient(circle at 50% 24%, #fff 0 12%, transparent 13%), radial-gradient(circle at 50% 76%, #fff 0 12%, transparent 13%); }
.emblem.e3 { --c: #8f5bd6; }
.emblem.e3::after { background: linear-gradient(transparent 43%, rgba(255, 255, 255, 0.95) 43% 57%, transparent 57%), linear-gradient(90deg, transparent 43%, rgba(255, 255, 255, 0.95) 43% 57%, transparent 57%); }
.emblem.large { width: 64px; height: 64px; }

/* -------------------------------------------- face to face: the seats */
.seats { position: fixed; left: 0; top: 0; width: 100vw; height: 100dvh; z-index: 3; pointer-events: none; }
.seats.turned { left: 50%; top: 50%; width: 100dvh; height: 100vw; transform: translate(-50%, -50%) rotate(90deg); }
.seat {
  position: absolute;
  left: 50%;
  width: min(100% - 16px, 520px);
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 12px;
  border-radius: 20px;
  background: var(--glass);
  border: 1.5px solid var(--line);
  box-shadow: 0 6px 20px -10px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  transition: border-color 0.35s, box-shadow 0.35s, opacity 0.35s;
  opacity: 0.8;
}
.seat.near { bottom: calc(env(safe-area-inset-bottom) + 6px); transform: translateX(-50%); }
.seat.far { top: calc(env(safe-area-inset-top) + 6px); transform: translateX(-50%) rotate(180deg); }
.seats.turned .seat.near { bottom: 6px; }
.seats.turned .seat.far { top: 6px; }
.seat.active { opacity: 1; border-color: var(--pc); box-shadow: 0 0 0 3px color-mix(in oklab, var(--pc) 35%, transparent), 0 8px 24px -8px color-mix(in oklab, var(--pc) 60%, black); }
.seat-who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.seat-who .emblem { width: 26px; height: 26px; }
.seat-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.seat-txt b { font: 700 15px var(--round); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-txt small, .seat-hole small { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-hole { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; min-width: 0; max-width: 11em; }
.seat-hole b { font: 700 13px var(--round); white-space: nowrap; }
.seat-tools { display: flex; gap: 2px; }

/* -------------------------------------------------- cards in the middle */
.upright {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none;
  padding: 16px;
}
body.face .upright { transform: rotate(var(--face-rot)); }
.upright > * { grid-area: 1 / 1; }
.title-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 26px 16px;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  animation: titlein 2.25s var(--ease) both;
}
.title-card small { font: 700 11px var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-ink); }
.title-card b { font: 800 26px/1.1 var(--round); text-align: center; }
.title-card span { font-size: 14px; color: var(--ink-soft); }
@keyframes titlein {
  0% { opacity: 0; transform: translateY(14px) scale(0.94); }
  14% { opacity: 1; transform: none; }
  80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-10px) scale(0.98); }
}
.pop-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: popin 2.25s var(--spring) both;
  transform-origin: 50% 60%;
}
.pop-label b {
  font: 900 40px/1 var(--round);
  color: #fff;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25), 0 6px 22px rgba(0, 0, 0, 0.45);
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.15);
}
.pop-label small { margin-top: 6px; padding: 3px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); color: #fff; font: 700 13px var(--round); }
.pop-label.good b { color: #c8ffb5; }
.pop-label.big b { font-size: 54px; color: #ffe27a; text-shadow: 0 2px 0 #b8741a, 0 0 30px rgba(255, 200, 80, 0.7), 0 8px 26px rgba(0, 0, 0, 0.45); }
@keyframes popin {
  0% { opacity: 0; transform: scale(0.4) translateY(16px); }
  12% { opacity: 1; transform: scale(1.12); }
  22% { transform: scale(1); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translateY(-26px) scale(0.96); }
}
.handover {
  pointer-events: auto;
  width: min(100%, 360px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px 22px 18px;
  border-radius: 26px;
  background: var(--glass);
  border: 1.5px solid color-mix(in oklab, var(--pc) 45%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--pc) 18%, transparent), 0 26px 60px -22px rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  backdrop-filter: blur(16px) saturate(1.1);
  animation: cardin 0.45s var(--spring) both;
}
.handover.out { animation: cardout 0.22s var(--ease) both; }
.handover .big-ball { margin: 2px 0 10px; animation: bob 2.6s ease-in-out infinite; filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.3)); }
.handover h2 { margin: 0; font: 800 24px/1.15 var(--round); }
.handover p { margin: 6px 0 0; font-size: 14px; color: var(--ink-soft); }
.handover .btn { margin-top: 16px; width: 100%; min-height: 52px; font: 700 17px var(--round); flex: none; }
.handover .note { font-size: 12px; margin-top: 10px; }
@keyframes cardin { from { opacity: 0; transform: translateY(24px) scale(0.92); } }
@keyframes cardout { to { opacity: 0; transform: scale(0.96); } }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* ---------------------------------------------------------------- menu */
.menu {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: linear-gradient(180deg, var(--scrim-top) 0, transparent 18%, transparent 36%, var(--scrim-bottom) 100%);
  animation: fade 0.35s var(--ease);
  touch-action: pan-y;
}
@keyframes fade { from { opacity: 0; } }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; max-width: 720px; margin: 0 auto; padding: 10px 10px 4px 16px; flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.brand img { width: 40px; height: 40px; flex: 0 0 auto; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)); }
.brand span { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand b { font: 800 23px var(--round); letter-spacing: 0.01em; white-space: nowrap; }
.brand small { font-size: 11px; color: var(--ink-soft); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.account-chip { display: flex; align-items: center; margin-left: 4px; }
.account-chip:empty { display: none; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.icon-btn:hover { background: var(--btn-bg); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg, .btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.card {
  width: min(100% - 20px, 560px);
  margin: auto auto 12px;
  padding: 14px 14px 10px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
  animation: rise 0.45s var(--ease);
}
.card .label, .opt-row h3 { margin: 0 0 7px 2px; font: 700 11px var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.card .label + * { margin-bottom: 12px; }
.resume { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; margin-bottom: 12px; border-radius: 16px; background: var(--accent-soft); }
.resume span { flex: 1; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.resume b { font: 700 15px var(--round); }
.resume small { font-size: 12.5px; color: var(--ink-soft); }
.resume .btn { flex: 0 0 auto; }

.courses { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.course {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 7px 7px;
  text-align: left;
  border-radius: 18px;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
  min-width: 0;
}
.course .thumb { width: 56px; height: 84px; border-radius: 11px; flex: 0 0 auto; box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.45); }
.course .ctext { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.course b { font: 700 16px/1.15 var(--round); }
.course small { font-size: 12px; color: var(--ink-soft); line-height: 1.25; }
.course small.best { color: var(--accent-ink); font-weight: 600; }
.course:active { transform: scale(0.98); }
.course[aria-checked="true"], .mode[aria-checked="true"] { border-color: var(--accent); background: var(--paper); box-shadow: 0 0 0 3px var(--accent-soft); }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode {
  appearance: none;
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 1px;
  padding: 8px 6px 9px;
  min-height: 64px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
}
.mode svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; color: var(--accent); }
.mode b { font: 700 14.5px var(--round); }
.mode small { font-size: 11.5px; color: var(--ink-soft); line-height: 1.2; }
.mode:active { transform: scale(0.98); }

.opts-grid { display: grid; gap: 8px; margin: 10px 0 2px; }
.opts-grid:not(:has(.opt-row:not([hidden]))) { display: none; }
.opt-row { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; }
.opt-row h3 { margin: 0; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt {
  appearance: none;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font: 600 14px var(--sans);
  padding: 6px 13px;
  min-height: 44px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.opt:active { transform: scale(0.97); }
.opt[aria-checked="true"] { border-color: var(--accent); background: var(--paper); box-shadow: 0 0 0 3px var(--accent-soft); }
.names { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 12px; }
.name-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  border: 1.5px solid color-mix(in oklab, var(--pc) 40%, var(--line));
  background: var(--paper);
  font: 600 14px var(--sans);
  cursor: pointer;
  max-width: 100%;
}
.name-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name-chip .edit { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; opacity: 0.55; }
.name-chip.cpu { cursor: default; opacity: 0.85; }
.hint { margin: 8px 4px 2px; font-size: 12.5px; line-height: 1.4; color: var(--ink-soft); text-align: center; }

.btn {
  appearance: none;
  flex: 1;
  border: 1px solid var(--btn-line);
  background: var(--btn-bg);
  color: var(--ink);
  font: 600 15px var(--sans);
  padding: 10px 14px;
  min-height: 46px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s, filter 0.2s;
}
.btn svg { width: 19px; height: 19px; }
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: scale(0.97); }
.btn.inline { flex: none; }
.btn.primary {
  background: linear-gradient(180deg, var(--primary-a), var(--primary-b));
  color: var(--primary-ink);
  border-color: var(--primary-line);
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.btn.primary.danger { background: linear-gradient(180deg, var(--danger-a), var(--danger-b)); border-color: var(--danger-b); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.play { width: 100%; min-height: 54px; font: 700 18px var(--round); border-radius: 16px; }

@media (max-width: 420px) {
  .top { padding-left: 10px; padding-right: 4px; }
  .brand img { width: 34px; height: 34px; }
  .brand b { font-size: 20px; }
  .brand small { font-size: 10px; letter-spacing: 0.04em; }
  .nav { gap: 0; }
  .opt-row { grid-template-columns: 1fr; gap: 5px; }
  .opts .opt { flex: 1 1 0; padding-left: 8px; padding-right: 8px; }
  .course { flex-direction: column; align-items: stretch; text-align: center; padding: 7px; gap: 6px; }
  .course .thumb { width: 100%; height: 64px; object-fit: cover; }
  .course .ctext { align-items: center; }
}
@media (max-width: 360px) {
  .mode small { display: none; }
  .mode { min-height: 54px; }
}
/* short landscape: the card goes wide */
@media (orientation: landscape) and (max-height: 560px) {
  .top { padding-top: 4px; }
  .brand img { width: 32px; height: 32px; }
  .brand b { font-size: 19px; }
  .card { width: min(100% - 24px, 820px); margin: 4px auto 8px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; padding: 10px 12px 8px; }
  .card > .resume, .card > .btn.play, .card > .hint { grid-column: 1 / -1; }
  .card > .resume { grid-row: 1; }
  .card > .btn.play { grid-column: 1; grid-row: 5; align-self: end; }
  .card > .hint { grid-row: 6; }
  .card > #menu-course, .card > #courses { grid-column: 1; }
  .card > #menu-players, .card > #modes, .card > .opts-grid, .card > .names { grid-column: 2; }
  .card > #menu-course { grid-row: 2; }
  .card > #courses { grid-row: 3 / span 2; align-self: start; }
  .card > #menu-players { grid-row: 2; }
  .card > #modes { grid-row: 3; }
  .card > .opts-grid { grid-row: 4; }
  .card > .names { grid-row: 5; margin: 8px 0; }
  .courses { grid-template-columns: 1fr; }
  .course .thumb { width: 44px; height: 66px; }
  .mode { min-height: 52px; padding: 5px; }
  .mode small { display: none; }
  .opt { min-height: 40px; padding: 4px 12px; }
  .btn.play { min-height: 46px; margin-top: 6px; }
}
@media (orientation: landscape) and (max-height: 420px) {
  .hint, .brand small { display: none; }
}

/* -------------------------------------------------------- sheets, dialogs */
.backdrop { position: fixed; inset: 0; z-index: 20; background: var(--backdrop); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade 0.25s; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  z-index: 21;
  max-width: 560px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.34s var(--ease);
}
.sheet.small { max-width: 420px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 22px; flex: 0 0 auto; min-height: 58px; }
.sheet h2 { font: 800 23px var(--round); margin: 0; letter-spacing: 0.01em; }
.sheet-body {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 20px 24px;
  font-size: 15px;
  line-height: 1.55;
  -webkit-user-select: text;
  user-select: text;
  touch-action: pan-y;
}
.sheet-body h3 { font: 700 16px var(--round); margin: 20px 0 8px; color: var(--ink); }
.sheet-body h3:first-child { margin-top: 6px; }
.panel-body .row, .sheet-body > .row { display: flex; gap: 8px; margin-top: 8px; }
.panel-body .tools { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.panel-body .tools .icon-btn { border: 1px solid var(--btn-line); background: var(--btn-bg); }
.panel-body .confirm { font: 600 16px/1.4 var(--round); text-align: center; margin: 8px 0 14px; }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0; padding-left: 20px; }
.prose li { margin: 5px 0; }
.prose li b { font-weight: 650; }
.about { font-size: 13px; margin-top: 10px; }
.about b { display: block; font-weight: 600; color: var(--ink); }
.note { font-size: 12.5px; color: var(--ink-soft); margin: 14px 0 0; }
@media (min-width: 700px) and (min-height: 560px) {
  .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 24px; max-height: 86dvh; animation: popm 0.3s var(--ease); }
}
@media (orientation: landscape) and (max-height: 560px) {
  .sheet { max-height: 96dvh; }
}
@keyframes popm { from { opacity: 0; transform: translateY(-50%) scale(0.96); } }
/* face to face: a sheet sits in the middle and faces the player it is for */
body.face .sheet {
  --face-extra: 0rad;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  width: min(92vw, 560px);
  max-height: 84dvh;
  border-radius: 24px;
  transform: translate(-50%, -50%) rotate(calc(var(--face-base) + var(--face-extra)));
  animation: fade 0.3s var(--ease);
}
body.face .sheet.facing-far { --face-extra: 3.14159rad; }
body.face.land .sheet { width: min(92dvh, 560px); max-height: 92vw; }

/* --------------------------------------------------------- the scorecard */
.scorecard {
  margin: 2px 0 6px;
  padding: 12px 10px 10px;
  border-radius: 14px;
  background: var(--card-paper);
  color: var(--card-ink);
  box-shadow: inset 0 0 0 1px var(--card-line), 0 10px 24px -14px rgba(60, 40, 10, 0.6);
  background-image: repeating-linear-gradient(0deg, transparent 0 29px, var(--card-line) 29px 30px);
  background-position: 0 6px;
  -webkit-user-select: none;
  user-select: none;
}
.sc-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px 6px; }
.sc-head b { font: 800 17px var(--round); }
.sc-head small { font: 600 12px var(--sans); color: color-mix(in oklab, var(--card-ink) 60%, transparent); }
table.sc { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; table-layout: fixed; }
table.sc th, table.sc td { padding: 4px 3px; text-align: center; border-bottom: 1px solid var(--card-line); white-space: nowrap; }
table.sc th { font: 700 10.5px var(--sans); letter-spacing: 0.04em; text-transform: uppercase; color: color-mix(in oklab, var(--card-ink) 65%, transparent); vertical-align: bottom; }
table.sc th.h, table.sc td.h { text-align: left; width: 38%; }
table.sc th.par, table.sc td.par { width: 11%; color: color-mix(in oklab, var(--card-ink) 65%, transparent); }
table.sc th.pl { text-transform: none; letter-spacing: 0; font: 700 12px var(--round); color: var(--card-ink); overflow: hidden; text-overflow: ellipsis; }
table.sc th.pl .emblem { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }
table.sc th.pl span { display: block; overflow: hidden; text-overflow: ellipsis; }
table.sc td.h b { display: inline-block; width: 1.6em; font: 800 14px var(--round); }
table.sc td.h small { font-size: 12px; overflow: hidden; text-overflow: ellipsis; display: inline-block; max-width: calc(100% - 1.8em); vertical-align: bottom; }
table.sc tr.now td { background: color-mix(in oklab, var(--accent) 12%, transparent); }
table.sc tfoot td { border-bottom: 0; padding-top: 8px; font: 800 16px var(--round); }
table.sc tfoot td.h { font: 800 13px var(--round); text-transform: uppercase; letter-spacing: 0.05em; }
table.sc tfoot small { display: block; font: 700 11.5px var(--round); }
.topar.under { color: #2b8a3e; }
.topar.over { color: #b8441f; }
@media (prefers-color-scheme: dark) {
  .topar.under { color: #7ee08f; }
  .topar.over { color: #ff9b78; }
}
.mark { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 3px; font: 800 15px var(--round); border-radius: 50%; }
.mark.ace { background: #f0b429; color: #3a2400; box-shadow: 0 0 0 2px #fff3c4 inset, 0 0 10px rgba(240, 180, 41, 0.7); }
.mark.albatross, .mark.eagle { box-shadow: 0 0 0 1.5px currentColor, 0 0 0 3.5px var(--card-paper), 0 0 0 5px currentColor; color: #2b8a3e; }
.mark.birdie { box-shadow: 0 0 0 1.5px currentColor; color: #2b8a3e; }
.mark.bogey { border-radius: 4px; box-shadow: 0 0 0 1.5px currentColor; color: #b8441f; }
.mark.double, .mark.over { border-radius: 4px; box-shadow: 0 0 0 1.5px currentColor, 0 0 0 3.5px var(--card-paper), 0 0 0 5px currentColor; color: #b8441f; }
@media (prefers-color-scheme: dark) {
  .mark.albatross, .mark.eagle, .mark.birdie { color: #7ee08f; }
  .mark.bogey, .mark.double, .mark.over { color: #ff9b78; }
}
.mark.fresh { animation: ink 0.55s var(--spring) both; animation-delay: var(--d, 0ms); }
@keyframes ink {
  0% { opacity: 0; transform: scale(2.2) rotate(-12deg); }
  60% { opacity: 1; transform: scale(0.92) rotate(2deg); }
  100% { transform: none; }
}
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; margin: 10px 0 0; font-size: 11.5px; color: color-mix(in oklab, var(--card-ink) 70%, transparent); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .mark { min-width: 16px; height: 16px; font-size: 10px; }
.card-next { margin-top: 12px; }
.card-next .btn { min-height: 52px; font: 700 17px var(--round); }

/* ------------------------------------------------------------- results */
.podium { list-style: none; margin: 4px 0 12px; padding: 0; display: grid; gap: 6px; }
.podium li {
  display: grid;
  grid-template-columns: 22px auto 1fr auto auto;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--paper-2);
  animation: rise 0.45s var(--ease) both;
}
.podium li:nth-child(2) { animation-delay: 0.08s; }
.podium li:nth-child(3) { animation-delay: 0.16s; }
.podium li:nth-child(4) { animation-delay: 0.24s; }
.podium li.first { background: color-mix(in oklab, var(--pc) 16%, var(--paper-2)); box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--pc) 55%, transparent); }
.podium .rank { font: 800 15px var(--round); color: var(--ink-soft); text-align: center; }
.podium .nm { font: 700 16px var(--round); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium .tot { font: 800 16px var(--round); font-variant-numeric: tabular-nums; }
.podium .tp { font: 700 13px var(--round); color: var(--ink-soft); min-width: 2.4em; text-align: right; }
.badge { text-align: center; margin: 0 0 12px; padding: 8px 12px; border-radius: 12px; background: linear-gradient(90deg, #f6d36b, #f0b429); color: #3a2400; font: 800 15px var(--round); animation: popin2 0.6s var(--spring) both 0.3s; }
@keyframes popin2 { from { opacity: 0; transform: scale(0.8); } }
.friends-board { margin: 4px 0 6px; }
.friends-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 18px 0 4px; }
.friends-head h3 { margin: 0 !important; }
.friends-head .opt { min-height: 36px; padding: 3px 11px; font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 4px 0 6px; }
.tile { background: var(--paper-2); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.tile small { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.tile b { font: 800 21px var(--round); font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th { text-align: left; vertical-align: bottom; font-weight: 600; color: var(--ink-soft); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px; border-bottom: 1px solid var(--line); }
td { padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th.num, td.num { text-align: right; }
td.name { font-weight: 600; max-width: 12em; overflow: hidden; text-overflow: ellipsis; }
td.who { max-width: 9em; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
table.holes .mark { min-width: 22px; height: 22px; font-size: 13px; }
@media (max-width: 420px) {
  table.recent { font-size: 12px; }
  table.recent td, table.recent th { padding-left: 2px; padding-right: 2px; }
}

/* ------------------------------------------------------------- settings */
.swatch { display: inline-block; width: 24px; height: 24px; border-radius: 7px; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); }
.swatch.auto { background: linear-gradient(135deg, #7fc35c 50%, #1d2b4f 50%); }
.swatch.day { background: radial-gradient(circle at 70% 30%, #fff6c8 0 18%, transparent 20%), linear-gradient(#8fd06a, #4e9a3c); }
.swatch.golden { background: radial-gradient(circle at 70% 35%, #ffe2a0 0 18%, transparent 20%), linear-gradient(#e7a04f, #7d8a3a); }
.swatch.night { background: radial-gradient(circle at 70% 30%, #fff2c0 0 14%, transparent 16%), linear-gradient(#26345e, #1a3a2c); }
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 14px; cursor: pointer; font-size: 15px; line-height: 1.35; min-height: 32px; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { flex: 0 0 auto; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.25s; box-shadow: inset 0 0 0 1px var(--line); }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.25s var(--ease); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { display: grid; gap: 4px; margin-top: 10px; }
.field span { font-size: 12.5px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.field .emblem { width: 16px; height: 16px; }
.field input {
  appearance: none;
  font: 500 16px var(--sans); /* 16 px or more: iOS never zooms in on focus */
  color: var(--ink);
  background: var(--paper-2);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
  -webkit-user-select: text;
  user-select: text;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 74px);
  transform: translate(-50%, -6px);
  z-index: 15;
  background: var(--toast);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  width: max-content;
  max-width: min(90vw, 440px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.face .toast { top: 50%; transform: translate(-50%, -50%) rotate(var(--face-rot)); }

@media (prefers-reduced-motion: reduce) {
  .menu, .card, .sheet, .backdrop, .handover, .podium li, .badge { animation: fade 0.2s; }
  .handover .big-ball { animation: none; }
  .title-card, .pop-label { animation-name: fadeinout; animation-timing-function: linear; }
  .mark.fresh { animation: fade 0.3s both; animation-delay: var(--d, 0ms); }
  .pchip, .pchip.active { transition: none; transform: none; }
}
@keyframes fadeinout { 0% { opacity: 0; } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
