/* friendlycasuals.com – stil. Tokens øverst er kopi av .claude/skills/web-design/tokens.css (hold dem like). */

@font-face { font-family: "Barlow Condensed"; src: url("fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("fonts/barlow-condensed-latin-800-normal.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  color-scheme: dark;

  /* Grunn: mosegrønn kull (skogen i Rust), skilt med lyshetssteg – ikke med skygger */
  --ground:  #161b17;
  --surface: #1e2420;
  --raised:  #283029;
  --line:    #3d473f;   /* bare dekor/skillelinjer (1.6:1) – aldri eneste kant på et skjemafelt */
  --edge:    #6f7a6c;   /* kant på input, select og knapper uten fyll (≥ 3:1, WCAG 1.4.11) */

  /* Blekk */
  --ink:     #ece6d6;   /* bein-hvit, 14.0 / 12.7 / 10.9 */
  --soft:    #b4b09f;   /* dempet tekst, 8.0 / 7.3 / 6.3 */

  /* Aksent: glo. Under 5 % av skjermen. Som tekst bare på ground/surface (5.3 / 4.8) */
  --accent:    #e8643a;
  --on-accent: #161b17; /* tekst på aksentflate, 5.3 */

  /* Status – alltid sammen med tekst eller form, aldri farge alene */
  --ok:   #9fd36b;      /* 10.0 / 9.0 / 7.8 */
  --warn: #e8b84f;      /* 9.5 / 8.6 / 7.4 */
  --bad:  #f2786a;      /* 6.4 / 5.8 / 5.0 */
  --info: #8cc3e8;      /* 9.2 / 8.4 / 7.2 */
  --danger-fill: #8a2c22; /* fyll på farlige knapper, --ink på toppen 6.8 */

  /* Typografi: to familier. Mono bare for ekte kode/kommandoer */
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif-condensed, sans-serif;
  --font-body: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* Størrelser: få og langt fra hverandre (nettside), tettere i verktøy */
  --text-sm: 0.875rem;  /* 14 px – minste tekst, bare i verktøy/tabeller */
  --text-md: 1.0625rem; /* 17 px – brødtekst nettside */
  --text-lg: 1.375rem;  /* 22 px – utsagn/ingress */
  --text-xl: clamp(2rem, 4vw, 3rem);
  --text-display: clamp(3.5rem, 11vw, 9rem);

  /* Avstand: 4/8-skala */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px; --s9: 120px;
  --gutter: clamp(1rem, 2.2vw, 2rem);

  /* Form: rett eller helt rund – ikke «myk 12 px» overalt */
  --radius: 4px;
  --radius-pill: 999px;
  --focus: 0 0 0 3px var(--ground), 0 0 0 5px var(--ink);

  /* Bevegelse */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-expo: cubic-bezier(.16, 1, .3, 1);   /* avsløringer på 700 ms og mer */
  --t-press: 140ms; --t-hover: 180ms; --t-ui: 240ms; --t-reveal: 700ms;

  /* Lag */
  --z-sticky: 20; --z-toast: 100;
}

/* ---------- Side ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--s5); }
body {
  margin: 0; min-height: 100dvh;
  background: var(--ground); color: var(--ink);
  font: 400 var(--text-md)/1.55 var(--font-body);
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius); }
[tabindex="-1"]:focus { box-shadow: none; }
.skip { position: absolute; left: var(--gutter); top: -100px; background: var(--ink); color: var(--ground); padding: var(--s2) var(--s3); z-index: var(--z-toast); }
.skip:focus { top: var(--s2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
img { max-width: 100%; height: auto; }
h2 { font: 800 var(--text-xl)/1 var(--font-display); letter-spacing: -.01em; margin: 0 0 var(--s5); text-wrap: balance; }

/* 12-kolonners rutenett */
.grid {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--s5); padding-inline: var(--gutter);
  max-width: 1760px; margin-inline: auto;
}
.grid > * { grid-column: 1 / -1; }

