/* Structure shared by every theme. Themes (css/themes/*.css) add look and feel on top.
   Charts and the heatmap use --chart (defaults to the text colour) and --grid, so they
   pick up each theme without the theme having to know about them. */

:root {
  --chart: currentColor;
  --grid: color-mix(in srgb, currentColor 18%, transparent);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
[hidden] { display: none !important; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.frame { max-width: 760px; margin: 0 auto; padding: 24px 16px 32px; }

/* Masthead */
.masthead { text-align: center; }
.title { margin: 0; }
.title a { color: inherit; text-decoration: none; }
.ticker { display: none; overflow: hidden; white-space: nowrap; }
.ticker span { display: inline-block; padding-left: 100%; animation: ticker 60s linear infinite; }
@keyframes ticker { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .ticker span { animation: none; padding-left: 0; } }

.periods { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 16px; }
.periods select { padding: 6px 8px; border: 1px solid currentColor; border-radius: 4px; background: transparent; max-width: 60vw; }
.periods select option { color: #000; background: #fff; }

/* Panels */
.panel { margin-top: 32px; }
.panel-title { margin: 0 0 12px; }
.panel h3 { margin: 20px 0 8px; }
.note { margin: 0 0 8px; opacity: .75; font-size: .9em; }
.empty { opacity: .75; }

/* Tables */
.board { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.board th, .board td { padding: 6px; text-align: left; }
.board .num { text-align: right; }
.board .rank { width: 2.5em; }
.board a { color: inherit; text-decoration: none; }
.board a:hover { text-decoration: underline; }
.board th button { all: unset; cursor: pointer; }
.board th button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.board th[aria-sort="descending"] button::after { content: " ▾"; }
.board th[aria-sort="ascending"] button::after { content: " ▴"; }

/* Player card */
.player { display: grid; gap: 12px; }
.avatar { display: none; }
.player-name, .player-sum { margin: 0; }
.meters, .facts, .results { list-style: none; margin: 0; padding: 0; }
.meters li { display: grid; grid-template-columns: 8em 1fr 4em; gap: 12px; align-items: center; margin: 6px 0; }
.meters .value { text-align: right; font-variant-numeric: tabular-nums; }
.meters a { text-decoration: none; }
.meter { display: block; height: 10px; }
.meter span { display: block; height: 100%; width: var(--v); background: currentColor; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.facts .label { display: block; }
.facts a { text-decoration: none; }
.form { margin: 0; }

/* Hero */
.countdown { margin: 0 0 12px; display: flex; flex-direction: column; gap: 2px; }
.countdown .when { font-size: 1.3em; font-weight: bold; }
.countdown .when::first-letter { text-transform: uppercase; }
.countdown.live { font-size: 1.4em; font-weight: bold; }
.recap h3::first-letter { text-transform: none; }
.recap p { margin: 4px 0; }
.recap details { margin-top: 8px; }
.recap summary { cursor: pointer; }
.results li { padding: 2px 0; }
.results .result { font-variant-numeric: tabular-nums; padding: 0 4px; }
.winner { font-weight: bold; }
.memory { margin: 12px 0 0; font-style: italic; }
.rivalry b { padding: 0 6px; }

/* Attendance heatmap: one row per player, one cell per evening, darker = more games that night.
   Names stay put; the cells scroll sideways on narrow screens, starting at the latest evening. */
.heatmap { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.hm-names { display: grid; grid-auto-rows: 16px; font-size: 12px; line-height: 16px; }
.hm-names span { white-space: nowrap; max-width: 7em; overflow: hidden; text-overflow: ellipsis; }
.hm-names a { text-decoration: none; }
.hm-scroll { overflow-x: auto; direction: rtl; padding-bottom: 6px; }
.hm-grid { direction: ltr; display: grid; grid-template-columns: repeat(var(--cols), 9px); grid-auto-rows: 16px; align-items: center; column-gap: 2px; width: max-content; }
.cell { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--chart); }
.cell.l0 { background: var(--grid); }
.cell.l1 { opacity: .3; }
.cell.l2 { opacity: .5; }
.cell.l3 { opacity: .75; }
.hm-legend { display: flex; gap: 3px; align-items: center; justify-content: flex-end; font-size: .8em; opacity: .8; margin: 4px 0 12px; }
.hm-legend span:first-child { margin-right: 4px; }
.hm-legend span:last-child { margin-left: 4px; }

/* SVG charts */
.chart { width: 100%; margin: 8px 0; }
.chart-svg { display: block; overflow: visible; }
.chart-svg .bar { fill: var(--chart); }
.chart-svg .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { fill: var(--chart); }
.chart-svg .marker { stroke: var(--surface, Canvas); stroke-width: 2; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .ref { stroke: currentColor; stroke-width: 1; stroke-dasharray: 3 3; opacity: .5; }
.chart-svg .crosshair { stroke: currentColor; stroke-width: 1; opacity: .4; }
.chart-svg .tick { fill: currentColor; opacity: .7; font-size: 11px; font-family: system-ui, sans-serif; letter-spacing: 0; text-transform: none; font-style: normal; font-weight: normal; }
.chart-svg .hit { fill: transparent; }
.chart-svg .hit:hover + .bar, .chart-svg .bar:hover { opacity: .8; }

/* Tooltip: deliberately plain so it reads the same on every theme */
.tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  max-width: 240px; padding: 6px 10px; border-radius: 6px;
  background: #111; color: #f4f4f4;
  font: 13px/1.35 system-ui, sans-serif; letter-spacing: 0; text-transform: none;
  box-shadow: 0 4px 12px rgb(0 0 0 / .25);
}

.back { margin-top: 32px; }

/* Matchkväll ---------------------------------------------------------------------------- */
.cta { display: inline-block; margin-top: 16px; text-decoration: none; }
.start-link { margin: 0 0 12px; }
.countdown.live a { text-decoration: none; }

.btn {
  display: inline-block; padding: 8px 14px; min-height: 40px;
  border: 1px solid currentColor; border-radius: 6px; background: transparent;
  text-decoration: none; line-height: 1.4;
}
.btn.primary { font-weight: bold; border-width: 2px; }
.btn.small { min-height: 32px; padding: 2px 10px; }
.btn:disabled, .save:disabled { opacity: .4; cursor: not-allowed; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.warn { margin: 8px 0; padding: 8px 12px; border-left: 4px solid currentColor; font-weight: bold; }
.note small, .tonight small { opacity: .75; }

.pin-form, .add-form { display: flex; gap: 8px; margin: 12px 0; }
.pin-form input, .add-form input, .edit-form input {
  font: inherit; color: inherit; background: transparent;
  border: 1px solid currentColor; border-radius: 6px; padding: 8px 10px; min-height: 40px;
}
.pin-form input { width: 8em; letter-spacing: .3em; font-size: 1.3em; }
.add-form input { flex: 1; min-width: 0; }
.edit-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.edit-form input { width: 4.2em; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  padding: 8px 14px; min-height: 44px; border-radius: 999px;
  border: 1px solid currentColor; background: transparent;
}
/* Selected chips get a heavy border and a mark rather than a fill, so they read on every theme. */
.chip[aria-pressed="true"], .chip.team1, .chip.team2 { border-width: 3px; font-weight: bold; background: color-mix(in srgb, currentColor 12%, transparent); }
.chip[aria-pressed="true"]::before { content: "✓ "; }
.chip.team2 { border-style: dashed; }
.chip.team0 { opacity: .7; }
.chip small { opacity: .8; font-weight: normal; }

.scoreboard { display: grid; gap: 8px; }
.side { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; }
.score { font-variant-numeric: tabular-nums; min-width: 2ch; text-align: center; font-size: 2.6em; line-height: 1; }
.ctl { display: flex; gap: 6px; }
.ctl button { min-width: 56px; min-height: 56px; font-size: 1.5em; touch-action: manipulation; }
.status { display: flex; justify-content: space-between; gap: 12px; margin: 0; }
.queue, .tonight { margin: 8px 0 0; padding-left: 1.6em; }
.queue li, .tonight li { padding: 4px 0; }
.tonight .row-tools { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.tonight .pending { font-style: italic; }
.save { display: block; width: 100%; margin-top: 16px; padding: 14px; min-height: 52px; }
.end { margin-top: 32px; text-align: center; }

.footer { margin-top: 48px; display: flex; gap: 12px; justify-content: center; align-items: baseline; flex-wrap: wrap; font-size: .85em; opacity: .8; }
.linklike { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

@media (max-width: 480px) {
  .meters li { grid-template-columns: 6.5em 1fr 3.5em; }
  .facts { grid-template-columns: 1fr; }
  .board .opt { display: none; }
}
