/* Secret Palpatine. Palette pulled from Pelle Boström's "Secret Sith" art. */

:root {
  --ink: #050507;
  --panel: #0d0f16;
  --panel-2: #141824;
  --line: #262c3d;
  --text: #e9e7e1;
  --muted: #8d93a6;
  --sep: #d11a0e;
  --sep-dark: #5c0b07;
  --sep-hi: #ff4a3a;
  --loy: #3d63ff;
  --loy-dark: #1c33a0;
  --loy-hi: #7d98ff;
  --gold: #ffae00;
  --gold-hi: #ffc94d;
  --paper: #cfcfcf;
  --crawl: #ffe81f;
  --ok: #58d68d;
  --radius: 14px;
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
img {
  max-width: 100%;
}
a {
  color: var(--gold);
}
b.loy,
.loy {
  color: var(--loy-hi);
}
b.sep,
.sep {
  color: var(--sep-hi);
}
[hidden] {
  display: none !important;
}

/* A static starfield: cheap enough for phones. */
#stars {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 27% 72%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 44% 33%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 81%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 12%, #fff7 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 56%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 90%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 6%, #fff6 50%, transparent 51%),
    radial-gradient(ellipse at 50% -20%, #1a2150 0%, transparent 60%),
    var(--ink);
  background-size:
    380px 380px, 290px 290px, 520px 520px, 330px 330px, 410px 410px, 610px 610px, 270px 270px, 450px 450px,
    100% 100%, 100% 100%;
}

/* ------------------------------------------------------------------ buttons */

.btn {
  appearance: none;
  border: 2px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: 700 15px/1.1 var(--font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 14px 18px;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  touch-action: manipulation;
  transition:
    transform 0.08s,
    background 0.15s,
    border-color 0.15s;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #111;
}
.btn.gold {
  border-color: var(--gold);
  color: var(--gold);
}
.btn.ghost {
  background: transparent;
}
.btn.big {
  width: 100%;
  min-height: 60px;
  font-size: 17px;
}
.btn.wide {
  width: 100%;
}
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: 700 13px var(--font);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #0008;
  color: var(--text);
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  cursor: pointer;
}
.mini {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.mini:disabled {
  opacity: 0.25;
}
.mini.danger {
  color: var(--sep-hi);
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.row > * {
  flex: 1 1 0;
}
.center {
  text-align: center;
}

/* ------------------------------------------------------------------ toasts */

#toasts {
  position: fixed;
  left: 50%;
  top: max(12px, env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  background: #1b2030f2;
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 10px 30px #0009;
  transition:
    opacity 0.4s,
    transform 0.4s;
}
.toast.error {
  border-color: var(--sep);
}
.toast.out {
  opacity: 0;
  transform: translateY(-8px);
}

/* -------------------------------------------------------------------- home */

.home {
  max-width: 520px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px 40px;
  display: grid;
  gap: 16px;
}
.logo {
  text-align: center;
  padding: 12px 0 4px;
}
.logo-kicker {
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--muted);
  font-weight: 700;
}
.logo h1 {
  margin: 6px 0 14px;
  font-size: clamp(38px, 12vw, 64px);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--paper);
}
.logo h1 span {
  color: var(--sep);
  text-shadow: 0 0 28px #d11a0e66;
}
.logo-cards {
  display: flex;
  justify-content: center;
  gap: 0;
}
.logo-cards img {
  width: 28%;
  max-width: 130px;
  border-radius: 8px;
  box-shadow: 0 12px 30px #000c;
}
.logo-cards img:nth-child(1) {
  transform: rotate(-8deg) translate(18px, 8px);
}
.logo-cards img:nth-child(2) {
  z-index: 1;
  transform: translateY(-4px) scale(1.06);
}
.logo-cards img:nth-child(3) {
  transform: rotate(8deg) translate(-18px, 8px);
}
.panel {
  background: #0d0f16e6;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 14px;
}
.panel h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.panel p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
input {
  font: 600 18px var(--font);
  color: var(--text);
  background: var(--ink);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  width: 100%;
}
input:focus {
  outline: none;
  border-color: var(--gold);
}
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.4em;
  font-weight: 800;
}
.howto summary {
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 14px;
}
.howto p {
  color: var(--text);
  opacity: 0.85;
}
.credit {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ------------------------------------------------------------------- board */

.board {
  display: grid;
  gap: 1.2cqw;
  container-type: inline-size;
  width: 100%;
}
.track {
  position: relative;
  aspect-ratio: 2400 / 805;
  background-size: 100% 100%;
  border-radius: 1.2cqw;
  overflow: hidden;
  box-shadow: 0 1cqw 3cqw #000a;
}
.slot {
  position: absolute;
  border-radius: 0.6cqw;
}
.slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.6cqw;
  box-shadow: 0 0.4cqw 1.2cqw #000c;
  animation: dealIn 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.slot.next {
  box-shadow:
    inset 0 0 0 0.3cqw #fff6,
    0 0 2cqw #fff3;
  animation: pulse 2.4s ease-in-out infinite;
}
.slot-override {
  position: absolute;
  background: #cf1a0f;
  border: 0.25cqw solid #6d0c07;
  border-radius: 0.6cqw;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1.2cqw;
  color: #6d0c07;
  text-align: center;
}
.slot-override svg {
  width: 45%;
}
.slot-override span {
  color: var(--gold);
  font-weight: 800;
  font-size: 0.72cqw;
  line-height: 1.25;
  letter-spacing: 0.02em;
}
.veto-chip {
  position: absolute;
  left: 66.06%;
  width: 11.26%;
  top: 80%;
  text-align: center;
  font-weight: 900;
  font-size: 1cqw;
  color: #111;
  background: var(--gold);
  border-radius: 99px;
  padding: 0.3cqw 0;
}
.pile {
  position: absolute;
  top: 8%;
  width: 5.2%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #0b1a66;
  border: 0.25cqw solid var(--loy-hi);
  color: #fff;
  font-size: 1.9cqw;
}
.pile.draw {
  left: 2.2%;
}
.pile.discard {
  right: 2.2%;
}
.tracker-token {
  position: absolute;
  width: 3.4%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0%, #ddd 35%, #888 100%);
  box-shadow: 0 0 1.4cqw #fff8;
  transition:
    left 0.8s cubic-bezier(0.3, 1.4, 0.5, 1),
    top 0.8s;
}
.tracker-token.hot {
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--gold-hi) 40%, #b86b00 100%);
  box-shadow: 0 0 2cqw var(--gold);
}

