:root {
  --bg: #0d1117;
  --bg-card: #161d27;
  --bg-raised: #1d2733;
  --border: #2b3846;
  --text: #d7e1ec;
  --text-dim: #8296ab;
  --accent: #4fb3ff;
  --accent-dim: #2a6ea8;
  --ok: #4fd08a;
  --warn: #e8c15a;
  --bad: #e86a6a;
  /* Run identities on the compare page (issue 135); blue/orange stays
     CVD-distinct. */
  --run-a: #4fb3ff;
  --run-b: #ffa657;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win: any author display rule on an
   element (display: flex on the compare overlay, display: block on
   its entry button...) silently beats the UA's [hidden] otherwise -
   the compare overlay's close button "did nothing" this way. */
[hidden] { display: none !important; }

html {
  /* Mobile browsers inflate "small" text on their own otherwise. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Sans", system-ui, sans-serif;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

h1, h2 { font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin-top: 2rem; color: var(--text); }

/* Header */
.site-header {
  display: flex;
  /* Wraps on narrow screens - with the language toggle the row no
     longer fits a phone, and wrapped rows beat clipped links. */
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  row-gap: 0.2rem;
  padding: 0.7rem 1.2rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; }
.brand-logo { display: block; }
.site-header nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.site-header nav a { color: var(--text-dim); padding: 0.15rem 0; }
.site-header nav a:hover { color: var(--text); text-decoration: none; }
.site-header nav a[aria-current="page"] {
  color: var(--text);
  border-bottom: 2px solid var(--accent);
}
.header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.header-user a.login { color: var(--accent); }
.discord-link {
  display: flex;
  align-items: center;
  color: var(--text-dim);
}
/* Discord brand blurple on hover, so the mark reads as "that Discord". */
.discord-link:hover { color: #5865f2; }
.discord-icon { width: 22px; height: 22px; fill: currentColor; }
.lang-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.lang-toggle button {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.1rem 0.6rem;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}
.lang-toggle button:hover { color: var(--text); }
.lang-toggle button.lang-active {
  background: var(--bg-raised);
  color: var(--text);
  cursor: default;
}
.username {
  color: var(--text-dim);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar { border-radius: 50%; display: block; }
@media (max-width: 480px) {
  .site-header { gap: 1rem; padding: 0.7rem 0.8rem; }
  .username { display: none; }
  .login-full { display: none; }
}

/* Off-screen but read by screen readers (aria-live seek announcements). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Avatar dropdown menu */
.user-menu { position: relative; }
.user-menu summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  user-select: none;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover,
.user-menu[open] summary { background: var(--bg-raised); }
.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 11rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0;
  z-index: 10;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}
.user-menu-panel a,
.user-menu-panel button.linklike {
  display: block;
  width: 100%;
  padding: 0.4rem 1rem;
  color: var(--text-dim);
  text-align: left;
}
.user-menu-panel a:hover,
.user-menu-panel button.linklike:hover {
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
}
.user-menu-panel a.mod-link { color: var(--warn); }
.user-menu-panel a.mod-link:hover { color: var(--warn); }
.user-menu-panel hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.35rem 0;
}
.user-menu summary { position: relative; }
.notify-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}
.draft-badge {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0 0.4rem;
  border-radius: 8px;
  background: var(--warn);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem;
}

/* Hero */
.hero p { color: var(--text-dim); max-width: 44rem; }

/* Tables */
table.runs {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.92rem;
}
table.runs th, table.runs td {
  padding: 0.5rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.runs th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.runs tr:last-child td { border-bottom: none; }
/* Rows that link to a run page (data-href, see app.js) */
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: var(--bg-raised); }
td.time a { font-variant-numeric: tabular-nums; font-weight: 600; }
td.rank { color: var(--text-dim); width: 2.5rem; }
td.players { color: var(--text-dim); }
td.date, td.pb { white-space: nowrap; }
/* Video / telemetry marks squeezed in next to the time */
table.runs th.media, table.runs td.media {
  width: 3rem;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
  white-space: nowrap;
}
.media-mark {
  font-size: 0.85rem;
  cursor: default;
}
.media-mark + .media-mark { margin-left: 0.25rem; }

.empty { color: var(--text-dim); font-style: italic; }

/* Quest list */
.quest-list { list-style: none; padding: 0; margin: 0; }
.quest-list li { padding: 0.2rem 0; }
.breadcrumb { color: var(--text-dim); font-size: 0.9rem; }
/* What a quest rule requires, shown under the leaderboard heading */
.quest-description { color: var(--text-dim); max-width: 46rem; }

/* Quest index: one page, one block per episode */
.quest-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 1rem 0 0.5rem;
}
.quest-search {
  flex: 1;
  min-width: 16rem;
  max-width: 26rem;
}
.alias-badge {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0 0.35rem;
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.count-badge {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0 0.4rem;
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
/* Quests the desktop client cannot time yet (no detection triggers) */
.no-timer-badge {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0 0.35rem;
  border: 1px dashed var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  cursor: help;
}
.no-timer-note {
  margin: 0.35rem 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-style: italic;
}
/* Segment rules (partial-quest categories from Manage quests) nest under
   the quest they are derived from instead of mixing with real quests */
.segment-list {
  list-style: none;
  margin: 0.15rem 0 0.25rem;
  padding-left: 0.9rem;
  border-left: 2px solid var(--border);
}
.segment-list li { padding: 0.15rem 0; }

/* Quests with no verified records fade back so record-holders stand out
   when the full list is shown */
.quest-list li.no-records > a { color: var(--text-dim); }
.quest-list li.no-records .alias-badge {
  border-color: var(--border);
  color: var(--text-dim);
}
.quest-list li.no-records .count-badge { opacity: 0.55; }
.episode-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
}
.episode-jump a {
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-dim);
}
.episode-jump a:hover { color: var(--text); text-decoration: none; border-color: var(--accent-dim); }

