/* ============================================================
   ClubTap — reimagined. Match Programme skin.
   Map-first, chrome-light. Responsive: mobile (<760) = bottom
   sheet; desktop = floating panels. One codebase, both feel native.
   ============================================================ */
:root {
  --paper: #efe6d0;
  --panel: #f6efdd;
  --card: #fbf6e8;
  --ink: #23201a;
  --muted: #7d7259;
  --line: #ccc0a0;
  --line-soft: #ddd1b2;
  --orange: #c8521f;
  --green: #16563a;
  --green-deep: #0f3f2a;
  --gold: #d99f24;
  --map: #d8c79c;
  --land: #b9ba84;
  --land-line: #8a8a55;
  --grat: rgba(80,72,45,0.20);
  --disp: "Oswald", sans-serif;
  --body: "Barlow", sans-serif;
  --safe-top: max(14px, env(safe-area-inset-top));
  --shadow: 0 8px 24px rgba(35,28,16,0.16);
  --shadow-lg: 0 18px 50px rgba(35,28,16,0.30);
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: #cddbdc; /* matches map water tone so iOS status bar area blends with the map under viewport-fit=cover */
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
.disp { font-family: var(--disp); }

/* film grain over everything */
.ct-grain {
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  opacity: 0.5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------- stage + map ---------------- */
.ct-stage {
  position: fixed; inset: 0;
  width: 100%; height: 100vh; height: 100dvh;
  overflow: hidden;
}
.ct-map {
  position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab;
  background: var(--map);
  background-image:
    radial-gradient(circle at 68% 24%, rgba(22,86,58,0.10), transparent 55%),
    radial-gradient(circle at 20% 80%, rgba(200,82,31,0.08), transparent 50%);
}
.ct-map:active { cursor: grabbing; }
.ct-map.is-locked { cursor: default; }
.ct-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.ct-land {
  position: absolute;
  background: var(--land);
  border: 3px solid var(--land-line);
  box-shadow: inset 0 0 0 6px rgba(255,255,255,0.06);
}
/* graticule painted on the world so it pans/zooms with the map */
.ct-world::before {
  content: ""; position: absolute; left: -200px; top: -200px; right: -200px; bottom: -200px;
  background-image:
    linear-gradient(var(--grat) 1.5px, transparent 1.5px),
    linear-gradient(90deg, var(--grat) 1.5px, transparent 1.5px);
  background-size: 120px 120px, 120px 120px;
  z-index: -1;
}
.ct-place { position: absolute; display: flex; align-items: center; gap: 6px; transform: translate(-50%,-50%); }
.ct-place i { width: 7px; height: 7px; border-radius: 50%; background: var(--land-line); box-shadow: 0 0 0 3px rgba(247,239,221,0.4); }
.ct-place span {
  font-family: var(--disp); font-weight: 600; font-size: 15px; letter-spacing: 0.18em;
  color: rgba(60,52,28,0.55); text-transform: uppercase;
}

/* fx overlay (screen-space markers + arc) */
.ct-fx { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
.ct-arc { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ct-arc-path { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-dasharray: 2 7; stroke-linecap: round; }

.ct-pin { position: absolute; }
.ct-pin--guess {
  width: 22px; height: 22px; transform: translate(-50%,-50%);
  border-radius: 50%; background: var(--orange);
  border: 3px solid var(--card); box-shadow: 0 6px 14px rgba(35,28,16,0.4);
}
.ct-pin--answer {
  transform: translate(-50%,-100%);
  display: flex; flex-direction: column; align-items: center;
  filter: drop-shadow(0 8px 10px rgba(35,28,16,0.4));
}
.ct-flag {
  width: 42px; height: 42px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--disp); font-weight: 700; font-size: 22px;
  border: 3px solid var(--card);
}
.ct-pin--answer::after {
  content: ""; width: 3px; height: 16px; background: var(--card);
  margin-top: -1px; box-shadow: 0 0 0 1px rgba(35,28,16,0.3);
}
.ct-pin.pop { animation: pinPop .5s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pinPop { 0% { transform: translate(-50%,-50%) scale(0); } 60% { transform: translate(-50%,-50%) scale(1.25);} 100%{ transform: translate(-50%,-50%) scale(1);} }
.ct-pin--answer.pop { animation: flagPop .55s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes flagPop { 0% { transform: translate(-50%,-100%) scale(0); } 60% { transform: translate(-50%,-100%) scale(1.2);} 100%{ transform: translate(-50%,-100%) scale(1);} }

/* ---------------- crosshair reticle ---------------- */
.ct-reticle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  z-index: 25; pointer-events: none; width: 64px; height: 64px;
  transition: opacity .3s, transform .3s;
}
.ct-reticle::before, .ct-reticle::after {
  content: ""; position: absolute; background: var(--ink); opacity: 0.8;
}
.ct-reticle::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
.ct-reticle::after { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }
.ct-reticle .ring {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 26px; height: 26px; border: 2px solid var(--ink); border-radius: 50%;
  background: rgba(251,246,232,0.35);
}
.ct-reticle .dot {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--orange);
}
.ct-reticle.hide { opacity: 0; transform: translate(-50%,-50%) scale(.6); }
.ct-reticle.aim { animation: aimPulse 2.4s ease-in-out infinite; }
@keyframes aimPulse { 0%,100% { transform: translate(-50%,-50%) scale(1);} 50%{ transform: translate(-50%,-50%) scale(1.08);} }

/* ---------------- top actions ---------------- */
.ct-top-actions {
  position: absolute; z-index: 40;
  top: calc(var(--safe-top) + 18px); right: 20px;
  display: flex; align-items: center; gap: 8px;
}
.ct-signin {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 5px; border-radius: 999px; cursor: pointer;
  background: var(--green); border: 1.5px solid var(--green-deep); color: #f4ecd2;
  font-family: var(--disp); font-weight: 600; font-size: 13px; letter-spacing: 0.04em;
  box-shadow: var(--shadow);
}
.ct-signin-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.18); border: 1.5px solid rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--disp); font-weight: 700; font-size: 13px;
}
/* mobile: sign-in tucks into top-right of the fixture card */
@media (max-width: 759px) {
  .ct-top-actions {
    top: calc(var(--safe-top) + 18px); left: 20px; right: 20px;
    display: block; pointer-events: none;
  }
  .ct-signin {
    position: absolute; top: 0; right: 0;
    padding: 3px; box-shadow: 0 2px 6px rgba(35,28,16,0.15);
    pointer-events: auto;
  }
  .ct-signin-avatar { width: 26px; height: 26px; font-size: 12px; }
  .ct-signin-label { display: none; }
  .ct-fixture { padding-right: 44px; }
}

