:root {
  color-scheme: dark;
  /* page colour: neutral gray when idle; app.js tints it from the song's cover */
  --bg: #1b1a1b;
  --text: #ece5e1;
  --muted: #8d807c;
  --faint: #5f5552;
  --card: #2f2523;
  --bar-bg: rgba(255, 255, 255, 0.18);
  --bar-fill: #f2ece8;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  transition: background-color 1.2s ease;
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(20px, 5vh, 56px) 16px 12px;
}

/* ── text ─────────────────────────────────────────── */

.title {
  margin: 0 0 6px;
  /* sized so "## below is the current track i'm listening to" (46 characters)
     stays on one line: 28px on desktop, shrinks with the screen on phones */
  font-size: min(28px, calc((100vw - 32px) / 28));
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.title::before {
  content: "## ";
  color: var(--muted);
}

.subtitle {
  margin: 0 0 14px;
  font-size: min(15px, max(11px, calc((100vw - 32px) / 32))); /* smaller than the title on phones */
  font-weight: 600;
  color: var(--text);
  opacity: 0.85;
}

/* ── player card ──────────────────────────────────── */

.player {
  position: relative;
  display: flex;
  gap: 18px;
  align-items: stretch;
  padding: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  animation: rise 0.5s ease both;
}
.player[hidden] { display: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* blurred album-art glow behind everything */
.ambient {
  position: absolute;
  inset: -40%;
  z-index: -2;
  background-size: cover;
  background-position: center;
  filter: blur(48px) saturate(1.5);
  opacity: 0.85;
  transition: opacity 0.6s ease, background-image 0.6s ease;
  animation: drift 24s ease-in-out infinite alternate;
}
.player::after {
  /* darken so text stays readable */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(20, 14, 13, 0.55), rgba(20, 14, 13, 0.25));
}
body.no-ambient .ambient { opacity: 0; }

@keyframes drift {
  from { transform: rotate(0deg) scale(1); }
  to   { transform: rotate(14deg) scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .ambient, .player { animation: none; }
}

/* film grain */
.grain {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.18;
  pointer-events: none;
  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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.art {
  flex: none;
  width: 100px;
  height: 100px;
  border-radius: 6px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.art { cursor: zoom-in; }

.info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2px 0;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.meta { min-width: 0; }

.track {
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artist {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artist .by { color: var(--muted); }
#artist {
  border-bottom: 1px dotted rgba(255, 255, 255, 0.35);
}

.logo {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--text);
  opacity: 0.9;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}
.time {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 3.5ch;
}
.time:last-child { text-align: right; }
.play {
  width: 20px;
  height: 20px;
  color: var(--text);
}

.bar {
  margin-top: 8px;
  height: 4px;
  border-radius: 4px;
  background: var(--bar-bg);
  overflow: hidden;
}
.fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--bar-fill);
  transition: width 0.25s linear;
}

/* Last.fm doesn't give a position, so the bar just shimmers */
.player.no-progress .time { visibility: hidden; }
.player.no-progress .fill {
  width: 35%;
  animation: shimmer 2.4s ease-in-out infinite;
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(290%); }
}

/* ── nothing playing ────────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 128px;
  padding: 24px 16px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: rise 0.5s ease both;
}
.empty[hidden] { display: none; }
.empty {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.empty:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }
.empty-face {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.empty-face.pop { animation: pop 0.25s ease; }
@keyframes pop {
  0%   { transform: scale(0.9); opacity: 0.6; }
  60%  { transform: scale(1.06); }
  100% { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .empty-face.pop { animation: none; }
}
.empty-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* ── footnote ─────────────────────────────────────── */

.footnote {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--faint);
}
.footnote[hidden] { display: none; }