.episode-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  margin: 1.5rem 0;
  scroll-margin-top: 1rem;
}
.episode-title {
  margin: 0 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--accent-dim);
  color: var(--accent);
  font-size: 1.3rem;
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem 1.8rem;
}
.category-group h3 {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.category-group .quest-list { font-size: 0.92rem; }

/* Filter tabs */
.filter-tabs { display: flex; gap: 1.5rem; margin: 1rem 0; flex-wrap: wrap; }
.tab-group { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.tab {
  padding: 0.35rem 0.9rem;
  color: var(--text-dim);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
}
.tab:last-child { border-right: none; }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { background: var(--accent-dim); color: #fff; }
.tab .tab-count {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.35rem;
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.tab.active .tab-count {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}
/* Tabs whose category has no verified runs fade back, like
   .quest-list li.no-records */
.tab.tab-empty:not(.active) { color: var(--text-dim); opacity: 0.55; }
.other-categories { color: var(--text-dim); }

/* Records list */
.records-filter {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.records-filter label { color: var(--text-dim); }
.records-context { color: var(--text-dim); }
.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin: 1.5rem 0;
}
.pagination .page-info { color: var(--text-dim); }
.pagination .disabled { color: var(--border); }

/* Badges & notices */
.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}
.status-pending { background: #3a3320; color: var(--warn); }
.status-approved { background: #1e3a2a; color: var(--ok); }
.status-rejected { background: #3a2020; color: var(--bad); }
.status-draft { background: var(--bg-raised); color: var(--text-dim); }
.status-aborted { background: #332720; color: var(--warn); }
.status-unranked { background: var(--bg-raised); color: var(--text-dim); }
.status-held { background: #20303a; color: var(--accent); }
td.visibility { color: var(--text-dim); font-size: 0.85rem; }
.visibility-public { color: var(--ok); }

.notice {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem 1rem;
  margin: 1rem 0;
  background: var(--bg-card);
}
.notice-pending { border-color: var(--warn); }
.notice-rejected { border-color: var(--bad); }
.notice-held { border-color: var(--accent); }
.notice ul { margin: 0.3rem 0; padding-left: 1.2rem; }

/* Client cheat-heuristic flags (submitter / moderators only) */
.cheat-flags {
  border: 1px solid var(--bad);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  margin: 1rem 0;
  background: #3a2020;
}
.cheat-flags strong { color: var(--bad); }
.cheat-flags p { margin: 0.4rem 0 0; }
.cheat-flags ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }

/* Video embed */
/* Run page: stacked by default; on wide screens the video and its
   forms move to a sticky right-hand column so the player stays in
   view while scrolling the telemetry tables - seeking from a rooms
   or weapons row is otherwise invisible (psostats-style). */
@media (min-width: 1200px) {
  main.run-page { max-width: 1520px; }
  .run-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 440px;
    gap: 0 1.5rem;
    align-items: start;
  }
  .run-main { grid-column: 1; grid-row: 1; min-width: 0; }
  .run-aside {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: 1rem;
  }
  .run-aside .video-embed { margin-top: 0; }
}

.video-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  max-width: 800px;
  margin: 1rem 0;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.video-embed iframe,
.video-embed video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-sync-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin: -0.5rem 0 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.video-sync-form { display: flex; gap: 0.35rem; align-items: center; }
.video-sync-form input { width: 6.5rem; font-size: 0.85rem; }

/* Theater mode (issue 137): the sidebar caps the player around 440px
   and OS fullscreen hides every other window, so a toggle swells the
   embed to the browser window instead. The embed itself goes fixed -
   reparenting the iframe would reload it and drop the player API. */
.theater-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  padding: 0.25rem 0.55rem;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.7;
}
.theater-toggle:hover,
.theater-toggle:focus-visible { opacity: 1; }
.video-embed.theater {
  position: fixed;
  inset: 0;
  z-index: 60; /* over the page chrome, under .compare-overlay (100) */
  aspect-ratio: auto;
  max-width: none;
  margin: 0;
  border: 0;
  border-radius: 0;
}
body.theater-lock { overflow: hidden; }
/* The sticky sidebar is its own stacking context, so a theater embed
   inside it stays trapped under later page content - the party
   perspective players painted over it. Raising the sidebar while any
   theater is open frees the main embed; a theater in the perspectives
   list still wins the resulting tie by document order. */
body.theater-lock .run-aside { z-index: 60; }

/* Party perspectives (run page group section) */
.group-member .group-time { font-weight: 600; margin-right: 0.35rem; }
.group-member .video-embed { margin-top: 0.5rem; }

/* Compare mode: fullscreen overlay laying every perspective of one
   attempt out under a single transport (built by app.js). */
.compare-open {
  display: block;
  margin: 0.5rem 0 1rem;
  padding: 0.45rem 0.9rem;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.compare-open:hover { border-color: var(--accent); }
body.compare-lock { overflow: hidden; }
.compare-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.6rem 1rem 0.8rem;
  background: var(--bg);
  overflow-y: auto;
}
.compare-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.compare-header h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.compare-header button {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.7rem;
  font-size: 1rem;
  cursor: pointer;
}
.compare-header button:hover { border-color: var(--accent); }
.compare-header button.active,
.compare-solo-tabs button.active {
  border-color: var(--accent);
  color: var(--accent);
}
.compare-views { display: inline-flex; gap: 0.25rem; }
.compare-solo-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.compare-solo-tabs button {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.compare-body {
  flex: 1;
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  min-height: 0;
}
.compare-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(30rem, 100%), 1fr));
  gap: 0.75rem;
  align-content: center;
}
/* 3-4 perspectives: a fixed two-row layout matching the exported
   video - 3 = top pair plus a centered bottom tile, 4 = 2x2. The
   column cap keeps both rows of 16:9 video inside the viewport
   under the header and transport. */
.compare-grid.tiles-3:not(.solo),
.compare-grid.tiles-4:not(.solo) {
  grid-template-columns:
    repeat(2, minmax(0, calc((100vh - 18rem) / 2 * 16 / 9)));
  justify-content: center;
}
.compare-grid.tiles-3:not(.solo) .compare-tile:last-child {
  grid-column: 1 / -1;
  width: calc(50% - 0.375rem);
  justify-self: center;
}
/* Solo: one perspective fills the stage; the hidden tiles keep
   playing so a tab switch lands on the same quest moment. The width
   cap keeps a 16:9 video inside the viewport under the transport. */
.compare-grid.solo { grid-template-columns: 1fr; }
.compare-grid.solo .compare-tile { display: none; }
.compare-grid.solo .compare-tile.active {
  display: block;
  width: 100%;
  max-width: min(100%, calc((100vh - 16rem) * 16 / 9));
  margin: 0 auto;
}
.compare-drawer {
  width: 18rem;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
}
.compare-drawer h3 {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.compare-room {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  width: 100%;
  padding: 0.28rem 0.4rem;
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}
.compare-room:hover { background: var(--bg-raised); }
.compare-room.now-room {
  background: var(--bg-raised);
  box-shadow: inset 2px 0 0 var(--accent);
}
.compare-room-index { color: var(--text-dim); min-width: 1.3rem; }
.compare-room-area {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compare-room-meta {
  color: var(--text-dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 760px) {
  .compare-body { flex-direction: column; }
  .compare-drawer { width: auto; max-height: 30vh; }
  /* The fixed 3/4-perspective desktop layout sizes its columns off the
     viewport HEIGHT, which overflows a phone sideways - stack instead
     and let the page scroll. */
  .compare-grid.tiles-3:not(.solo),
  .compare-grid.tiles-4:not(.solo) {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }
  .compare-grid.tiles-3:not(.solo) .compare-tile:last-child {
    grid-column: auto;
    width: auto;
  }
  /* Title + up to five buttons cannot share one phone row. */
  .compare-header { flex-wrap: wrap; }
  .compare-header h2 { flex-basis: 100%; }
}
.compare-tile video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.compare-tile-bar {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
.compare-tile-name { font-weight: 600; }
.compare-tile-warn { color: var(--warn); font-size: 0.8rem; }
.compare-tile-buffering { display: none; color: var(--warn); }
.compare-tile.buffering .compare-tile-buffering { display: inline; }
.compare-calibrate {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}
.compare-calibrate button {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.compare-calibrate button.primary { border-color: var(--accent); }
.compare-transport {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.compare-seek { position: relative; }
.compare-seek input[type="range"] { width: 100%; margin: 0; display: block; }
.compare-markers { position: relative; height: 10px; }
.compare-marker {
  position: absolute;
  top: 0;
  width: 4px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 1px;
  background: var(--text-dim);
  cursor: pointer;
  transform: translateX(-50%);
}
.compare-marker-death { background: var(--bad); }
.compare-controls {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}
.compare-play {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.9rem;
  font-size: 1rem;
  cursor: pointer;
}
.compare-time { font-variant-numeric: tabular-nums; }
.compare-audio {
  display: inline-flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.compare-audio label { display: inline-flex; gap: 0.25rem; align-items: center; }
.compare-keys { margin-left: auto; color: var(--text-dim); font-size: 0.8rem; }

/* Run hero: the at-a-glance summary strip under the title (replaces
   the old .run-details <dl> - facts on one glanceable row instead of a
   labeled list to read top to bottom). */
.run-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  margin: 0.8rem 0;
}
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.7rem;
  align-items: baseline;
}
.hero-stat { display: flex; flex-direction: column; }
.hero-label {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.hero-value { font-size: 1.05rem; font-weight: 600; }
.hero-time .hero-value {
  font-size: 1.7rem;
  line-height: 1.15;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.hero-players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.3rem;
  margin-top: 0.55rem;
}
.hero-byline {
  margin: 0.55rem 0 0;
  color: var(--text-dim);
  font-size: 0.88rem;
}
.run-hero .notes { margin: 0.55rem 0 0; }

/* Sticky in-page section nav (run page): which sections exist and one
   click to each. Sits under the theater embed (z 60). */
.section-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.25rem;
  margin: 0.8rem 0;
  padding: 0.35rem 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.section-nav a {
  color: var(--text-dim);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
}
.section-nav a:hover {
  color: var(--text);
  background: var(--bg-raised);
  text-decoration: none;
}
.section-nav a[aria-current] { color: var(--accent); background: var(--bg-raised); }
/* Jump targets stop below the sticky nav instead of underneath it. The
   nav wraps to two lines on narrow screens, so app.js keeps
   --section-nav-h at its measured height; the fallback covers no-JS. */
main.run-page [id] {
  scroll-margin-top: calc(var(--section-nav-h, 2.7rem) + 0.7rem);
}

/* The compare picker rides in the video column (.run-aside): comparing
   is a video activity. Its h2 would otherwise carry the page-level
   2rem top margin and float away from the player. */
.run-aside .compare-picker { margin-top: 0.4rem; }
.run-aside .compare-picker h2 { margin-top: 0.8rem; font-size: 1rem; }
.run-aside .compare-picker .button-primary { display: block; }

.player-list { list-style: none; padding: 0; margin: 0; }
.class-name { color: var(--accent); font-weight: 600; }
.notes { white-space: pre-wrap; }

/* Forms */
form.submit-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 34rem;
}
form.submit-form label { display: flex; flex-direction: column; gap: 0.25rem; }
form.submit-form label.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }
input[type="text"], input[type="url"], input[type="search"], select, textarea {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}
fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
legend { color: var(--text-dim); padding: 0 0.4rem; }
.player-row { display: flex; gap: 0.5rem; align-items: center; }
.player-row input { flex: 1; }
.player-num { color: var(--text-dim); width: 1.2rem; }

button {
  font-family: inherit;
  font-size: 0.95rem;
  border-radius: 5px;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
}
button.primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }
button.primary:hover { background: var(--accent); }
a.button-primary {
  display: inline-block;
  font-size: 0.95rem;
  border-radius: 5px;
  padding: 0.45rem 1rem;
  border: 1px solid var(--accent-dim);
  background: var(--accent-dim);
  color: #fff;
  text-decoration: none;
}
a.button-primary:hover { background: var(--accent); }
button.danger { background: #6d2b2b; border-color: #6d2b2b; color: #fff; }
button.linklike {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0;
  cursor: pointer;
}
button.linklike:hover { color: var(--text); }
form.inline { display: inline-flex; gap: 0.5rem; align-items: center; }

/* Likes: a toggle button on the run page, a compact tally in listings.
   The thumb fills from muted to accent once you've liked a run - the way
   a video site marks it - and pops briefly when toggled on. */
.run-like, .like-form { margin: 0.25rem 0 0.85rem; }
.like-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.like-button:hover { color: var(--accent); border-color: var(--accent); }
.like-button .like-icon { width: 1.1em; height: 1.1em; fill: currentColor; }
.like-button .like-label { font-weight: 600; }
.like-button .like-count {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.like-button.liked {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.like-button.liked .like-count { color: var(--accent); }
.like-button.pop .like-icon { animation: like-pop 0.32s ease; }
@keyframes like-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35); }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .like-button.pop .like-icon { animation: none; }
}

/* Listing tally: a muted thumb + count next to the media marks. */
.like-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
  cursor: default;
}
.like-mark .like-icon { width: 0.95em; height: 0.95em; fill: currentColor; }
.like-mark .like-mark-count { font-variant-numeric: tabular-nums; }
.media-mark + .like-mark { margin-left: 0.3rem; }

/* Drafts (auto-submitted runs awaiting a video) */
.draft-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin: 0.8rem 0;
}
.draft-item p { margin: 0 0 0.6rem; }
.held-item {
  background: var(--bg-card);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin: 0.8rem 0;
}
.held-item p { margin: 0 0 0.6rem; }
/* In-place publish/discard feedback (app.js): a published item keeps
   its row but reads as settled; a discarded one fades away. */
.held-item.held-done { border-color: var(--border); }
.held-item.held-gone { opacity: 0; transition: opacity 0.4s; }
.held-status { font-weight: 600; margin: 0; }
.held-status.published { color: var(--ok); }
.draft-actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.draft-actions input[type="url"] { min-width: 20rem; }
.page-actions { font-size: 0.9rem; }
.auto-publish { margin: 1.5rem 0; }
.auto-publish > p:first-of-type {
  color: var(--text-dim);
  font-size: 0.9rem;
  max-width: 46rem;
}

/* Login page */
form.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
  max-width: 20rem;
}

/* API tokens */
form.token-form { display: flex; gap: 0.5rem; margin: 1rem 0; max-width: 30rem; }
form.token-form input { flex: 1; }
.token-value {
  display: inline-block;
  padding: 0.3rem 0.6rem;
  background: var(--bg-raised);
  border: 1px solid var(--accent-dim);
  border-radius: 5px;
  font-size: 0.95rem;
  user-select: all;
  word-break: break-all;
}

/* Quest management: trigger inputs */
.trigger-field { display: flex; gap: 0.5rem; }
.trigger-field select { flex: 0 0 9rem; }
.trigger-field input { width: 7rem; }
td.triggers { font-family: monospace; font-size: 0.82rem; color: var(--text-dim); }
.trigger-editor-row td { padding-top: 0; border-bottom: 1px solid var(--border); }
.trigger-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem 0 0.9rem;
  max-width: 34rem;
}
.trigger-edit-form label { display: flex; flex-direction: column; gap: 0.2rem; }
.trigger-help { margin: 0.5rem 0 1rem; color: var(--text-dim); font-size: 0.9rem; }
.trigger-help summary { cursor: pointer; color: var(--accent); }
/* Rules table: description and aliases edit in place */
td.rule-description { min-width: 18rem; }
.rule-description-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
}
.rule-description-form textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 0.9rem;
}
.rule-aliases-form {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.4rem;
}
.rule-aliases-form input {
  width: 10rem;
  font-size: 0.85rem;
}

