:root {
  --bg: #080814;
  --panel: #151525;
  --panel-2: #1f1d34;
  --text: #f8f7ff;
  --muted: #b9b3d6;
  --pink: #ff4fd8;
  --cyan: #37f6ff;
  --yellow: #ffe66d;
  --green: #6dff9a;
  --red: #ff5c7a;
  --line: rgba(255, 255, 255, 0.16);
  --shadow: 0 0 28px rgba(55, 246, 255, 0.16);
}

/* Game boards use only public participant information. */
.game-scene {
  position: relative;
  overflow: hidden;
  margin: 0 0 24px;
  padding: 24px;
  border: 1px solid #38506b;
  background: #111c2a;
}
.scene-heading { position: relative; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.scene-heading h3 { margin: 0; color: #fff; font-size: 1.25rem; }
.scene-eyebrow { margin: 0 0 8px; color: #89ede8; font-size: .72rem; font-weight: bold; letter-spacing: 0; }
.scene-count { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #638178; color: #d0f6db; font-size: .8rem; font-weight: bold; }
.mafia-scene { background: #171831; }
.mafia-scene.is-day { background: #344050; border-color: #a77d73; }
.mafia-scene.is-day .scene-eyebrow { color: #ffe39a; }
.city-skyline { height: 72px; display: flex; align-items: flex-end; gap: 5px; margin: 10px 0 0; overflow: hidden; opacity: .7; }
.city-skyline span { flex: 1; min-width: 18px; background-color: #080d1e; background-image: repeating-linear-gradient(90deg, transparent 0 9px, #e6b661 9px 12px, transparent 12px 21px); background-size: 100% 5px; background-repeat: repeat-y; border-top: 8px solid #080d1e; }
.city-skyline span:nth-child(4n+1) { height: 45%; }
.city-skyline span:nth-child(4n+2) { height: 85%; }
.city-skyline span:nth-child(4n+3) { height: 60%; }
.city-skyline span:nth-child(4n) { height: 100%; }
.scene-players { position: relative; display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; padding-top: 16px; border-top: 2px solid #64718a; }
.scene-player { min-width: 0; display: grid; justify-items: center; align-content: start; gap: 5px; text-align: center; }
.scene-avatar { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border: 2px solid #76dfd5; background: #1c3a46; color: #edfffb; font-size: 1rem; font-weight: bold; }
.scene-player-name { max-width: 100%; overflow-wrap: anywhere; font-size: .85rem; font-weight: bold; }
.scene-player-status { color: #a9e8c4; font-size: .72rem; }
.scene-player.is-out, .bunker-person.is-out { opacity: .55; }
.is-out .scene-avatar { border-color: #ac8992; background: #40343f; }
.is-out .scene-player-status, .is-out .bunker-person-status { color: #f0b2ba; }
.bunker-scene { border-color: #557c69; background: #182923; }
.bunker-meter { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 22px 0 16px; color: #c3d9ca; font-size: .85rem; }
.bunker-meter strong { color: #fff; }
.bunker-meter-track { grid-column: 1 / -1; height: 7px; background: #3c5549; }
.bunker-meter-track span { display: block; height: 100%; background: #a4e891; }
.bunker-roster { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 8px; }
.bunker-person { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px; border: 1px solid #496a58; background: #20382c; }
.bunker-person-details { display: grid; flex: 1; min-width: 0; gap: 4px; }
.bunker-person-details strong, .bunker-person-details span { overflow-wrap: anywhere; }
.bunker-person-details span { color: #b7d0c0; font-size: .78rem; line-height: 1.35; }
.bunker-person-status { flex: 0 0 auto; color: #a4e891; font-size: .72rem; }
@media (max-width: 480px) {
  .game-scene { padding: 16px; }
  .scene-players { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .scene-heading h3 { font-size: 1.1rem; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  background:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, rgba(255,79,216,0.16), transparent 32%),
    radial-gradient(circle at 80% 20%, rgba(55,246,255,0.15), transparent 30%),
    var(--bg);
  background-size: 28px 28px, 28px 28px, auto, auto, auto;
}

a { color: inherit; text-decoration: none; }

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.home-screen {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 24px;
}

.brand-panel {
  padding: 22px 0 4px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 18px;
}

.jollysync-mark {
  position: relative;
  display: inline-block;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  background: url('/static/jollysync-icon.svg') center / contain no-repeat;
  filter: drop-shadow(0 0 12px rgba(55, 246, 255, 0.2));
}

.jollysync-mark.small {
  width: 30px;
  height: 30px;
  margin-right: 8px;
  vertical-align: middle;
}

.kicker {
  margin: 0 0 10px;
  color: var(--cyan);
  text-transform: uppercase;
  font-size: 0.82rem;
  letter-spacing: 0;
}

h1, h2, h3 {
  margin: 0 0 14px;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2.4rem, 8vw, 5.4rem);
  color: var(--yellow);
  text-shadow: 4px 4px 0 #5a236c, 0 0 22px rgba(255, 230, 109, 0.28);
}

h2 { font-size: 1.45rem; color: var(--cyan); }
h3 { font-size: 1.1rem; color: var(--yellow); }

.subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.grid {
  display: grid;
  gap: 18px;
}

.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lobby-layout { grid-template-columns: 1.3fr 0.7fr; }
.game-layout { grid-template-columns: 320px minmax(0, 1fr); align-items: start; }

.panel {
  background: linear-gradient(180deg, rgba(31,29,52,0.96), rgba(16,16,31,0.98));
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,255,255,0.04);
}

label {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.96rem;
}

input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 2px solid rgba(55,246,255,0.45);
  border-radius: 6px;
  background: #090918;
  color: var(--text);
  padding: 12px 13px;
  font: inherit;
  outline: none;
}

textarea { min-height: 76px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 230, 109, 0.14);
}

.code-input, .code-box {
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
}

.code-box {
  display: inline-grid;
  min-width: 180px;
  place-items: center;
  margin: 10px 0 18px;
  padding: 16px 20px;
  border: 2px dashed var(--pink);
  color: var(--yellow);
  font-size: 2rem;
  background: rgba(255,79,216,0.08);
}

button, .button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  padding: 12px 18px;
  color: #090918;
  background: var(--yellow);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #ad8619;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary { background: var(--pink); color: var(--text); box-shadow: 0 4px 0 #87206f; }
.primary.cyan { background: var(--cyan); color: #061014; box-shadow: 0 4px 0 #16838c; }
.danger { width: 100%; margin-top: 18px; background: var(--red); color: var(--text); box-shadow: 0 4px 0 #8f2438; }
.ghost { background: transparent; color: var(--text); border: 2px solid var(--line); box-shadow: none; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

.game-picker {
  margin: 18px 0;
}

.host-mode { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 18px; padding: 14px; }
.host-mode[hidden] { display: none; }
.host-mode legend { color: var(--yellow); padding: 0 6px; }
.host-mode label { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.host-mode input { width: 18px; min-height: 18px; margin: 0; }

.game-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.game-card {
  display: grid;
  align-content: start;
  justify-items: start;
  min-height: 152px;
  padding: 14px;
  color: var(--text);
  text-align: left;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(55,246,255,0.32);
  box-shadow: none;
}

.game-card strong {
  color: var(--yellow);
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.game-card span {
  color: var(--muted);
  line-height: 1.35;
}

.game-card em {
  margin-top: 12px;
  color: var(--green);
  font-style: normal;
  font-size: 0.9rem;
}

.game-card.selected {
  border-color: var(--green);
  background: rgba(109,255,154,0.11);
  box-shadow: 0 0 18px rgba(109,255,154,0.18);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.logo {
  display: inline-flex;
  align-items: center;
  color: var(--yellow);
  font-weight: 900;
}
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.05);
}

.players {
  list-style: none;
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.players li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
}
.players li > span { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.players .remove-offline { width: 32px; height: 32px; min-height: 32px; padding: 0; background: transparent; color: var(--red); border: 1px solid var(--red); box-shadow: none; font-size: 1.25rem; }

.compact li { padding: 9px 10px; }
.game-timer { padding: 16px 0; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.timer-display { display: block; color: var(--yellow); font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.timer-controls[hidden] { display: none; }
.timer-controls label { margin: 0; }
.timer-controls button { min-width: 0; }
.timer-controls input { min-width: 0; }
.company-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 16px; }
.company-options label { display: flex; align-items: center; gap: 8px; margin: 0; }
.company-options input { width: 18px; min-height: 18px; margin: 0; }
.offline { color: var(--red); }
.online { color: var(--green); }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 14px 16px;
  border: 2px solid var(--red);
  border-radius: 8px;
  background: #1f1019;
  color: var(--text);
  box-shadow: 0 0 20px rgba(255,92,122,0.22);
}

.game-root {
  min-height: 460px;
}

.game-root :is(.game-root, section, .story) > :is(button, .actions) + :is(button, .actions),
.game-root > :is(button, .actions) + :is(button, .actions) {
  margin-top: 16px;
}

.story-image {
  display: block;
  width: min(100%, 512px);
  height: auto;
  margin: 18px 0;
  border-radius: 6px;
}

.question-list {
  display: grid;
  gap: 14px;
}

.story, .result-line {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(55,246,255,0.07);
  line-height: 1.55;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.choice-grid button {
  min-height: 64px;
  background: var(--panel-2);
  color: var(--text);
  border: 2px solid var(--cyan);
  box-shadow: none;
}

.role-card {
  border: 2px solid var(--yellow);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  background: rgba(255,230,109,0.08);
}

.scoreboard {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.scoreboard div {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.mafia-progress-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 12px; }
.mafia-progress-heading h3 { margin: 0; }
.mafia-progress-heading > span { color: var(--muted); font-weight: bold; white-space: nowrap; }
.mafia-action-list { display: grid; gap: 8px; }
.mafia-action-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 12px 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, .12); }
.mafia-action-actor, .mafia-action-target { display: grid; align-content: start; gap: 5px; min-width: 0; }
.mafia-action-actor span, .mafia-action-target span { color: var(--muted); font-size: .8rem; }
.mafia-action-role { text-transform: capitalize; }
.mafia-action-row strong { overflow-wrap: anywhere; line-height: 1.35; }
.mafia-action-target .is-done { color: var(--green); }
.mafia-action-target .is-pending { color: var(--yellow); }
.mafia-roles { margin: 20px 0; }
.mafia-roles summary { color: var(--cyan); cursor: pointer; font-weight: bold; }
@media (max-width: 420px) {
  .mafia-action-row { grid-template-columns: 1fr; gap: 10px; }
}

.game-root :is(.scoreboard, .question-list, .story, .result-line) + :is(h2, h3, button, .actions),
.game-root form + :is(h2, h3, button, .actions),
.game-root .story > .scoreboard + :is(h2, h3, button, .actions),
.game-root .story > .question-list + :is(h2, h3, button, .actions) {
  margin-top: 24px;
}

@media (max-width: 860px) {
  .two, .lobby-layout, .game-layout {
    grid-template-columns: 1fr;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .choice-grid {
    grid-template-columns: 1fr;
  }
  .game-card-grid {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: clamp(2.2rem, 14vw, 4.2rem);
  }
  .brand-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
}