/* ---------- Toppfelt: navn + 3 lenker ---------- */
.topbar { align-items: center; padding-block: var(--s3); row-gap: var(--s2); }
.topbar-name { grid-column: 1 / span 6; font: 800 1.375rem/1 var(--font-display); color: var(--ink); text-decoration: none; }
.topbar nav { grid-column: 7 / -1; display: flex; justify-content: flex-end; gap: var(--s1); }
.topbar nav a, .footer-links a { color: var(--soft); text-decoration: none; padding: 0 var(--s3); min-height: 44px; display: inline-flex; align-items: center; border-radius: var(--radius); }
.topbar nav a:hover, .footer-links a:hover { color: var(--ink); }
.topbar nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.topbar nav a.nav-action { color: var(--accent); font-weight: 600; }
@media (max-width: 559px) {
  .topbar-name { grid-column: 1 / -1; }
  .topbar nav { grid-column: 1 / -1; justify-content: flex-start; margin-left: calc(var(--s3) * -1); }
}

/* ---------- Felles for undersidene (forsiden har i tillegg front.css) ---------- */
.lead { font-size: var(--text-lg); line-height: 1.4; color: var(--ink); margin: 0 0 var(--s6); max-width: 36ch; text-wrap: pretty; }
.lead strong { font-weight: 700; }
.btn {
  min-height: 44px; padding: 0 var(--s5);
  font: 600 var(--text-md)/1 var(--font-body); color: var(--on-accent);
  background: var(--accent); border: 0; border-radius: var(--radius); cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-hover) ease;
}
.btn:hover { background-color: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn:active { transform: scale(.97); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.pill { display: inline-block; padding: 0 var(--s3); border-radius: var(--radius-pill); background: var(--raised); font-weight: 600; }
.pill.ok { color: var(--ok); } .pill.bad { color: var(--bad); }

/* Bunntekst: navnet i full bredde, lenker og «not affiliated» */
footer { padding-block: var(--s8) var(--s6); }
.wordmark { font: 800 clamp(3rem, 15.5vw, 16rem)/.8 var(--font-display); letter-spacing: -.03em; margin: 0 0 var(--s5) -.04em; color: var(--raised); white-space: nowrap; overflow: hidden; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--s1); margin: 0 0 var(--s3) calc(var(--s3) * -1); }
footer p { margin: 0; color: var(--soft); font-size: var(--text-sm); }
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:active { transform: none; }
}

/* ---------- Stats-siden ---------- */
.stats-hero { padding-block: var(--s7) var(--s6); align-items: end; row-gap: var(--s5); }
.stats-hero h1 { font: 800 clamp(3rem, 8vw, 6rem)/.9 var(--font-display); letter-spacing: -.02em; margin: 0 0 var(--s4); margin-left: -.03em; }
.stats-hero .lead { margin-bottom: var(--s5); max-width: 40ch; }
.stats-period { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s3) var(--s5); }
.section-head { margin-bottom: var(--s5); }
.section-head h2 { margin-bottom: var(--s2); }
.section-head p { margin: 0; color: var(--soft); }