/* ---------------- club fixture card ---------------- */
.ct-fixture {
  position: absolute; z-index: 35;
  left: 12px; right: 12px; top: calc(var(--safe-top) + 10px);
  display: flex; align-items: center; gap: 13px;
  padding: 11px 15px 11px 11px;
  background: var(--card);
  border: 1.5px solid var(--ink);
  box-shadow: var(--shadow), 0 0 0 4px var(--card), 0 0 0 5.5px var(--ink);
  transition: opacity .35s, transform .35s;
}
.ct-fixture .meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ct-crest {
  width: 50px; height: 50px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--disp); font-weight: 700; font-size: 26px;
  border: 2px solid var(--ink); background: var(--card); color: var(--green);
  cursor: pointer; transition: transform .12s, box-shadow .14s, background .14s;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.ct-crest:hover { background: var(--panel); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1), 0 2px 0 rgba(35,28,16,0.18); }
.ct-crest:active { transform: scale(.96); }
.ct-crest:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 3px;
}
.ct-fixture .meta .lbl {
  font-family: var(--disp); font-weight: 600; font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
.ct-fixture .meta h1 {
  font-family: var(--disp); font-weight: 700; font-size: 22px; line-height: 1;
  letter-spacing: 0.01em; text-transform: uppercase; color: var(--green);
}
.ct-fixture .meta .sub { font-size: 12.5px; line-height: 1.2; color: var(--muted); }

/* ---------------- zoom controls ---------------- */
.ct-zoom {
  position: absolute; right: 14px; bottom: 96px; z-index: 35; display: flex; flex-direction: column;
  border: 1.5px solid var(--ink); border-radius: 5px; overflow: hidden;
  box-shadow: var(--shadow); background: var(--panel);
}
.ct-zoom button {
  width: 44px; height: 44px; border: 0; background: var(--panel); color: var(--ink);
  font-family: var(--disp); font-size: 24px; font-weight: 600; cursor: pointer; line-height: 1;
}
.ct-zoom button:active { background: var(--line-soft); }
.ct-zoom button + button { border-top: 1.5px solid var(--ink); }

/* ---------------- action dock ---------------- */
.ct-dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.ct-dock > * { pointer-events: auto; }
.ct-hint {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: rgba(35,28,16,0.82); color: #f4ecd2;
  font-size: 12.5px; font-weight: 500; letter-spacing: 0.01em;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(6px);
  transition: opacity .4s, transform .4s;
}
.ct-hint.show { opacity: 1; transform: translateY(0); }
.ct-hint .k { font-family: var(--disp); font-weight: 700; color: var(--gold); }

.ct-guess {
  width: 100%; max-width: 460px; min-height: 56px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1.5px solid var(--green-deep); border-radius: 6px;
  background: var(--green); color: #f8f1df;
  font-family: var(--disp); font-weight: 700; font-size: 19px;
  letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
  box-shadow: var(--shadow-lg), 0 0 0 4px var(--card), 0 0 0 5.5px var(--green-deep);
  transition: transform .12s, filter .15s;
}
.ct-guess .tgt { font-size: 13px; font-weight: 600; opacity: 0.78; letter-spacing: 0.04em; }
.ct-guess:hover { filter: brightness(1.06); }
.ct-guess:active { transform: scale(.975); }

/* ---------------- reveal sheet / card ---------------- */
.ct-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 45;
  background: var(--card); color: var(--ink);
  border-top: 1.5px solid var(--ink);
  box-shadow: 0 -16px 44px rgba(35,28,16,0.26);
  transform: translateY(110%); transition: transform .5s cubic-bezier(.2,.8,.25,1);
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
}
.ct-sheet.open { transform: translateY(0); }
.ct-sheet-grip { width: 42px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }

