:root{
  --bg:#050812;
  --bg-deep:#02050c;
  --panel:#0b1324;
  --panel-soft:#111b31;
  --line:rgba(210,230,255,.12);
  --line-strong:rgba(163,217,255,.26);
  --text:#f3f8ff;
  --muted:#9caec9;
  --accent:#9fe7ff;
  --accent-2:#baffd8;
  --danger:#ff8e98;
  --warning:#ffd79f;
  --shadow:0 26px 70px rgba(0,0,0,.42);
  --radius:24px;
}

*{box-sizing:border-box}
html,body{min-height:100%}
html{scroll-behavior:smooth}
body{
  margin:0;
  font-family:"Inter","Segoe UI",sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at 14% 18%, rgba(116,170,255,.18), transparent 22%),
    radial-gradient(circle at 82% 14%, rgba(160,120,255,.14), transparent 20%),
    radial-gradient(circle at 55% 78%, rgba(133,255,214,.10), transparent 24%),
    linear-gradient(180deg, #0a1020 0%, var(--bg) 42%, var(--bg-deep) 100%);
  position:relative;
  overflow-x:hidden;
}

body::before,
body::after{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
}

body::before{
  background:
    radial-gradient(rgba(255,255,255,.92) 1px, transparent 1.7px),
    radial-gradient(rgba(159,231,255,.48) 1px, transparent 1.8px);
  background-size:56px 56px, 94px 94px;
  background-position:0 0, 28px 14px;
  opacity:.22;
  animation:starDrift 68s linear infinite;
}

body::after{
  background:
    linear-gradient(120deg, transparent 0 44%, rgba(255,255,255,.07) 47%, transparent 50%) 12% 18% / 220px 2px no-repeat,
    linear-gradient(120deg, transparent 0 44%, rgba(159,231,255,.10) 47%, transparent 50%) 84% 24% / 180px 2px no-repeat,
    linear-gradient(120deg, transparent 0 44%, rgba(186,255,216,.08) 47%, transparent 50%) 68% 74% / 160px 2px no-repeat;
  opacity:.5;
  animation:shootingStars 12s ease-in-out infinite;
}

@keyframes starDrift{
  from{transform:translate3d(0,0,0)}
  to{transform:translate3d(-180px,-120px,0)}
}

@keyframes shootingStars{
  0%,100%{transform:translateX(0);opacity:.25}
  20%{opacity:.55}
  50%{transform:translateX(-18px);opacity:.15}
}

code{color:var(--accent)}

.home-link{
  position:relative;
  z-index:1;
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:22px 24px 0;
  max-width:1280px;
  margin:0 auto;
}

.home-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
}

.topbar{
  position:relative;
  z-index:1;
  max-width:1280px;
  margin:18px auto 0;
  padding:24px 26px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:18px;
  border:1px solid var(--line);
  border-radius:32px;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.08), transparent 32%),
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.025));
  box-shadow:var(--shadow);
  backdrop-filter:blur(14px);
}

.topbar::after{
  content:"";
  position:absolute;
  right:22px;
  top:20px;
  width:64px;
  height:64px;
  border-radius:50%;
  background:radial-gradient(circle, rgba(159,231,255,.16), rgba(159,231,255,0));
  pointer-events:none;
}

.topbarRight{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.brand{
  min-width:260px;
}

.brand .title{
  font-family:"Orbitron","Segoe UI",sans-serif;
  font-size:clamp(24px,3vw,36px);
  font-weight:700;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:var(--accent);
}

.brand .subtitle{
  margin-top:8px;
  color:var(--muted);
  font-size:14px;
  letter-spacing:.02em;
}

.counters{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.pill{
  display:inline-flex;
  align-items:center;
  min-height:40px;
  padding:8px 14px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.045);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.04);
  font-size:13px;
  font-weight:600;
  color:var(--text);
}

.pill span{
  color:var(--muted);
  margin-right:6px;
}

.timerPill{
  min-width:132px;
  justify-content:center;
  font-variant-numeric:tabular-nums;
}

.timerInline{
  margin-top:14px;
}

.dangerText{
  color:var(--danger);
  font-weight:800;
}

.app{
  position:relative;
  z-index:1;
  max-width:1280px;
  margin:0 auto;
  padding:22px 24px 34px;
}

.view.hidden{display:none}

.panel{
  padding:22px;
  border-radius:30px;
  border:1px solid var(--line);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.055), transparent 28%),
    linear-gradient(180deg, rgba(13,21,40,.94), rgba(7,12,24,.94));
  box-shadow:var(--shadow);
}

.panelHead{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
}

h1{
  margin:0;
  font-size:22px;
  font-weight:800;
  letter-spacing:.01em;
}