/* Rekorder: lederen i hver kategori. Den første (spilletid) er dobbelt så bred, så lista får en start */
.records-section { padding-block: var(--s6) var(--s5); }
.records { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: var(--s2); }
.records li { background: var(--surface); border-radius: var(--radius); padding: var(--s4) var(--s4) var(--s3); display: grid; align-content: start; min-width: 0; }
.record-label { justify-self: start; font: 600 var(--text-sm)/1.3 var(--font-body); color: var(--soft); background: none; border: 0; padding: 0; min-height: 24px; cursor: pointer; text-align: left; }
.record-label:hover { color: var(--ink); text-decoration: underline; }
.record-value { margin: var(--s1) 0 var(--s2); font: 800 clamp(2.25rem, 4vw, 3rem)/1 var(--font-display); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.record-name { color: var(--ink); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; justify-self: start; }
.record-name:hover { color: var(--accent); text-decoration: underline; }
.record-next { margin: var(--s1) 0 0; color: var(--soft); font-size: var(--text-sm); overflow-wrap: anywhere; }
.records li:first-child { background: var(--raised); }
@media (min-width: 560px) {
  .records li:first-child { grid-column: span 2; }
  .records li:first-child .record-value { font-size: clamp(3rem, 7vw, 5rem); }
}
.stats-art { width: 160px; justify-self: start; }
@media (max-width: 559px) { .stats-art { display: none; } }   /* på mobil skjøv maskoten rekordene ned under første skjerm */
.updated { margin: 0; color: var(--soft); }
.updated.stale { color: var(--warn); }
.notice { color: var(--warn); }

.tiles { margin: 0 0 var(--s6); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.tiles div { background: var(--surface); border-radius: var(--radius); padding: var(--s4); }
.tiles dt { color: var(--soft); font-size: var(--text-sm); margin-bottom: var(--s1); }
.tiles dd { margin: 0; font: 600 1.75rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; display: grid; gap: 2px; }
@media (max-width: 767px) { .tiles div:last-child { grid-column: 1 / -1; } }
.tiles dd small { font: 400 var(--text-sm)/1.3 var(--font-body); color: var(--soft); }
.tiles .pill { font: 600 1.125rem/1.6 var(--font-body); justify-self: start; }

.chart-section { padding-block: var(--s5); }
.chart-head h3, .map-text h3 { font: 800 1.75rem/1 var(--font-display); margin: 0; }
.map-text h3 { margin-bottom: var(--s4); }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.chart-head h2 { margin: 0; }
.seg { display: inline-flex; background: var(--surface); border-radius: var(--radius); padding: var(--s1); gap: var(--s1); }
.seg-btn { font: 600 var(--text-sm)/1 var(--font-body); color: var(--soft); background: none; border: 0; border-radius: var(--radius); min-height: 40px; padding: 0 var(--s4); cursor: pointer; touch-action: manipulation; }
.seg-btn[aria-pressed="true"] { background: var(--raised); color: var(--ink); }
.chart { margin: 0; }
.chart-plot { background: var(--surface); border-radius: var(--radius); padding: var(--s3) var(--s2) var(--s1); min-height: 160px; }
.chart-plot svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-empty { margin: 0; padding: var(--s6) var(--s3); color: var(--soft); }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis { fill: var(--soft); font: 400 13px var(--font-body); font-variant-numeric: tabular-nums; }
.series { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.series.main { stroke: var(--accent); }
.series.peak { stroke: var(--soft); stroke-width: 1.5; stroke-dasharray: 4 4; }
.series-label { font: 600 13px var(--font-body); }
.series-label.main { fill: var(--accent); } .series-label.peak { fill: var(--soft); }
.cursor { stroke: var(--ink); stroke-width: 1; }
.readout { margin: var(--s1) var(--s2) var(--s2); color: var(--ink); font-variant-numeric: tabular-nums; min-height: 1.5em; }
.chart figcaption { color: var(--soft); margin-top: var(--s3); font-size: var(--text-sm); }
.chart-table { margin-top: var(--s4); }
.chart-table summary { cursor: pointer; color: var(--accent); min-height: 44px; display: inline-flex; align-items: center; }
.table-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-top: var(--s2); }
.table-wrap table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.table-wrap th, .table-wrap td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); }
.table-wrap th { color: var(--soft); font-weight: 600; font-size: var(--text-sm); background: var(--surface); position: sticky; top: 0; }