.ct-verdict { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ct-stamp {
  font-family: var(--disp); font-weight: 700; font-size: 27px; letter-spacing: 0.02em;
  text-transform: uppercase; line-height: 0.95;
  color: var(--green); position: relative;
}
.ct-stamp.t-decent { color: var(--gold); }
.ct-stamp.t-far, .ct-stamp.t-miss { color: var(--orange); }
.ct-ground { font-size: 13.5px; color: var(--muted); }
.ct-ground b { color: var(--ink); font-weight: 700; }

.ct-readout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 13px 0 4px;
}
.ct-readout--3 { grid-template-columns: 1fr 1fr 1fr; }
.ct-readout--3 .ct-stat .v { font-size: 22px; }
.ct-readout--3 .ct-stat { padding: 9px 10px; }
.ct-stat {
  border: 1.5px solid var(--ink); border-radius: 5px; padding: 9px 12px;
  background: var(--panel);
}
.ct-stat .k { font-family: var(--disp); font-weight: 600; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.ct-stat .v { font-family: var(--disp); font-weight: 700; font-size: 27px; line-height: 1; font-variant-numeric: tabular-nums; margin-top: 2px; }
.ct-stat.score { background: var(--green); border-color: var(--green-deep); color: #f4ecd2; }
.ct-stat.score .k { color: rgba(244,236,210,0.7); }
.ct-stat .v small { font-size: 14px; font-weight: 600; opacity: 0.7; }

/* proximity bar — makes scoring legible */
.ct-prox { margin-top: 11px; }
.ct-prox .track {
  position: relative; height: 12px; border-radius: 999px; overflow: hidden;
  border: 1.5px solid var(--ink);
  background: linear-gradient(90deg, var(--green) 0 22%, #5e8a2f 22% 42%, var(--gold) 42% 64%, var(--orange) 64% 100%);
}
.ct-prox .knob {
  position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%;
  background: var(--card); border: 2.5px solid var(--ink);
  transform: translate(-50%,-50%); transition: left 1s cubic-bezier(.3,1,.3,1); left: 100%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.ct-prox .legend {
  display: flex; justify-content: space-between; margin-top: 6px;
  font-family: var(--disp); font-weight: 600; font-size: 9.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.ct-rank {
  margin-top: 11px; padding: 9px 12px; border-radius: 5px;
  background: var(--panel); border: 1px dashed var(--line);
  font-size: 13px; color: var(--muted);
}
.ct-rank b { color: var(--green); font-family: var(--disp); font-weight: 700; }

.ct-next {
  margin-top: 14px; width: 100%; min-height: 52px;
  border: 1.5px solid var(--ink); border-radius: 6px;
  background: var(--orange); color: #fff;
  font-family: var(--disp); font-weight: 700; font-size: 18px; letter-spacing: 0.06em;
  text-transform: uppercase; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .12s, filter .15s;
}
.ct-next:hover { filter: brightness(1.05); }
.ct-next:active { transform: scale(.98); }

/* ---------------- end summary ---------------- */
.ct-end-head { text-align: center; margin-bottom: 10px; }
.ct-end-head .lbl { font-family: var(--disp); font-weight: 600; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.ct-end-head .total { font-family: var(--disp); font-weight: 700; font-size: 54px; line-height: 0.9; color: var(--green); font-variant-numeric: tabular-nums; }
.ct-endstats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.ct-endstats .ct-stat { text-align: center; }
.ct-endstats .ct-stat .v { font-size: 20px; }
.ct-share-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  margin: 14px 0 6px;
}
.ct-recap-tile {
  display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  padding: 0; border: 0; background: transparent; cursor: pointer;
  transition: transform .12s;
}
.ct-recap-tile:active { transform: scale(.96); }
.ct-recap-crest {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1 / 1; background: var(--card);
  border: 1.5px solid var(--ink); border-radius: 6px; overflow: hidden;
  font-family: var(--disp); font-weight: 700; font-size: 18px; color: var(--ink);
}
.ct-recap-crest img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.ct-recap-bar {
  display: block; height: 5px; border-radius: 3px;
  border: 1px solid var(--ink); background: var(--muted);
}
.ct-recap-tile[data-tier="banger"] .ct-recap-bar,
.ct-recap-tile[data-tier="great"]  .ct-recap-bar { background: var(--green); }
.ct-recap-tile[data-tier="decent"] .ct-recap-bar { background: var(--gold); }
.ct-recap-tile[data-tier="far"]    .ct-recap-bar,
.ct-recap-tile[data-tier="miss"]   .ct-recap-bar { background: var(--orange); }
.ct-recap-tile.is-active .ct-recap-crest {
  box-shadow: 0 0 0 2px var(--gold);
}

/* end-head: score centered with a small share icon to the right */
.ct-end-total-row {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; column-gap: 10px; margin-top: 2px;
}
.ct-end-total-spacer { /* keeps the total perfectly centered */ }
.ct-share-icon {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 8px; cursor: pointer;
  background: var(--green); color: #f4ecd2;
  border: 1.5px solid var(--green-deep); border-radius: 999px;
  font-family: var(--disp); font-weight: 700; font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  box-shadow: var(--shadow);
  transition: transform .12s, filter .14s;
}
.ct-share-icon svg { width: 14px; height: 14px; fill: currentColor; }
.ct-share-icon:hover { filter: brightness(1.08); }
.ct-share-icon:active { transform: scale(.96); }
.ct-share-icon.share-button--copied { background: var(--orange); border-color: var(--ink); }

/* today's table — windowed league standings around YOU */
.ct-table {
  margin-top: 14px; border: 1.5px solid var(--ink); border-radius: 6px;
  background: var(--card); overflow: hidden;
}
.ct-table-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 13px; background: var(--panel); border-bottom: 1.5px solid var(--ink);
}
.ct-table-head .t {
  font-family: var(--disp); font-weight: 700; font-size: 12px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--green);
}
.ct-fulltable {
  font-family: var(--disp); font-weight: 600; font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); background: none; border: 0;
  cursor: pointer; padding: 2px 0; transition: color .14s;
}
.ct-fulltable:hover { color: var(--orange); }
.ct-table-rows { display: flex; flex-direction: column; }
.ct-trow {
  display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 11px;
  padding: 8px 13px; border-top: 1px solid var(--line-soft); font-size: 14.5px;
}
.ct-trow:first-child { border-top: 0; }
.ct-trow .pos {
  font-family: var(--disp); font-weight: 700; font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums; text-align: right;
}
.ct-trow .who {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-weight: 600; white-space: nowrap; overflow: hidden;
}
.ct-trow .flag { flex: none; font-size: 16px; line-height: 1; }
.ct-trow .who .nm { overflow: hidden; text-overflow: ellipsis; }
.ct-trow .pts {
  font-family: var(--disp); font-weight: 700; font-size: 15px; color: var(--green);
  font-variant-numeric: tabular-nums;
}
.ct-trow.you { background: var(--gold); }
.ct-trow.you .pos, .ct-trow.you .pts { color: var(--ink); }
.you-pill {
  flex: none; font-family: var(--disp); font-weight: 700; font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--gold); background: var(--ink);
  padding: 2px 6px; border-radius: 3px;
}
.ct-trow.gap {
  padding: 4px 13px; color: var(--muted); justify-items: start;
  font-family: var(--disp); font-weight: 700; letter-spacing: 0.2em;
  border-top: 1px dashed var(--line);
}
.ct-trow.gap span { grid-column: 1 / -1; text-align: center; opacity: 0.7; }

/* full leaderboard modal */
.ct-modal {
  position: absolute; inset: 0; z-index: 95; display: none;
  align-items: center; justify-content: center; padding: 22px;
  background: rgba(20,16,8,0.52);
}
.ct-modal.open { display: flex; }
.ct-modal-card {
  width: min(440px, 100%); max-height: min(80vh, 640px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 12px;
  box-shadow: var(--shadow-lg), 0 0 0 5px var(--card), 0 0 0 6.5px var(--ink);
  animation: ct-modal-in .26s cubic-bezier(.2,.9,.3,1);
}
@keyframes ct-modal-in { from { transform: translateY(14px) scale(.985); } }
.ct-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 15px 18px; background: var(--green); color: #f4ecd2;
  border-bottom: 1.5px solid var(--ink);
}
.ct-modal-head .lbl {
  font-family: var(--disp); font-weight: 600; font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: rgba(244,236,210,0.72); white-space: nowrap;
}
.ct-modal-head h2 {
  font-family: var(--disp); font-weight: 700; font-size: 23px; line-height: 1.04;
  text-transform: uppercase; letter-spacing: 0.01em; margin-top: 2px;
}
.ct-modal-close {
  flex: none; width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  border: 1.5px solid rgba(244,236,210,0.45); background: transparent; color: #f4ecd2;
  font-size: 14px; line-height: 1; transition: background .14s;
}
.ct-modal-close:hover { background: rgba(244,236,210,0.14); }
.ct-modal-rows { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ct-modal-rows .ct-trow { font-size: 15px; }
.ct-end-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.ct-share, .ct-again {
  min-height: 50px; border-radius: 6px; cursor: pointer;
  font-family: var(--disp); font-weight: 700; font-size: 16px; letter-spacing: 0.05em; text-transform: uppercase;
  border: 1.5px solid var(--ink); transition: transform .12s, filter .15s;
}
.ct-share { background: var(--green); color: #f4ecd2; border-color: var(--green-deep); }
.ct-again { background: var(--gold); color: var(--ink); }
.ct-share:active, .ct-again:active { transform: scale(.98); }
.ct-share.copied { background: var(--orange); }

/* confetti */
.ct-confetti { position: fixed; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; }
.ct-conf { position: absolute; width: 9px; height: 13px; will-change: transform, opacity; }

/* ============================================================
   DESKTOP ( >= 760px ) — floating panels instead of bottom sheet
   ============================================================ */
@media (min-width: 760px) {
  :root { --safe-top: 6px; }
  .ct-top { padding: 18px 22px; }
  .ct-fixture { left: 22px; right: auto; top: 22px; max-width: 380px; }
  .ct-top-actions { top: 22px; right: 22px; }
  .ct-fixture .meta h1 { font-size: 27px; }
  .ct-crest { width: 58px; height: 58px; font-size: 30px; }
  .ct-zoom { right: 22px; top: 50%; bottom: auto; transform: translateY(-50%); }
  .ct-dock { bottom: 22px; }

  /* floating card; reveal sits centered, full-time summary anchors bottom-left */
  .ct-sheet {
    left: 50%; right: auto; bottom: 22px; width: min(560px, calc(100% - 44px));
    transform: translate(-50%, 140%); border: 1.5px solid var(--ink);
    border-radius: 12px; padding: 20px 22px;
    box-shadow: var(--shadow-lg), 0 0 0 5px var(--card), 0 0 0 6.5px var(--ink);
  }
  .ct-sheet.open { transform: translate(-50%, 0); }
  .ct-stage.phase-end .ct-sheet {
    left: 22px; width: min(440px, calc(100% - 44px));
    transform: translateY(140%);
  }
  .ct-stage.phase-end .ct-sheet.open { transform: translateY(0); }
  .ct-sheet-grip { display: none; }
  .ct-stamp { font-size: 32px; }
  .ct-end-head .total { font-size: 64px; }
}

@media (min-width: 760px) and (max-width: 1100px) {
  .ct-fixture { max-width: 320px; }
}

/* ============================================================
   ADAPTER LAYER — wires Mapbox + dialogs to the match-programme skin
   ============================================================ */

/* sheet body visibility is driven by the phase class on .ct-stage */
.ct-reveal-body, .ct-end-body { display: none; }
.phase-reveal .ct-reveal-body { display: block; }
.phase-end .ct-end-body { display: block; }

/* breathing room between the verdict stamp and the ground line */
.ct-verdict { display: block; margin-bottom: 8px; }
.ct-stamp { line-height: 1.03; }
.ct-ground { margin-top: 6px; }


/* legacy DOM nodes the app.js still writes into but the new UI doesn't render */
.ct-legacy { position: absolute; left: -10000px; top: -10000px; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

/* Mapbox container — anchored directly to the visible viewport, and
   pulled UP past the safe-area-top so the map paints behind the iOS
   notch even in regular Safari (viewport-fit=cover). */
#map {
  position: fixed;
  top: calc(-1 * env(safe-area-inset-top, 0px));
  left: 0; right: 0;
  bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
  width: 100%; height: auto;
  background: var(--map); z-index: 0;
}
.mapboxgl-canvas { outline: 0; }
/* hide Mapbox's own NavigationControl — we use .ct-zoom */
.mapboxgl-ctrl-bottom-right, .mapboxgl-ctrl-top-right,
.mapboxgl-ctrl-bottom-left, .mapboxgl-ctrl-top-left { display: none !important; }
.mapboxgl-ctrl-attrib { display: none !important; }

/* marker styling — these elements are spawned by mapbox-gl */
.guess-marker {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--orange); border: 3px solid var(--card);
  box-shadow: 0 6px 14px rgba(35,28,16,0.4);
}

/* answer pin: crest flag + stem + label, anchored at the tip */
.answer-pin {
  display: flex; flex-direction: column; align-items: center;
  filter: drop-shadow(0 8px 10px rgba(35,28,16,0.35));
  pointer-events: none;
}
.answer-pin__flag {
  width: 58px; height: 58px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--green); color: var(--card);
  border: 3px solid var(--card);
  font-family: var(--disp); font-weight: 700; font-size: 28px;
  box-shadow: 0 0 0 1.5px var(--ink);
  overflow: hidden;
}
.answer-pin__flag img { width: 100%; height: 100%; object-fit: contain; padding: 4px; background: var(--card); }
.answer-pin__stem {
  width: 3px; height: 18px; background: var(--card);
  box-shadow: 0 0 0 1px var(--ink);
  margin-top: -1px;
}
.answer-pin__label {
  margin-bottom: 4px; padding: 3px 8px 2px;
  background: var(--card); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 4px;
  font-family: var(--disp); font-weight: 700; font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}

/* small toast over the map */
.ct-toast {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  z-index: 60; padding: 8px 14px; border-radius: 999px;
  background: rgba(35,28,16,0.85); color: #f4ecd2;
  font-family: var(--disp); font-weight: 600; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
  box-shadow: var(--shadow);
}

/* setup state (missing token) */
.ct-setup {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--paper);
}
.ct-setup-card {
  max-width: 460px; padding: 22px 24px;
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 8px;
  box-shadow: var(--shadow), 0 0 0 4px var(--card), 0 0 0 5.5px var(--ink);
}
.ct-setup-card h2 {
  font-family: var(--disp); font-weight: 700; font-size: 22px;
  text-transform: uppercase; color: var(--green); margin-bottom: 8px;
}
.ct-setup-card p { font-size: 14px; line-height: 1.5; color: var(--muted); }

