/* ===========================================================================
   Digdir Gym Leaderboard — whiteboard / hand-drawn theme
   One rule set per component, in page order. Media queries and TV mode last.
   =========================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --marker-blue:  #2563eb;
  --marker-red:   #b91c1c;
  --marker-green: #15803d;
  --marker-amber: #f59e0b;
  --ink:          #1e293b;
  --ink-soft:     #475569;
  --whiteboard:   #fbfbf8;
  --panel:        rgba(255, 255, 255, 0.72);
  --line:         #d8dae0;
  --gold:   #fbbf24;
  --silver: #cbd5e1;
  --bronze: #d8956b;
  /* sticky notes (the Friday lift) and the highlighter on your own name */
  --note:        #fdeb86;
  --note-paper:  linear-gradient(172deg, #fff7b8, var(--note));
  --note-ink:    #7c5d00;
  --note-soft:   #6b5a1e;
  --note-rule:   rgba(124,93,0,.35);
  --highlighter: linear-gradient(transparent 58%, rgba(250,204,21,.5) 58%, rgba(250,204,21,.5) 92%, transparent 92%);
  --shadow:    0 2px 0 rgba(0,0,0,0.06), 0 6px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 0 rgba(0,0,0,0.06), 0 12px 30px rgba(0,0,0,0.14);
  --radius: 14px;
}