/* Mod queue */
.mod-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}
.mod-item h2 { margin-top: 0; }
.mod-actions { display: flex; gap: 1rem; margin-top: 0.8rem; flex-wrap: wrap; }
.mod-actions input { min-width: 18rem; }

/* Telemetry (run detail) */
.telemetry { margin-top: 2rem; }
.telemetry-note { color: var(--text-dim); font-size: 0.85rem; }
/* Unified telemetry timeline */
.timeline-block { margin: 1rem 0; }
.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.5rem;
  margin-bottom: 0.6rem;
}
.tl-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
}
.tl-legend-item:hover { border-color: var(--text-dim); }
.tl-legend-item.off { opacity: 0.4; }
.tl-legend-item.off .tl-swatch { border-top-style: dotted; }
.tl-swatch {
  display: inline-block;
  width: 16px;
  border-top: 3px solid;
}
.tl-swatch-dash { border-top-style: dashed; }
/* pan-y: horizontal touch drags scrub the tooltip (app.js) while
   vertical swipes still scroll the page. */
.timeline-chart { position: relative; touch-action: pan-y; }
.timeline-svg {
  width: 100%;
  height: 260px;
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.timeline-svg polyline { stroke-width: 1.6; }
.tl-series.off { display: none; }
.tl-grid { stroke: var(--border); stroke-width: 1; }
.tl-event { stroke-width: 1; }
.tl-event-death { stroke: var(--bad); }
.tl-event-floor { stroke: var(--text-dim); stroke-dasharray: 2 3; }
.tl-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.tl-event-label {
  position: absolute;
  top: 2px;
  padding-left: 3px;
  font-size: 0.65rem;
  color: var(--text-dim);
  max-width: 7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-event-label.tl-event-death { color: var(--bad); }
.tl-ticks {
  position: relative;
  height: 1.1rem;
  font-size: 0.7rem;
  color: var(--text-dim);
}
.tl-tick { position: absolute; transform: translateX(-50%); }
.timeline-note { color: var(--text-dim); font-size: 0.78rem; margin: 0.4rem 0 0; }
/* Per-room analysis table */
.rooms-block { margin: 1rem 0; }
.rooms-block .timeline-note { margin-bottom: 0.6rem; }
.rooms-block input#reset-overhead { width: 4rem; font-size: 0.85rem; }
.rooms-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.2rem;
  margin-bottom: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}
/* Hunt planner: section id + wanted item, filled from the server's
   drop tables; picking an item auto-checks its droppers with rates */
.rooms-controls .hunt-label,
.rooms-controls select#hunt-section,
.rooms-controls select#hunt-item {
  font-size: 0.85rem;
}
.rooms-controls select#hunt-section { max-width: 9rem; }
.rooms-controls select#hunt-item { max-width: 16rem; }

