/* ===== BOTC — Trouble Brewing (minimal + fullscreen + print + lightbox) ===== */
* {
  box-sizing: border-box;
}

:root {
  --bg: #251d38;
  /* The deep, dusty purple from the book cover's base */
  --card: #281f3f;
  /* A slightly lighter purple for cards and panels */
  --text: #d9d5e5;
  /* A faded, lavender-tinted white for readability */
  --muted: #8a819b;
  /* A muted, grayish purple for secondary text */
  --accent: #cca43b;
  /* The antique, slightly desaturated gold of the title */
  --border: #4f4761;
  /* A darker purple to create subtle borders */
  --shadow: 0 6px 18px rgba(15, 12, 22, .4);
  /* A shadow tinted with purple */
  --shadow-hover: 0 8px 24px rgba(15, 12, 22, .5);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, sans-serif;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.04) 1px, transparent 0);
  background-size: 20px 20px;
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 980px;
  margin: 32px auto;
  padding: 0 16px;
}

.header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 3vw, 32px);
}

.header .sub {
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.card h2 {
  margin: 0 0 12px;
  font-size: clamp(18px, 2.5vw, 24px);
}

.roles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

fieldset {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

legend {
  color: var(--muted);
  padding: 0 6px;
}

/* NEW STYLE for the current required role count */
.role-current-count {
  font-size: 1.0em;
  /* Keep it similar size to team name */
  font-weight: 600;
  /* Bold the number */
  margin-left: 4px;
}

/* NEW STYLE for the selected role count */
.role-selected-count {
  font-size: 1.0em;
  font-weight: 700;
  /* Make it bolder to stand out */
  margin-left: 4px;
}

/* Color coding for the role count in the legend - APPLIED TO ALL TEAMS */
.role-current-count[data-team-type="Townsfolk"] {
  color: #0077be;
  /* Blue (Good) */
}

.role-current-count[data-team-type="Outsider"] {
  color: #0077be;
  /* Blue (Good) */
}

.role-current-count[data-team-type="Minion"] {
  color: #c92a2a;
  /* Red (Evil) */
}

.role-current-count[data-team-type="Demon"] {
  color: #c92a2a;
  /* Red (Evil) */
}

/* Color coding for selected counts */
.role-selected-count[data-team-type="Townsfolk"] {
  color: #0077be;
  /* Blue (Good) */
}

.role-selected-count[data-team-type="Outsider"] {
  color: #0077be;
  /* Blue (Good) */
}

.role-selected-count[data-team-type="Minion"] {
  color: #c92a2a;
  /* Red (Evil) */
}

.role-selected-count[data-team-type="Demon"] {
  color: #c92a2a;
  /* Red (Evil) */
}

/* Muted state for when player count is too low */
.role-current-count.muted-count {
  color: var(--muted) !important;
}

label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

input[type="checkbox"] {
  margin-right: 10px;
  transform: scale(1.2);
}

.role-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 4px;
  border-radius: 8px;
  transition: background-color 0.2s ease-in-out;
  flex-wrap: wrap;
  /* ADDED: Allows the controls div to wrap below the label */
}

.role-item:hover {
  background-color: rgba(34, 48, 74, 0.5);
}

.role-item label {
  flex-grow: 1;
  min-width: 120px;
}

/* NEW RULE: Ensures the controls themselves wrap if they are too wide */
.role-controls {
  flex-wrap: wrap;
  gap: 6px;
}

.role-preset-select:focus,
.player-name-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.role-preset-select {
  background: #0f1524;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  flex-shrink: 0;
}

input.role-preset-select {
  width: 50px;
  text-align: center;
}

.player-name-input {
  background: #0f1524;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  width: 100%;
  max-width: 120px;
  flex-shrink: 0;
}


.actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

button {
  background: var(--accent);
  border: none;
  color: #08101f;
  padding: 10px 16px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out;
}

button:hover {
  background: #5a93e8;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.ghost:hover {
  background-color: var(--accent);
  color: #08101f;
  border-color: var(--accent);
}

button:active {
  transform: translateY(1px);
}

.night-block {
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.night-block summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.night-block summary::-webkit-details-marker {
  display: none;
}

.night-block summary h3 {
  margin: 8px 0;
  color: #cfe1ff;
}

.night-block summary::after {
  content: '▼';
  font-size: 0.8em;
  color: var(--muted);
  transition: transform 0.2s ease-in-out;
  padding-right: 10px;
}

.night-block[open]>summary::after {
  transform: rotate(180deg);
}

#firstNightList,
#eachNightList {
  padding-left: 22px;
  margin: 10px 0 0;
}

#firstNightList li,
#eachNightList li {
  margin: 10px 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background-color 0.2s ease-in-out;
}

#firstNightList li:hover,
#eachNightList li:hover {
  background-color: rgba(34, 48, 74, 0.7);
}


.meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.meta b {
  color: #d9e7ff;
}

li.active {
  outline: 3px solid var(--accent);
  border-radius: 8px;
  padding: 4px 6px;
}

li.active,
li.active:hover {
  background-color: var(--border);
}


#scriptSection.fullscreen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  padding: 40px 28px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#scriptSection.fullscreen h2 {
  font-size: clamp(32px, 4vw, 48px);
  text-align: center;
  margin: 0 0 20px;
}

#scriptSection.fullscreen .night-block summary h3 {
  font-size: clamp(22px, 3vw, 34px);
  text-align: center;
  margin: 0;
}

