/* ===========================================================================
   TRAITORS — styles.css
   Mobile-first, dark deep-space UI. No web fonts, no images.
   =========================================================================== */

:root {
  --bg:        #070a14;
  --bg2:       #0a0e1a;
  --panel:     #111726;
  --panel2:    #161d30;
  --panel3:    #1d2740;
  --line:      #26314e;
  --line2:     #344063;
  --text:      #e6ecf7;
  --text-dim:  #9aa7c2;
  --text-mut:  #67738f;
  --accent:    #5ad1ff;
  --accent2:   #7c5cff;
  --crew:      #4fd1c5;
  --traitor:   #fc8181;
  --warn:      #ecc94b;
  --good:      #68d391;
  --bad:       #f56565;
  --glitch:    #f6ad55;
  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 10px 30px rgba(0,0,0,.45);
  --maxw:      980px;
  --font:      "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono:      "SF Mono", "Consolas", "Roboto Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 700px at 75% -10%, rgba(124,92,255,.14), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(90,209,255,.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* starfield */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 60% 70%, rgba(255,255,255,.35), transparent),
    radial-gradient(1px 1px at 80% 20%, rgba(255,255,255,.4), transparent),
    radial-gradient(1px 1px at 35% 85%, rgba(255,255,255,.3), transparent),
    radial-gradient(1px 1px at 90% 55%, rgba(255,255,255,.4), transparent),
    radial-gradient(1px 1px at 12% 60%, rgba(255,255,255,.3), transparent),
    radial-gradient(2px 2px at 50% 40%, rgba(160,200,255,.25), transparent);
  opacity: .7;
  pointer-events: none;
}

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 12px env(safe-area-inset-bottom) 12px;
  padding-top: calc(env(safe-area-inset-top));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------- header / hud */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px 10px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(to bottom, var(--bg) 60%, rgba(7,10,20,.0));
  backdrop-filter: blur(2px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  letter-spacing: .14em;
}
.brand-mark {
  color: var(--accent);
  font-size: 20px;
  filter: drop-shadow(0 0 8px rgba(90,209,255,.6));
}
.brand-name {
  font-weight: 800;
  font-size: 18px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hud {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-btn, .acct-btn {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  min-width: 38px;
  height: 38px;
  padding: 0 9px;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color .15s, background .15s, transform .05s;
}
.hud-btn:hover, .acct-btn:hover { border-color: var(--line2); background: var(--panel3); }
.hud-btn:active { transform: scale(.94); }

/* -------------------------------------------------- main / screens */
main {
  flex: 1;
  padding-bottom: 24px;
  animation: fadein .25s ease;
}
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen { display: flex; flex-direction: column; gap: 16px; }

h1, h2, h3 { margin: 0 0 .3em; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 .8em; }
.muted { color: var(--text-dim); }
.dim { color: var(--text-mut); }
.center { text-align: center; }

/* -------------------------------------------------- buttons */
button { font-family: inherit; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s, border-color .15s, background .15s, box-shadow .15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(120deg, var(--accent2), var(--accent));
  border-color: transparent;
  color: #07101c;
  box-shadow: 0 6px 18px rgba(92,124,255,.28);
}
.btn.primary:hover { box-shadow: 0 8px 26px rgba(92,124,255,.42); }
.btn.danger { border-color: var(--bad); color: #ffd9d9; }
.btn.danger:hover { background: rgba(245,101,101,.14); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* -------------------------------------------------- cards / panels */
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 12px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line2);
  color: var(--text-dim);
}
.tag.crew    { color: var(--crew);    border-color: rgba(79,209,197,.5);  background: rgba(79,209,197,.08); }
.tag.traitor { color: var(--traitor); border-color: rgba(252,129,129,.5); background: rgba(252,129,129,.08); }
.tag.neutral { color: var(--glitch);  border-color: rgba(246,173,85,.5);  background: rgba(246,173,85,.08); }
.tag.dead    { color: var(--text-mut);border-color: var(--line); }

/* -------------------------------------------------- TITLE SCREEN */
.title-hero {
  text-align: center;
  padding: 22px 12px 8px;
}
.title-logo {
  font-size: clamp(40px, 13vw, 76px);
  font-weight: 900;
  letter-spacing: .06em;
  line-height: 1;
  background: linear-gradient(180deg, #fff, var(--accent) 55%, var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 20px rgba(92,124,255,.35));
  margin-bottom: 6px;
}
.title-sub {
  color: var(--text-dim);
  letter-spacing: .22em;
  text-transform: uppercase;
  font-size: 12px;
  margin-bottom: 18px;
}
.title-tag {
  max-width: 540px;
  margin: 0 auto 22px;
  color: var(--text-dim);
  font-size: 15px;
}
.title-menu {
  display: grid;
  gap: 10px;
  max-width: 360px;
  margin: 0 auto;
}
.title-rank {
  margin: 18px auto 0;
  max-width: 360px;
  text-align: center;
  color: var(--text-mut);
  font-size: 13px;
}
.title-rank b { color: var(--text); }

/* -------------------------------------------------- SETUP */
.opt-grid { display: grid; gap: 10px; }
.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: left;
}
.opt:hover { border-color: var(--line2); }
.opt.sel { border-color: var(--accent); background: rgba(90,209,255,.07); box-shadow: 0 0 0 1px rgba(90,209,255,.25) inset; }
.opt .opt-main { display: flex; flex-direction: column; gap: 2px; }
.opt .opt-name { font-weight: 700; }
.opt .opt-desc { font-size: 12.5px; color: var(--text-dim); }
.opt .opt-meta { font-size: 12px; color: var(--text-mut); white-space: nowrap; }

.role-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pill {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--line2); color: var(--text-dim); background: var(--panel3);
}

/* -------------------------------------------------- PORTRAITS */
.portrait {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: block;
  border: 2px solid var(--line2);
  background: var(--panel3);
  overflow: hidden;
}
.portrait svg { display: block; width: 100%; height: 100%; }
.portrait.dead { filter: grayscale(1) brightness(.6); opacity: .65; }
.portrait.lg { width: 64px; height: 64px; }
.portrait.sm { width: 34px; height: 34px; border-width: 1.5px; }
.portrait.me { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(90,209,255,.35); }

/* -------------------------------------------------- MATCH SCREEN */
.match-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.phase-banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  border: 1px solid var(--line2);
  background: linear-gradient(120deg, var(--panel2), var(--panel3));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.phase-banner .pb-left { display: flex; align-items: center; gap: 12px; }
.phase-icon { font-size: 26px; }
.phase-title { font-weight: 800; font-size: 17px; letter-spacing: .04em; }
.phase-sub { color: var(--text-dim); font-size: 12.5px; }
.phase-banner.discussion { border-color: rgba(90,209,255,.45); box-shadow: 0 0 24px rgba(90,209,255,.12) inset; }
.phase-banner.vote       { border-color: rgba(236,201,75,.5);  box-shadow: 0 0 24px rgba(236,201,75,.12) inset; }
.phase-banner.night      { border-color: rgba(124,92,255,.5);  box-shadow: 0 0 24px rgba(124,92,255,.14) inset; }
.phase-banner.over       { border-color: var(--line2); }

.round-chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--panel);
}