/* /hunt: quest drop-efficiency page. The controls sit in one labeled
   console card so each pill row names what it switches. */
.hunt-controls {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 1rem 0 0.8rem;
  padding: 0.75rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.7rem;
}
.control-label {
  flex: 0 0 7rem;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.control-hint { color: var(--text-dim); font-size: 0.8rem; }
.control-hint a { color: var(--accent); }
@media (max-width: 640px) {
  .control-label { flex-basis: 100%; }
}
.section-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.section-chip {
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--text-dim);
}
.section-chip::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  background: var(--section-color, var(--text-dim));
  vertical-align: baseline;
}
.section-chip.active {
  border-color: var(--section-color, var(--accent));
  box-shadow: inset 0 0 0 1px var(--section-color, var(--accent));
  color: var(--text);
  background: var(--bg-raised);
  font-weight: 600;
}
.section-chip[data-section="Viridia"] { --section-color: #4caf50; }
.section-chip[data-section="Greenill"] { --section-color: #9acd32; }
.section-chip[data-section="Skyly"] { --section-color: #64c8e8; }
.section-chip[data-section="Bluefull"] { --section-color: #4169e1; }
.section-chip[data-section="Purplenum"] { --section-color: #9b59d0; }
.section-chip[data-section="Pinkal"] { --section-color: #e87ab0; }
.section-chip[data-section="Redria"] { --section-color: #e05252; }
.section-chip[data-section="Oran"] { --section-color: #e8963c; }
.section-chip[data-section="Yellowboze"] { --section-color: #e0c840; }
.section-chip[data-section="Whitill"] { --section-color: #e8e8e8; }
.section-chip-all::before { display: none; }
.hunt-table .section-chip { padding: 0.05rem 0.45rem; white-space: nowrap; }
.rbr-label { color: var(--text-dim); font-size: 0.8rem; margin-right: 0.2rem; }
.rbr-note { color: var(--accent); font-size: 0.85rem; }
.hunt-table-wrap { overflow-x: auto; margin: 0.6rem 0; }
.hunt-table { border-collapse: collapse; width: 100%; }
.hunt-table th, .hunt-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.9rem;
  vertical-align: top;
}
.hunt-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hunt-table tbody tr:hover td { background: var(--bg-card); }
.hunt-table th.num, .hunt-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hunt-table td.item { font-weight: 600; }
.hunt-table td.contributors { color: var(--text-dim); font-size: 0.82rem; }
/* The shared per-run scale: a thin single-hue meter under the number,
   sized against the table's top row. */
.hunt-table .meter {
  height: 4px;
  min-width: 5rem;
  margin-top: 4px;
  background: var(--bg-raised);
  border-radius: 2px;
  overflow: hidden;
}
.hunt-table .meter-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--accent);
  border-radius: 2px;
}
/* Target-enemy dropdown: checkboxes, so several enemies (say, every
   enemy dropping the hunted item) combine into one quit-point answer */
.target-enemy-picker { position: relative; }
.target-enemy-picker summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-raised);
}
.target-enemy-picker summary::-webkit-details-marker { display: none; }
.target-enemy-picker summary::after { content: " ▾"; color: var(--text-dim); }
.target-enemy-picker #target-enemy-current { color: var(--text); }
.target-enemy-options {
  position: absolute;
  left: 0;
  top: calc(100% + 0.3rem);
  z-index: 15;
  max-height: 15rem;
  /* Nowrap rows on a phone: cap to the viewport and scroll sideways
     rather than vanish off screen. */
  max-width: min(24rem, calc(100vw - 1.5rem));
  overflow-x: auto;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}
.target-enemy-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.12rem 0;
  cursor: pointer;
}
.target-enemy-option:hover { color: var(--text); }
/* Per-enemy drop-rate denominator: fills the weighted (expected drops)
   mode; right-aligned so the checkbox column stays scannable */
.target-enemy-option .target-rate {
  margin-left: auto;
  padding-left: 0.8rem;
  color: var(--text-dim);
}
.target-enemy-option .target-rate-input {
  width: 3.8rem;
  font-size: 0.8rem;
  padding: 0.1rem 0.25rem;
}
/* Edge shadows appear only while columns are cut off, so a horizontally
   scrollable table doesn't read as a complete one (mostly mobile).
   .table-scroll is the generic wrapper every wide table gets so a phone
   scrolls the table, not the whole page; --scroll-bg matches the
   table's own background so the shadow fades into it. */
.table-scroll,
.rooms-scroll,
.hunt-table-wrap,
.km-table-wrap {
  overflow-x: auto;
  background:
    linear-gradient(90deg, var(--scroll-bg, var(--bg-card)) 40%, transparent) left / 32px 100%,
    linear-gradient(270deg, var(--scroll-bg, var(--bg-card)) 40%, transparent) right / 32px 100%,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.6), transparent) left / 12px 100%,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.6), transparent) right / 12px 100%;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}