@keyframes pulse {
  50% {
    box-shadow:
      inset 0 0 0 0.3cqw #fffa,
      0 0 3cqw #fff6;
  }
}
@keyframes dealIn {
  from {
    transform: translateY(-30%) rotate(-8deg) scale(1.4);
    opacity: 0;
  }
}

/* ----------------------------------------------------------------- senators */

.senators {
  display: grid;
  gap: 6px;
  align-content: start;
}
.senator {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f1320d9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 52px;
}
.senator.is-sc {
  border-color: #aaa;
  background: linear-gradient(90deg, #1d1d1d, #0f1320);
}
.senator.is-vc {
  border-color: var(--gold);
}
.senator.me .s-name small {
  color: var(--gold);
}
.senator.dead {
  opacity: 0.4;
  filter: grayscale(1);
}
.senator.dead .s-name {
  text-decoration: line-through;
}
.senator.role-loyalist {
  border-color: var(--loy);
}
.senator.role-separatist,
.senator.role-palpatine {
  border-color: var(--sep);
}
.s-main {
  flex: 1;
  min-width: 0;
}
.s-name {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.s-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.s-side {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
  background: #ffffff14;
  color: var(--muted);
}
.tag.ok {
  color: var(--ok);
}
.tag.gold {
  color: #111;
  background: var(--gold);
}
.tag.dead {
  color: #fff;
  background: var(--sep-dark);
}
.tag.off {
  color: var(--gold);
}
.placard {
  height: 30px;
  border-radius: 3px;
}
.placard.nominee {
  opacity: 0.55;
  outline: 2px dashed var(--gold);
  outline-offset: 2px;
}
.vote-mini {
  height: 30px;
  border-radius: 3px;
  animation: dealIn 0.5s both;
}
.role-thumb {
  height: 44px;
  border-radius: 4px;
}
.log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  align-content: start;
  font-size: 13px;
  color: var(--muted);
}
.log li:first-child {
  color: var(--text);
}

/* --------------------------------------------------------------- game over */

.gameover {
  text-align: center;
  display: grid;
  gap: 8px;
  justify-items: center;
}
.go-kicker {
  letter-spacing: 0.3em;
  font-weight: 800;
  font-size: 12px;
  color: var(--muted);
}
.gameover h1 {
  margin: 0;
  font-weight: 900;
  font-size: clamp(32px, 6vw, 72px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.gameover.loyalist h1 {
  color: var(--loy-hi);
  text-shadow: 0 0 40px #3d63ff88;
}
.gameover.separatist h1 {
  color: var(--sep-hi);
  text-shadow: 0 0 40px #d11a0e88;
}
.gameover p {
  margin: 0;
  max-width: 60ch;
  color: var(--text);
}
.reveal-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}
.reveal-card {
  margin: 0;
  width: clamp(70px, 9vw, 130px);
  animation: dealIn 0.6s both;
}
.reveal-card:nth-child(2) { animation-delay: 0.08s; }
.reveal-card:nth-child(3) { animation-delay: 0.16s; }
.reveal-card:nth-child(4) { animation-delay: 0.24s; }
.reveal-card:nth-child(5) { animation-delay: 0.32s; }
.reveal-card:nth-child(6) { animation-delay: 0.4s; }
.reveal-card:nth-child(7) { animation-delay: 0.48s; }
.reveal-card:nth-child(8) { animation-delay: 0.56s; }
.reveal-card:nth-child(9) { animation-delay: 0.64s; }
.reveal-card:nth-child(10) { animation-delay: 0.72s; }
.reveal-card img {
  width: 100%;
  border-radius: 6px;
  display: block;
}
.reveal-card figcaption {
  font-weight: 800;
  font-size: 13px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reveal-card.dead img {
  filter: grayscale(1) brightness(0.6);
}

/* ------------------------------------------------------------------ overlays */

.fx {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, #000c 0%, #000f 80%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}
.fx.show {
  opacity: 1;
  pointer-events: auto;
}
.fx-card {
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
  max-width: 900px;
  animation: zoomIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.fx-kicker {
  letter-spacing: 0.3em;
  font-size: clamp(11px, 1.4vw, 18px);
  font-weight: 800;
  color: var(--muted);
}
.fx h2 {
  margin: 0;
  font-weight: 900;
  font-size: clamp(28px, 6vw, 84px);
  letter-spacing: 0.03em;
  line-height: 1;
}
.fx h2.pass {
  color: var(--ok);
}
.fx h2.fail,
.fx h2.separatist {
  color: var(--sep-hi);
}
.fx h2.loyalist {
  color: var(--loy-hi);
}
.fx p {
  margin: 0;
  font-size: clamp(15px, 1.8vw, 26px);
  color: var(--text);
}
.fx-votes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(6px, 1vw, 16px);
}
.fx-vote {
  margin: 0;
  width: clamp(70px, 11vw, 170px);
  animation: flipIn 0.6s both;
}
.fx-vote img {
  width: 100%;
  display: block;
  border-radius: 6px;
}
.fx-vote figcaption {
  font-weight: 800;
  margin-top: 4px;
  font-size: clamp(12px, 1.4vw, 20px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fx-policy {
  width: clamp(120px, 16vw, 260px);
  border-radius: 10px;
  box-shadow: 0 20px 60px #000;
  animation: flipIn 0.9s both;
}
.fx-card.choke h2 {
  animation: choke 1.2s ease-in-out;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}
@keyframes zoomIn {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}
@keyframes flipIn {
  from {
    transform: perspective(600px) rotateY(90deg);
    opacity: 0;
  }
}
@keyframes choke {
  20%,
  60% {
    transform: translateX(-4px) scaleY(0.96);
  }
  40%,
  80% {
    transform: translateX(4px) scaleY(0.96);
  }
}

/* ======================================================================= TV */

.view-tv {
  overflow: hidden;
}
.tv {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 1.2vh 1.4vw;
  gap: 1.2vh;
}
.tv-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 2vw;
}
.tv-logo {
  font-weight: 900;
  letter-spacing: 0.08em;
  font-size: clamp(16px, 1.6vw, 30px);
  line-height: 1;
  color: var(--paper);
}
.tv-logo span {
  color: var(--sep);
}
.tv-phase {
  text-align: center;
}
.ph-title {
  font-size: clamp(18px, 2.2vw, 42px);
  font-weight: 800;
  line-height: 1.1;
}
.ph-title b {
  color: var(--gold);
}
.ph-sub {
  color: var(--muted);
  font-size: clamp(12px, 1.1vw, 20px);
  font-weight: 600;
}
.tv-join {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tv-join .code.small {
  font-weight: 900;
  font-size: clamp(16px, 1.6vw, 28px);
  letter-spacing: 0.2em;
  color: var(--gold);
  border: 2px solid var(--gold);
  padding: 4px 10px;
  border-radius: 8px;
}
.tv-tools {
  display: flex;
  gap: 8px;
}
.tv-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(260px, 25vw, 480px);
  gap: 1.4vw;
  min-height: 0;
}
.tv-board {
  display: grid;
  align-content: center;
  min-height: 0;
}
/* Fit two stacked boards (each 2400x805) into the available height. */
.tv-board .board {
  width: min(100%, calc((100dvh - 14vh) * 2400 / 805 / 2 - 1vw));
  margin: 0 auto;
}
.tv-side {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1.4vh;
  min-height: 0;
  overflow: hidden;
}
.tv-side .senator {
  min-height: 0;
  padding: 0.6vh 0.8vw;
}
.tv-side .s-name {
  font-size: clamp(14px, 1.2vw, 24px);
}
.tv-side .placard,
.tv-side .vote-mini {
  height: clamp(24px, 3vh, 44px);
}
.tv-side .log {
  font-size: clamp(12px, 0.9vw, 17px);
  overflow: hidden;
  mask-image: linear-gradient(#000 60%, transparent);
}
.tv:not(.in-game) .tv-body {
  visibility: hidden;
}
.tv-lobby:empty,
.tv-over:empty {
  display: none;
}
.tv-lobby {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 4vh 4vw;
}
.lobby-card {
  display: grid;
  gap: 2.4vh;
  justify-items: center;
  text-align: center;
  width: min(1100px, 100%);
}
.lobby-join {
  display: flex;
  align-items: center;
  gap: 3vw;
  background: #0d0f16e6;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2.4vh 2.4vw;
}
.lobby-join .qr {
  width: clamp(160px, 22vh, 300px);
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}
.lobby-join .code {
  font-size: clamp(48px, 10vh, 120px);
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--gold);
  line-height: 1;
}
.lobby-join .url {
  font-size: clamp(16px, 2.4vh, 28px);
  color: var(--muted);
  font-weight: 700;
  margin-top: 1vh;
}
.lobby-hint,
.lobby-status {
  margin: 0;
  font-size: clamp(16px, 2.2vh, 26px);
  color: var(--muted);
}
.lobby-status {
  color: var(--text);
  font-weight: 700;
}
.lobby-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.lobby-p {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px 10px 10px;
  font-weight: 800;
  font-size: clamp(16px, 2.2vh, 26px);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: zoomIn 0.4s both;
}
.lobby-p span {
  background: var(--gold);
  color: #111;
  border-radius: 50%;
  width: 1.6em;
  height: 1.6em;
  display: grid;
  place-items: center;
  font-size: 0.8em;
}
.lobby-p em,
.lobby-seats em {
  font-style: normal;
  font-size: 0.6em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.lobby-p.off {
  opacity: 0.5;
}
.lobby-empty {
  color: var(--muted);
  font-size: 20px;
}
.tv-over {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: #000d;
  padding: 4vh 4vw;
  animation: zoomIn 0.6s both;
}
.tv-over .reveal-card {
  width: clamp(90px, 11vw, 190px);
}
.tv-over .reveal-card figcaption {
  font-size: clamp(14px, 1.3vw, 22px);
}

/* -------------------------------------------------------------------- crawl */

.crawl {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #000;
  overflow: hidden;
  font-family: 'News Cycle', 'Franklin Gothic Medium', 'Arial Narrow', sans-serif;
}
.crawl-intro {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #4bd5ee;
  font-size: clamp(20px, 3vw, 48px);
  opacity: 0;
}
.crawl.go .crawl-intro {
  animation: intro 5s ease-in-out both;
}
.crawl-stage {
  position: absolute;
  inset: 0;
  /* Deep perspective scaled to the screen keeps the text big and wide for most of the crawl. */
  perspective: 160vh;
  perspective-origin: 50% 30%;
  display: flex;
  justify-content: center;
}
.crawl-text {
  position: absolute;
  top: 100%;
  width: min(96vw, 2000px);
  color: var(--crawl);
  font-size: clamp(32px, 5.6vw, 150px);
  line-height: 1.35;
  font-weight: 700;
  text-align: justify;
  transform-origin: 50% 100%;
  opacity: 0;
}
.crawl.go .crawl-text {
  animation: crawl 40s linear 5s both;
}
.crawl-text h1 {
  text-align: center;
  font-size: 1.4em;
  margin: 0 0 0.6em;
  letter-spacing: 0.04em;
}
.crawl-text .ep {
  text-align: center;
  margin: 0;
}
.crawl-skip {
  position: absolute;
  right: 3vw;
  bottom: 3vh;
  font-family: var(--font);
}
@keyframes intro {
  15%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
@keyframes crawl {
  0% {
    opacity: 0;
    transform: rotateX(22deg) translateY(0);
  }
  1% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotateX(22deg) translateY(-150%);
  }
}

/* =================================================================== PLAYER */

.view-player {
  overflow-x: hidden;
}
.pv {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}
.pv-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: #050507ee;
  border-bottom: 1px solid var(--line);
}
.pv-who {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.pv-who b {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pv-code {
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-size: 13px;
}
.pv-top-btns {
  display: flex;
  gap: 8px;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sep);
  flex: none;
}
.dot.on {
  background: var(--ok);
}
.pv-grid {
  display: grid;
  min-height: 0;
}
.pv-boardcol {
  display: none;
  padding: 14px;
  gap: 14px;
  align-content: start;
}
.show-board .pv-boardcol {
  display: grid;
}
.show-board .pv-panel {
  display: none;
}
.pv-panel {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  padding: 14px 14px max(14px, env(safe-area-inset-bottom));
  min-height: calc(100dvh - 60px);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.view-player.over .pv-status,
.view-player.over .pv-mini,
.pv-status:empty,
.pv-mini:empty,
.pv-id:empty {
  display: none;
}
.st-title {
  font-weight: 800;
  font-size: 19px;
  line-height: 1.2;
}
.st-title b {
  color: var(--gold);
}
.st-sub {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.pv-mini {
  display: grid;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.mini-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
}
.mini-row .lbl {
  width: 86px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.pips {
  display: flex;
  gap: 4px;
}
.pips i {
  width: 16px;
  height: 10px;
  border-radius: 2px;
  background: #ffffff18;
}
.pips i.loy {
  background: var(--loy);
}
.pips i.sep {
  background: var(--sep);
}
.pips i.hot {
  background: var(--gold);
}
.mini-note {
  color: var(--muted);
  margin-left: auto;
  text-align: right;
}
.pv-action {
  display: grid;
  gap: 12px;
  align-content: start;
}
.act-kicker {
  font-size: 11px;
  letter-spacing: 0.25em;
  font-weight: 800;
  color: var(--muted);
}
.act-title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.02em;
}
.act-sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.act-sub b {
  color: var(--text);
}
.act-sub.small {
  font-size: 12px;
}

/* Target picker */
.targets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.target {
  appearance: none;
  background: var(--panel-2);
  border: 2px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  min-height: 58px;
  padding: 8px;
  font: 700 16px var(--font);
  cursor: pointer;
  display: grid;
  place-content: center;
  text-align: center;
  touch-action: manipulation;
}
.target small {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.target:disabled {
  opacity: 0.35;
}
.target.sel {
  border-color: var(--gold);
  background: #ffae0022;
}

/* Voting */
.ballot-q {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  align-items: baseline;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.ballot-q span {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.ballot-q b {
  font-size: 20px;
}
.vote-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.vote-btn {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  touch-action: manipulation;
  transition: transform 0.08s;
}
.vote-btn:active {
  transform: scale(0.95);
}
.vote-btn img {
  display: block;
  width: 100%;
}
.sealed {
  display: grid;
  gap: 12px;
  text-align: center;
}
.sealed-mark {
  font-size: 22px;
  font-weight: 900;
  color: var(--ok);
}
.vote-check {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

/* Hold-to-reveal */
.hold {
  position: relative;
  border-radius: 16px;
  background: repeating-linear-gradient(135deg, #10131c 0 10px, #0c0f16 10px 20px);
  border: 2px dashed #39405a;
  min-height: 88px;
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  cursor: pointer;
  overflow: hidden;
}
.hold-cover {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.12em;
  font-size: 13px;
  padding: 16px;
}
.fp {
  width: 34px;
  height: 34px;
  flex: none;
}
.hold-secret {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: #07080c;
  visibility: hidden;
  opacity: 0;
}
.hold.on {
  border-style: solid;
  border-color: #555;
}
.hold.on .hold-secret {
  visibility: visible;
  opacity: 1;
}
.hold.on .hold-cover {
  visibility: hidden;
}
.hold.small {
  min-height: 70px;
}
.hold.small .hold-secret,
.hold.intel .hold-secret {
  justify-content: center;
  flex-direction: column;
  gap: 8px;
}
.idpad {
  min-height: 110px;
}
/* Role reveal sits centered in the pad (art and text as one centered group). */
.idpad .hold-secret {
  justify-content: center;
}
.idpad .role-text {
  text-align: center;
  justify-items: center;
}
.idpad .allies {
  justify-content: center;
}
.idpad.on {
  min-height: 190px;
}
.role-art {
  height: 170px;
  border-radius: 8px;
}
.role-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.role-kicker {
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--muted);
  font-weight: 800;
}
.role-name {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}
.role-name.loyalist {
  color: var(--loy-hi);
}
.role-name.separatist,
.role-name.palpatine {
  color: var(--sep-hi);
}
.role-team {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.allies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.allies span {
  font-weight: 800;
  font-size: 14px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #d11a0e33;
}
.allies-note {
  font-size: 13px;
  color: var(--muted);
}
.id-extra {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.party-art {
  height: 150px;
  border-radius: 8px;
}
.intel-text {
  font-size: 18px;
  font-weight: 700;
}
.intel-text .loyalist {
  color: var(--loy-hi);
}
.intel-text .separatist {
  color: var(--sep-hi);
}
.hold.intel {
  min-height: 200px;
}
.peek-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.peek-card {
  width: 80px;
}
.peek-card img {
  width: 100%;
  display: block;
  border-radius: 6px;
}

/* Face-down decree cards */
.hand {
  display: grid;
  gap: 10px;
}
.hand.n3 {
  grid-template-columns: repeat(3, 1fr);
}
.hand.n2 {
  grid-template-columns: repeat(2, 1fr);
  padding: 0 8%;
}
.pcard {
  position: relative;
  display: block;
  border: 3px solid transparent;
  background: none;
  padding: 0;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  aspect-ratio: 424 / 662;
  transition: transform 0.12s;
}
.pcard .back {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 9px;
}
.pcard .face {
  position: absolute;
  inset: 0;
  visibility: hidden;
  border-radius: 9px;
  overflow: hidden;
  background: #07080c;
  display: grid;
  place-items: center;
}
.pcard .face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pcard.on .face {
  visibility: visible;
}
.pcard.on {
  transform: scale(1.03);
}
.hand-slot {
  display: grid;
  gap: 8px;
}
.hand-slot.sel .pcard {
  border-color: var(--gold);
}
.pick-btn {
  appearance: none;
  min-height: 48px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: 800 14px var(--font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}
.pick-btn.on {
  background: var(--gold);
  border-color: var(--gold);
  color: #111;
}
.pcard .grip {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  color: #0008;
}
.pcard.on .grip {
  display: none;
}
.face-text {
  font-weight: 900;
  /* Horizontal and sized so "SEPARATIST" fits across a card on narrow phones. */
  font-size: clamp(10px, 3.2vw, 15px);
  letter-spacing: 0.03em;
  color: #bbb;
  text-align: center;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.peek-card .face-text {
  font-size: 11px;
  padding: 18px 0;
  text-align: center;
  background: #151515;
  border-radius: 6px;
}

/* Waiting */
.waiting {
  display: grid;
  gap: 12px;
}
.wait-msg {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 0;
}
.dead-note {
  background: var(--sep-dark);
  border-radius: 10px;
  padding: 12px;
  font-weight: 700;
  text-align: center;
}
.senators.compact .senator {
  min-height: 44px;
  padding: 6px 10px;
}
.senators.compact .placard,
.senators.compact .vote-mini {
  height: 24px;
}

/* Lobby */
.lobby {
  display: grid;
  gap: 12px;
}
.lobby-head {
  display: flex;
  gap: 14px;
  align-items: center;
}
.lobby-head .qr {
  width: 110px;
  background: #fff;
  border-radius: 10px;
  padding: 5px;
}
.lobby-head .code {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--gold);
  line-height: 1;
}
.lobby-head .url {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}
.lobby h3,
.menu-card h3 {
  margin: 4px 0 0;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.lobby-seats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.lobby-seats li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  min-height: 50px;
}
.lobby-seats li.off {
  opacity: 0.5;
}
.lobby-seats .seat {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gold);
  color: #111;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 13px;
  flex: none;
}
.lobby-seats b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seat-btns {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.qr-btn {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  cursor: zoom-in;
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--muted);
  font: 800 9px var(--font);
  letter-spacing: 0.12em;
  flex: none;
}
.qr-btn img {
  display: block;
}

/* Desktop vote pop-up */
.vote-modal {
  position: fixed;
  inset: 0;
  z-index: 45; /* above the page, below the vote-reveal overlay (.fx) */
  display: grid;
  place-items: center;
  padding: 24px;
  background: #000b;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.15s ease-out;
}
.vote-card {
  animation: zoomIn 0.25s ease-out;
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 2px solid var(--gold);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 0 60px #ffae0033, 0 30px 80px #000;
}
.vote-card .act-title {
  font-size: 30px;
}
.vote-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}
.vote-foot .btn {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 13px;
}

/* In-game confirmation pop-up */
.dlg-modal {
  position: fixed;
  inset: 0;
  z-index: 95; /* above everything else, including the vote pop-up and overlays */
  display: grid;
  place-items: center;
  padding: 16px;
  background: #000c;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.15s ease-out;
}
.dlg-card {
  animation: zoomIn 0.2s ease-out;
  width: min(460px, 100%);
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 30px 80px #000;
}
.dlg-card.danger {
  border-color: var(--sep);
  box-shadow: 0 0 60px #d11a0e44, 0 30px 80px #000;
}
.dlg-card.danger .act-title {
  color: var(--sep-hi);
}
.dlg-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}
.btn.danger {
  background: var(--sep);
  border-color: var(--sep);
  color: #fff;
}

/* Big QR: white, edge to edge, bright enough to scan from across a booth. */
.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #fff;
  color: #111;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.5vh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  cursor: zoom-out;
}
.qr-modal img {
  width: min(96vw, 78dvh);
  height: auto;
  image-rendering: pixelated;
}
.qr-code {
  font-weight: 900;
  font-size: clamp(40px, 13vw, 96px);
  letter-spacing: 0.18em;
  line-height: 1;
}
.qr-url {
  font-weight: 700;
  font-size: 15px;
  color: #444;
  word-break: break-all;
  text-align: center;
}
.qr-hint {
  font-size: 12px;
  color: #888;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Result */
.you-result {
  text-align: center;
  font-weight: 900;
  letter-spacing: 0.12em;
  padding: 10px;
  border-radius: 10px;
}
.you-result.won {
  background: #1d4d2d;
}
.you-result.lost {
  background: var(--sep-dark);
}

/* Menu */
.pv-menu {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #000c;
  display: grid;
  align-items: end;
}
.menu-card {
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 16px 16px max(20px, env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  max-height: 88dvh;
  overflow: auto;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.menu-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.menu-row {
  appearance: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 14px;
  font: 700 15px var(--font);
  text-decoration: none;
  cursor: pointer;
}
.menu-row.danger {
  color: var(--sep-hi);
}
.menu-note {
  margin: -4px 0 4px;
  color: var(--muted);
  font-size: 12px;
}
.switch {
  width: 44px;
  height: 26px;
  border-radius: 99px;
  background: #333;
  position: relative;
  transition: background 0.2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s;
}
.switch.on {
  background: var(--ok);
}
.switch.on::after {
  left: 21px;
}
.intel-item {
  display: grid;
  gap: 6px;
}
.intel-label {
  font-size: 13px;
  font-weight: 700;
}

/* ------------------------------------------------------------ stealth mode */
/* Secrets as small grey text: no art, no colour, nothing to catch at a glance. */

.stealth .hold-secret,
.stealth .pcard .face,
.stealth .vote-check {
  color: #b9b9b9 !important;
}
.stealth .hold-secret .role-name,
.stealth .hold-secret .intel-text span,
.stealth .hold-secret .allies span {
  color: #cfcfcf !important;
  background: #222 !important;
  text-shadow: none;
}
.stealth .hold-secret .role-name {
  background: none !important;
  font-size: 24px;
}
.stealth .hold-secret img {
  filter: grayscale(1) brightness(0.7);
}

/* ------------------------------------------------------------------ desktop */

@media (min-width: 980px) {
  .pv-grid {
    grid-template-columns: minmax(0, 1fr) 440px;
    height: calc(100dvh - 58px);
  }
  .pv-boardcol,
  .show-board .pv-boardcol {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    grid-template-rows: auto 1fr;
    overflow: auto;
    align-content: start;
  }
  #pvBoard {
    grid-column: 1;
    grid-row: 1 / span 2;
  }
  #pvPlayers {
    grid-column: 2;
  }
  #pvLog {
    grid-column: 2;
  }
  .show-board .pv-panel,
  .pv-panel {
    display: grid;
    border-left: 1px solid var(--line);
    background: #07080cdd;
    overflow: auto;
    min-height: 0;
  }
  #boardBtn,
  .pv-mini,
  .waiting .senators {
    display: none !important;
  }
  .view-player:not(.in-lobby) .pv-boardcol:has(#pvBoard:empty) {
    display: none;
  }
  .pv-grid:has(#pvBoard:empty) {
    grid-template-columns: 1fr;
  }
}

/* Menu: bottom sheet on phones (thumb reach), centered dialog on desktop. */
@media (min-width: 980px) {
  .pv-menu {
    align-items: center;
    padding: 24px;
  }
  .menu-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    max-height: 85dvh;
    box-shadow: 0 30px 80px #000;
    animation: zoomIn 0.2s ease-out;
  }
}

/* Game over on desktop: results take over the screen instead of the side panel. */
.results-chip,
.desk-only {
  display: none;
}
@media (min-width: 980px) {
  .desk-only {
    display: inline-flex;
    justify-self: center;
  }
  .view-player.over:not(.over-min) .pv-panel {
    position: fixed;
    inset: 58px 0 0 0;
    z-index: 30;
    max-width: none;
    border-left: 0;
    background: #050507f2;
    backdrop-filter: blur(4px);
    padding: 4vh 4vw 6vh;
    overflow: auto;
    display: block;
    animation: fadeIn 0.3s ease-out;
  }
  .view-player.over:not(.over-min) .pv-action {
    max-width: 1200px;
    margin: 0 auto;
    gap: 20px;
  }
  .view-player.over:not(.over-min) .pv-action > .row {
    max-width: 620px;
    width: 100%;
    justify-self: center;
  }
  .view-player.over:not(.over-min) .reveal-card {
    width: clamp(110px, 10vw, 170px);
  }
  .view-player.over:not(.over-min) .reveal-card figcaption {
    font-size: 15px;
  }
  .view-player.over:not(.over-min) .you-result {
    justify-self: center;
    padding: 10px 28px;
  }
  /* Viewing the final board: same layout and scale as normal play; the side
     panel shows a compact result card (see finalBoardHTML). */
  .view-player.over.over-min .results-chip {
    display: inline-block;
    border-color: var(--gold);
    color: var(--gold);
  }
}
.final-card {
  display: grid;
  gap: 12px;
  text-align: center;
}
.final-card h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  text-transform: uppercase;
}
.final-card.loyalist h2 {
  color: var(--loy-hi);
}
.final-card.separatist h2 {
  color: var(--sep-hi);
}

@media (max-width: 380px) {
  .targets {
    grid-template-columns: 1fr 1fr;
  }
  .role-art {
    height: 140px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