/* ===== auth + profile dialogs — match-programme ticket-stub card =====
   The cream/ink double-border halo lives on the <dialog> itself so it
   renders the same matted frame as the .ct-sheet end summary. */
dialog.auth-modal, dialog.leaderboard-modal {
  padding: 0; margin: auto;
  width: min(440px, calc(100vw - 32px));
  max-height: min(88vh, 740px);
  background: var(--card); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 12px;
  box-shadow: var(--shadow-lg), 0 0 0 5px var(--card), 0 0 0 6.5px var(--ink);
  overflow: hidden;
  animation: ct-modal-in .26s cubic-bezier(.2,.9,.3,1);
}
dialog.auth-modal::backdrop,
dialog.leaderboard-modal::backdrop {
  background: rgba(20,16,8,0.58);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
/* film grain overlay so dialogs match the rest of the paper UI */
dialog.auth-modal::after,
dialog.leaderboard-modal::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  opacity: 0.5; mix-blend-mode: multiply; border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.auth-modal__panel, .leaderboard-modal__panel {
  width: 100%; max-height: inherit;
  display: flex; flex-direction: column;
  background: transparent; color: inherit;
  border: 0;
}

/* ticket-stub header — green band, ink eyebrow bar, perforated bottom */
.auth-modal__head, .leaderboard-modal__head {
  position: relative;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px 18px; background: var(--green); color: #f4ecd2;
  border-bottom: 1.5px solid var(--ink);
}
.auth-modal__head::before, .leaderboard-modal__head::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 5px; background: var(--gold);
}
.auth-modal__head::after, .leaderboard-modal__head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1.5px; height: 4px;
  background-image: radial-gradient(circle at 6px 50%, var(--card) 1.6px, transparent 2px);
  background-size: 12px 4px; background-repeat: repeat-x;
  pointer-events: none;
}
.auth-modal__head h2, .leaderboard-modal__head h2 {
  font-family: var(--disp); font-weight: 700; font-size: 22px; line-height: 1.04;
  text-transform: uppercase; letter-spacing: 0.01em; margin-top: 4px;
}
.auth-modal__head .result-card__label,
.leaderboard-modal__head .result-card__label {
  font-family: var(--disp); font-weight: 600; font-size: 10px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--gold);
}
.leaderboard-modal__close, .auth-modal__close {
  flex: none; width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  border: 1.5px solid rgba(244,236,210,0.45); background: transparent; color: #f4ecd2;
  display: flex; align-items: center; justify-content: center;
  transition: background .14s, border-color .14s;
}
.leaderboard-modal__close:hover, .auth-modal__close:hover {
  background: rgba(244,236,210,0.14); border-color: rgba(244,236,210,0.85);
}
.leaderboard-modal__close svg, .auth-modal__close svg { width: 14px; height: 14px; fill: currentColor; }