/* These tables sit on the page background, not a card. */
.hunt-table-wrap,
.km-table-wrap { --scroll-bg: var(--bg); }
/* table.runs paints an opaque card background that would hide the edge
   shadows - the card color moves to the wrapper (color sits under the
   shadow images) and the table itself goes transparent. */
.table-scroll { background-color: var(--bg-card); }
.table-scroll > table.runs { background: transparent; }
.rooms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}
.rooms-table th, .rooms-table td {
  padding: 0.25rem 0.6rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.rooms-table th:nth-child(2), .rooms-table td:nth-child(2) { text-align: left; }
.rooms-table th { color: var(--text-dim); font-weight: 600; }
.rooms-table tfoot td { color: var(--text-dim); border-bottom: none; }
.rooms-table .room-area { max-width: 22rem; }
.room-enemies {
  color: var(--text-dim);
  font-size: 0.75rem;
  white-space: normal;
}
.rooms-table tr.best-row td { background: rgba(79, 179, 255, 0.12); }
.rooms-table tr.best-row td:first-child { border-left: 2px solid var(--accent); }
/* Names the highlight in place: rendered by the server on the initial
   best row, moved and reworded by app.js when the target mode changes. */
.best-row-badge {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0 0.45rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  cursor: help;
}
.best-row-badge::before { content: "★ "; font-size: 0.85em; }
/* Rows seek the video when a player is present (class set by app.js) */
.rooms-table.seekable tbody tr[data-start] { cursor: pointer; }
.rooms-table.seekable tbody tr[data-start]:hover td { background: var(--bg-raised); }
/* The Enter cell doubles as the seek affordance */
.rooms-table.seekable tbody tr[data-start] td:nth-child(3)::before {
  content: "▶ ";
  font-size: 0.7em;
  color: var(--accent);
  opacity: 0.75;
}
.rooms-table.seekable tbody tr[data-start]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* Playback feedback: flash the clicked row, mark the row being played */
@keyframes seek-flash {
  from { box-shadow: inset 0 0 0 999px rgba(79, 179, 255, 0.3); }
  to { box-shadow: inset 0 0 0 999px rgba(79, 179, 255, 0); }
}
.rooms-table tr.seek-flash td,
.usage-row.seek-flash { animation: seek-flash 0.9s ease-out; }
.rooms-table tbody tr.now-row td { background: rgba(79, 179, 255, 0.1); }
.rooms-table tbody tr.now-row td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
/* Hover breakdown: cumulative per-enemy kills and kills/min (app.js) */
.room-tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  display: none;
  background: rgba(13, 17, 23, 0.94);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
  white-space: nowrap;
  max-width: calc(100vw - 8px);
  overflow: hidden;
}
.room-tooltip .tt-time { color: var(--text); font-weight: 600; margin-bottom: 0.15rem; }
.room-tooltip .tt-row { display: flex; align-items: center; gap: 0.35rem; }
.room-tooltip .tt-label { color: var(--text-dim); }
.room-tooltip .tt-count { margin-left: auto; padding-left: 0.8rem; color: var(--text); }
.room-tooltip .tt-value { min-width: 4.2em; text-align: right; color: var(--text); }
.room-tooltip .tt-target .tt-label,
.room-tooltip .tt-target .tt-count,
.room-tooltip .tt-target .tt-value { color: var(--accent); }
.usage-row.now-row { outline: 1px solid var(--accent); }