.toggle {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.toggle:hover, .toggle:focus-visible { color: var(--muted); }

/* ── recently played ─────────────────────────────── */

.recent { margin-top: 28px; }
.recent[hidden] { display: none; }

.heading {
  margin: 0 0 6px;
  font-size: clamp(18px, 3vw, 24px);
  font-weight: 800;
}
.heading::before { content: "## "; color: var(--muted); }

/* scrollable box, ~10 songs tall */
.recent-box {
  position: relative;
  margin-top: 10px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}
.recent-box:not(.scrolls)::after { display: none; }
.recent-box::after {
  /* fade at the bottom hints there's more to scroll */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 32px;
  pointer-events: none;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.35));
  transition: opacity 0.2s ease;
}
/* scrolled to the bottom: nothing more to hint at, so drop the fade */
.recent-box.at-end::after { opacity: 0; }
.recent-list {
  list-style: none;
  margin: 0;
  padding: 4px 14px;
  /* app.js sets max-height so the list ends at the bottom of the screen */
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.recent-box.expanded.scrolls .recent-list { padding-bottom: 8px; }
.recent-item[hidden] { display: none; }
.recent-list::-webkit-scrollbar { width: 8px; }
.recent-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}
.recent-item a {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 4px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}
.recent-item a:hover,
.recent-item a:focus-visible { background: rgba(255, 255, 255, 0.05); }

.recent-art {
  cursor: zoom-in;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}
.recent-text { min-width: 0; }
.recent-title,
.recent-artist {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-title { font-size: 14px; font-weight: 700; line-height: 1.35; }
.recent-artist { font-size: 12px; line-height: 1.35; color: var(--muted); }
.recent-time {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}


.more {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.more[hidden] { display: none; }
.more:hover,
.more:focus-visible { color: var(--text); }

/* ── links to the other pages ───────────────────── */

.site-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 28px;
  margin-top: 48px;
  font-size: 14px;
  font-weight: 600;
}
.site-foot {
  margin: 14px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
}
.site-foot:empty { display: none; }
.contact-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 18px;
}
.contact-pill {
  text-decoration: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.contact-pill svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linejoin: round;
}
.contact-pill:hover,
.contact-pill:focus-visible,
.contact-pill[data-open] { color: var(--text); background: rgba(255, 255, 255, 0.09); }
.contact-pill[data-copied]::after {
  content: "copied";
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--faint);
}
.site-links a {
  color: var(--muted);
  text-decoration: none;
}
.site-links a::before { content: "["; color: var(--faint); }
.site-links a::after { content: "]"; color: var(--faint); }
.site-links a:hover,
.site-links a:focus-visible,
.site-links a[aria-current="page"] { color: var(--text); }

/* ── enlarged cover ──────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 10, 10, 0.85);
  backdrop-filter: blur(8px);
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.lightbox[hidden] { display: none; }
.lightbox.open { opacity: 1; }
.lightbox img {
  max-width: min(90vw, 640px);
  max-height: 85vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  transition: transform 0.2s ease;
}
.lightbox.open img { transform: none; }

/* ── phones ───────────────────────────────────────── */