.map-section { display: grid; gap: var(--s5); align-items: start; padding-block: var(--s6) 0; }
.map-facts { margin: 0 0 var(--s4); display: flex; gap: var(--s6); }
.map-facts dt { color: var(--soft); font-size: var(--text-sm); }
.map-facts dd { margin: 0; font: 600 1.75rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.map-note { color: var(--soft); max-width: 40ch; }
.map-figure { margin: 0; }
.map-figure figcaption { color: var(--soft); font-size: var(--text-sm); margin-top: var(--s2); }
.map-frame { position: relative; aspect-ratio: 1; background: #0f2a36; border-radius: var(--radius); overflow: hidden; }
.map-frame img { display: block; max-width: none; height: auto; }
.map-grid { position: absolute; width: auto; height: auto; pointer-events: none; }
.map-grid line { stroke: rgba(0, 0, 0, .35); stroke-width: 3; vector-effect: non-scaling-stroke; }
.map-grid text { fill: rgba(0, 0, 0, .55); font: 700 40px var(--font-body); }

/* ---------- Toppliste ---------- */
.board { padding-block: var(--s6) var(--s8); }
.board-controls { display: grid; gap: var(--s3) var(--s5); align-items: end; margin-bottom: var(--s4); }
.field { display: grid; gap: var(--s1); }
.field label { color: var(--soft); font-size: var(--text-sm); }
.field select, .field input {
  min-height: 44px; padding: 0 var(--s3); font: inherit; color: var(--ink);
  background: var(--ground); border: 1px solid var(--edge); border-radius: var(--radius);
}
.field-search input { width: 100%; max-width: 320px; }
.field-search { justify-self: stretch; }
.board-wrap { max-height: none; }
.board-table { min-width: 720px; }
.board-table th { white-space: nowrap; vertical-align: bottom; }
.board-table td { white-space: nowrap; }
.num { text-align: right; }
.table-wrap th.num, .table-wrap td.num { text-align: right; }
.sort { font: inherit; color: inherit; background: none; border: 0; padding: var(--s1) 0; cursor: pointer; min-height: 32px; }
.sort:hover, .sort.active { color: var(--ink); }
.board-table td.sorted { color: var(--ink); font-weight: 600; position: relative; }
/* Søyle under tallet i sortert kolonne: andel av lederen (--share settes av stats.js) */
.board-table td.sorted::after { content: ""; position: absolute; right: var(--s3); bottom: 3px; height: 3px; width: calc((100% - 2 * var(--s3)) * var(--share, 0)); background: var(--accent); border-radius: 2px; }
.board-table td { color: var(--soft); }
.board-table .rank { width: 3rem; color: var(--soft); font-variant-numeric: tabular-nums; }
.board-table .player { position: sticky; left: 0; background: var(--ground); min-width: 12rem; max-width: 18rem; white-space: normal; }
.board-table thead .player { background: var(--surface); }
.board-table .player a { color: var(--ink); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.board-table .player a:hover { color: var(--accent); text-decoration: underline; }
.board-table .sid { display: block; font-size: 13px; color: var(--soft); font-variant-numeric: tabular-nums; }
.board-table tr.top .rank { color: var(--accent); font: 800 1.25rem/1 var(--font-display); }
.board-empty { color: var(--soft); padding: var(--s5) 0; margin: 0; }
.pager[hidden] { display: none; }
.pager { display: flex; align-items: center; gap: var(--s4); margin-top: var(--s4); color: var(--soft); font-variant-numeric: tabular-nums; }
.pager-btn { min-height: 44px; padding: 0 var(--s4); font: 600 var(--text-sm)/1 var(--font-body); color: var(--ink); background: var(--surface); border: 1px solid var(--edge); border-radius: var(--radius); cursor: pointer; }
.pager-btn:disabled { opacity: .45; cursor: not-allowed; }
.board-note { color: var(--soft); font-size: var(--text-sm); max-width: 70ch; margin: var(--s5) 0 0; }
.server { padding-block: var(--s8); border-top: 1px solid var(--line); }
.server-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.server-head h2 { margin: 0; }

/* ---------- Spillerprofil ---------- */
.profile-hero { padding-block: var(--s6) var(--s5); }
.crumb { margin: 0 0 var(--s4); }
.crumb a { color: var(--soft); }
.profile-hero h1 { font: 800 clamp(2.5rem, 7vw, 5rem)/.95 var(--font-display); letter-spacing: -.02em; margin: 0 0 var(--s4); overflow-wrap: anywhere; }
.profile-meta { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); color: var(--soft); margin: 0; font-variant-numeric: tabular-nums; }
.profile-meta b { color: var(--ink); }
.profile { padding-block: var(--s4) var(--s8); row-gap: var(--s6); }
.profile-controls { grid-column: 1 / -1; }
.profile-block h2, .profile-wide h2 { font: 800 1.75rem/1 var(--font-display); margin: 0 0 var(--s4); }
.statlist { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.statlist div { background: var(--surface); border-radius: var(--radius); padding: var(--s3); }
.statlist dt { color: var(--soft); font-size: var(--text-sm); }
.statlist dd { margin: 0; font: 600 1.5rem/1.15 var(--font-display); font-variant-numeric: tabular-nums; }

/* ---------- Bredere skjermer ---------- */
@media (min-width: 768px) {
  .stats-head { grid-column: 1 / span 9; }
  .stats-art { grid-column: 10 / span 3; width: min(100%, 240px); justify-self: end; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .map-section { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
  .board-controls { grid-template-columns: auto 1fr; }
  .profile-block { grid-column: span 4; }
  .profile-wide { grid-column: span 4; }
  .profile-wide:last-child { grid-column: span 8; }
}
@media (min-width: 1024px) {
  .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .chart { max-width: 1200px; }
}