/* Narrow screens: keep the rooms columns that answer "where/when/how
   fast", the rest stays reachable by horizontal scroll. */
@media (max-width: 700px) {
  .rooms-table th:nth-child(5), .rooms-table td:nth-child(5),
  .rooms-table th:nth-child(8), .rooms-table td:nth-child(8),
  .rooms-table th:nth-child(9), .rooms-table td:nth-child(9) { display: none; }
  .room-enemies {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

.timeline-chart.seekable { cursor: pointer; }
.timeline-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px solid var(--accent);
  pointer-events: none;
  display: none;
}
.timeline-crosshair {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px solid var(--text-dim);
  pointer-events: none;
  display: none;
}
.timeline-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  display: none;
  background: rgba(13, 17, 23, 0.94);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
  white-space: nowrap;
}
.timeline-tooltip .tt-time {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 0.15rem;
}
.timeline-tooltip .tt-row { display: flex; align-items: center; gap: 0.35rem; }
.timeline-tooltip .tt-dot {
  width: 8px;
  height: 3px;
  display: inline-block;
}
.timeline-tooltip .tt-label { color: var(--text-dim); }
.timeline-tooltip .tt-value { margin-left: auto; padding-left: 0.6rem; color: var(--text); }
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.8rem;
}
.telemetry-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem 1rem;
}
.telemetry-block h3 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
}
.telemetry-block h3 + .usage-row { margin-top: 0; }
.usage-row {
  position: relative;
  margin: 0.25rem 0;
  background: var(--bg-raised);
  border-radius: 4px;
  overflow: hidden;
  min-height: 1.5rem;
}
.usage-bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent-dim);
  opacity: 0.45;
}
.usage-label {
  position: relative;
  display: block;
  padding: 0.1rem 0.5rem;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.usage-detail { color: var(--text-dim); white-space: nowrap; }
/* Each moment a weapon comes into use is its own explicit seek button;
   the row itself is not clickable (several uses = no single target). */
.usage-starts {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.1rem 0.5rem 0.3rem;
}
button.seek-chip {
  font-size: 0.72rem;
  padding: 0 0.4rem;
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
button.seek-chip::before {
  content: "▶ ";
  font-size: 0.7em;
  opacity: 0.75;
}
button.seek-chip:hover { background: var(--bg-raised); border-color: var(--accent); }
.equipment-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
}
.equipment-list li { padding: 0.15rem 0; }
.equipment-type {
  display: inline-block;
  min-width: 4.5rem;
  color: var(--text-dim);
  text-transform: capitalize;
}
.equipment-time { color: var(--text-dim); font-size: 0.9em; }
.usage-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
}
.chip-tech { border-color: var(--accent-dim); }
.event-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  max-height: 16rem;
  overflow-y: auto;
}
.event-list li { padding: 0.1rem 0; color: var(--text-dim); }
.event-list .event-death { color: var(--bad); }
.player-level, .section-id { color: var(--text-dim); font-size: 0.85rem; }

