@font-face {
  font-family: 'Inter Variable';
  src: url('inter-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Bebas Neue';
  src: url('bebas-neue-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* Public research uses the app's ink, parchment and ember design tokens. */
:root {
  color-scheme: dark;
  --ink-0: #0c0e12;
  --ink-1: #13161c;
  --ink-2: #1a1e26;
  --ink-3: #232833;
  --border: #272c37;
  --border-strong: #3b4251;
  --text: #f2e8d5;
  --text-2: #c4b8a1;
  --text-3: #8d8473;
  --ember: #ff6a1f;
  --ember-bright: #ff9147;
  --ember-text: #ff8b42;
  --link: #ff9a5c;
  --text-on-ember: #1b0d03;
  --positive: #9ccf9a;
  --negative: #ec8672;
  --warning: #e9b65a;
  --info: #9db7cc;
  --mixed: #b9a6e3;
  --toka: #f2c94c;
  --savu: #a970e0;
  font: 15px/1.5 'Inter Variable', Inter, system-ui, sans-serif;
  background: var(--ink-0);
  color: var(--text);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    color-scheme: light;
    --ink-0: #f5eddc;
    --ink-1: #fffaf0;
    --ink-2: #fbf3e2;
    --ink-3: #f0e5cf;
    --border: #e3d6bb;
    --border-strong: #c9b995;
    --text: #1f1a13;
    --text-2: #574c3c;
    --text-3: #82755f;
    --ember: #d2470c;
    --ember-bright: #e8601f;
    --ember-text: #b23a07;
    --link: #a53405;
    --text-on-ember: #fff8ee;
    --positive: #2f7a3b;
    --negative: #b53a25;
    --warning: #8f5f00;
    --info: #3d6483;
    --mixed: #6d4eaa;
  }
}

:root[data-theme='light'] {
  color-scheme: light;
  --ink-0: #f5eddc;
  --ink-1: #fffaf0;
  --ink-2: #fbf3e2;
  --ink-3: #f0e5cf;
  --border: #e3d6bb;
  --border-strong: #c9b995;
  --text: #1f1a13;
  --text-2: #574c3c;
  --text-3: #82755f;
  --ember: #d2470c;
  --ember-bright: #e8601f;
  --ember-text: #b23a07;
  --link: #a53405;
  --text-on-ember: #fff8ee;
  --positive: #2f7a3b;
  --negative: #b53a25;
  --warning: #8f5f00;
  --info: #3d6483;
  --mixed: #6d4eaa;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(60rem 34rem at 50% -8rem, rgb(255 106 31 / .14), transparent 70%), var(--ink-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-underline-offset: .2em; }
a:hover { color: var(--ember-bright); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--ember-bright); outline-offset: 3px; }
[hidden] { display: none !important; }

.site-header {
  min-height: 53px;
  padding: 0 max(20px, calc((100vw - 1380px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--ink-0) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 6px; background: linear-gradient(180deg, var(--ember-bright), var(--ember));
  color: var(--text-on-ember); box-shadow: 0 5px 16px -7px var(--ember);
}
.brand-mark svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.75; }
.brand-name { font: 400 1.35rem/.95 'Bebas Neue', Impact, sans-serif; letter-spacing: .06em; }
.brand-name em { color: var(--ember-text); font-style: normal; }
.site-header nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.site-header nav a { padding: 14px 10px; color: var(--text-2); text-decoration: none; font-size: .82rem; font-weight: 650; }
.site-header nav a:hover { color: var(--text); background: var(--ink-2); }
.site-header nav .app-link { color: var(--ember-text); }

main, .site-footer { max-width: 1440px; margin: auto; padding-left: 24px; padding-right: 24px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 175px; gap: 48px; align-items: center; padding: 64px 0 52px; }
.hero-copy { max-width: 720px; }
.eyebrow { color: var(--ember-text); font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 12px; }
.hero h1, .section h2, .share-screen h1, .inspector h3, .group-card h3 {
  font-family: 'Bebas Neue', Impact, sans-serif; font-weight: 400; letter-spacing: .035em; text-transform: uppercase;
}
.hero h1 { font-size: clamp(3.4rem, 6vw, 5.75rem); line-height: .94; margin: 0 0 18px; text-wrap: balance; text-shadow: 0 2px 40px rgb(255 106 31 / .25); }
.lede { color: var(--text-2); font-size: clamp(1rem, 1.4vw, 1.13rem); max-width: 620px; margin: 0 0 28px; }
.hero-actions, .section-tools, .share-toolbar > div { display: flex; gap: 10px; flex-wrap: wrap; }
.primary-button, .ghost-button, button {
  min-height: 40px; border-radius: 10px; padding: 8px 14px;
  display: inline-flex; justify-content: center; align-items: center;
  text-decoration: none; font-size: .88rem; font-weight: 650;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.primary-button { border: 1px solid var(--ember); background: linear-gradient(180deg, var(--ember-bright), var(--ember)); color: var(--text-on-ember); box-shadow: inset 0 1px 0 rgb(255 255 255 / .28), 0 6px 20px -8px var(--ember); }
.primary-button:hover { color: var(--text-on-ember); filter: brightness(1.06); }
.ghost-button, button { background: var(--ink-2); border: 1px solid var(--border-strong); color: var(--text); }
.ghost-button:hover, button:hover { background: var(--ink-3); border-color: var(--text-3); color: var(--text); }
.hero-stat { display: grid; gap: 1px; border-left: 1px solid var(--border-strong); padding-left: 28px; }
.hero-stat strong { font: 400 3.1rem/.92 'Bebas Neue', Impact, sans-serif; color: var(--ember-text); margin-top: 10px; }
.hero-stat span { color: var(--text-2); font-size: .78rem; }
.method-note { max-width: 1050px; margin: 0 0 56px; padding: 14px 17px; border: 1px solid var(--border); border-left: 3px solid var(--ember); border-radius: 10px; background: var(--ink-1); color: var(--text-2); font-size: .85rem; }
.method-note strong { color: var(--text); }
.preview-note { border-color: var(--ember); }

.section { margin-bottom: 72px; scroll-margin-top: 70px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 20px; }
.section h2 { font-size: clamp(2.35rem, 4vw, 3.4rem); line-height: .95; margin: 0 0 8px; }
.section-subtitle { margin: 0; color: var(--text-2); }
.section-tools { align-items: end; }
.controls, .table-controls {
  display: flex; align-items: end; flex-wrap: wrap; gap: 12px;
  margin-bottom: 15px; padding: 16px;
  background: var(--ink-1); background-image: linear-gradient(180deg, rgb(255 255 255 / .025), transparent 40%);
  border: 1px solid var(--border); border-radius: 16px;
}
.controls label, .table-controls label { display: grid; gap: 6px; min-width: 148px; flex: 1; color: var(--text-2); font-size: .76rem; font-weight: 650; }
.controls select, .table-controls select, .table-controls input, .share-url-label input {
  width: 100%; min-height: 40px; padding: 8px 10px;
  background: var(--ink-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px;
}
.controls .check-label { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; min-height: 40px; align-self: end; white-space: nowrap; }
.check-label input { width: 18px; height: 18px; accent-color: var(--ember); }
.reset-button { align-self: end; white-space: nowrap; }
.map-summary, .table-topline { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin: 8px 0 13px; color: var(--text-2); font-size: .82rem; }
.legend { display: flex; gap: 13px; flex-wrap: wrap; }
.legend span { white-space: nowrap; }
.legend-dot { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 50%; }
.legend-region { display: inline-block; width: 14px; height: 9px; margin-right: 5px; border: 1px dashed var(--ember-text); border-radius: 4px; background: rgb(255 106 31 / .12); }
.bond { background: var(--positive); } .tension { background: var(--negative); } .game { background: var(--warning); } .neutral { background: var(--info); } .mixed { background: var(--mixed); }
.castaway-browser { display: none; }
.cast-load-error { margin: 0 0 14px; }
.cast-load-error button { min-height: 34px; margin-left: 8px; }

.map-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.map-frame, .inspector, .group-card, .table-wrap { background: var(--ink-1); background-image: linear-gradient(180deg, rgb(255 255 255 / .025), transparent 40%); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 1px 2px rgb(0 0 0 / .4); }
.map-frame { overflow: hidden; min-height: 570px; }
.map-alliance-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--ink-1); }
.map-alliance-bar[hidden] { display: none; }
.map-alliance-bar__label { margin-right: 4px; color: var(--text-3); font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.alliance-chip { display: inline-flex; gap: 7px; min-height: 34px; padding: 5px 10px; border-color: var(--border-strong); background: var(--ink-2); font-size: .78rem; }
.alliance-chip::before { content: ''; display: inline-block; width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--alliance-color); }
.alliance-chip[aria-pressed='true'] { border-color: var(--alliance-color); box-shadow: 0 0 0 1px var(--alliance-color); }
.alliance-chip--empty { color: var(--text-3); font-size: .8rem; }
.map-frame svg { display: block; width: 100%; }
.map-hint { color: var(--text-3); font-size: .8rem; padding: 0 18px 15px; margin: -6px 0 0; }
.inspector { padding: 22px; }
.inspector h3 { font-size: 1.9rem; line-height: 1; margin: 0 0 12px; }
.inspector p { color: var(--text-2); margin: 0 0 14px; }
.inspector .eyebrow { margin-bottom: 8px; }
.inspector .minor { font-size: .8rem; color: var(--text-3); }
.person-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 15px; }
.mini-avatar { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--toka); color: #1b0d03; font-weight: 700; }
.mini-avatar.savu { background: var(--savu); color: #1b0d03; }
.mini-avatar, .castaway-tile__portrait, .player-card__portrait { position: relative; overflow: hidden; }
.mini-avatar img, .castaway-tile__portrait img, .player-card__portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.player-card__portrait img { object-position: center 24%; }
.connection-list, .evidence-list { display: grid; gap: 8px; }
.evidence-list { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.connection-button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; }
.connection-button span:last-child { font-size: .75rem; color: var(--text-3); }
.inspector .status-pill, .tag { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: .69rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; border: 1px solid transparent; }
.status-pill.bond, .tag.bond { color: var(--positive); background: rgb(156 207 154 / .12); border-color: rgb(156 207 154 / .3); }
.status-pill.tension, .tag.tension { color: var(--negative); background: rgb(236 134 114 / .13); border-color: rgb(236 134 114 / .3); }
.status-pill.game, .tag.game { color: var(--warning); background: rgb(233 182 90 / .12); border-color: rgb(233 182 90 / .3); }
.status-pill.neutral, .tag.neutral { color: var(--info); background: rgb(157 183 204 / .12); border-color: rgb(157 183 204 / .3); }
.status-pill.mixed, .tag.mixed { color: var(--mixed); background: rgb(185 166 227 / .12); border-color: rgb(185 166 227 / .3); }
.evidence-card { padding: 12px; background: var(--ink-2); border-left: 3px solid var(--border-strong); border-radius: 6px; }
.evidence-card p { font-size: .85rem; margin: 5px 0 8px; }
.evidence-card .meta { font-size: .74rem; color: var(--text-3); }
.evidence-card .meta strong { color: var(--text); }
.evidence-card .sources { display: flex; gap: 8px; flex-wrap: wrap; font-size: .75rem; }
.inspector-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.inspector-tools button { font-size: .82rem; }
.pair-empty { padding: 13px; border: 1px dashed var(--border-strong); border-radius: 8px; }
.pair-empty strong { color: var(--ember-text); }
#relationship-map .node, #relationship-map .edge { cursor: pointer; }
#relationship-map .node:hover .node-ring, #relationship-map .node:focus-visible .node-ring, #relationship-map .node.selected .node-ring { stroke: var(--ember-bright); stroke-width: 4; }
#relationship-map .edge:hover .visible-link { stroke-width: 6; }
#relationship-map .node text { pointer-events: none; }
#relationship-map .node image { pointer-events: none; }
#relationship-map .node.dimmed { opacity: .28; }
#relationship-map .edge.dimmed { opacity: .1; }
#relationship-map .alliance-region { cursor: pointer; }
#relationship-map .alliance-region.selected polygon { stroke-width: 5; fill-opacity: .22; }
#relationship-map .alliance-region.dimmed { opacity: .3; }
#relationship-map .alliance-region:focus-visible polygon { stroke-width: 5; }

.group-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(275px, 1fr)); gap: 14px; }
.group-card { padding: 18px; }
.group-card h3 { font-size: 1.55rem; line-height: 1; margin: 0 0 7px; }
.group-card p { margin: 0 0 9px; color: var(--text-2); }
.group-card .meta { font-size: .75rem; color: var(--text-3); }
.member-list { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.member-list span { background: var(--ink-3); border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px 8px; font-size: .76rem; }
.group-card a { font-size: .8rem; }
.group-card.is-selected { border-color: var(--ember); box-shadow: 0 0 0 1px var(--ember); }
.group-card .group-origin { display: inline-block; margin: 0 0 10px; color: var(--ember-text); font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.group-card .group-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin: 12px 0 0; }
.group-card .group-actions button { min-height: 36px; font-size: .8rem; }
.alliance-activity { margin-top: 28px; scroll-margin-top: 76px; }
.alliance-activity h3 { margin: 0 0 8px; font: 400 clamp(2rem, 3vw, 2.6rem)/1 'Bebas Neue', Impact, sans-serif; letter-spacing: .035em; text-transform: uppercase; }
.activity-count { margin: 0 0 10px; color: var(--text-3); font-size: .8rem; }
.activity-kind { display: inline-block; margin-bottom: 4px; color: var(--ember-text); font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.activity-alliance { min-width: 180px; }
.activity-alliance button { min-height: 0; padding: 0; border: 0; background: none; color: var(--link); text-align: left; }
.activity-alliance button:hover { background: none; color: var(--ember-bright); text-decoration: underline; }
.activity-summary { min-width: 320px; }
.activity-summary p { margin: 0; }
.activity-source { min-width: 170px; font-size: .8rem; }
.activity-source a { display: block; }
.activity-row--naming { background: rgb(255 106 31 / .06) !important; }
.reviewed-people { min-width: 215px; }
.reviewed-people strong { display: block; color: var(--text); }
.reviewed-people span { display: block; color: var(--text-2); font-size: .78rem; margin-top: 3px; }
.reviewed-people button { min-height: 0; padding: 0; margin-top: 6px; border: 0; background: none; color: var(--link); font-size: .78rem; }
.reviewed-people button:hover { background: none; color: var(--ember-bright); text-decoration: underline; }
.reviewed-summary { min-width: 320px; }
.reviewed-summary p { margin: 0; }
.reviewed-source { min-width: 180px; }
.reviewed-source a { display: block; font-size: .8rem; }

.table-controls label:first-child { flex: 2 1 250px; }
.table-controls label { flex: 1 1 155px; }
.table-topline p { margin: 0; }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; color: var(--text-2); letter-spacing: .08em; text-transform: uppercase; font-size: .7rem; background: var(--ink-2); position: sticky; top: 0; z-index: 1; }
td, th { padding: 12px 15px; vertical-align: top; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: rgb(255 255 255 / .015); }
tbody tr:hover { background: var(--ink-3); }
tbody tr:target { outline: 2px solid var(--ember); outline-offset: -2px; }
.time-cell { min-width: 140px; font-variant-numeric: tabular-nums; }
.time-cell strong { display: block; color: var(--ember-text); }
.clip-time { display: block; color: var(--text-3); font-size: .75rem; }
.pair-cell { min-width: 225px; font-weight: 700; }
.pair-cell button { display: block; min-height: 0; padding: 0; background: none; border: 0; color: var(--link); text-align: left; font-weight: 700; }
.pair-cell button:hover { color: var(--ember-bright); text-decoration: underline; background: none; }
.summary-cell { min-width: 350px; }
.summary-cell p { margin: 0 0 5px; }
.summary-cell details { color: var(--text-2); font-size: .78rem; }
.summary-cell summary { width: fit-content; cursor: pointer; color: var(--link); }
.summary-cell details p { margin: 5px 0; }
.summary-cell details a { margin-right: 10px; }
.category-cell { min-width: 130px; }
.empty { padding: 25px; }
.source-section { border-top: 1px solid var(--border); padding-top: 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 45px; color: var(--text-2); }
.source-section ul { margin: 0 0 15px; padding-left: 18px; }
.source-section li { margin: 5px 0; }
.source-separator { color: var(--text-3); margin: 0 7px; }
.site-footer { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--border); color: var(--text-3); padding-top: 22px; padding-bottom: 30px; font-size: .75rem; }

body.player-dialog-open { overflow: hidden; }
.player-dialog {
  width: min(560px, calc(100vw - 24px)); max-width: none; max-height: min(720px, calc(100dvh - 24px));
  margin: auto; padding: 0; color: var(--text); background: var(--ink-1);
  border: 1px solid var(--border-strong); border-radius: 18px;
  box-shadow: 0 30px 100px rgb(0 0 0 / .7); overflow: auto;
}
.player-dialog::backdrop { background: rgb(3 5 8 / .76); backdrop-filter: blur(5px); }
.player-dialog__panel { position: relative; padding: 28px; }
.player-dialog__close { position: absolute; z-index: 1; right: 14px; top: 14px; width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 1.8rem; line-height: 1; }
.player-card__hero { display: grid; justify-items: center; gap: 14px; text-align: center; }
.player-card__portrait { display: grid; flex: none; place-items: center; width: min(100%, 208px); aspect-ratio: 1; border: 2px solid var(--toka); border-radius: 18px; background: var(--toka); color: #1b0d03; font-size: 3rem; font-weight: 800; box-shadow: 0 12px 30px rgb(0 0 0 / .3); }
.player-card__portrait.savu { border-color: var(--savu); background: var(--savu); }
.player-card__hero-copy { min-width: 0; }
.player-card__hero .eyebrow { margin: 0 0 5px; font-size: .64rem; }
.player-card__hero h2 { margin: 0 0 10px; font: 400 clamp(1.85rem, 5vw, 2.75rem)/.95 'Bebas Neue', Impact, sans-serif; letter-spacing: .025em; text-transform: uppercase; overflow-wrap: anywhere; }
.player-card__badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; align-items: center; }
.player-card__tribe, .player-card__status { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: .72rem; font-weight: 700; }
.player-card__tribe { border-color: var(--toka); color: var(--toka); }
.player-card__tribe.savu { border-color: var(--savu); color: var(--savu); }
.player-card__status { color: var(--text-2); }
.player-card__bio { margin: 16px 0 0; color: var(--text-2); font-size: .86rem; line-height: 1.5; text-align: center; }
.player-card__note { margin: 8px 0 0; color: var(--text-3); font-size: .75rem; text-align: center; }
.player-card__actions, .player-card__links { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 18px; }
.player-card__actions button { min-height: 42px; }
.player-card__links { margin-top: 14px; }
.player-card__links a { font-size: .82rem; font-weight: 700; }
.player-card__links button { min-height: 36px; font-size: .8rem; }
.player-card__video { margin-top: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--ink-0); text-align: center; }
.player-card__video iframe { display: block; width: min(100%, 230px); aspect-ratio: 9 / 16; max-height: 380px; margin: auto; border: 0; border-radius: 8px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 20; padding: 10px 15px; background: var(--ember); color: var(--text-on-ember); border-radius: 10px; box-shadow: 0 10px 30px rgb(0 0 0 / .5); font-weight: 700; }
.load-error { position: fixed; z-index: 20; top: 20px; right: 20px; max-width: 360px; padding: 20px; background: var(--ink-2); border: 1px solid var(--negative); border-radius: 10px; }
.load-error p { margin: 0 0 10px; }
.share-screen { max-width: 1320px; margin: 0 auto; padding: 28px 25px 65px; }
.share-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.share-screen h1 { font-size: clamp(2.5rem, 4vw, 3.5rem); margin: 28px 0 5px; }
.share-screen > p { color: var(--text-2); }
.card-frame { max-width: 1200px; margin: 25px auto; overflow: hidden; border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 64px -12px rgb(0 0 0 / .7); }
.card-frame svg { display: block; width: 100%; }
.share-url-label { display: grid; gap: 7px; max-width: 800px; margin: 20px auto; color: var(--text-2); font-size: .84rem; font-weight: 700; }
.status { max-width: 800px; min-height: 22px; margin: auto; color: var(--ember-text); }
body.share-mode main, body.share-mode .site-header, body.share-mode .site-footer { display: none; }
body.share-mode #share-screen { display: block; }