/* roster */
.roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}
.roster-card {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: var(--radius-sm);
  padding: 7px 8px;
  position: relative;
  transition: border-color .15s, background .15s;
  min-width: 0;
}
.roster-card.dead { opacity: .62; }
.roster-card.me   { border-color: var(--accent); }
.roster-card.selectable { cursor: pointer; }
.roster-card.selectable:hover { border-color: var(--accent); background: rgba(90,209,255,.06); }
.roster-card.targeted { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: rgba(90,209,255,.1); }
.roster-card .rc-body { min-width: 0; flex: 1; }
.roster-card .rc-name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster-card .rc-sub { font-size: 11px; color: var(--text-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-badge {
  position: absolute; top: -7px; right: -7px;
  font-size: 10px; font-weight: 800;
  padding: 1px 6px; border-radius: 999px;
  border: 1px solid var(--line2); background: var(--panel3); color: var(--text-dim);
}
.rc-badge.traitor { color: var(--traitor); border-color: var(--traitor); background: #2a1116; }
.rc-badge.crew    { color: var(--crew); border-color: var(--crew); background: #0e2422; }
.rc-badge.neutral { color: var(--glitch); border-color: var(--glitch); background: #2a1d0c; }
.rc-suspbar {
  position: absolute; left: 6px; right: 6px; bottom: 2px; height: 3px;
  border-radius: 2px; background: var(--line); overflow: hidden;
}
.rc-suspbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--good), var(--warn), var(--bad)); }
.rc-vote-count {
  position: absolute; bottom: 4px; right: 6px;
  font-size: 11px; font-weight: 800; color: var(--warn);
  background: rgba(0,0,0,.4); border-radius: 6px; padding: 0 5px;
}

/* discussion log */
.log-wrap { display: flex; flex-direction: column; }
.log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  min-height: 180px;
  overflow-y: auto;
  padding: 4px 4px 4px 0;
  scroll-behavior: smooth;
}
.log-line {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  animation: logIn .25s ease;
}
@keyframes logIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.log-line .ll-body {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  border-top-left-radius: 3px;
  padding: 7px 11px;
  min-width: 0;
  flex: 1;
}
.log-line .ll-name { font-weight: 700; font-size: 12.5px; color: var(--accent); margin-bottom: 1px; }
.log-line .ll-name .ll-role { color: var(--text-mut); font-weight: 600; font-size: 11px; margin-left: 6px; }
.log-line .ll-text { font-size: 14px; color: var(--text); }
.log-line.me .ll-body { background: rgba(90,209,255,.08); border-color: rgba(90,209,255,.35); }
.log-line.me .ll-name { color: var(--accent); }
.log-line.sys .ll-body { background: transparent; border: 1px dashed var(--line2); }
.log-line.sys .ll-text { color: var(--text-dim); font-style: italic; }
.log-line.scan .ll-body { border-color: rgba(99,179,237,.5); background: rgba(99,179,237,.07); }
.log-line.reveal .ll-body { border-color: rgba(236,201,75,.5); background: rgba(236,201,75,.07); }
.log-line.reveal .ll-text { color: var(--warn); font-weight: 600; font-style: normal; }
.log-empty { color: var(--text-mut); text-align: center; padding: 20px; font-size: 13px; }

/* action bar */
.action-bar { display: flex; flex-direction: column; gap: 10px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.act-btn {
  flex: 1 1 auto;
  min-width: 96px;
  background: var(--panel2);
  border: 1px solid var(--line2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 8px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: border-color .15s, background .15s, transform .05s;
}
.act-btn .act-ico { font-size: 17px; }
.act-btn:hover:not(:disabled) { border-color: var(--accent); background: rgba(90,209,255,.07); }
.act-btn:active:not(:disabled) { transform: scale(.96); }
.act-btn:disabled { opacity: .4; cursor: not-allowed; }
.act-hint { font-size: 12px; color: var(--text-dim); }
.speech-pips { display: inline-flex; gap: 3px; margin-left: 6px; }
.speech-pip { width: 8px; height: 8px; border-radius: 50%; background: var(--line2); }
.speech-pip.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* target chooser inline */
.chooser-note {
  font-size: 13px; color: var(--text-dim); margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}

/* heat meter */
.heat {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; background: var(--panel2);
}
.heat .heat-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.heat .heat-fill { height: 100%; transition: width .4s ease, background .4s; }
.heat .heat-label { font-weight: 700; font-size: 13px; white-space: nowrap; }
.heat .heat-note { font-size: 11.5px; color: var(--text-dim); }

/* night / private info panel */
.info-panel {
  border: 1px solid rgba(124,92,255,.4);
  background: rgba(124,92,255,.06);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.info-panel.crew-info { border-color: rgba(99,179,237,.4); background: rgba(99,179,237,.06); }
.info-panel h3 { color: var(--accent); }
.known-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.known-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.known-item .ki-res { margin-left: auto; font-weight: 700; }
.known-item .ki-res.traitor { color: var(--traitor); }
.known-item .ki-res.crew { color: var(--crew); }

/* vote tally */
.vote-tally { display: flex; flex-direction: column; gap: 6px; }
.tally-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tally-row .tr-name { width: 120px; flex: 0 0 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tally-row .tr-bar { flex: 1; height: 14px; background: var(--line); border-radius: 7px; overflow: hidden; }
.tally-row .tr-fill { height: 100%; background: linear-gradient(90deg, var(--warn), var(--bad)); transition: width .4s; }
.tally-row .tr-num { width: 26px; text-align: right; font-weight: 700; }

/* -------------------------------------------------- GAME OVER */
.over-hero { text-align: center; padding: 14px; }
.over-result { font-size: 34px; font-weight: 900; letter-spacing: .04em; }
.over-result.win  { color: var(--good); text-shadow: 0 0 24px rgba(104,211,145,.4); }
.over-result.lose { color: var(--bad);  text-shadow: 0 0 24px rgba(245,101,101,.4); }
.over-sub { color: var(--text-dim); margin-top: 4px; }
.recap-list { display: flex; flex-direction: column; gap: 7px; }
.recap-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); background: var(--panel2);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.recap-row .rr-body { flex: 1; min-width: 0; }
.recap-row .rr-name { font-weight: 700; font-size: 14px; }
.recap-row .rr-fate { font-size: 12px; color: var(--text-mut); }
.reward-row { display: flex; flex-wrap: wrap; gap: 8px; }
.reward-chip {
  border: 1px solid var(--line2); background: var(--panel3);
  border-radius: 999px; padding: 6px 12px; font-size: 13px;
  display: flex; align-items: center; gap: 6px;
}
.reward-chip.new { border-color: var(--warn); color: var(--warn); box-shadow: 0 0 16px rgba(236,201,75,.25); }

/* -------------------------------------------------- STATS / CODEX / SETTINGS */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 10px; }
.stat-box {
  border: 1px solid var(--line); background: var(--panel2);
  border-radius: var(--radius-sm); padding: 12px; text-align: center;
}
.stat-box .sb-num { font-size: 24px; font-weight: 800; color: var(--accent); }
.stat-box .sb-label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }

.ach-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 560px) { .ach-grid { grid-template-columns: 1fr 1fr; } }
.ach {
  display: flex; align-items: center; gap: 11px;
  border: 1px solid var(--line); background: var(--panel2);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.ach.locked { opacity: .5; }
.ach .ach-ico {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 10px;
  display: grid; place-items: center; font-size: 20px;
  background: var(--panel3); border: 1px solid var(--line2);
}
.ach.unlocked .ach-ico { border-color: var(--warn); background: rgba(236,201,75,.12); }
.ach .ach-body { min-width: 0; }
.ach .ach-name { font-weight: 700; font-size: 13.5px; }
.ach .ach-desc { font-size: 12px; color: var(--text-dim); }

.codex-role {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line); background: var(--panel2);
  border-radius: var(--radius-sm); padding: 12px;
}
.codex-role .cr-ico {
  width: 42px; height: 42px; flex: 0 0 auto; border-radius: 10px;
  display: grid; place-items: center; font-size: 20px; font-weight: 800;
  border: 1px solid var(--line2);
}
.codex-role .cr-name { font-weight: 800; font-size: 15px; margin-bottom: 3px; }
.codex-role .cr-blurb { font-size: 13px; color: var(--text-dim); }

.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--line); padding: 12px 2px;
}
.setting-row:last-child { border-bottom: none; }
.setting-row .sr-label { font-weight: 600; }
.setting-row .sr-desc { font-size: 12px; color: var(--text-dim); }