/* Profile statistics */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}
.stats-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 1rem;
  font-size: 0.9rem;
}
.stats-list dt { color: var(--text-dim); }
.stats-list dd { margin: 0; text-align: right; }
.class-distribution {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem 1rem;
}
.class-distribution h3 { margin: 0 0 0.6rem; font-size: 0.95rem; }

/* Compare page (issue 135): two runs of one quest side by side. Run A
   keeps --run-a and run B --run-b across the header, the videos and
   the rooms table; the timeline tells its pairs apart by dash instead,
   matching the swatches (A solid, B dashed). */
/* Quest picker: app.js's searchable upgrade of the /runs quest filter,
   in the /quests index's style - an input filtering a grouped panel. */
.quest-picker { position: relative; flex: 1; min-width: 16rem; max-width: 26rem; }
.quest-picker input { width: 100%; }
.quest-picker-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.3rem);
  z-index: 30;
  /* Phones in landscape (and the on-screen keyboard) leave little
     height - never let the panel outgrow the viewport. */
  max-height: min(22rem, 60vh);
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}
.quest-picker-group {
  padding: 0.35rem 0.8rem 0.15rem;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.quest-picker-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.3rem 0.8rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}
.quest-picker-item:hover,
.quest-picker-item.active { background: var(--bg-card); }
.quest-picker-item .alias-badge { margin-left: auto; }

.compare-picker { margin: 1.2rem 0; }
.compare-picker .compare-fastest {
  display: inline-block;
  margin-bottom: 0.6rem;
}
.compare-picker form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.compare-picker select { max-width: 100%; font-size: 0.9rem; }
.compare-picker .help { margin: 0.3rem 0 0; }