@media (max-width: 520px) {
  .player { gap: 12px; padding: 12px; }
  .art { width: 72px; height: 72px; }
  .track { font-size: 15px; }
  .footnote { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* ── /surf ────────────────────────────────────────── */

.surf .title { white-space: normal; font-size: clamp(22px, 6vw, 28px); }
.surf-loading { font-size: 13px; color: var(--muted); }
.surf-loading[hidden],
.surf-section[hidden],
.surf-error[hidden],
.surf-sub[hidden],
.surf-item[hidden],
.ksf-stats[hidden],
.surf .subtitle[hidden] { display: none; }

.surf-section { margin-top: 28px; }
.surf-section.off { display: none !important; } /* hidden in /dashboard */
.surf-sub {
  margin: 18px 0 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}
.surf-sub::before { content: "### "; color: var(--faint); }
.surf-error { font-size: 12px; color: var(--muted); }
.surf-none { font-size: 12px; color: var(--faint); padding: 6px 0; }

/* stats panel */
.ksf-stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px 20px;
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
}
.ksf-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px 14px;
  align-content: start;
}
.ksf-num { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ksf-num-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ksf-num-value {
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ksf-num-of { font-size: 10px; font-weight: 600; color: var(--faint); }
.ksf-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ksf-bars { display: flex; flex-direction: column; gap: 6px; }
.ksf-bar-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}
.ksf-bar-n { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ksf-bar-row .ksf-bar-n:first-child { text-align: right; }
.ksf-bar {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.ksf-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  min-width: 2px;
  border-radius: 999px;
  background: #e889d8;
}
.ksf-bar-stages { background: #d6c84a; }
.ksf-bar-bonuses { background: #6fb6e8; }
.ksf-bar-name,
.ksf-bar-pct {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
.ksf-bar-name { left: 8px; }
.ksf-bar-pct { left: 50%; transform: translate(-50%, -50%); }
.ksf-counts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ksf-counts[hidden] { display: none; }
.ksf-count { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ksf-count-label {
  width: 100%;
  padding: 4px 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}
.ksf-count-value { font-size: 12px; font-variant-numeric: tabular-nums; }

/* map rows */
.surf-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.surf-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding-right: 12px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}
a.surf-row:hover,
a.surf-row:focus-visible { background: rgba(255, 255, 255, 0.07); }
.surf-thumb {
  position: relative;
  height: 40px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.surf-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.surf-thumb.loaded img { opacity: 1; }
.surf-thumb-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 6px;
  font-size: 10px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.surf-mid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
  padding: 6px 0;
}
.surf-map {
  font-size: 13px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.surf-map.inline { font-size: inherit; }
.surf-chip {
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.surf-chip.dim { color: var(--muted); }
/* momentum: tap a map's picture or name to see if it's ranked, beta or unranked */
.surf-status-tap { cursor: help; }
.surf-status {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  font-size: 11px;
  font-weight: 700;
  color: var(--text, #eee);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.surf-item.show-status .surf-status { opacity: 1; }
.surf-activity { font-size: 13px; min-width: 0; }
.surf-activity b { color: var(--muted); font-weight: 700; }
.surf-trophy { width: 16px; height: 16px; flex: none; }
.surf-date {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .ksf-stats { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .surf-row { grid-template-columns: 76px minmax(0, 1fr) auto; gap: 10px; padding-right: 10px; }
  .surf-thumb { height: 100%; min-height: 44px; }
  .surf-map { font-size: 12px; }
  .surf-activity { font-size: 12px; }
  .surf-chip.wr-diff { display: none; }
}
.mm-stats { grid-template-columns: minmax(0, 1fr); margin-bottom: 4px; }
.mm-stats .ksf-numbers { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
/* maps per rank 1-10 / group g1-g6: two flat rows under the numbers */
.mm-places[hidden] { display: none; }
#ksf-places { grid-column: 1 / -1; }
.mm-places {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.mm-place-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 56px;
  gap: 10px;
  align-items: center;
}
.mm-place-name { font-size: 11px; color: var(--muted); }
.mm-place-cells { display: grid; gap: 6px; }
.mm-place-ranks { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.mm-place-groups { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.mm-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 0 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  cursor: default;
}
.mm-place-label { font-size: 10px; color: var(--muted); }
.mm-place-value { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.mm-place.zero .mm-place-value { color: var(--faint); }
.mm-place-total { background: rgba(232, 137, 216, 0.12); }
@media (max-width: 640px) {
  .mm-place-row { grid-template-columns: minmax(0, 1fr) 56px; }
  .mm-place-name { grid-column: 1 / -1; }
  .mm-place-ranks { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .mm-place-groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.surf-chip-of { color: var(--faint); font-size: 10px; }
.surf-chip.hot { background: rgba(232, 137, 216, 0.22); }
/* group / top % chips: a color picked in /dashboard (pink by default), fading the further from the wr */
.surf-chip.lv { background: rgba(var(--chip-rgb), var(--a)); }
.surf-chip.lv.grp { --chip-rgb: var(--grp-rgb, 232, 137, 216); }
.surf-chip.lv.pct { --chip-rgb: var(--pct-rgb, 232, 137, 216); }
.surf-chip.lv1 { --a: 0.45; }
.surf-chip.lv2 { --a: 0.38; }
.surf-chip.lv3 { --a: 0.32; }
.surf-chip.lv4 { --a: 0.26; }
.surf-chip.lv5 { --a: 0.21; }
.surf-chip.lv6 { --a: 0.16; }
.surf-chip.lv7 { --a: 0.12; }
.surf-chip.lv8 { --a: 0.07; color: var(--muted); }

/* "show all maps i've completed": scrollable box, like the songs list on the home page */
#ksf-all-btn, #momentum-all-btn { margin: 8px 0 4px; }
.surf-all[hidden], .surf-all-note[hidden] { display: none; }
.more[disabled] { opacity: 0.6; cursor: default; }
.surf-all-note { margin: 4px 0 8px; font-size: 12px; color: var(--muted); }
.surf-sort { display: flex; flex-wrap: wrap; gap: 16px; margin: 0 0 10px; }
.surf-sort[hidden] { display: none; }
.surf-sort .more { margin: 0; }
.surf-sort .more[aria-pressed="true"] { color: var(--text); }
.surf-scroll {
  position: relative;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  /* fade at the bottom hints there's more to scroll */
  -webkit-mask-image: linear-gradient(#000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 32px), transparent);
}
.surf-scroll:not(.scrolls),
.surf-scroll.at-end { -webkit-mask-image: none; mask-image: none; }
.surf-scroll::-webkit-scrollbar { width: 8px; }
.surf-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 8px; }

/* no wr/cp/b/top row: let the completion bars fill the space instead */
.ksf-side:has(.ksf-counts[hidden]) { justify-content: center; }
.ksf-side:has(.ksf-counts[hidden]) .ksf-bars { gap: 12px; }
.ksf-side:has(.ksf-counts[hidden]) .ksf-bar { height: 28px; }
.ksf-side:has(.ksf-counts[hidden]) .ksf-bar-name,
.ksf-side:has(.ksf-counts[hidden]) .ksf-bar-pct { font-size: 13px; }
.ksf-side:has(.ksf-counts[hidden]) .ksf-bar-name { left: 12px; }
.ksf-side:has(.ksf-counts[hidden]) .ksf-bar-n { font-size: 12px; }
.ksf-side:has(.ksf-counts[hidden]) .ksf-bar-row { grid-template-columns: 44px minmax(0, 1fr) 44px; }

/* "← home" in the top-left corner, like on /meow */
.home-link {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 16px;
  font-size: 12px;
  color: var(--faint);
  text-decoration: none;
}
.home-link:hover, .home-link:focus-visible { color: var(--text); }
.wrap.surf { padding-top: max(44px, clamp(20px, 5vh, 56px)); }

/* ── /dbd ─────────────────────────────────────────── */

#dbd[hidden], .dbd-adepts[hidden], .dbd .more[hidden] { display: none; }
.dbd-profile { display: flex; align-items: center; gap: 14px; margin: 18px 0 14px; min-width: 0; }
.dbd-avatar { width: 56px; height: 56px; border-radius: 8px; flex: none; }
.dbd-who { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dbd-name { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 800; min-width: 0; }
.dbd-status { font-size: 11px; font-weight: 600; color: var(--muted); }
.dbd-status::before { content: "● "; color: var(--faint); }
.dbd-status.on::before { color: #7fd17f; }
.dbd-links { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.ksf-stats.one-col { grid-template-columns: minmax(0, 1fr); }

.dbd .ksf-num { gap: 4px; }
.dbd-top {
  align-self: flex-start;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.dbd-top.hot { background: rgba(232, 137, 216, 0.22); color: var(--text); }

.dbd-splits { justify-content: flex-start; gap: 18px; }
.dbd-overview .ksf-numbers { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dbd-overview .dbd-splits[hidden] { display: none; }
.dbd-note-small { font-size: 10px; color: var(--faint); }
@media (max-width: 640px) { .dbd-overview .ksf-numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dbd-extras { margin: 0; }
.dbd-split { display: flex; flex-direction: column; gap: 6px; }
.dbd-split-bar { display: flex; gap: 2px; height: 18px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
.dbd-split-a { background: #e889d8; }
.dbd-split-b { background: #6fb6e8; }
.dbd-split-legend { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; font-weight: 600; color: var(--muted); }

.dbd-rank { display: flex; flex-direction: column; gap: 4px; }
.dbd-rank-row { display: flex; align-items: center; gap: 12px; }
.dbd-pips { display: flex; gap: 4px; }
.dbd-pip { width: 10px; height: 10px; transform: rotate(45deg); border: 1px solid var(--muted); }
.dbd-pip.on { background: #e889d8; border-color: #e889d8; }

.dbd-buttons { display: flex; flex-wrap: wrap; gap: 0 18px; }
.dbd-adepts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
}
.dbd-adept { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; font-size: 10px; font-weight: 600; text-align: center; }
.dbd-adept-icon { width: 40px; height: 40px; flex: none; border-radius: 6px; background: rgba(255,255,255,0.05); overflow: hidden; }
.dbd-adept-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.dbd-adept.missing { color: var(--faint); }
.dbd-adept.missing .dbd-adept-icon { filter: grayscale(1); opacity: 0.45; }

.dbd .surf-all { margin-top: 8px; }
.dbd-statlist { list-style: none; margin: 0 0 6px; padding: 0; }
.dbd-stat { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 6px; font-size: 12px; border-radius: 6px; }
.dbd-stat:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }
.dbd-stat-label { color: var(--muted); min-width: 0; }
.dbd-stat-right { display: flex; align-items: baseline; gap: 8px; flex: none; }
.dbd-stat-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.dbd .surf-scroll .surf-sub:first-child { margin-top: 4px; }

.dbd-ach-bar { margin-bottom: 4px; }
.dbd-ach { grid-template-columns: 44px minmax(0, 1fr) auto; }
.dbd-ach-icon { width: 44px; height: 44px; background: rgba(255, 255, 255, 0.06); }
.dbd-ach-icon img { width: 100%; height: 100%; display: block; }
.dbd-ach-mid { flex-direction: column; align-items: flex-start; gap: 2px; }
.dbd-ach-desc { font-size: 11px; color: var(--muted); }
.dbd-ach.missing { opacity: 0.55; }
/* "● last online 3 days ago · playing since jan 2025", under the subtitle */
.dbd-seen { margin: -8px 0 12px; font-size: 11px; color: var(--muted); }
.dbd-seen[hidden] { display: none; }
.dbd-seen .dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--faint); vertical-align: 1px; }
.dbd-seen .dot.on { background: #7bd88f; box-shadow: 0 0 6px #7bd88f; }
.dbd-seen b { color: var(--text); font-weight: 600; }
.dbd-note { margin-top: 24px; font-size: 11px; color: var(--faint); }
.dbd-note:empty { display: none; }
@media (max-width: 520px) {
  .dbd-ach { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .dbd-ach-icon { width: 40px; height: 100%; min-height: 40px; }
}

/* ── /fortnite ───────────────────────────────────── */

#fn[hidden], #fn-stats[hidden], #fn-window-error[hidden] { display: none; }
.fn-tabs { display: flex; gap: 16px; margin: 4px 0 14px; }
.fn-tabs .more { margin: 0; }
.fn-tabs .more[aria-pressed="true"] { color: var(--text); }
.fn-modes {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(5, minmax(0, 1fr));
  gap: 8px 12px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.fn-modes span { text-align: right; white-space: nowrap; }
.fn-modes .fn-head { font-size: 11px; color: var(--muted); }
.fn-modes span:nth-child(6n + 1) { text-align: left; }
.fn-mode { font-weight: 600; }
@media (max-width: 480px) {
  .fn-modes { font-size: 12px; gap: 8px 8px; }
}

@media (max-width: 480px) {
  .site-links { column-gap: 18px; }
}

/* ── /movies ─────────────────────────────────────── */

#mv[hidden] { display: none; }
.movies .recent { margin-top: 28px; }
/* rows aren't links here, but look like the ones on / */
.recent-item .recent-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 4px 8px;
  margin: 0 -8px;
}
.mv-poster { height: 54px; cursor: zoom-in; }
.mv-stars { color: var(--text); letter-spacing: 1px; }
.mv-heart { margin-left: 6px; color: #e889d8; }
.mv-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 92px;
  margin-top: 8px;
}
.mv-bar {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.04);
}
.mv-bar-fill { width: 100%; border-radius: 3px; background: #e889d8; }
.mv-chart-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

/* ── links page (meow.ibemeowing.xyz) ───────────── */

.links-wrap {
  --w: min(520px, calc(100vw - 32px));
  --gap: 16px;
  width: var(--w);
  margin: 0 auto;
  padding: clamp(28px, 8vh, 72px) 0 40px;
}
.link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  /* 3 rows make a square card */
  grid-auto-rows: max(62px, calc((var(--w) - var(--gap)) / 2 / 3 - var(--gap) * 2 / 3));
  gap: var(--gap);
  grid-template-areas:
    "music fortnite"
    "music movies"
    "music movies"
    "surf movies"
    "surf dbd"
    "minigames meow";
}
.link-tile {
  --pic: none;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 12px 14px;
  border-radius: 22px;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
  isolation: isolate;
  transition: transform 0.2s ease;
}
.link-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--pic) center / cover no-repeat;
  filter: saturate(0.85);
  transition: transform 0.4s ease;
}
.link-tile::after {
  /* darken the bottom so the text stays readable on any picture */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(transparent 35%, rgba(0, 0, 0, 0.6));
}
.link-tile:hover::before,
.link-tile:focus-visible::before { transform: scale(1.04); }
.link-tile:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.link-icon {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--text);
  color: #1b1a1b;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}
.link-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  text-align: right;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}
/* short cards: keep the text clear of the icon */
.link-tile[data-page="fortnite"] .link-text,
.link-tile[data-page="dbd"] .link-text,
.link-tile[data-page="meow"] .link-text,
.link-tile[data-page="minigames"] .link-text { padding-left: 40px; }
.link-text b { font-size: 15px; font-weight: 800; }
.link-text small {
  max-width: 100%;
  font-size: 11px;
  color: rgba(233, 228, 220, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.links-wrap .site-foot { margin-top: 28px; }
@media (max-width: 420px) {
  .links-wrap { --gap: 12px; }
  .link-tile { border-radius: 18px; padding: 10px 12px; }
  .link-icon { top: 10px; left: 10px; min-width: 24px; height: 24px; font-size: 12px; }
  .link-tile[data-page="fortnite"] .link-text,
  .link-tile[data-page="dbd"] .link-text,
  .link-tile[data-page="meow"] .link-text,
  .link-tile[data-page="minigames"] .link-text { padding-left: 30px; }
}
/* meow without a picture: a little dot sky like /meow */
.link-tile[data-page="meow"]:not(.has-pic)::before {
  background:
    radial-gradient(circle, rgba(233, 228, 220, 0.55) 1px, transparent 1.6px) 0 0 / 14px 14px,
    radial-gradient(circle at 70% 30%, rgba(232, 137, 216, 0.25), transparent 60%),
    #111;
}
/* minigames without a picture: a little checkerboard */
.link-tile[data-page="minigames"]:not(.has-pic)::before {
  background:
    repeating-conic-gradient(rgba(233, 228, 220, 0.07) 0 25%, transparent 0 50%) 0 0 / 20px 20px,
    radial-gradient(circle at 30% 70%, rgba(137, 216, 232, 0.22), transparent 60%),
    #111;
}

/* ── /minigames ───────────────────────────────────── */
.mg-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 22px 0 8px; }
.mg-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 112px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-decoration: none;
  transition: filter 0.15s ease, transform 0.2s ease;
}
.mg-card:hover, .mg-card:focus-visible { filter: brightness(1.12); transform: translateY(-2px); }
.mg-card:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.mg-card b { font-size: 19px; font-weight: 800; }
.mg-card small { font-size: 12px; line-height: 1.35; color: rgba(233, 228, 220, 0.72); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.mg-blocks { background: linear-gradient(115deg, #393047 10%, #342c44 55%, #273444); }
.mg-words { background: linear-gradient(115deg, #323e31 12%, #394030 70%, #322e2a); }
.mg-art { position: absolute; z-index: -1; pointer-events: none; opacity: 0.45; }
.mg-blocks-art {
  right: -8px; top: -30px;
  display: grid; grid-template-columns: repeat(4, 38px); grid-auto-rows: 38px; gap: 4px;
  transform: rotate(-9deg);
}
.mg-blocks-art i { background: #786594; border-radius: 4px; }
.mg-blocks-art i:nth-child(4n + 1) { visibility: hidden; }
.mg-blocks-art i:nth-child(6), .mg-blocks-art i:nth-child(10) { background: #55678d; }
.mg-blocks-art i:nth-child(8), .mg-blocks-art i:nth-child(11) { background: #50728b; }
.mg-words-art { right: -20px; bottom: -4px; display: flex; gap: 5px; transform: rotate(-8deg); }
.mg-words-art i {
  display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 5px; background: #507962; font-style: normal; font-weight: 800; font-size: 22px; color: #e3e9df;
}
.mg-words-art i:nth-child(2), .mg-words-art i:nth-child(4) { background: #907a48; }
.mg-2048 { background: linear-gradient(115deg, #463629 10%, #3f3127 60%, #312a27); }
.mg-2048-art {
  right: -40px; top: -18px;
  display: grid; grid-template-columns: repeat(4, 34px); grid-auto-rows: 34px; gap: 4px;
  transform: rotate(-9deg);
}
.mg-2048-art i {
  display: grid; place-items: center; border-radius: 5px; background: #a8875f;
  font-style: normal; font-weight: 800; font-size: 12px; letter-spacing: -0.06em; color: #2b231c;
}
.mg-2048-art i:nth-child(odd) { background: #c19a63; }
.mg-2048-art i:last-child { background: #e0b955; font-size: 9px; }
.mg-slots { background: linear-gradient(115deg, #3e2747 10%, #35233f 60%, #2a2233); }
.mg-slots-art { right: -36px; top: 50%; display: flex; gap: 4px; transform: translateY(-50%) rotate(-8deg); }
.mg-slots-art img { width: 56px; height: 56px; padding: 5px; border-radius: 8px; background: #1d1724; border: 1px solid #5b4566; }
.mg-cases { background: linear-gradient(115deg, #2c3324 10%, #262c21 60%, #1f231d); }
.mg-cases-art { right: -58px; top: 50%; display: flex; gap: 2px; transform: translateY(-50%) rotate(-8deg); }
.mg-cases-art img { width: 64px; height: 48px; object-fit: contain; }

/* ── music page: last.fm listening stats (stats.js) ── */

.lfm { margin-top: 28px; }
.lfm[hidden], .lfm-block[hidden], .lfm [hidden] { display: none; }
.lfm-block { margin-top: 14px; }
.lfm-block.loading { opacity: 0.55; transition: opacity 0.2s ease; }
.lfm-tabs { display: flex; flex-wrap: wrap; gap: 16px; margin: 4px 0 12px; }
.lfm-tabs .more { margin: 0; }
.lfm-tabs .more[aria-pressed="true"] { color: var(--text); }
.lfm-label {
  margin: 22px 0 10px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lfm-tabs + .lfm-label { margin-top: 0; }
.lfm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 26px; }
.lfm-head + .lfm-sec .lfm-label { margin-top: 12px; }
.lfm-head .lfm-label { margin: 0; }
.lfm-range select {
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.lfm-range select:hover, .lfm-range select:focus-visible { color: var(--text); }
.lfm-range option { background: #1b1a1b; color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* totals: this period vs the one before */
.lfm-bars { display: grid; gap: 10px; }
.lfm-total-text { font-size: 13px; color: var(--muted); margin-bottom: 5px; font-variant-numeric: tabular-nums; }
.lfm-total-text b { color: var(--text); font-weight: 700; }
.lfm-bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.lfm-bar-fill { height: 100%; border-radius: inherit; background: #8d807c; transition: width 0.5s ease; }
.lfm-total.now .lfm-bar-fill { background: #d23c3c; }

/* artists / albums: one big tile + four small */
.lfm-mosaic {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  aspect-ratio: 2 / 1;
  gap: 2px;
  border-radius: var(--radius);
  overflow: hidden;
}
.lfm-tile {
  position: relative;
  display: block;
  min-height: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  text-decoration: none;
}
.lfm-tile:first-child { grid-row: span 2; }
.lfm-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.lfm-tile:hover img, .lfm-tile:focus-visible img { transform: scale(1.04); }
.lfm-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, rgba(0, 0, 0, 0.8));
}
.lfm-tile-text {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 9px;
  z-index: 1;
  display: grid;
  gap: 1px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.lfm-tile-text b { font-size: 13px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lfm-tile-text span, .lfm-tile-text small { font-size: 11px; color: rgba(255, 255, 255, 0.82); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lfm-tile:first-child .lfm-tile-text { left: 14px; bottom: 14px; }
.lfm-tile:first-child .lfm-tile-text b { font-size: clamp(16px, 2.6vw, 22px); }

/* top tracks */
.lfm-tracks { list-style: none; margin: 0; padding: 0; }
.lfm-track a {
  display: grid;
  grid-template-columns: 22px 36px minmax(0, 1fr) minmax(70px, 34%);
  gap: 12px;
  align-items: center;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}
.lfm-track + .lfm-track { border-top: 1px solid rgba(255, 255, 255, 0.06); }
.lfm-track a:hover, .lfm-track a:focus-visible { background: rgba(255, 255, 255, 0.05); }
.lfm-rank { font-size: 12px; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.lfm-track-art { width: 36px; height: 36px; border-radius: 4px; object-fit: cover; background: rgba(255, 255, 255, 0.06); }
.lfm-track-title, .lfm-track-artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lfm-track-title { font-size: 14px; font-weight: 700; line-height: 1.35; }
.lfm-track-artist { font-size: 12px; color: var(--muted); line-height: 1.35; }
.lfm-count {
  position: relative;
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, rgba(210, 60, 60, 0.22) var(--w, 100%), transparent var(--w, 100%));
  border-radius: 4px;
}

@media (max-width: 520px) {
  .lfm-mosaic { grid-template-columns: 1fr 1fr; grid-template-rows: none; aspect-ratio: auto; grid-auto-rows: 120px; }
  .lfm-tile:first-child { grid-row: span 2; grid-column: span 2; }
  .lfm-unit { display: none; }
  .lfm-track a { grid-template-columns: 18px 32px minmax(0, 1fr) 64px; gap: 10px; }
  .lfm-track-art { width: 32px; height: 32px; }
}

/* momentum: tap the time on a row → menu with my fastest times on that map */
.surf-chip.mm-times-btn { cursor: pointer; transition: background 0.15s ease; }
.surf-chip.mm-times-btn::after { content: " ▾"; color: var(--faint); font-size: 9px; }
.surf-chip.mm-times-btn:hover,
.surf-chip.mm-times-btn:focus-visible,
.surf-chip.mm-times-btn.open { background: rgba(255, 255, 255, 0.14); outline: none; }
.mm-times {
  position: fixed;
  z-index: 50;
  min-width: 220px;
  max-width: calc(100vw - 16px);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #262223;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-variant-numeric: tabular-nums;
}
.mm-times-note { margin: 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-times-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mm-time { display: flex; justify-content: space-between; gap: 18px; padding: 3px 0; font-size: 12px; }
.mm-time-date { color: var(--muted); white-space: nowrap; }
.mm-time-time { font-weight: 600; white-space: nowrap; }
.mm-time.pb .mm-time-date { color: var(--text); }
.mm-time.pb .mm-time-time { font-weight: 800; color: rgb(var(--pct-rgb, 232, 137, 216)); }