@media (max-width: 1050px) {
  .hero { gap: 25px; }
  .site-header { align-items: start; flex-wrap: wrap; padding-top: 9px; padding-bottom: 9px; }
  .site-header nav { gap: 0; }
  .site-header nav a { padding: 5px 8px; }
}
@media (max-width: 720px) {
  main, .site-footer { padding-left: 16px; padding-right: 16px; }
  .site-header { display: block; padding: 11px 16px; }
  .site-header nav { margin-top: 8px; gap: 3px; }
  .site-header nav a { font-size: .76rem; }
  .hero { display: block; padding: 48px 0 38px; }
  .hero h1 { font-size: clamp(3.2rem, 12vw, 4.7rem); }
  .hero-stat { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-top: 30px; padding: 15px 0 0; border-left: 0; border-top: 1px solid var(--border); }
  .hero-stat strong { font-size: 1.8rem; margin: 0; }
  .hero-stat span { font-size: .72rem; margin-right: 13px; }
  .method-note { margin-bottom: 45px; }
  .section { margin-bottom: 56px; }
  .section-heading { display: block; }
  .section-tools { margin-top: 14px; }
  .controls, .table-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .controls label, .table-controls label { min-width: 0; }
  .controls .check-label, .reset-button { grid-column: 1 / -1; }
  .map-summary, .table-topline { display: block; }
  .legend { margin-top: 8px; gap: 7px 13px; }
  .castaway-browser { display: block; margin: 16px 0; padding: 15px; border: 1px solid var(--border); border-radius: 16px; background: var(--ink-1); }
  .castaway-browser__heading { display: flex; justify-content: space-between; align-items: end; gap: 10px; margin-bottom: 10px; }
  .castaway-browser__heading .eyebrow { margin: 0 0 2px; }
  .castaway-browser__heading h3 { margin: 0; font: 400 1.7rem/1 'Bebas Neue', Impact, sans-serif; letter-spacing: .03em; text-transform: uppercase; }
  .castaway-browser__heading > span { color: var(--text-3); font-size: .72rem; white-space: nowrap; }
  .castaway-browser__search { display: grid; gap: 5px; margin-bottom: 12px; color: var(--text-2); font-size: .76rem; font-weight: 700; }
  .castaway-browser__search input { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--ink-2); color: var(--text); }
  .castaway-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .castaway-tile { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 64px; padding: 7px; border: 1px solid var(--border); border-radius: 10px; background: var(--ink-2); color: var(--text); text-align: left; }
  .castaway-tile:hover { border-color: var(--ember); }
  .castaway-tile.is-selected { border-color: var(--ember); box-shadow: inset 0 0 0 1px var(--ember); }
  .castaway-tile__portrait { display: grid; flex: none; place-items: center; width: 46px; height: 46px; border: 2px solid var(--toka); border-radius: 50%; background: var(--toka); color: #1b0d03; font-size: .82rem; font-weight: 800; }
  .castaway-tile__portrait.savu { border-color: var(--savu); background: var(--savu); }
  .castaway-tile__info { display: grid; gap: 2px; min-width: 0; }
  .castaway-tile__info strong { font-size: .73rem; line-height: 1.12; overflow-wrap: anywhere; }
  .castaway-tile__info small { color: var(--text-3); font-size: .64rem; line-height: 1.12; }
  .map-frame { min-height: 0; overflow: auto; }
  .map-alliance-bar { position: sticky; left: 0; width: 100%; min-width: 0; }
  .map-frame svg { min-width: 680px; }
  .map-hint { margin: 0; }
  .source-section { grid-template-columns: 1fr; gap: 8px; }
  .site-footer { display: block; }
  .site-footer span { display: block; margin-bottom: 6px; }
  .table-wrap { border: 0; background: none; box-shadow: none; overflow: visible; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 0 0 9px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--ink-1) !important; }
  td { min-width: 0 !important; border: 0; padding: 0; }
  td:nth-child(1) { grid-column: 1; grid-row: 1; }
  td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  td:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  td:nth-child(4) { grid-column: 2; grid-row: 1; }
  #alliance-activity-rows tr { grid-template-columns: 1fr auto; }
  #alliance-activity-rows td:nth-child(1) { grid-column: 1; grid-row: 1; }
  #alliance-activity-rows td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  #alliance-activity-rows td:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  #alliance-activity-rows td:nth-child(4) { grid-column: 1 / -1; grid-row: 4; }
  .activity-alliance, .activity-summary, .activity-source { min-width: 0; }
  #reviewed-rows td:nth-child(1) { grid-column: 1; grid-row: 1; }
  #reviewed-rows td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  #reviewed-rows td:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  #reviewed-rows td:nth-child(4) { grid-column: 1 / -1; grid-row: 4; }
  .share-toolbar { display: block; }
  .share-toolbar > div { margin-top: 12px; }
  .share-screen { padding: 16px; }
}
@media (max-width: 470px) {
  .controls, .table-controls { grid-template-columns: 1fr; }
  .controls .check-label, .reset-button { grid-column: auto; }
  .section-tools { display: grid; }
  .section-tools button { width: 100%; }
  .player-dialog__panel { padding: 22px 16px 18px; }
  .player-card__hero { gap: 12px; }
  .player-card__portrait { width: min(100%, 156px); font-size: 2rem; }
  .player-card__actions { display: grid; grid-template-columns: 1fr; }
  .player-card__actions button { width: 100%; }
}

/* Section navigation lives beside the document; the header links to pages. */
.page-outline { position: fixed; left: 12px; top: 100px; z-index: 25; width: 44px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--ink-1); color: var(--text-2); box-shadow: 0 6px 24px #0003; }
.page-outline[open] { width: 244px; }
.page-outline summary { display: flex; align-items: center; gap: 12px; padding: 12px; cursor: pointer; list-style: none; white-space: nowrap; font-size: .8rem; font-weight: 650; }
.page-outline summary::-webkit-details-marker { display: none; }
.page-outline summary svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.page-outline:not([open]) summary span { display: none; }
.page-outline nav { padding: 0 8px 8px; }
.page-outline nav a { display: block; padding: 10px 12px; border-radius: 5px; font-size: .8rem; text-decoration: none; color: var(--text-2); }
.page-outline nav a[hidden] { display: none; }
.page-outline nav a:hover, .page-outline nav a[aria-current] { background: var(--ink-2); color: var(--ember-text); }
.page-outline :focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
body:not(.share-mode) #main-content { margin-left: max(64px, calc((100% - 1440px) / 2)); }
body.share-mode .page-outline { display: none; }
@media (max-width: 700px) { .page-outline { top: 130px; left: 8px; } }