.hint{
  margin:14px 0 0;
  color:var(--muted);
  font-size:14px;
}

.deckTools{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-end;
}

.inline{
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--muted);
  font-size:13px;
}

input[type="number"],
input[type="text"]{
  min-width:96px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.1);
  background:rgba(255,255,255,.04);
  color:var(--text);
  outline:none;
}

input[type="number"]:focus,
input[type="text"]:focus{
  border-color:var(--line-strong);
  box-shadow:0 0 0 3px rgba(159,231,255,.08);
}

.rolesList{
  margin-top:18px;
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(340px, 1fr));
  gap:12px;
}

.roleRow{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  min-height:84px;
  padding:14px 16px;
  border-radius:22px;
  border:1px solid rgba(255,255,255,.08);
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.02)),
    rgba(8,13,25,.58);
  transition:transform .16s ease, border-color .18s ease, box-shadow .18s ease;
}

.roleRow::before{
  content:"";
  position:absolute;
  right:18px;
  top:14px;
  width:38px;
  height:16px;
  opacity:.38;
  background:
    radial-gradient(circle, rgba(227,247,255,.9) 0 2px, transparent 3px) 0 6px / 12px 12px no-repeat,
    radial-gradient(circle, rgba(227,247,255,.9) 0 2px, transparent 3px) 14px 0 / 12px 12px no-repeat,
    radial-gradient(circle, rgba(227,247,255,.9) 0 2px, transparent 3px) 28px 8px / 12px 12px no-repeat;
}

.roleRow::after{
  content:"";
  position:absolute;
  right:23px;
  top:22px;
  width:26px;
  height:1px;
  background:rgba(227,247,255,.38);
  transform:rotate(9deg);
}

.roleRow:hover{
  transform:translateY(-2px);
  border-color:rgba(159,231,255,.22);
  box-shadow:0 18px 36px rgba(0,0,0,.18), 0 0 0 1px rgba(159,231,255,.06);
}

.roleRow.highlighted{
  border-color:rgba(186,255,216,.34);
  box-shadow:0 0 0 1px rgba(186,255,216,.12), 0 18px 34px rgba(0,0,0,.18);
}

.roleLeft{
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width:0;
}

.roleName{
  font-weight:800;
  font-size:15px;
  letter-spacing:.01em;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  cursor:pointer;
  transition:color .14s ease;
}

.roleName.selected{
  color:var(--accent-2);
}

.roleRule{
  font-size:12px;
  color:var(--muted);
}

.roleRight{
  display:flex;
  align-items:center;
  gap:10px;
  position:relative;
  z-index:1;
}

.counter{
  width:52px;
  text-align:center;
  font-weight:800;
  font-size:18px;
  color:var(--accent);
  font-variant-numeric:tabular-nums;
}

.btn{
  cursor:pointer;
  border:1px solid rgba(255,255,255,.1);
  background:rgba(255,255,255,.05);
  color:var(--text);
  padding:11px 15px;
  border-radius:16px;
  font-weight:700;
  letter-spacing:.01em;
  transition:transform .14s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
  user-select:none;
}

.btn:hover{
  transform:translateY(-1px);
  border-color:rgba(159,231,255,.22);
  background:rgba(255,255,255,.08);
  box-shadow:0 12px 24px rgba(0,0,0,.16);
}

.btn:active{transform:translateY(1px)}

.btn.primary{
  background:linear-gradient(135deg, rgba(159,231,255,.2), rgba(186,255,216,.14));
  border-color:rgba(159,231,255,.28);
}

.btn.ghost{
  background:transparent;
}

.btn.danger{
  background:linear-gradient(135deg, rgba(255,142,152,.2), rgba(255,215,159,.12));
  border-color:rgba(255,142,152,.34);
  color:#fff7f8;
}

.btn.small{
  padding:8px 11px;
  border-radius:12px;
  font-size:13px;
}

.btn.win{
  background:linear-gradient(135deg, rgba(255,255,255,.05), rgba(159,231,255,.05));
}

.footerActions{
  margin-top:18px;
  display:flex;
  justify-content:flex-end;
}

.centerStage{
  min-height:calc(100vh - 190px);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:16px;
  text-align:center;
}

.hidden{display:none !important}

.bigPhase{
  color:var(--muted);
  font-weight:700;
  letter-spacing:.18em;
  text-transform:uppercase;
  font-size:13px;
}