dialog.crest-modal {
  padding: 0; margin: auto;
  width: min(320px, calc(100vw - 32px));
  background: var(--card); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 12px;
  box-shadow: var(--shadow-lg), 0 0 0 5px var(--card), 0 0 0 6.5px var(--ink);
  overflow: hidden;
  animation: ct-modal-in .22s cubic-bezier(.2,.9,.3,1);
}
dialog.crest-modal::backdrop {
  background: rgba(20,16,8,0.58);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.crest-modal__panel {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 44px 24px 24px;
  background: transparent;
}
.crest-modal__close {
  position: absolute; top: 12px; right: 12px;
  background: var(--green); color: #f4ecd2;
  border-color: var(--green-deep);
}
.crest-modal__close:hover {
  background: var(--green-deep); border-color: var(--green-deep);
}
.crest-modal__image {
  width: min(210px, 64vw); aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; border: 2px solid var(--ink);
  background: var(--panel); color: var(--green);
  font-family: var(--disp); font-size: 72px; font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1), var(--shadow);
}
.crest-modal__image img {
  width: 100%; height: 100%; object-fit: contain; padding: 18px;
  filter: drop-shadow(0 5px 7px rgba(35,28,16,0.18));
}
.crest-modal__panel h2 {
  max-width: 100%;
  font-family: var(--disp); font-size: 24px; line-height: 1.04;
  text-transform: uppercase; color: var(--green); text-align: center;
  overflow-wrap: anywhere; text-wrap: balance;
}