/* ---- page ------------------------------------------------------------------ */
body {
  font-family: 'Caveat', cursive;
  font-size: 1.15rem;
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  padding: 32px;
  background:
    radial-gradient(circle at 18% 22%, rgba(37,99,235,0.06), transparent 45%),
    radial-gradient(circle at 82% 78%, rgba(245,158,11,0.06), transparent 45%),
    var(--whiteboard);
  position: relative;
}
/* faint graph-paper grid */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(37,99,235,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,0.04) 1px, transparent 1px);
  background-size: 26px 26px;
}
body:has(dialog.modal[open]) { overflow: hidden; }
.container { max-width: 1440px; margin: 0 auto; }
[hidden] { display: none !important; }
/* Read by screen readers, not shown: names for what the page says with an emoji alone. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--marker-blue); outline-offset: 4px; }
button, input, select { -webkit-tap-highlight-color: transparent; }
.svg-defs { position: absolute; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 300; background: white; padding: 8px 16px; }
.skip-link:focus { top: 12px; }

/* ---- header ---------------------------------------------------------------- */
header { margin-bottom: 28px; }
.header-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.eyebrow { font: 700 .72rem/1.5 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .18em; color: var(--ink-soft); margin-bottom: 8px; }
.eyebrow span { color: var(--marker-blue); padding: 0 8px; }
.header-titles h1 {
  display: flex; align-items: center; gap: 12px;
  font-family: 'Permanent Marker', cursive;
  font-size: clamp(2rem, 3.5vw, 3.2rem);
  color: var(--marker-blue);
  letter-spacing: 1px;
  transform: rotate(-0.7deg);
  text-shadow: 2px 2px 0 rgba(37,99,235,0.12);
}
.header-titles h1 img { flex-shrink: 0; }
.title-period { color: var(--marker-amber); margin-left: -12px; }
.subtitle {
  font-family: 'Indie Flower', cursive;
  font-size: 1.35rem; color: var(--ink-soft);
  transform: rotate(0.4deg);
}
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 24px; }
.auth-area { display: flex; align-items: center; gap: 10px; }
.auth-user {
  font-size: 1.2rem; color: var(--ink-soft);
  background: var(--panel); border: 2px solid var(--line);
  border-radius: 999px; padding: 4px 14px;
}
.auth-user.view-only { border-style: dashed; }
/* ⚖️ Bodyweight ranking: the toggle reads as switched on while it is pressed. */
.bodyweight-toggle[aria-pressed="true"] { color: var(--marker-blue); border-color: var(--marker-blue); background: #e9efff; }
.bodyweight-toggle[aria-pressed="true"]::after { content: ' ✓'; content: ' ✓' / ''; }

/* ---- buttons and chips ----------------------------------------------------- */
.btn {
  font-family: 'Caveat', cursive; font-size: 1.2rem; font-weight: 700;
  cursor: pointer; border: 2px solid var(--ink);
  border-radius: 12px; padding: 8px 18px; color: #fff; background: var(--ink);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.18);
  transition: transform .08s ease, box-shadow .08s ease, filter .12s ease;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 rgba(0,0,0,0.2); filter: brightness(1.05); }
.btn:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 rgba(0,0,0,0.2); }
.btn-primary   { background: var(--marker-blue);  border-color: #1d4ed8; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--ink); }
.btn-ghost     { background: transparent; color: var(--ink-soft); border-color: var(--line); box-shadow: none; }
.btn-edit      { background: var(--marker-green); border-color: #059669; padding: 6px 14px; }
.btn-danger    { background: var(--marker-red);   border-color: #dc2626; padding: 6px 14px; }
button:disabled, input:disabled, [aria-disabled="true"] { cursor: not-allowed; opacity: .6; transform: none; }
/* A control whose action is running stays focusable (js/app.js runAction), and looks busy. */
[aria-busy="true"] { cursor: progress; }
.btn[aria-disabled="true"]:is(:hover, :active) { transform: none; box-shadow: 2px 2px 0 rgba(0,0,0,0.18); filter: none; }
.btn-ghost[aria-disabled="true"]:is(:hover, :active) { box-shadow: none; }

.count-badge {
  background: var(--marker-red); color: #fff; border-radius: 999px;
  padding: 0 7px; margin-left: 4px; font-size: 0.95rem; font-weight: 700;
}
/* approval-type tags */
.tag { font-family: 'Indie Flower', cursive; font-size: 0.85rem; padding: 1px 8px; border-radius: 999px; vertical-align: middle; }
.status-chip { font-family: 'Indie Flower', cursive; font-size: 0.9rem; padding: 1px 8px; border-radius: 999px; }
/* chip tones, shared by tags, member statuses and the changes in a PR or a progression */
.tag-peer, .status-self, .history-delta.first               { background: #dbeafe; color: #1e40af; }
.tag-admin, .status-pending                                 { background: #fef3c7; color: #92400e; }
.status-active, .delta.up, .history-delta.up                { background: #dcfce7; color: #166534; }
.tag-warn, .status-blocked, .delta.down, .history-delta.down { background: #fee2e2; color: #991b1b; }
.status-admin                                               { background: #ede9fe; color: #5b21b6; }
.badge-chip { margin-left: 6px; font-size: 1.05rem; vertical-align: middle; }
.badge-chip.pending { filter: grayscale(0.2); opacity: 0.8; }
.badge-chip.fresh { margin-left: 4px; }

/* ---- member controls, the Friday lift and board status ---------------------- */
.toolbar { display: flex; align-items: center; gap: 16px 28px; flex-wrap: wrap; margin-bottom: 22px; }
.controls { display: flex; gap: 12px; flex-wrap: wrap; }
body:not(.signed-in) .controls { display: none; }
/* The Friday lift: a sticky note on the whiteboard, with a strip of tape. */
.next-lift {
  position: relative; display: flex; align-items: center; gap: 4px 20px; flex-wrap: wrap;
  min-width: 0; max-width: 100%; padding: 10px 16px 10px 18px;
  background: var(--note-paper);
  border-radius: 2px 2px 16px 2px;
  box-shadow: 0 1px 0 rgba(0,0,0,.05), 4px 8px 14px rgba(120,90,0,.16);
  transform: rotate(-0.8deg);
}
.next-lift::before {
  content: ''; position: absolute; top: -9px; left: 32px; width: 72px; height: 18px;
  background: rgba(255,255,255,.62); border: 1px solid rgba(0,0,0,.06); transform: rotate(2.5deg);
}
.next-lift-eyebrow { font: 700 .7rem/1.4 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .14em; color: var(--note-ink); }
.next-lift-when { letter-spacing: .06em; }
.next-lift-name { font-family: 'Permanent Marker', cursive; font-size: 1.6rem; line-height: 1.15; color: var(--ink); }
.next-lift .btn { box-shadow: 1px 1px 0 rgba(0,0,0,.15); }
/* Members also see the next planned session; it opens the planner on that session. */
.next-session {
  display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: 22rem;
  padding: 0; font: inherit; color: inherit; text-align: left; background: none; border: 0;
}
/* A dashed line between the two parts, whichever comes first. */
.next-lift > :nth-child(2):not(.btn) { padding-left: 18px; border-left: 2px dashed var(--note-rule); }
/* A session before Friday leads; the Friday lift is just its emoji (named in its tooltip). */
.next-session.lead .next-session-what { font-size: 1.6rem; line-height: 1.15; }
.next-lift-main.compact { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: default; }
.next-lift-emoji { font-size: 1.5rem; line-height: 1; }
button.next-session { cursor: pointer; }
button.next-session:hover .next-session-what { color: var(--marker-blue); }
.next-session-what { font-family: 'Permanent Marker', cursive; font-size: 1.15rem; line-height: 1.3; overflow-wrap: anywhere; }
.next-session-who { font-family: 'Indie Flower', cursive; font-size: 1rem; color: var(--note-soft); }
/* Members join the Friday lift from here too. */
.next-friday-who {
  display: block; margin-top: 2px; padding: 0; font-family: 'Indie Flower', cursive; font-size: 1rem; color: var(--note-soft);
  background: none; border: 0; cursor: pointer; text-decoration: underline dotted rgba(124,93,0,.45); text-underline-offset: 3px;
}
.next-friday-who:hover { color: var(--marker-blue); }
.tv-next-lift { display: none; }
/* Role-gated controls: hidden by default, shown when the body has the matching class */
.own-only, .claim-only, .review-only, .admin-only { display: none; }
body.is-active  .own-only    { display: inline-flex; }
body.can-claim  .claim-only  { display: inline-flex; }
body.can-review .review-only { display: inline-flex; }
body.is-admin   .admin-only  { display: inline-flex; }

.board-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 20px; padding: 14px 0; border-top: 1px solid var(--line); color: var(--ink-soft); font: .78rem/1.6 system-ui, sans-serif; }
.board-meta-end { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; }
/* ✨ What's new: a quiet link, with a dot until this browser has opened the latest release. */
.changelog-link {
  font: inherit; color: var(--marker-blue); background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 3px;
}
.changelog-link.unseen::after {
  content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 6px; vertical-align: middle;
  border-radius: 50%; background: var(--marker-red);
}
.connection-status { display: flex; align-items: center; gap: 12px; }
#boardStatus::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; background: var(--ink-soft); }
#boardStatus[data-state="live"]::before { background: var(--marker-green); box-shadow: 0 0 0 3px #15803d12; }
#boardStatus[data-state="error"]::before { background: var(--marker-red); }
#retryBtn { padding: 2px 10px; font-size: 1rem; }

/* ---- tabs ------------------------------------------------------------------ */
.tab-navigation { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 24px; border-bottom: 2px solid var(--line); padding-top: 8px; padding-bottom: 8px; }
.tab-btn {
  position: relative; white-space: nowrap;
  font-family: 'Permanent Marker', cursive; font-size: 1.15rem;
  background: none; border: none; cursor: pointer; color: var(--ink-soft);
  padding: 8px 16px; border-radius: 8px 8px 0 0; transition: all .12s ease;
}
.tab-btn:hover { color: var(--ink); background: rgba(37,99,235,0.06); }
.tab-btn.active { color: var(--marker-blue); background: #e9efff; box-shadow: none; }
.tab-btn.active::after { content: ''; position: absolute; bottom: -3px; left: 12px; right: 12px; height: 3px; border-radius: 50%; background: var(--marker-blue); }
.tab-icon { margin-right: 6px; }

/* This Friday's lift: a small sticky note on its board's top corner (taking no room from the
   board), or one line on Other Lifts. */
.leaderboard-section h2 .friday-tag { position: absolute; top: -12px; right: 18px; }
.friday-tag {
  display: inline-block; padding: 1px 8px 2px; vertical-align: middle; white-space: nowrap;
  font: 700 .66rem/1.5 system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--note-ink);
  background: var(--note); border-radius: 2px 2px 8px 2px; box-shadow: 1px 2px 4px rgba(120,90,0,.14); transform: rotate(-2deg);
}
.friday-callout { margin: -6px 0 18px; font-family: 'Indie Flower', cursive; font-size: 1.1rem; color: var(--ink-soft); }
.friday-callout .friday-tag { margin: 0 6px 0 0; }

/* While ranking by bodyweight: how the boards are adjusted. */
.mode-note { margin: -10px 0 20px; font-family: 'Indie Flower', cursive; font-size: 1.05rem; color: var(--ink-soft); }
.mode-note strong { color: var(--marker-blue); }
.tab-content { display: none; }
.tab-content:focus { outline: none; } /* the skip link lands here; no ring around a whole tab */
.tab-content.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- boards ---------------------------------------------------------------- */
.leaderboards {
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  align-items: start;
}
#lifts-tab .leaderboards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#other-tab .leaderboards { grid-template-columns: repeat(2, minmax(0, 1fr)); } /* four boards, two by two */
#total-tab .leaderboard-section, #cardio-tab .leaderboard-section, #latest-tab .leaderboard-section { width: 100%; max-width: 820px; margin: 0 auto; }
.leaderboard-section {
  position: relative; min-width: 0; background: rgba(255,255,255,.85); border: 2px solid var(--ink);
  border-radius: var(--radius); padding: 20px 16px 12px;
  box-shadow: var(--shadow);
  transform: rotate(-0.3deg);
}
.leaderboard-section:nth-child(2) { transform: rotate(0.4deg); }
.leaderboard-section:nth-child(3) { transform: rotate(-0.2deg); }
.leaderboard-total { transform: none; }
.leaderboard-section h2 {
  font-family: 'Permanent Marker', cursive; font-size: 1.5rem; color: var(--ink);
  margin-bottom: 12px; padding-bottom: 12px; border-bottom: 2px solid var(--line);
}
.leaderboard-section:is([data-lift="bench"], [data-lift="bw-bench"]) h2 { color: var(--marker-blue); }
.leaderboard-section:is([data-lift="squat"], [data-lift="bw-squat"]) h2 { color: #865023; }
.leaderboard-section:is([data-lift="deadlift"], [data-lift="bw-deadlift"]) h2 { color: #62518c; }

.leaderboard-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.leaderboard-table th {
  font-family: 'Indie Flower', cursive; font-size: 1rem; text-transform: uppercase;
  letter-spacing: 1px; color: var(--ink-soft); text-align: left;
  padding: 6px; border-bottom: 2px solid var(--line);
}
.leaderboard-table td { padding: 9px 6px; border-bottom: 1px dashed var(--line); }
.leaderboard-table th:last-child, .leaderboard-table td:last-child { text-align: right; }
.leaderboard-table tr:last-child td { border-bottom: none; }
.leaderboard-table td.empty-state { text-align: center; padding: 32px 8px; }
.leaderboard-table th:first-child { width: 3.5rem; }
.leaderboard-table th:last-child { width: 6rem; }
#totalTable th:last-child, [data-lift^="bw-"] .leaderboard-table th:last-child { width: 7rem; }
.leaderboard-table td:nth-child(2) { overflow-wrap: anywhere; }
.leaderboard-table tbody tr:hover { background: #2563eb06; }
.rank { font-weight: 700; font-size: 1.25rem; }
.athlete-name { font-size: 1.3rem; font-weight: 600; }
.pr-value { font-size: 1.4rem; font-weight: 700; color: var(--marker-blue); }
.pr-value, .podium-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The signed-in member's own entries get a highlighter stroke. */
.is-me .athlete-link, .athlete-link.is-me { background: var(--highlighter); }
.achievement-badge.is-me { border-color: var(--marker-blue); }

/* Latest verified PRs */
.latest-table th:first-child { width: auto; }
.latest-table th:last-child { width: 9rem; }
.latest-who { display: flex; align-items: center; gap: 10px; }
.latest-who > svg { flex: 0 0 auto; }
.latest-who > span { display: flex; flex-direction: column; min-width: 0; }
.latest-who .athlete-link { align-self: flex-start; font-size: 1.25rem; font-weight: 600; overflow-wrap: anywhere; }
.latest-lift { font-family: 'Indie Flower', cursive; font-size: 1rem; color: var(--ink-soft); }
.latest-when { white-space: nowrap; }
.latest-table .delta { display: block; width: max-content; margin: 2px 0 0 auto; }

/* athlete name as a history link */
.athlete-link {
  font-family: inherit; font-size: inherit; font-weight: inherit; color: inherit;
  background: none; border: none; padding: 0; cursor: pointer;
  text-decoration: underline; text-decoration-style: dotted;
  text-decoration-color: var(--line); text-underline-offset: 3px;
  text-align: inherit; transition: color .12s ease, text-decoration-color .12s ease;
}
.athlete-link:hover { color: var(--marker-blue); text-decoration-color: var(--marker-blue); }
.podium-name .athlete-link { text-decoration: none; }
.podium-name .athlete-link:hover { color: var(--marker-blue); }

/* ---- podium ---------------------------------------------------------------- */
.podium-container {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 8px; margin: 18px 0 14px; flex-wrap: nowrap;
}
.podium-spot { display: flex; flex-direction: column; align-items: center; width: 33%; max-width: 200px; min-width: 0; }
.podium-athlete { display: flex; flex-direction: column; align-items: center; width: 100%; margin-bottom: 6px; }
.podium-avatars { display: flex; align-items: flex-end; justify-content: center; height: 80px; width: 100%; }
.podium-avatars svg { max-width: 100%; min-width: 0; }
.tie-join { font-size: 1rem; color: var(--ink-soft); }
.podium-medal { margin-top: -6px; line-height: 0; }
.medal-svg { display: block; }
.podium-name { max-width: 100%; overflow-wrap: anywhere; font-size: 1.3rem; font-weight: 700; line-height: 1.25; text-align: center; }
.podium-value { margin-top: 3px; font-size: 1.15rem; color: var(--ink-soft); }
.podium-stand {
  width: 100%; border: 2px solid var(--ink); border-bottom: none;
  border-radius: 6px 8px 0 0; display: flex; align-items: flex-start;
  justify-content: center; padding: .25rem; color: #473e32;
  font-family: 'Permanent Marker', cursive; font-size: 1.8rem; line-height: 1;
  min-height: calc(1em + .5rem + 2px);
}
/* Steps and lettering share a scale, including Chrome zoom and TV root sizing. */
.podium-spot.first  .podium-stand { height: 5.375rem; background: var(--gold);   border-color: #d99e16; }
.podium-spot.second .podium-stand { height: 3.875rem; background: var(--silver); border-color: #94a3b8; }
.podium-spot.third  .podium-stand { height: 2.75rem; background: var(--bronze); border-color: #b06a44; }
.podium-spot.first  { order: 2; }
.podium-spot.second { order: 1; }
.podium-spot.third  { order: 3; }

/* ---- planner (a dialog): a week of planned sessions ------------------------- */
/* The week lays itself out by the room the dialog gives it, not by the screen. */
.planner { container: planner / inline-size; }
.planner-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.planner-nav { display: flex; align-items: center; gap: 10px; }
.planner-title { font-family: 'Permanent Marker', cursive; font-size: 1.6rem; color: var(--marker-blue); min-width: 11ch; text-align: center; }
.planner-span { display: block; font: 600 .78rem/1.4 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.planner-step { font-size: 1.6rem; line-height: 1; padding: 4px 14px; }
.planner-notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 12px 18px; font-size: 1.2rem;
  background: #eff6ff; border: 2px dashed var(--marker-blue); border-radius: 12px;
}
.planner-notice.warning { background: #fff7ed; border-color: var(--marker-amber); color: #9a3412; }
.planner-loading { margin-bottom: 16px; color: var(--ink-soft); }
.planner-week { list-style: none; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.planner-day {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 190px;
  padding: 10px 10px 12px; background: var(--panel); border: 2px dashed var(--line); border-radius: 12px;
}
.planner-day.today { border: 2px solid var(--marker-blue); background: #f5f8ff; }
.planner-day.friday { background: #fffbe6; }
.planner-day.past { opacity: .55; }
.planner-day-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.planner-weekday { font-family: 'Permanent Marker', cursive; font-size: 1.2rem; }
.planner-date { font-family: 'Caveat', cursive; font-size: 1.15rem; color: var(--ink-soft); }
.planner-today { margin-left: auto; font: 700 .65rem/1.6 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .12em; color: var(--marker-blue); }
.friday-chip {
  align-self: flex-start; justify-self: start; max-width: 100%; padding: 2px 10px 4px; font-family: 'Permanent Marker', cursive; font-size: 1rem; line-height: 1.3;
  background: var(--note); border-radius: 2px 2px 10px 2px; transform: rotate(-1deg); box-shadow: 1px 2px 4px rgba(120,90,0,.14);
}
/* In the planner, members join the Friday lift from its note. */
.friday-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 4px 10px 8px; }
.friday-card .plan-activity { font-family: inherit; font-size: 1rem; font-weight: 400; }
.friday-card-who { font-family: 'Caveat', cursive; font-size: 1.05rem; font-weight: 600; color: var(--marker-green); overflow-wrap: anywhere; }
.friday-card.joined { box-shadow: 0 0 0 2px var(--marker-green), 1px 2px 4px rgba(120,90,0,.14); }
.friday-chip-label { display: block; font: 700 .6rem/1.6 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .14em; color: var(--note-ink); }
.planner-plans { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.plan-card { position: relative; min-width: 0; padding: 8px 10px; background: #fff; border: 2px solid var(--line); border-radius: 10px; box-shadow: 1px 1px 0 rgba(0,0,0,.05); }
.plan-card.mine { border-color: var(--marker-blue); }
.plan-card.joined { border-color: var(--marker-green); background: #f3fbf5; }
.plan-card.over { opacity: .7; border-style: dashed; }
.plan-what { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; line-height: 1.25; }
.plan-time { font: 700 .85rem/1.5 system-ui, sans-serif; font-variant-numeric: tabular-nums; color: var(--marker-blue); }
/* The title opens the session, like a name opens an athlete's story. */
.plan-activity {
  font: inherit; font-size: 1.25rem; font-weight: 700; color: inherit; text-align: left; overflow-wrap: anywhere;
  background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline dotted var(--line); text-underline-offset: 3px;
}
.plan-activity:hover { color: var(--marker-blue); text-decoration-color: var(--marker-blue); }
.plan-note { margin-top: 2px; font-family: 'Indie Flower', cursive; font-size: .98rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.plan-people { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-top: 4px; font-size: 1.1rem; }
.plan-host { display: inline-flex; align-items: center; gap: 4px; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.plan-host svg { flex: 0 0 auto; }
.plan-joiners { min-width: 0; color: var(--marker-green); font-weight: 600; overflow-wrap: anywhere; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.plan-remove {
  position: absolute; top: 2px; right: 4px; width: 26px; height: 26px; padding: 0; font-size: 1.2rem; line-height: 1;
  color: var(--ink-soft); background: none; border: 0; border-radius: 50%; cursor: pointer; opacity: .55;
}
.plan-remove:hover, .plan-remove:focus-visible { color: var(--marker-red); opacity: 1; }
.plan-card:has(.plan-remove) .plan-what { padding-right: 18px; }
.plan-join { background: #fff; color: var(--marker-green); border-color: var(--marker-green); }
.plan-join.joined { background: var(--marker-green); color: #fff; }
/* One session: who comes when, and the time you'll come. */
.plan-session { max-width: 560px; }
.session-eyebrow { margin-top: 12px; }
.session-eyebrow + .session-title { margin-top: 0; }
.session-title { margin-top: 12px; font-family: 'Permanent Marker', cursive; font-size: 1.5rem; overflow-wrap: anywhere; }
.session-title:focus { outline: none; }
.session-when { font: 600 .85rem/1.6 system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.session-people { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.session-people li { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; }
.session-people li svg { flex: 0 0 auto; }
.session-people .plan-time { min-width: 3.2em; }
.session-name { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.session-people .is-me .session-name { background: var(--highlighter); }
.join-form { padding-top: 12px; border-top: 2px dashed var(--line); }
.join-form .form-group input { max-width: 12rem; }
.join-form .field-hint { display: block; color: var(--ink-soft); }
.planner-add {
  margin-top: auto; padding: 4px; font-family: 'Caveat', cursive; font-size: 1.15rem; font-weight: 700; color: var(--ink-soft);
  background: none; border: 2px dashed var(--line); border-radius: 10px; cursor: pointer;
}
.planner-add:hover { color: var(--marker-blue); border-color: var(--marker-blue); }
.planner-empty { color: var(--ink-soft); font-family: 'Indie Flower', cursive; font-size: 1rem; }
.plan-form { max-width: 560px; }
/* Too narrow for seven columns: each day becomes a row, its sessions side by side. */
@container planner (max-width: 1060px) {
  .planner-week { grid-template-columns: 1fr; }
  .planner-day { min-height: 0; display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 8px 14px; align-items: start; }
  .planner-day > :not(.planner-day-head) { grid-column: 2; }
  .planner-day-head { grid-row: 1 / span 3; flex-direction: column; border-bottom: 0; padding-bottom: 0; }
  .planner-today { margin-left: 0; }
  .planner-plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
  .planner-add { justify-self: start; margin-top: 0; padding: 2px 16px; }
}
/* Phone width: one column, each day's heading on top. */
@container planner (max-width: 520px) {
  .planner-day { grid-template-columns: 1fr; }
  .planner-day > :not(.planner-day-head) { grid-column: 1; }
  .planner-day-head { grid-row: auto; flex-direction: row; }
  .planner-today { margin-left: auto; }
  .planner-head > .btn { width: 100%; }
}

/* ---- hints and empty states ------------------------------------------------ */
.hint { text-align: center; color: var(--ink-soft); font-family: 'Indie Flower', cursive; font-size: 1.05rem; margin-top: 18px; }
.empty-state { text-align: center; color: var(--ink-soft); padding: 40px 8px; font-size: 1.15rem; }
.empty-state span { font-size: 1rem; }

/* ---- dialogs: native <dialog> opened with showModal() ----------------------- */
/* The dialog is a transparent full-viewport scroller; clicks on it (outside the
   card) close it, and the ::backdrop dims the inert page behind. */
.modal {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 24px; border: 0; background: transparent; color: inherit;
  overflow-y: auto; overscroll-behavior: contain;
}
.modal::backdrop { background: rgba(15,23,42,0.45); }
.modal-content {
  background: var(--whiteboard); border: 2px solid var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-width: 640px; margin: 3vh auto; padding: 26px; position: relative;
  animation: popIn .2s ease;
}
.modal-content:focus { outline: none; }
.modal-large { max-width: 760px; }
.modal-wide { max-width: 1400px; }
@keyframes popIn { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-content h2 { padding-right: 36px; font-family: 'Permanent Marker', cursive; font-size: 1.8rem; margin-bottom: 18px; color: var(--marker-blue); }
.close {
  position: absolute; top: 14px; right: 18px; font-size: 1.8rem; cursor: pointer;
  color: var(--ink-soft); line-height: 1; background: transparent; border: 0; width: 40px; height: 40px;
}
.close:hover { color: var(--marker-red); }
.modal-intro { color: var(--ink-soft); font-size: 1.1rem; margin-bottom: 16px; }

/* ---- forms ----------------------------------------------------------------- */
.form-body { display: flex; gap: 22px; flex-wrap: wrap; }
.form-fields { flex: 1 1 320px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1 1 90px; display: flex; flex-direction: column; min-width: 0; }
.form-row .form-group label { flex: 1; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 1.15rem; font-weight: 600; margin-bottom: 4px; color: var(--ink-soft); }
.form-group input, .form-group textarea {
  width: 100%; font-family: 'Caveat', cursive; font-size: 1.25rem;
  padding: 8px 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.form-group textarea { resize: vertical; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--marker-blue); }
.plan-friday { margin: -10px 0 8px; }
.form-section-title { font-family: 'Permanent Marker', cursive; font-size: 1.2rem; margin: 8px 0 10px; }
.lift-fields { border: 0; min-width: 0; }
.lift-fields legend { padding: 0; }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.form-grid .form-group { display: flex; flex-direction: column; min-width: 0; margin-bottom: 4px; }
.form-grid .form-group label { flex: 1; }
.unit { font-weight: 400; font-size: .95em; white-space: nowrap; }
.field-hint { min-height: 1.3em; margin-top: 2px; font-family: 'Indie Flower', cursive; font-size: .95rem; color: var(--marker-blue); }
.field-note { margin: 4px 0 8px; font-family: 'Indie Flower', cursive; font-size: .95rem; color: var(--ink-soft); }
.form-divider-or { text-align: center; color: var(--ink-soft); font-family: 'Indie Flower', cursive; margin: 10px 0; }
.achievement-fields { display: flex; flex-direction: column; gap: 8px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; cursor: pointer; }
.form-check input { width: 18px; height: 18px; accent-color: var(--marker-blue); }
.claim-select, .user-controls select {
  width: 100%; font-family: 'Caveat', cursive; font-size: 1.2rem;
  padding: 8px 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
.avatar-preview-container {
  flex: 0 0 150px; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; gap: 6px; padding-top: 6px;
}
.avatar-preview {
  border: 2px dashed var(--line); border-radius: 12px; padding: 10px;
  background: #fff; line-height: 0;
}
.avatar-note { font-family: 'Indie Flower', cursive; font-size: .95rem; color: var(--ink-soft); text-align: center; }
.form-actions { display: flex; gap: 12px; margin-top: 18px; }
/* The signed-in member's own pending requests, with Withdraw buttons. */
.own-requests { margin-bottom: 16px; padding: 10px 14px; border: 2px dashed var(--line); border-radius: 12px; background: var(--panel); }
.own-requests .form-section-title { margin-top: 0; }
.request-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.request-list li { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; font-size: 1.15rem; }
.btn-small { padding: 2px 12px; font-size: 1.05rem; }

/* ---- review queue, members and athlete management -------------------------- */
.review-list, .users-list { display: flex; flex-direction: column; gap: 10px; max-height: 62vh; overflow-y: auto; }
.review-row, .user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; flex-wrap: wrap;
}
.review-desc { font-size: 1.2rem; }
.review-desc .by { color: var(--ink-soft); font-size: 1rem; }
.review-actions, .user-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.user-controls select { width: auto; min-width: 150px; }
.user-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 1.2rem; }
.linked-to { color: var(--ink-soft); font-size: 1rem; margin-left: 6px; }
.review-list .form-section-title:not(:first-child) { margin-top: 14px; }
.delta { font-family: 'Indie Flower', cursive; font-size: .95rem; padding: 0 8px; border-radius: 999px; white-space: nowrap; }
.list-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.list-filter {
  flex: 1 1 180px; font-family: 'Caveat', cursive; font-size: 1.2rem; color: var(--ink);
  padding: 7px 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
.list-filter:focus { outline: none; border-color: var(--marker-blue); }

.athletes-list { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; }
.athlete-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 12px 16px;
}
.athlete-card-avatar { flex: 0 0 auto; line-height: 0; }
.athlete-card-info { flex: 1; }
.athlete-card-info h3 { font-size: 1.4rem; }
.athlete-stats { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-soft); font-size: 1.1rem; }
.athlete-card-actions { display: flex; gap: 8px; }
.athlete-card.archived { border-style: dashed; opacity: .85; }
.archived-list .athlete-card { margin-top: 12px; }
.archived-list summary {
  cursor: pointer; padding: 6px 2px; font-family: 'Indie Flower', cursive; font-size: 1.1rem; color: var(--ink-soft);
}

/* ---- hall of fame ---------------------------------------------------------- */
.fun-lifts-container { display: flex; flex-direction: column; gap: 24px; }
.achievement-section {
  background: var(--panel); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); min-width: 0;
}
.achievement-section h2 { font-family: 'Permanent Marker', cursive; font-size: 1.7rem; margin-bottom: 6px; }
.achievement-description { color: var(--ink-soft); font-size: 1.2rem; margin-bottom: 18px; }
.hall-of-fame { display: flex; flex-wrap: wrap; gap: 18px; }
.achievement-badge {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #fff; border: 2px solid var(--marker-amber); border-radius: 12px;
  padding: 12px 16px; min-width: 120px; max-width: 100%;
}
.badge-avatar { line-height: 0; }
.badge-name { font-size: 1.25rem; font-weight: 700; max-width: 100%; overflow-wrap: anywhere; text-align: center; }
.badge-subtitle { font-family: 'Indie Flower', cursive; font-size: 1rem; color: var(--marker-amber); }
.empty-achievement { color: var(--ink-soft); font-size: 1.2rem; }
.achievement-count { margin-top: 16px; font-family: 'Indie Flower', cursive; color: var(--ink-soft); }

/* ---- history / progression ------------------------------------------------- */
.history-body { display: flex; flex-direction: column; gap: 18px; max-height: 66vh; overflow-y: auto; }
.history-lift {
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.history-lift-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.history-lift-head h3 { font-family: 'Permanent Marker', cursive; font-size: 1.3rem; }
.history-delta { font-family: 'Indie Flower', cursive; font-size: 1.1rem; padding: 1px 10px; border-radius: 999px; }
.sparkline {
  width: 100%; height: auto; margin: 10px 0 6px; display: block;
  overflow: visible;
}
.sparkline .spark-line { fill: none; stroke: var(--marker-blue); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.sparkline circle { fill: #fff; stroke: var(--marker-blue); stroke-width: 2.5; }
.history-points {
  list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px;
  font-family: 'Indie Flower', cursive; color: var(--ink-soft); font-size: 1.05rem;
}
.history-points li { display: flex; gap: 6px; align-items: baseline; }
.history-points .hist-val { font-family: 'Caveat', cursive; font-weight: 700; color: var(--ink); font-size: 1.15rem; }
.history-note { margin-top: 8px; font-family: 'Indie Flower', cursive; font-size: 1rem; color: var(--ink-soft); }

/* ---- changelog ------------------------------------------------------------- */
.changelog { display: flex; flex-direction: column; gap: 16px; max-height: 66vh; overflow-y: auto; }
.changelog-release { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.changelog-release h3 { font-family: 'Permanent Marker', cursive; font-size: 1.25rem; margin-bottom: 6px; }
.changelog-date { margin-left: 8px; font-family: 'Indie Flower', cursive; font-size: 1rem; font-weight: 400; color: var(--ink-soft); }
.changelog-release ul { padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 1.15rem; }

/* ---- banners and toasts ---------------------------------------------------- */
.notice-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  background: #eff6ff; border: 2px solid var(--marker-blue); border-radius: 12px;
  padding: 12px 18px; margin-bottom: 20px; font-size: 1.2rem;
}
.config-banner {
  background: #fff7ed; border: 2px solid var(--marker-amber); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 20px; font-size: 1.15rem; color: #9a3412;
}
.config-banner code { background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 5px; font-family: monospace; font-size: .95rem; }
.toast-region { position: fixed; bottom: 24px; right: 24px; z-index: 200; max-width: calc(100vw - 48px); }
.toast {
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 1.2rem; box-shadow: var(--shadow-lg); animation: slideInRight .3s ease;
}
.toast.leaving { animation: slideInRight .3s ease reverse forwards; }
.toast.celebrate { background: var(--gold); color: var(--ink); border: 2px solid #d99e16; font-family: 'Permanent Marker', cursive; }
.toast.success { background: var(--marker-green); }
.toast.error   { background: var(--marker-red); }
@keyframes slideInRight { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- responsive ------------------------------------------------------------ */
@media (max-width: 960px) {
  #lifts-tab .leaderboards, #other-tab .leaderboards { grid-template-columns: 1fr; }
  .leaderboard-section { transform: none !important; }
  .header-actions { padding-top: 0; }
  .podium-spot { max-width: 180px; }
  .tab-navigation { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tab-navigation::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 8px 12px; }
}
@media (max-width: 600px) {
  body { padding: 14px; }
  header { margin-bottom: 16px; }
  .header-top { flex-direction: column; gap: 10px; }
  .eyebrow { margin-bottom: 4px; }
  html:not(.tv-mode) .tv-toggle { display: none; }
  .auth-user { font-size: 1.05rem; padding: 2px 10px; }
  .header-actions .btn { font-size: 1.05rem; padding: 4px 12px; }
  .toolbar { gap: 14px; margin-bottom: 14px; }
  .controls { gap: 8px; }
  .next-lift { width: 100%; transform: rotate(-0.5deg); }
  .next-lift-name { font-size: 1.4rem; }
  .next-session { width: 100%; max-width: none; }
  .next-lift > :nth-child(2):not(.btn, .compact) { width: 100%; padding: 8px 0 0; border-left: 0; border-top: 2px dashed var(--note-rule); }
  .next-lift > :nth-child(2).compact { padding-left: 0; border-left: 0; flex-direction: row; align-items: center; gap: 6px; }
  .controls .btn { font-size: 1.05rem; padding: 6px 12px; }
  .toast-region { left: 14px; right: 14px; bottom: 14px; max-width: none; }
  .header-titles h1 { font-size: 1.85rem; gap: 8px; }
  .header-titles h1 img { width: 36px; height: 36px; }
  .subtitle { font-size: 1.05rem; }
  .tab-btn { font-size: 1rem; padding: 10px 12px; }
  .tab-icon { display: none; }
  .auth-area { flex-wrap: wrap; }
  .podium-name { font-size: 1.1rem; }
  .form-body { flex-direction: column-reverse; }
  .form-fields { flex-basis: auto; width: 100%; min-width: 0; }
  .modal { padding: 10px; }
  .modal-content { padding: 18px; margin: 12px auto; }
  .modal-content h2 { font-size: 1.5rem; }
  .athlete-card { flex-wrap: wrap; }
  .athlete-card-info { min-width: 0; }
  .athlete-card-actions { margin-left: auto; }
  .avatar-preview-container { flex-basis: auto; flex-direction: row; justify-content: center; padding: 0; }
  .avatar-preview { padding: 0; border: 0; background: none; }
  .avatar-preview svg { width: 64px; height: 80px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ===========================================================================
   TV / display mode (html.tv-mode) — full-screen landscape board that uses the
   horizontal space and auto-cycles tabs hands-free. Toggled by ?tv or the 📺
   button; rotation, paging and the countdown bar are driven from js/tv.js.
   =========================================================================== */
/* Scale every rem-based size up for across-the-room reading; adapts 1080p→4K. */
html.tv-mode { font-size: clamp(18px, 1.15vw, 30px); }
/* Fit the viewport exactly — clip, never scroll. */
html.tv-mode, .tv-mode body { height: 100vh; overflow: hidden; }
.tv-mode body { padding: 18px 28px; }
.tv-mode .container { max-width: none; height: 100%; margin: 0; display: flex; flex-direction: column; }

/* A TV is read-only — drop the interactive chrome and tap hints. */
.tv-mode .controls,
.tv-mode .next-lift,
.tv-mode .auth-area,
.tv-mode .bodyweight-toggle,
.tv-mode .mode-note,
.tv-mode .subtitle,
.tv-mode .hint,
.tv-mode .eyebrow,
.tv-mode .board-meta { display: none; }
/* Keep connection trouble visible on an unattended display; use the paging reserve. */
.tv-mode .board-meta.connection-warning {
  display: flex; position: fixed; right: 28px; bottom: 6px; z-index: 10;
  max-width: calc(100% - 56px); padding: 3px 8px; border: 0;
  border-radius: 6px; background: var(--whiteboard); font-size: .65rem;
}
.tv-mode .board-meta #athleteCount, .tv-mode .changelog-link { display: none; }

/* Compact header so the board claims the height. */
.tv-mode header { margin-bottom: 12px; }
.tv-mode .header-titles h1 { font-size: 2.4rem; }
/* The Friday note as one sticky line in the header (clear of the exit button): this Friday's
   lift, and on a TV signed in as a member the next session too, as on the note. */
.tv-mode .header-top { flex-wrap: nowrap; }
.tv-mode .header-titles { flex: 0 0 auto; }
.tv-mode .tv-next-lift {
  display: flex; align-self: center; min-width: 0; overflow: hidden; margin: 0 11rem 0 auto;
  padding: 4px 18px 6px; font-family: 'Permanent Marker', cursive; font-size: 1.7rem; color: var(--ink);
  background: var(--note-paper); border-radius: 2px 2px 14px 2px;
  box-shadow: 3px 6px 12px rgba(120,90,0,.16); transform: rotate(-1deg);
}
.tv-mode .tv-note { display: flex; align-items: center; gap: 2px 22px; min-width: 0; }
.tv-mode .tv-part { display: flex; align-items: baseline; gap: .4em; flex: 0 0 auto; white-space: nowrap; }
.tv-mode .tv-session { flex-shrink: 1; min-width: 0; }
.tv-mode .tv-part + .tv-part { padding-left: 22px; border-left: 2px dashed var(--note-rule); }
.tv-mode .tv-next-lift-when { font: 700 .75rem/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .14em; color: var(--note-ink); }
.tv-mode .tv-session:not(.lead), .tv-mode .tv-friday.compact { font-size: 1.25rem; }
.tv-mode .tv-friday.compact { flex-direction: column; align-items: center; gap: 2px; }
.tv-mode .tv-session-what { flex: 0 1 auto; min-width: 2em; overflow: hidden; text-overflow: ellipsis; }
.tv-mode .tv-session-who { font-family: 'Indie Flower', cursive; font-size: .65em; color: var(--note-soft); }
/* Narrower TVs: the Friday lift and a session after it stack, so the note stays beside the title. */
@media (max-width: 1500px) {
  .tv-mode .tv-note.friday-first { flex-direction: column; align-items: flex-start; }
  .tv-mode .tv-note.friday-first .tv-part + .tv-part { padding-left: 0; border-left: 0; }
}

/* The 📺 button becomes a faint, always-available exit in the corner. */
.tv-mode .tv-toggle { position: fixed; top: 12px; right: 12px; z-index: 50; opacity: 0.2; transition: opacity .15s ease; }
.tv-mode .tv-toggle:hover { opacity: 1; }

/* Tab strip → centered indicator with a per-tab countdown bar. */
.tv-mode .tab-navigation { justify-content: center; gap: 18px; margin-bottom: 16px; }
.tv-mode .tab-btn { font-size: 1.5rem; overflow: hidden; }
.tv-mode .tab-btn.active::after { left: 0; bottom: 0; height: 4px; width: 0; }
.tv-mode .tab-btn.active.rotating::after { animation: tvProgress var(--rotate-ms, 15000ms) linear var(--rotate-delay, 0ms) forwards; }
@keyframes tvProgress { from { width: 0; } to { width: 100%; } }

/* Active tab fills the remaining height and clips rather than scrolls. */
.tv-mode .tab-content.active { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.tv-mode .leaderboards { align-content: start; padding-top: 14px; } /* room for a board's Friday sticker */
.tv-mode .leaderboard-section { transform: none; }
.tv-mode .hall-table th, .tv-mode .hall-table td { width: auto; text-align: left; overflow-wrap: anywhere; }
.tv-mode .hall-of-fame { justify-content: center; }
.tv-mode .badge-name { font-size: 1.35rem; }

/* Main lifts: three equal columns, each board with its own podium. */
.tv-mode #lifts-tab .leaderboards { grid-template-columns: repeat(3, 1fr); gap: 28px; }
/* Other lifts: every board in one row, since paging needs that. Four boards share the width,
   so below ~1565px wide, where the 18px root minimum would crowd them, the lettering and
   columns shrink with the screen (min(1rem, 1.15vw) is the root size without that minimum). */
.tv-mode #other-tab { --tv-scale: min(1rem, 1.15vw); }
.tv-mode #other-tab .leaderboards { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 20px; }
.tv-mode #other-tab .leaderboard-section h2 { font-size: calc(1.6 * var(--tv-scale)); }
.tv-mode #other-tab .athlete-name { font-size: calc(1.5 * var(--tv-scale)); }
.tv-mode #other-tab .pr-value { font-size: calc(1.7 * var(--tv-scale)); }
.tv-mode #other-tab .podium-name { font-size: calc(1.45 * var(--tv-scale)); }
.tv-mode #other-tab .podium-value { font-size: calc(1.15 * var(--tv-scale)); }
.tv-mode #other-tab .leaderboard-table th:first-child { width: calc(3.5 * var(--tv-scale)); }
.tv-mode #other-tab .leaderboard-table th:last-child { width: calc(7 * var(--tv-scale)); }
/* Cardio: centered, capped width so a lone board doesn't sprawl; several tile. */
.tv-mode #cardio-tab .leaderboards { display: flex; justify-content: center; gap: 28px; }
.tv-mode #cardio-tab .leaderboard-section { flex: 1 1 420px; max-width: 760px; }
/* Total: prominent podium + a big centered table (don't stretch one column wide). */
.tv-mode #total-tab .leaderboards { display: block; }
.tv-mode #total-tab .leaderboard-section, .tv-mode #latest-tab .leaderboard-section { max-width: 70vw; margin: 0 auto; }
/* A PR verified while the TV is on gets a big, friendly banner. */
.tv-mode .toast-region { left: 50%; right: auto; top: 18px; bottom: auto; transform: translateX(-50%); }
.tv-mode .toast.celebrate { font-size: 2rem; padding: 14px 32px; }

/* Hall of Fame tiles across the width (centered so a lone section doesn't sprawl). */
.tv-mode .fun-lifts-container { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 24px; align-content: start; }
.tv-mode .achievement-section { flex: 1 1 420px; max-width: 900px; background: rgba(255,255,255,.85); padding: 20px 16px 12px; }

/* A touch bigger for legibility from a distance. */
.tv-mode .leaderboard-section h2 { font-size: 1.9rem; }
.tv-mode .athlete-name { font-size: 1.5rem; }
.tv-mode .pr-value { font-size: 1.7rem; }
.tv-mode .leaderboard-table td { padding: 6px 10px; }
.tv-mode .podium-name { font-size: 1.45rem; }

/* Keep the podium, but trim its footprint in TV mode so more ranked rows fit beside it.
   Shorter stands and a tighter stack here; BoardView.podium draws smaller figures and
   medals on TV. It shows on a board's first page only (js/tv.js). */
.tv-mode .podium-avatars { height: 60px; }
.tv-mode .podium-athlete { margin-bottom: 2px; }
.tv-mode .podium-medal { margin-top: -4px; }
.tv-mode .podium-stand { font-size: 1.4rem; }
.tv-mode .podium-spot.first  .podium-stand { height: 3.6rem; }
.tv-mode .podium-spot.second .podium-stand { height: 2.8rem; }
.tv-mode .podium-spot.third  .podium-stand { height: 2rem; }

/* The latest verified PRs: one quiet line along the bottom of every tab. Items that don't fit
   wrap onto a second line, which is clipped out of sight. */
.tv-latest { display: none; }
/* fit() withdraws it on a tab whose rows would not fit beside it (see js/tv.js). */
html.tv-latest-withdrawn .tv-latest { display: none; }
/* If a row still can't fit, the achievement badges after names go too (see js/tv.js). */
html.tv-mode.tv-badges-withdrawn .achievement-chip { display: none; }
.tv-mode .tv-latest {
  display: flex; align-items: center; gap: 18px; flex: 0 0 auto; height: 2.6rem; margin-top: 6px; padding: 0 4px; overflow: hidden;
  border-top: 2px dashed var(--line); color: var(--ink-soft);
}
.tv-latest-label { flex: 0 0 auto; font: 700 .72rem/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .14em; color: #b45309; }
.tv-latest-list { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0 28px; flex: 1 1 auto; min-width: 0; height: 2.6rem; overflow: hidden; }
.tv-latest-item { display: flex; align-items: center; gap: 7px; height: 2.6rem; white-space: nowrap; font-size: 1.15rem; }
.tv-latest-item svg { flex: 0 0 auto; }
/* Long names end in an ellipsis; the padding keeps the handwriting's overhanging strokes (the
   "d" in Hallvard) inside the clipped box. */
.tv-latest-name { max-width: 14em; overflow: hidden; text-overflow: ellipsis; padding: .2em .25em .2em .1em; font-weight: 700; color: var(--ink); }
.tv-latest-lift { font-weight: 700; color: var(--marker-blue); font-variant-numeric: tabular-nums; }
.tv-latest-when { font-family: 'Indie Flower', cursive; font-size: .9em; }

/* Page dots: shown when a tab's roster spans more than one screen. The rotation
   cycles a page per tick before advancing to the next tab; the active dot tracks
   which slice is on screen. TvDisplay.PAGE_PAD (js/tv.js) reserves the room below. */
.tv-page-dots { position: absolute; left: 0; right: 0; bottom: 8px; display: flex; justify-content: center; gap: 12px; }
.tv-page-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); opacity: 0.4; }
.tv-page-dot.active { background: var(--marker-blue); border-color: var(--marker-blue); opacity: 1; }