.roleButton{
  width:min(840px, 92vw);
  min-height:170px;
  padding:34px 24px;
  border-radius:34px;
  border:1px solid rgba(255,255,255,.12);
  background:
    radial-gradient(circle at top left, rgba(159,231,255,.14), transparent 28%),
    linear-gradient(180deg, rgba(18,29,54,.94), rgba(8,14,28,.95));
  color:var(--text);
  font-family:"Orbitron","Segoe UI",sans-serif;
  font-size:clamp(26px,5vw,48px);
  font-weight:700;
  letter-spacing:.06em;
  text-transform:uppercase;
  cursor:pointer;
  box-shadow:var(--shadow);
}

.tinyNarration{
  padding:7px 12px;
  font-size:12px;
  border-radius:999px;
  opacity:.95;
}

.narrationText{
  color:var(--text);
  max-height:min(68vh, 640px);
  overflow:auto;
  padding-right:8px;
  line-height:1.7;
  white-space:pre-wrap;
}

.smallHint{
  color:var(--muted);
  min-height:18px;
}

#flowHint{display:none}

.infiltrationMsg{
  margin-top:6px;
  padding:10px 14px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.1);
  background:rgba(255,215,159,.08);
  color:var(--warning);
  font-weight:700;
  font-size:13px;
}

.row{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:center;
}

.row.wrap{flex-wrap:wrap}
.gap{gap:12px}

.miniatureToolbar{
  justify-content:flex-end;
  margin-bottom:8px;
}

.rolesGrid,
.votesGrid{
  margin-top:18px;
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(240px, 1fr));
  gap:12px;
}

.votesGrid .hint{
  grid-column:1 / -1;
}

.roleCard{
  position:relative;
  overflow:hidden;
  min-height:92px;
  padding:14px 16px;
  border-radius:22px;
  border:1px solid rgba(255,255,255,.08);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.05), transparent 30%),
    linear-gradient(180deg, rgba(14,22,40,.96), rgba(8,12,24,.96));
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.roleCard::after{
  content:"";
  position:absolute;
  inset:auto 14px 12px auto;
  width:42px;
  height:42px;
  border-radius:50%;
  background:radial-gradient(circle, rgba(159,231,255,.12), rgba(159,231,255,0));
}

.roleCard .name{
  font-weight:800;
  position:relative;
  z-index:1;
}

.roleCard .count{
  color:var(--muted);
  font-variant-numeric:tabular-nums;
  position:relative;
  z-index:1;
}

.roleCard .actions{
  display:flex;
  gap:8px;
  position:relative;
  z-index:1;
}

.voteCard.selected{
  border-color:rgba(255,142,152,.46);
  box-shadow:0 0 0 1px rgba(255,142,152,.14), 0 16px 32px rgba(0,0,0,.14);
}

.voteCountBtn{
  min-width:58px;
  text-align:center;
  font-weight:800;
  font-variant-numeric:tabular-nums;
}

.dayMessages{
  margin-top:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.msg{
  padding:12px 14px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.04);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.msg strong{font-weight:900}

.msg .left{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.msg .sub{
  color:var(--muted);
  font-size:13px;
}

.wins{
  margin-top:18px;
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:10px;
}

.overlay{
  position:fixed;
  inset:0;
  z-index:50;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:rgba(2,5,12,.62);
  backdrop-filter:blur(10px);
}

.overlay.hidden{display:none}

.modal{
  width:min(560px, 92vw);
  padding:18px;
  border-radius:26px;
  border:1px solid rgba(255,255,255,.11);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.06), transparent 28%),
    linear-gradient(180deg, rgba(16,24,44,.96), rgba(7,11,22,.98));
  box-shadow:var(--shadow);
}

.modalTitle{
  margin-bottom:10px;
  font-size:16px;
  font-weight:900;
}

.modalBody{
  color:var(--muted);
  line-height:1.45;
}

.modalActions{
  margin-top:14px;
  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
}

@media (max-width:980px){
  .topbar,
  .panelHead{
    flex-direction:column;
  }

  .topbarRight,
  .deckTools{
    justify-content:flex-start;
  }
}

@media (max-width:760px){
  .home-link,
  .app{
    padding-left:16px;
    padding-right:16px;
  }

  .topbar{
    margin-left:16px;
    margin-right:16px;
    padding:20px 18px;
    border-radius:26px;
  }

  .panel{
    padding:18px;
    border-radius:24px;
  }

  .rolesList{
    grid-template-columns:1fr;
  }

  .rolesGrid,
  .votesGrid,
  .wins{
    grid-template-columns:1fr;
  }

  .roleRow,
  .roleCard,
  .msg{
    align-items:flex-start;
    flex-direction:column;
  }

  .roleRight,
  .roleCard .actions{
    width:100%;
    justify-content:flex-end;
  }

  .roleButton{
    min-height:150px;
    border-radius:28px;
  }

  .row{
    flex-wrap:wrap;
  }
}