/* body sections — `display: flex` overrides the HTML hidden attribute, so reset it */
.auth-signed-out, .auth-signed-in {
  display: flex; flex-direction: column; gap: 14px; padding: 22px 20px 4px;
}
.auth-signed-out[hidden], .auth-signed-in[hidden],
.profile-first-name[hidden] { display: none !important; }
.auth-copy {
  font-size: 13.5px; line-height: 1.5; color: var(--muted);
  font-family: var(--body);
}

/* buttons — double-bordered, match-programme style */
.auth-primary-button, .auth-secondary-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--disp); font-weight: 700; font-size: 15px; letter-spacing: 0.06em;
  text-transform: uppercase; cursor: pointer; min-height: 50px;
  border: 1.5px solid var(--ink); border-radius: 6px;
  transition: transform .12s, filter .14s, box-shadow .14s;
}
.auth-primary-button {
  background: var(--green); color: #f4ecd2; border-color: var(--green-deep);
  box-shadow: var(--shadow), 0 0 0 3px var(--card), 0 0 0 4.5px var(--green-deep);
}
.auth-secondary-button {
  background: var(--panel); color: var(--ink);
  box-shadow: 0 2px 0 var(--line);
}
.auth-primary-button:hover, .auth-secondary-button:hover { filter: brightness(1.06); }
.auth-primary-button:active, .auth-secondary-button:active { transform: scale(.985); }
.auth-primary-button[disabled] { opacity: .6; cursor: progress; }