#scriptSection.fullscreen ol {
  font-size: clamp(18px, 2.5vw, 30px);
  line-height: 1.6;
  max-width: 1100px;
  margin: 0 auto 12px;
}

#scriptSection.fullscreen li {
  margin: 18px 0;
}

#scriptSection.fullscreen .meta {
  font-size: clamp(14px, 1.6vw, 18px);
}

#exitFullscreenBtn {
  position: fixed;
  top: 16px;
  right: 16px;
  background: var(--accent);
  color: #08101f;
  padding: 8px 14px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  border: none;
  z-index: 10000;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fb;
    --card: #fff;
    --text: #0b0f16;
    --muted: #4b5b70;
    --border: #d7deea;
  }

  body {
    background: var(--bg);
    color: var(--text);
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .header,
  .roles,
  .actions,
  .footer {
    display: none !important;
  }

  #scriptSection {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  #scriptSection h2 {
    margin: 0 0 8px;
  }

  ol {
    font-size: 12pt;
    line-height: 1.5;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 12px;
    margin: 16px auto;
  }

  .card {
    padding: 12px;
  }

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

  .role-item {
    flex-wrap: wrap;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  #scriptSection.fullscreen ol {
    padding-left: 20px;
  }
}


/* =================================================================== */
/* ===== NO CHANGES BEYOND THIS POINT (CARD UI) ====================== */
/* =================================================================== */


/* ===== Lightbox (card viewer) ===== */
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10050;
  padding: 20px;
}

#lightbox.show {
  display: flex;
}

#lightbox figure {
  margin: 0;
  max-width: min(90vw, 900px);
  max-height: 90vh;
  display: grid;
  gap: 8px;
}

#lightboxImg {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: #111;
}

#lightboxCaption {
  text-align: center;
  color: #dfe9ff;
  font-size: clamp(16px, 2.2vw, 22px);
}

#lightboxClose {
  position: fixed;
  top: 14px;
  right: 14px;
  background: var(--accent);
  color: #08101f;
  border: 0;
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 800;
  cursor: pointer;
  z-index: 10060;
}


/* ===== Full-screen text card (Ask/Reveal) ===== */
#textCard {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10040;
  display: none;
  padding: 20px 14px;
}

#textCard.show {
  display: grid;
}

#textCard .inner {
  margin: 0 auto;
  max-width: 1200px;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  gap: 24px;
  height: 100%;
  text-align: center;
}

#textCard .badge {
  display: none;
}

#textCard .bigtext {
  font-size: clamp(32px, 8vw, 96px);
  line-height: 1.15;
  color: var(--text);
  word-break: break-word;
  align-self: end;
}

#textCard .toolbar {
  display: flex;
  justify-content: center;
  gap: 10px;
  align-self: start;
  grid-row: 3;
}

#textCard .toolbar button {
  background: var(--accent);
  color: #08101f;
  border: 0;
  padding: 10px 16px;
  font-weight: 800;
  border-radius: 12px;
  cursor: pointer;
}

#textCard .toolbar button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

@media (prefers-reduced-motion: reduce) {
  #textCard .bigtext {
    scroll-behavior: auto !important;
  }
}

#textCardFigure {
  grid-row: 2;
}

#textCardTokenImg {
  max-width: min(60vw, 320px);
  max-height: 45vh;
  border-radius: 50%;
  object-fit: cover;
  background: #111;
  box-shadow: var(--shadow);
}

#textCardTokenCaption {
  font-size: clamp(1rem, 2.5vw, 2rem);
  font-weight: 700;
  color: #fff;
  margin-top: 0.5rem;
  width: 100%;
}

#textCardTokenCaption ul {
  list-style: none;
  padding: 0;
  margin: 0;
  /* OVERRIDES for evil team list */
  font-size: clamp(1rem, 2.5vw, 2rem);
  text-align: left;
}

#textCardTokenCaption h4 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin-bottom: 1rem;
  color: var(--muted);
  text-align: center;
}

#controlRow {
  display: none;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  opacity: .95;
}

.controls .switch,
.controls .pill {
  display: none;
}

.controls .switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #0f1524;
}

.controls .switch input {
  transform: scale(1.2);
}

.controls button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
}

.pill {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #cfe1ff;
  background: #0f1524;
}


/* FIXES FOR TOKEN/NUMBER DISPLAY */

/* Style for small tokens in the Evil Team Info list */
.role-token-small {
  width: 40px;
  /* Increased size for visibility */
  height: 40px;
  border-radius: 50%;
  /* Keep the circular shape */
  object-fit: cover;
  vertical-align: middle;
  /* Align nicely with text */
  margin-right: 10px;
  background: #111;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

#textCardTokenCaption li {
  margin-bottom: 8px;
  /* Space out list items */
}

/* 1. Reduce the size of the "Ask" text when the figure (number/token) is present for better layout */
#textCardFigure:not([hidden])~.bigtext {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  align-self: center;
}

/* 2. Make the content of the caption (the number or token name) massive, but capped lower */
#textCardFigure:not([hidden]) #textCardTokenCaption {
font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 900;
  line-height: 1.1;
  margin-top: 0;
}


/* ===== Quick role picker modal ===== */
.picker {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  display: none;
  z-index: 10080;
}

.picker.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.picker-panel {
  width: min(92vw, 680px);
  max-height: 90vh;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.picker-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

#pickerSearch {
  flex: 1;
  background: #0f1524;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.picker-list {
  overflow: auto;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.picker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: #0f1524;
}

.picker-item small {
  color: var(--muted);
}

.picker-item:hover {
  outline: 2px solid var(--accent);
}

.picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}