/* toggle switch */
.switch { position: relative; width: 48px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--panel3); border: 1px solid var(--line2);
  border-radius: 999px; transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
  background: var(--text-dim); border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: rgba(90,209,255,.25); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); background: var(--accent); }

/* segmented */
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 999px; overflow: hidden; }
.seg button {
  background: transparent; border: none; color: var(--text-dim);
  padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg button.on { background: var(--accent); color: #07101c; }
.seg.seg-wrap { flex-wrap: wrap; }
.seg.seg-wrap button { padding: 7px 12px; font-size: 15px; }

/* -------------------------------------------------- back / nav bits */
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.back-btn {
  background: var(--panel2); border: 1px solid var(--line2); color: var(--text);
  border-radius: 9px; width: 38px; height: 38px; font-size: 18px; cursor: pointer;
  display: grid; place-items: center; flex: 0 0 auto;
}
.back-btn:hover { border-color: var(--accent); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-mut); margin: 4px 0; }

/* -------------------------------------------------- toast */
#toast-wrap {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 80;
  width: min(94vw, 440px); pointer-events: none;
}
.toast {
  background: var(--panel3); border: 1px solid var(--line2);
  color: var(--text); border-radius: 12px; padding: 11px 14px;
  font-size: 14px; box-shadow: var(--shadow);
  animation: toastIn .25s ease;
}
.toast.good { border-color: var(--good); }
.toast.bad  { border-color: var(--bad); }
.toast.warn { border-color: var(--warn); }
.toast.info { border-color: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* -------------------------------------------------- modal */
#modal-wrap {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 16px;
  background: rgba(4,7,14,.72); backdrop-filter: blur(3px);
}
#modal-wrap[hidden] { display: none; }
.modal {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line2); border-radius: var(--radius);
  padding: 18px; max-width: 460px; width: 100%;
  box-shadow: var(--shadow); animation: fadein .2s ease;
  max-height: 86vh; overflow-y: auto;
}
.modal h2 { margin-bottom: 8px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* big reveal flash for night/eject */
.reveal-flash {
  text-align: center; padding: 10px;
}
.reveal-flash .rf-name { font-size: 22px; font-weight: 800; }
.reveal-flash .rf-role { font-size: 15px; margin-top: 4px; }

/* responsive layout for wide screens */
@media (min-width: 760px) {
  .match-two {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 14px;
    align-items: start;
  }
  .log { max-height: 56vh; }
}

@media (max-width: 380px) {
  body { font-size: 15px; }
  .act-btn { min-width: 0; flex-basis: calc(33.3% - 6px); padding: 9px 4px; font-size: 12px; }
  .roster { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
}

/* reduced motion */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation-duration: .001ms !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==================================================================
   PASS & PLAY (local hotseat)
   Big tap targets, private screens, neutral pass gates. Works at 360px.
   ================================================================== */

/* setup: human-count stepper */
.pp-stepper { display: inline-flex; align-items: center; gap: 10px; }
.pp-step {
  width: 42px; height: 42px; border-radius: 10px; font-size: 22px; font-weight: 800;
  background: var(--panel3); border: 1px solid var(--line2); color: var(--text);
  cursor: pointer; display: grid; place-items: center; line-height: 1;
}
.pp-step:hover:not(:disabled) { border-color: var(--accent); }
.pp-step:active:not(:disabled) { transform: scale(.94); }
.pp-step:disabled { opacity: .4; cursor: not-allowed; }
.pp-count { font-size: 22px; font-weight: 800; min-width: 28px; text-align: center; color: var(--accent); }
.pp-ai-count { font-size: 20px; font-weight: 800; color: var(--text); }

/* setup: name inputs */
.pp-names { display: flex; flex-direction: column; gap: 8px; }
.pp-name-row { display: flex; align-items: center; gap: 10px; }
.pp-seat-num {
  width: 28px; height: 28px; flex: 0 0 auto; border-radius: 8px;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
  background: var(--panel3); border: 1px solid var(--line2); color: var(--text-dim);
}
.pp-name-input {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px;
  background: var(--panel2); border: 1px solid var(--line2); color: var(--text);
  border-radius: 9px; font-size: 15px; font-family: inherit;
}
.pp-name-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(90,209,255,.25); }

/* progress strip ("Player 2 of 5") */
.pp-progress {
  text-align: center; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-mut); font-family: var(--mono);
}