/* google button: white face, brand 'G', double-bordered like primary */
.auth-primary-button--google {
  background: var(--card); color: var(--ink); border-color: var(--ink);
  box-shadow: var(--shadow), 0 0 0 3px var(--card), 0 0 0 4.5px var(--ink);
}
.auth-google-icon { width: 18px; height: 18px; flex: none; }

/* small "or" divider above the email form */
.auth-email-form { display: flex; flex-direction: column; gap: 6px; position: relative; padding-top: 14px; }
.auth-email-form::before {
  content: "or"; position: absolute; top: -2px; left: 50%; transform: translateX(-50%);
  background: var(--card); padding: 0 10px;
  font-family: var(--disp); font-weight: 600; font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--muted);
}
.auth-email-form::after {
  content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 1px;
  background: var(--line-soft); z-index: -1;
}
.auth-email-form label {
  font-family: var(--disp); font-weight: 600; font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
.auth-email-form__row { display: flex; gap: 8px; }
.auth-email-form input[type="email"] {
  flex: 1; min-width: 0; padding: 11px 13px;
  font-family: var(--body); font-size: 14px; color: var(--ink);
  background: var(--panel); border: 1.5px solid var(--ink); border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(35,28,16,0.06);
  transition: box-shadow .14s, background .14s;
}
.auth-email-form input[type="email"]::placeholder { color: rgba(125,114,89,0.7); }
.auth-email-form input[type="email"]:focus {
  outline: 0; background: var(--card);
  box-shadow: 0 0 0 2px var(--gold), inset 0 1px 0 rgba(35,28,16,0.06);
}
.auth-email-form__row .auth-secondary-button { min-height: 46px; padding: 0 14px; }

/* account card (signed-in summary) — like a dashed ticket stub */
.auth-account-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--panel); border: 1px dashed var(--line); border-radius: 6px;
}
.auth-account-card__avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--green); color: #f4ecd2;
  font-family: var(--disp); font-weight: 700; font-size: 17px;
  border: 1.5px solid var(--ink);
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--ink);
}
.auth-account-card__avatar img { width: 100%; height: 100%; object-fit: cover; }
.auth-account-card__name {
  font-family: var(--disp); font-weight: 700; font-size: 16px;
  letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink);
}
.auth-account-card__avatar + div .auth-copy {
  font-size: 12.5px; margin-top: 2px;
}