.compare-page-header {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.compare-card {
  flex: 1 1 16rem;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
}
.compare-card-time {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
}
.compare-card-label { color: var(--text-dim); font-size: 0.8rem; }
.compare-card-meta { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.2rem; }
.compare-card-players { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.2rem; }
.compare-swatch { display: inline-block; width: 16px; border-top: 3px solid; }
.compare-swatch-a { border-top-color: var(--run-a); }
.compare-swatch-b { border-top-color: var(--run-b); border-top-style: dashed; }
.compare-vs {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-width: 8rem;
}
.compare-delta { font-size: 1.3rem; font-weight: 700; }
.compare-delta.delta-a { color: var(--run-a); } /* B slower: A leads */
.compare-delta.delta-b { color: var(--run-b); }
.compare-vs .help { margin: 0; }
.compare-swap { font-size: 0.85rem; }

/* Both players stay on screen while scrolling the rooms table -
   seeking from a row is otherwise invisible (the .run-aside idea).
   Flex, not grid: app.js grows each pane in proportion to its video's
   real aspect ratio, so two recordings of different shapes still show
   the game at one shared height. */
.compare-videos {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  gap: 0.8rem;
  background: var(--bg);
  padding: 0.4rem 0;
}
.compare-video-pane { flex: 1 1 0; min-width: 0; }
.compare-pane-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.compare-player {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.compare-player iframe,
.compare-player video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Aligned rooms table: Δ cells are colored by the run they favor,
   one-sided visits are dimmed, and while the videos play each run's
   current room is marked on its own edge of the row. */
.compare-rooms-table td.delta-a { color: var(--run-a); }
.compare-rooms-table td.delta-b { color: var(--run-b); }
.compare-rooms-table tr.one-sided td { color: var(--text-dim); }
.one-sided-mark { color: var(--text-dim); font-size: 0.85em; }
.death-mark { color: var(--bad); }
.compare-rooms-table.seekable tbody tr { cursor: pointer; }
.compare-rooms-table.seekable tbody tr:hover td { background: var(--bg-raised); }
.compare-rooms-table.seekable tbody tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* Each Enter cell doubles as that run's seek affordance */
.compare-rooms-table.seekable tbody tr[data-start-a] td:nth-child(3)::before {
  content: "▶ ";
  font-size: 0.7em;
  color: var(--run-a);
  opacity: 0.75;
}
.compare-rooms-table.seekable tbody tr[data-start-b] td:nth-child(4)::before {
  content: "▶ ";
  font-size: 0.7em;
  color: var(--run-b);
  opacity: 0.75;
}
.compare-rooms-table tbody tr.now-row-a td,
.compare-rooms-table tbody tr.now-row-b td { background: rgba(79, 179, 255, 0.07); }
.compare-rooms-table tbody tr.now-row-a td:first-child { box-shadow: inset 2px 0 0 var(--run-a); }
.compare-rooms-table tbody tr.now-row-b td:last-child { box-shadow: inset -2px 0 0 var(--run-b); }

/* Run B's timeline markers render dimmed next to run A's, and each
   run's finish line wears its identity color. */
.tl-event-death-b { stroke: var(--bad); opacity: 0.45; }
.tl-event-floor-b { stroke: var(--text-dim); stroke-dasharray: 2 3; opacity: 0.45; }
.tl-event-label.tl-event-death-b { color: var(--bad); opacity: 0.65; }
.tl-event-label.tl-event-floor-b { opacity: 0.65; }
.tl-event-finish { stroke: var(--run-a); }
.tl-event-finish-b { stroke: var(--run-b); }
.tl-event-label.tl-event-finish { color: var(--run-a); }
.tl-event-label.tl-event-finish-b { color: var(--run-b); }

@media (max-width: 700px) {
  .compare-videos { position: static; flex-direction: column; }
  .compare-video-pane { width: 100%; flex: none !important; }
  /* The generic .rooms-table rule above hides columns 5/8/9, but on
     the compare table those are the Δ columns - the whole point.
     Keep # / Area / Enter / Δ, drop the Stay and Kills pairs. */
  .compare-rooms-table th:nth-child(5), .compare-rooms-table td:nth-child(5),
  .compare-rooms-table th:nth-child(8), .compare-rooms-table td:nth-child(8) { display: table-cell; }
  .compare-rooms-table th:nth-child(6), .compare-rooms-table td:nth-child(6),
  .compare-rooms-table th:nth-child(7), .compare-rooms-table td:nth-child(7),
  .compare-rooms-table th:nth-child(9), .compare-rooms-table td:nth-child(9),
  .compare-rooms-table th:nth-child(10), .compare-rooms-table td:nth-child(10) { display: none; }
}

/* Kill planner (guaranteed-kill matrix, kill-matrix.js) */
.kill-matrix-section { margin-top: 2rem; }
.km-controls {
  display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem;
  margin: 0.75rem 0; align-items: center;
}
.km-control { color: var(--text-dim); font-size: 0.85rem; }
.km-control select, .km-control input[type="number"] {
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px; padding: 0.2rem 0.35rem;
}
.km-control input[type="number"] { width: 3.5rem; }
.km-table-wrap { overflow-x: auto; }
.km-table {
  border-collapse: collapse; font-size: 0.82rem; white-space: nowrap;
}
.km-table th, .km-table td {
  border: 1px solid var(--border); padding: 0.3rem 0.5rem; text-align: center;
}
.km-table thead th {
  background: var(--bg-raised); font-weight: 600; vertical-align: bottom;
}
.km-table .km-count { display: block; color: var(--text-dim); font-weight: 400; }
.km-weapon { text-align: left; background: var(--bg-card); }
.km-weapon-detail { color: var(--text-dim); font-size: 0.9em; }
.km-cell.km-ok { color: var(--ok); background: #16281e; font-weight: 600; }
.km-cell.km-hit { color: var(--warn); background: #2a2416; }
.km-cell.km-no { color: var(--text-dim); }
.km-cell.km-na { color: var(--text-dim); opacity: 0.5; }
.km-notes { margin-top: 0.6rem; }
.km-note { color: var(--text-dim); font-size: 0.8rem; margin: 0.25rem 0; }
.km-character { color: var(--text); font-weight: 600; }
.km-cell .km-line { display: block; white-space: nowrap; }
.km-line.km-ok { color: var(--ok); font-weight: 600; }
.km-line.km-hit { color: var(--warn); }
.km-line.km-no { color: var(--text-dim); }
.km-sn-tag {
  display: inline-block; font-size: 0.68em; font-weight: 700;
  padding: 0 0.25em; border-radius: 3px; vertical-align: 0.1em;
  background: var(--accent-dim); color: var(--bg);
}
.km-line.km-fast { opacity: 0.75; font-weight: 400; }

/* Dates: app.js re-renders each <time class="date"> in the viewer's
   timezone and appends a muted recency label ("· today"). The run
   page carries the run's own date in its hero strip so it cannot be
   mistaken for the compare candidates' dates further down. */
.date-rel { color: var(--text-dim); font-size: 0.85em; }

/* Client page: the download button and three quick steps are the whole
   pitch; everything long-form collapses into .client-faq below them. */
.client-reqs {
  display: inline-block;
  margin-left: 0.9rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.quick-steps { max-width: 44rem; padding-left: 1.4rem; }
.quick-steps li { margin: 0.55rem 0; }
.client-faq details {
  max-width: 44rem;
  margin: 0.5rem 0;
  padding: 0 0.9rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-card);
}
.client-faq summary {
  cursor: pointer;
  padding: 0.55rem 0;
  font-weight: 600;
}
.client-faq summary:hover { color: var(--accent); }
.client-faq details[open] { padding-bottom: 0.7rem; }
.client-faq p, .client-faq ul { color: var(--text-dim); }

/* ---- Mobile / touch (issue 85) ------------------------------------ */

/* Tap feedback: hover styles never fire on touch, so pressing a
   clickable row acknowledges the touch the way hover does a mouse. */
tr[data-href]:active td,
.rooms-table.seekable tbody tr[data-start]:active td,
.compare-rooms-table.seekable tbody tr:active td {
  background: var(--bg-raised);
}

/* Fingers need bigger targets than cursors (44px-ish rule of thumb). */
@media (pointer: coarse) {
  .site-header nav a { padding: 0.4rem 0; }
  .lang-toggle button { padding: 0.35rem 0.7rem; }
  .user-menu-panel a,
  .user-menu-panel button.linklike { padding: 0.6rem 1rem; }
  .tab { padding: 0.5rem 0.9rem; }
  .section-chip { padding: 0.3rem 0.7rem; }
  .tl-legend-item { padding: 0.3rem 0.6rem; }
  button.seek-chip { padding: 0.25rem 0.55rem; }
  .compare-header button,
  .compare-solo-tabs button,
  .compare-calibrate button { padding: 0.45rem 0.8rem; }
  /* Seek markers are 4px slivers - fine to click, hopeless to tap. */
  .compare-marker { width: 10px; }
  /* Keyboard shortcut hints mean nothing without a keyboard. */
  .compare-keys { display: none; }
}

@media (max-width: 700px) {
  /* iOS Safari zooms into any focused field whose text is under 16px,
     and the page stays zoomed after - keep form text at 16px on
     phones so focus never zooms. */
  input[type="text"], input[type="url"], input[type="search"],
  input[type="number"], input[type="password"], select, textarea,
  /* higher-specificity small controls that would otherwise keep
     their sub-16px size */
  .rooms-block input#reset-overhead,
  .target-enemy-option .target-rate-input,
  .rooms-controls select#hunt-section,
  .rooms-controls select#hunt-item {
    font-size: 16px;
  }
  /* Fixed min-widths that fit a desktop sidebar overflow a phone. */
  .draft-actions input[type="url"],
  .mod-actions input {
    min-width: 0;
    width: 100%;
  }
  .quest-search, .quest-picker { min-width: 0; }
}

@media (max-width: 480px) {
  .site-header nav { gap: 0.75rem; flex-wrap: wrap; }
}