/* the pass-the-device gate */
.pp-gate { text-align: center; padding: 26px 16px; }
.pp-gate-ico { font-size: 46px; margin-bottom: 6px; }
.pp-gate-title { color: var(--text-dim); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.pp-gate-name {
  font-size: clamp(26px, 8vw, 38px); font-weight: 900; margin: 4px 0 12px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.pp-gate-note { font-size: 12.5px; margin: 0 auto 14px; max-width: 320px; }
.pp-bigbtn { padding: 16px 18px; font-size: 16px; margin-top: 14px; min-height: 52px; }

/* private screens */
.pp-private { border-color: var(--line2); }
.pp-private-head { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.pp-reveal-head { display: flex; align-items: center; gap: 14px; }
.pp-role-name { font-size: 26px; font-weight: 900; line-height: 1.1; margin: 2px 0; }
.pp-mates { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }

/* engineer private scan result */
.pp-scan-result { text-align: center; padding: 14px; border-radius: var(--radius-sm); margin: 12px 0; border: 1px solid var(--line2); }
.pp-scan-result.good { border-color: rgba(104,211,145,.5); background: rgba(104,211,145,.08); }
.pp-scan-result.bad  { border-color: rgba(245,101,101,.5); background: rgba(245,101,101,.08); }
.pp-scan-result .portrait { margin: 0 auto; }
.pp-scan-name { font-weight: 800; font-size: 16px; margin-top: 8px; }
.pp-scan-verdict { font-size: 20px; font-weight: 900; margin-top: 2px; }
.pp-scan-result.good .pp-scan-verdict { color: var(--good); }
.pp-scan-result.bad  .pp-scan-verdict { color: var(--bad); }

/* discussion timer */
.pp-timer-row { margin-top: 10px; }
.pp-timer { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.pp-timer-num { font-family: var(--mono); font-size: 28px; font-weight: 800; color: var(--accent); }

/* human marker on roster cards */
.roster-card.human { border-color: rgba(90,209,255,.35); }
.roster-card.human .rc-name::after { content: " 👤"; font-size: 11px; }

/* claim-form selects in modal */
.pp-claim-form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.pp-fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.pp-select {
  height: 42px; padding: 0 10px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line2); border-radius: 9px; font-size: 14px; font-family: inherit;
}
.pp-select:focus { outline: none; border-color: var(--accent); }

/* over-screen per-human outcome chip */
.pp-outcome { font-size: 10px; font-weight: 800; letter-spacing: .05em; padding: 1px 6px; border-radius: 999px; margin-left: 6px; }
.pp-outcome.win  { color: var(--good); border: 1px solid var(--good); background: rgba(104,211,145,.1); }
.pp-outcome.lose { color: var(--text-mut); border: 1px solid var(--line2); }

/* utility */
.row { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.gap-sm { gap: 6px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.hidden { display: none !important; }
.grow { flex: 1; }
.scroll-x { overflow-x: auto; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.kbd {
  font-family: var(--mono); font-size: 11px; background: var(--panel3);
  border: 1px solid var(--line2); border-radius: 5px; padding: 1px 6px;
}
.badge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* -------------------------------------------------- SUSPICION NOTEBOOK */
.rc-note {
  position: absolute; top: -7px; left: -7px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; line-height: 1; cursor: pointer;
  background: var(--panel3); border: 1px solid var(--line2); color: var(--text-dim);
  padding: 0; transition: transform .05s, border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.rc-note:hover { border-color: var(--accent); }
.rc-note:active { transform: scale(.9); }
.rc-note.nb-trust   { border-color: var(--good); background: rgba(104,211,145,.16); }
.rc-note.nb-suspect { border-color: var(--bad);  background: rgba(245,101,101,.18); }

/* -------------------------------------------------- JUICE (reduced-motion safe) */
.fx-flash {
  position: fixed; inset: 0; z-index: 70; pointer-events: none;
  opacity: 0; animation: fxFlash .6s ease forwards;
}
.fx-flash.fx-win    { background: radial-gradient(circle at 50% 40%, rgba(104,211,145,.28), transparent 70%); }
.fx-flash.fx-lose   { background: radial-gradient(circle at 50% 40%, rgba(245,101,101,.28), transparent 70%); }
.fx-flash.fx-freeze { background: radial-gradient(circle at 50% 40%, rgba(90,209,255,.30), transparent 70%); }
.fx-flash.fx-neutral{ background: radial-gradient(circle at 50% 40%, rgba(124,92,255,.22), transparent 70%); }
@keyframes fxFlash {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}
.fx-pop { animation: fxPop .55s ease; }
@keyframes fxPop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
/* phase banners get a subtle entrance the first paint */
.phase-banner { animation: phaseIn .3s ease; }
@keyframes phaseIn { from { opacity: .25; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* reveal-flash emphasis */
.reveal-flash .rf-name { animation: rfRise .4s ease; }
@keyframes rfRise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Reduced motion: kill the juice entirely (flashes never even mount in JS, but
   belt-and-braces for the banner/pop animations and any prefers-reduced-motion). */
.reduce-motion .fx-flash, .reduce-motion .phase-banner, .reduce-motion .fx-pop,
.reduce-motion .reveal-flash .rf-name {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .fx-flash { display: none !important; }
  .phase-banner, .fx-pop, .reveal-flash .rf-name { animation: none !important; }
}

/* ==================================================================
   v1.3.0 — levels/XP, endless, difficulty, MVP, cosmetics, history
   Mobile-first; everything degrades cleanly at 360px.
   ================================================================== */

/* tag color for the neutral Jester reuses .neutral (glitch palette family) */

/* title-screen level badge + equipped title tag */
.title-rank .title-badge {
  display: inline-block; font-weight: 800; font-size: 12px; color: #07101c;
  background: linear-gradient(120deg, var(--accent2), var(--accent));
  border-radius: 999px; padding: 2px 9px; letter-spacing: .02em;
}
.title-name-tag { color: var(--accent); font-weight: 700; font-style: italic; }

/* XP bar (over screen + stats) */
.xp-card { margin-top: 10px; }
.xp-bar, .heat .heat-bar.xp { height: 9px; }
.xp-bar {
  height: 9px; border-radius: 5px; background: var(--line); overflow: hidden;
}
.xp-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .5s ease;
}
.xp-lvl { font-weight: 800; font-size: 14px; color: var(--accent); }
.lvl-badge, .lvl-badge.small {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px; font-weight: 900; color: #07101c;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  box-shadow: 0 6px 18px rgba(92,124,255,.3);
}

/* MVP / match highlights */
.mvp-list { display: flex; flex-direction: column; gap: 7px; }
.mvp-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); background: var(--panel2);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.mvp-row .mvp-body { min-width: 0; flex: 1; }
.mvp-row .mvp-label { font-weight: 800; font-size: 12.5px; color: var(--warn); letter-spacing: .02em; }
.mvp-row .mvp-detail { font-size: 12.5px; color: var(--text-dim); }

/* endless banners / cards */
.endless-banner { border-color: rgba(246,173,85,.4); }
.endless-banner .section-title { color: var(--glitch); }

/* mode + tier option cards reuse .opt; selected look already styled.
   give the mode cards a touch more presence. */
.mode-opt .opt-name { font-size: 15px; }
.tier-opt.sel { box-shadow: 0 0 0 1px var(--accent2) inset; border-color: var(--accent2); }
.tier-opt.sel { background: rgba(124,92,255,.08); }

/* cosmetics chips (titles + themes) */
.cos-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cos-chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line2); background: var(--panel3); color: var(--text-dim);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: border-color .15s, background .15s, color .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.cos-chip:hover:not(:disabled) { border-color: var(--accent); }
.cos-chip:active:not(:disabled) { transform: scale(.96); }
.cos-chip.on { border-color: var(--accent); color: var(--text); background: rgba(90,209,255,.12); box-shadow: 0 0 0 1px var(--accent) inset; }
.cos-chip.locked { opacity: .5; cursor: not-allowed; }
.theme-dot { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.25); }

/* match history (record book) */
.hist-list { display: flex; flex-direction: column; gap: 6px; }
.hist-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); background: var(--panel2);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.hist-row .hist-mode { font-size: 18px; flex: 0 0 auto; }
.hist-row .hist-body { min-width: 0; flex: 1; }
.hist-row .hist-line { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-row .hist-sub { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* narrow-screen tweaks for the new bits */
@media (max-width: 380px) {
  .lvl-badge { width: 40px; height: 40px; font-size: 19px; }
  .cos-chip { padding: 6px 10px; font-size: 12px; }
}

/* ==================================================================
   v1.4.0 — POLISH: accessibility, audio/settings UI, in-match help,
   text-size scaling, focus visibility, mobile/safe-area refinements.
   ================================================================== */

/* ---- Text-size accessibility (scales the whole UI via root font-size) ---- */
body.text-large  { font-size: 17.5px; }
body.text-xlarge { font-size: 19.5px; }
@media (max-width: 380px) {
  body.text-large  { font-size: 16.5px; }
  body.text-xlarge { font-size: 18px; }
}

/* ---- Visible keyboard focus on EVERY interactive element (a11y) ----
   Use :focus-visible so mouse clicks don't show a ring, but keyboard does. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.roster-card.selectable:focus-visible,
.opt:focus-visible,
.act-btn:focus-visible,
.cos-chip:focus-visible,
.rc-note:focus-visible,
.hud-btn:focus-visible,
.back-btn:focus-visible,
.pp-step:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
/* Fallback for engines without :focus-visible — keep a ring on keyboard focus. */
.roster-card.selectable:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.range:focus { outline: 3px solid var(--accent); outline-offset: 3px; }
/* Toggle switches: the real <input> is visually hidden, so move the focus ring
   onto the visible slider track instead of the 0-size checkbox. */
.switch input:focus-visible + .slider,
.switch input:focus + .slider { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Programmatically-focused headings (focus management) shouldn't show a ring. */
h1[tabindex="-1"]:focus, .phase-title[tabindex="-1"]:focus, .over-result[tabindex="-1"]:focus { outline: none; }

/* ---- Color-independent roster status (icon + word, not color alone) ---- */
.rc-status {
  display: inline-block; margin-right: 5px; font-size: 9px; line-height: 1;
  vertical-align: middle;
}
.rc-status.alive { color: var(--good); }
.rc-status.out   { color: var(--text-mut); }
/* a clear cross-hatch on dead cards so "dead" reads without relying on opacity/color */
.roster-card.dead { background-image: repeating-linear-gradient(45deg, transparent, transparent 7px, rgba(255,255,255,.025) 7px, rgba(255,255,255,.025) 9px); }
.roster-card.dead .rc-name { text-decoration: line-through; text-decoration-color: var(--text-mut); }

/* ---- Small HUD buttons inside the phase banner (help / recap) ---- */
.hud-btn.sm-hud {
  min-width: 32px; height: 32px; padding: 0 7px; font-size: 14px; border-radius: 8px;
}

/* ---- Volume slider (range) ---- */
.range {
  -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px;
  background: var(--line); outline: none; flex: 1; min-width: 88px; cursor: pointer;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: 2px solid #07101c; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.range::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent);
  border: 2px solid #07101c; cursor: pointer;
}
.range:disabled { opacity: .4; cursor: not-allowed; }
.vol-num { font-family: var(--mono); font-size: 12px; color: var(--text-dim); min-width: 38px; text-align: right; }

/* ---- Export/import save textarea ---- */
.save-blob {
  height: 120px; border-radius: 9px; line-height: 1.35;
  word-break: break-all; white-space: pre-wrap;
}
.save-blob:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(90,209,255,.25); }

/* ---- Tap targets: guarantee >=44px on the controls that matter on mobile ---- */
@media (pointer: coarse) {
  .act-btn { min-height: 48px; }
  .btn { min-height: 46px; }
  .roster-card.selectable { min-height: 48px; }
  .hud-btn, .back-btn { min-height: 40px; }
  .rc-note { width: 26px; height: 26px; }
}

/* ---- Safe-area insets for the fixed modal/toast on notched phones ---- */
#modal-wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* ---- Landscape: keep the match two-column even on short wide screens ---- */
@media (max-height: 480px) and (orientation: landscape) and (min-width: 640px) {
  .match-two { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; align-items: start; }
  .log { max-height: 64vh; }
}

/* ---- 360px hardening: prevent any horizontal overflow / banner crowding ---- */
@media (max-width: 360px) {
  .phase-banner { padding: 10px 12px; gap: 8px; }
  .phase-icon { font-size: 22px; }
  .phase-title { font-size: 15.5px; }
  .round-chip { padding: 3px 8px; font-size: 11px; }
  .tag { padding: 3px 7px; }
  .pp-gate { padding: 22px 12px; }
}

/* ---- Reduced motion: also kill the smooth scroll + heat/xp/tally transitions ---- */
.reduce-motion .heat .heat-fill,
.reduce-motion .xp-bar > span,
.reduce-motion .tally-row .tr-fill,
.reduce-motion .rc-suspbar > span,
.reduce-motion .log { transition: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) {
  .log { scroll-behavior: auto !important; }
  .heat .heat-fill, .xp-bar > span, .tally-row .tr-fill { transition: none !important; }
}

/* ---- A subtle, unified entrance for cards/log lines is already present;
   ensure the new modals' textareas and ranges inherit the dark theme cleanly. ---- */
textarea { font-family: var(--font); color: var(--text); background: var(--panel2); border: 1px solid var(--line2); }