/* secondary text link (sign out) */
.auth-text-button {
  background: none; border: 0; cursor: pointer; align-self: flex-start;
  padding: 4px 0; font-family: var(--disp); font-weight: 600; font-size: 12px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  transition: color .14s;
}
.auth-text-button:hover { color: var(--orange); }

/* status — small italic line at the bottom */
.auth-status {
  padding: 8px 20px 18px; font-size: 12.5px; line-height: 1.4;
  color: var(--muted); font-style: italic; min-height: 0;
}

/* ===== profile modal ===== */
.profile-first-name {
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 20px 0;
}
.profile-first-name label,
.profile-flag label {
  font-family: var(--disp); font-weight: 600; font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
.profile-first-name input,
.profile-flag select {
  padding: 11px 13px; font-family: var(--body); font-size: 14px; color: var(--ink);
  background: var(--panel); border: 1.5px solid var(--ink); border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(35,28,16,0.06);
  transition: box-shadow .14s, background .14s;
}
.profile-first-name input:focus,
.profile-flag select:focus {
  outline: 0; background: var(--card);
  box-shadow: 0 0 0 2px var(--gold), inset 0 1px 0 rgba(35,28,16,0.06);
}

.profile-options {
  display: flex; flex-direction: column; gap: 7px;
  padding: 16px 20px 0;
}
.profile-options::before {
  content: "Pick a name"; display: block; margin-bottom: 2px;
  font-family: var(--disp); font-weight: 600; font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
.profile-option {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  background: var(--panel); border: 1.5px solid var(--line-soft);
  border-radius: 6px; cursor: pointer;
  transition: border-color .14s, background .14s, box-shadow .14s;
}
.profile-option:hover { border-color: var(--line); }
.profile-option:has(input:checked) {
  border-color: var(--ink); background: var(--card);
  box-shadow: 0 0 0 2px var(--gold);
}
.profile-option input { flex: none; accent-color: var(--green); width: 16px; height: 16px; }
.profile-option > span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.profile-option strong {
  font-family: var(--disp); font-weight: 700; font-size: 15px;
  letter-spacing: 0.02em; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-option > span > span {
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}

.profile-flag {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 20px 0;
}

.profile-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 9px;
  padding: 18px 20px 4px;
}
.profile-sign-out {
  background: none; border: 0; cursor: pointer;
  margin: 8px 20px 14px;
  font-family: var(--disp); font-weight: 600; font-size: 12px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted); text-align: left;
  transition: color .14s;
}
.profile-sign-out:hover { color: var(--orange); }
.auth-signed-out, .auth-signed-in { padding-bottom: 6px; }

/* let the existing fitClubName() shrink long names by honoring the CSS var */
.ct-fixture .meta h1 { font-size: var(--club-name-size, 22px); }
@media (min-width: 760px) {
  .ct-fixture .meta h1 { font-size: var(--club-name-size, 27px); }
}
/* fit club logo image inside the crest box */
.ct-crest img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.ct-signin-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.auth-account-card__avatar img { width: 100%; height: 100%; object-fit: cover; }

/* status-line stub: also feed errors visibly via the toast or by overriding setup state */
.ct-stage.ct-setup-mode .ct-fixture .meta h1 { color: var(--orange); }
