/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #21262d;
  --border:    #30363d;
  --text:      #e6edf3;
  --text2:     #8b949e;
  --accent:    #c9a84c;   /* gold */
  --good:      #2d6fa4;   /* townsfolk blue */
  --outsider:  #2a7a6e;   /* teal */
  --minion:    #b05a1a;   /* orange */
  --demon:     #8b1f1f;   /* crimson */
  --dead-bg:   #1a1a1a;
  --dead-text: #555;
  --green:     #2ea043;
  --red:       #da3633;
  --radius:    8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #2d333b; border-color: #8b949e; }
.btn-primary { background: #1f4b8e; border-color: #388bfd; color: #fff; }
.btn-primary:hover { background: #2563be; }
.btn-danger { background: #4a1414; border-color: var(--red); color: #ff7b7b; }
.btn-danger:hover { background: #6b1e1e; }
.btn-execute { background: #1a1200; border-color: var(--accent); color: var(--accent); }
.btn-execute:hover { background: #2a1e00; border-color: #e0c060; }
.btn-poison-active { background: #071a07; border-color: #4caf50; color: #81c784; }
.btn-poison-active:hover { background: #0d2e0d; }
.btn-protect-active { background: #071020; border-color: #2196f3; color: #64b5f6; }
.btn-protect-active:hover { background: #0d1e38; }
.btn-red-herring-active { background: #1a0707; border-color: #f44336; color: #e57373; }
.btn-red-herring-active:hover { background: #2e0d0d; }
.btn-claude { background: #1a0d2e; border-color: #8b5cf6; color: #c4b5fd; }
.btn-claude:hover { background: #2d1a4a; border-color: #a78bfa; }
.btn-privacy { background: var(--bg3); border-color: var(--border); color: var(--text2); }
.btn-privacy:hover { background: #2d333b; border-color: var(--text2); color: var(--text); }
.btn-privacy.active { background: #1a1205; border-color: var(--accent); color: var(--accent); }
.btn-large { padding: 12px 32px; font-size: 15px; font-weight: 600; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Setup screen ─────────────────────────────────────────────────────── */
.setup-screen {
  height: 100vh;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  background: radial-gradient(ellipse at top, #1a1230 0%, var(--bg) 70%);
}

.setup-card {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.setup-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  letter-spacing: 0.04em;
}

.setup-subtitle {
  font-size: 15px;
  color: var(--text2);
  text-align: center;
  font-weight: 400;
}

.setup-row {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
}

.setup-left { display: flex; flex-direction: column; gap: 14px; }

.setup-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text2);
  font-weight: 500;
}

.setup-input {
  padding: 8px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  width: 80px;
}

.setup-textarea {
  padding: 8px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}

.guest-list-section {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guest-list-textarea {
  padding: 8px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.8;
  width: 100%;
}
.guest-list-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.dist-preview {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.8;
}
.dist-preview .dist-row { display: flex; justify-content: space-between; }
.dist-preview .dist-label { color: var(--text); }

.hint { font-size: 11px; color: var(--text2); font-weight: 400; }

.setup-right { display: flex; flex-direction: column; gap: 12px; }

.char-selection-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Character type sections */
.type-section { margin-bottom: 12px; }
.type-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 0;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.type-header.townsfolk { color: #6fb3d8; }
.type-header.outsider  { color: #5ec4b8; }
.type-header.minion    { color: #e09050; }
.type-header.demon     { color: #e05050; }

.type-count { font-size: 11px; color: var(--text2); }
.type-count.over { color: var(--red); font-weight: 700; }

.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}

.char-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg2);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s;
}
.char-card:hover { border-color: var(--text2); background: var(--bg3); }

.char-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--bg3);
}

.char-card-info { flex: 1; min-width: 0; }

.char-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.char-card-ability {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.45;
}

.char-card.included {
  background: #0f2a0f;
  border-color: var(--green);
}
.char-card.included .char-card-name { color: #7ee787; }
.char-card.included .char-card-ability { color: #4d9955; }

.char-card.excluded {
  background: #2a0f0f;
  border-color: var(--red);
}
.char-card.excluded .char-card-name { color: #ff7b7b; text-decoration: line-through; }
.char-card.excluded .char-card-ability { color: #7a3535; text-decoration: line-through; }

.char-card.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Setup presets ────────────────────────────────────────────────────── */
.preset-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.preset-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 2px;
}

.preset-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.preset-card:hover { background: var(--bg3); border-color: var(--text2); }
.preset-card.active { border-color: var(--accent); background: #1a1505; }

.preset-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.preset-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.preset-card.active .preset-name { color: var(--accent); }

.preset-diff {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.04em;
}
.diff-beginner { background: #0f2a0f; color: #7ee787; border: 1px solid #2ea043; }
.diff-balanced { background: #1a1505; color: #f0c040; border: 1px solid #b8860b; }
.diff-expert   { background: #2a0f0f; color: #ff7b7b; border: 1px solid #da3633; }

.preset-description {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 8px;
}

.preset-chars {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.preset-char-pill {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid;
  background: transparent;
  opacity: 0.85;
}

.setup-error {
  background: #3a1a1a;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: #ff7b7b;
  font-size: 13px;
}

/* ── Restore section ─────────────────────────────────────────────────────── */
.restore-section {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.restore-file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: var(--bg2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
  text-align: center;
}
.restore-file-label:hover { border-color: var(--text2); color: var(--text); }

.restore-preview {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
}
.restore-preview-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  color: var(--text2);
}
.restore-preview-row span:last-child { color: var(--text); font-weight: 600; }

.restore-error {
  background: #3a1a1a;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: #ff7b7b;
  font-size: 12px;
}

/* ── Grimoire screen layout ───────────────────────────────────────────── */
.grimoire-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.grimoire-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-center { display: flex; gap: 8px; }
.header-right { display: flex; gap: 8px; }

.game-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.phase-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.phase-badge.first_night { background: #1a2a4a; color: #7eb8e8; border: 1px solid #2d5a9e; }
.phase-badge.night       { background: #1a1a3a; color: #9e8ee8; border: 1px solid #4a3d9e; }
.phase-badge.day         { background: #3a2a00; color: #e8c870; border: 1px solid #9e7a00; }

.day-badge { font-size: 13px; color: var(--text2); }

.grimoire-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.grimoire-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Circle ──────────────────────────────────────────────────────────── */
.circle-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.circle-wrapper:fullscreen {
  background: var(--bg);
  width: 100vw;
  height: 100vh;
}
.circle-wrapper:fullscreen .circle-container {
  flex: 1;
}
.circle-wrapper:fullscreen .alive-count {
  font-size: 16px;
  bottom: 16px;
  right: 24px;
}
.circle-wrapper:fullscreen .player-token {
  width: 130px;
  height: 130px;
}
.circle-wrapper:fullscreen .token-icon,
.circle-wrapper:fullscreen .token-icon-placeholder {
  width: 114px;
  height: 114px;
}
.circle-wrapper:fullscreen .token-role-label { font-size: 15px; }
.circle-wrapper:fullscreen .token-name-label { font-size: 13px; }
.circle-wrapper:fullscreen .token-drunk-badge { width: 48px; height: 48px; }
.circle-wrapper:fullscreen .token-poison-badge      { width: 36px; height: 36px; font-size: 17px; }
.circle-wrapper:fullscreen .token-protect-badge     { width: 36px; height: 36px; font-size: 16px; }
.circle-wrapper:fullscreen .token-red-herring-badge { width: 36px; height: 36px; font-size: 16px; }
.circle-wrapper:fullscreen .free-reminder-token .free-token-label { font-size: 14px; }

.circle-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.circle-canvas {
  position: absolute;
  inset: 0;
  transform-origin: center center;
  will-change: transform;
}

/* iOS / no-API pseudo-fullscreen */
.circle-wrapper.pseudo-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9000;
  background: var(--bg);
  width: 100vw !important;
  height: 100dvh !important;
}
.circle-wrapper.pseudo-fullscreen .circle-container { flex: 1; }
.circle-wrapper.pseudo-fullscreen .alive-count { font-size: 16px; bottom: 16px; right: 24px; }

.alive-count {
  position: absolute;
  bottom: 8px;
  right: 16px;
  font-size: 12px;
  color: var(--text2);
}

.free-reminder-token {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1.5px solid;
  border-radius: 20px;
  padding: 3px 8px 3px 10px;
  cursor: grab;
  z-index: 10;
  user-select: none;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.free-reminder-token.dragging {
  cursor: grabbing;
  z-index: 60;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
  transition: none;
}
.free-token-label {
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}
.free-token-remove {
  background: none;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 1px;
  opacity: 0;
  color: inherit;
  transition: opacity 0.1s;
}
.free-reminder-token:hover .free-token-remove { opacity: 0.7; }

.palette-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9998;
  transform: translate(-50%, -50%);
  opacity: 0.85;
}

/* ── Player token ─────────────────────────────────────────────────────── */
.player-token {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: var(--bg2);
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transform: translate(-50%, -50%);
  transition: border-color 0.12s, box-shadow 0.12s;
  user-select: none;
  overflow: visible;
  z-index: 1;
}
.player-token:hover {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.15);
}
.player-token.dragging {
  cursor: grabbing;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  transition: none;
}

.player-token.townsfolk { border-color: var(--good); }
.player-token.outsider  { border-color: var(--outsider); }
.player-token.minion    { border-color: var(--minion); }
.player-token.demon     { border-color: var(--demon); }
.player-token.unassigned { border-color: var(--border); }

.player-token.dead {
  background: var(--dead-bg);
  border-color: #333 !important;
  opacity: 0.6;
}

.token-icon {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.player-token.dead .token-icon { filter: grayscale(1) opacity(0.4); }

.token-icon-placeholder {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: var(--text2);
}

.token-labels {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}
.token-role-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  background: rgba(13, 17, 23, 0.88);
  padding: 1px 6px;
  border-radius: 3px;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.token-name-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
  white-space: nowrap;
  background: rgba(13, 17, 23, 0.88);
  padding: 1px 6px;
  border-radius: 3px;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.token-labels-empty { display: none; }
.player-token.dead .token-role-label,
.player-token.dead .token-name-label { color: var(--dead-text); }

.role-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: #1c2128;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 13px;
  max-width: 240px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transform: translate(-50%, calc(-100% - 14px));
}
.role-tooltip-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.role-tooltip-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  margin-bottom: 6px;
}
.role-tooltip-type.townsfolk { color: var(--good); }
.role-tooltip-type.outsider  { color: var(--outsider); }
.role-tooltip-type.minion    { color: var(--minion); }
.role-tooltip-type.demon     { color: var(--demon); }
.role-tooltip-drunk {
  font-size: 10px;
  color: #ffca28;
  margin-bottom: 5px;
  font-style: italic;
}
.role-tooltip-ability {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.5;
  font-style: italic;
}

.token-shroud {
  display: none;
  font-size: 18px;
  position: absolute;
  top: -4px;
  right: -4px;
  line-height: 1;
  color: #cc3333;
}
.token-shroud.token-shroud-executed { color: var(--accent); }
.player-token.dead .token-shroud { display: block; }

.token-ghost-icon {
  display: none;
  font-size: 11px;
  position: absolute;
  bottom: -2px;
  right: -2px;
}
.player-token.ghost-used .token-ghost-icon { display: block; }

.token-drunk-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #ffca28;
  background: #1a1500;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.8), 0 2px 6px rgba(0,0,0,0.6);
  pointer-events: none;
}

.token-poison-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #4caf50;
  background: #071a07;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.8), 0 2px 6px rgba(0,0,0,0.6);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #81c784;
  line-height: 1;
}
.token-protect-badge {
  position: absolute;
  bottom: -6px;
  left: -6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #2196f3;
  background: #071020;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.8), 0 2px 6px rgba(0,0,0,0.6);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}

.token-red-herring-badge {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #f44336;
  background: #1a0707;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.8), 0 2px 6px rgba(0,0,0,0.6);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}

/* Reminder pips */
.token-reminders {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100px;
}
.reminder-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid rgba(255,255,255,0.2);
  cursor: default;
  position: relative;
}
.reminder-pip[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: 360px;
  flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1;
  padding: 11px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: color 0.12s, border-color 0.12s;
}
.sidebar-tab:hover { color: var(--text); }
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.night-order-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.night-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
  background: var(--bg3);
  cursor: pointer;
  transition: background 0.1s;
}
.night-step:hover { background: #2d333b; }
.night-step.done { opacity: 0.45; }
.night-step.done .step-name { text-decoration: line-through; }

.night-step.townsfolk { border-left-color: var(--good); }
.night-step.outsider  { border-left-color: var(--outsider); }
.night-step.minion    { border-left-color: var(--minion); }
.night-step.demon     { border-left-color: var(--demon); }
.night-step.meta      { border-left-color: var(--accent); background: #1a1508; }

.step-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  margin-top: 2px;
  background: transparent;
  transition: background 0.1s;
}
.night-step.done .step-check { background: var(--green); border-color: var(--green); }

.step-body { flex: 1; min-width: 0; }
.step-name { font-size: 14px; font-weight: 600; }
.step-instruction {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
  margin-top: 4px;
}
.step-num { font-size: 11px; color: var(--text2); flex-shrink: 0; margin-top: 2px; }
.step-icon { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

.night-step.poisoned { border-left-color: #4caf50 !important; background: #071a0f; }
.night-step.poisoned.done { opacity: 0.45; }

.night-step.drunk-step { border-left-color: #ffca28 !important; background: #1a1500; }

.step-icon-wrap {
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
}
.step-icon-wrap .step-icon { flex-shrink: unset; }
.step-minion-icons {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
  min-width: 42px;
}
.step-minion-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--minion);
}

.step-drunk-overlay {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #1a1500;
}
.step-drunk-warning {
  font-size: 11px;
  font-weight: 700;
  color: #ffe082;
  background: #1a1500;
  border: 1px solid #ffca28;
  border-radius: 8px;
  padding: 2px 8px;
  display: inline-block;
  margin-bottom: 4px;
}
.step-drunk-name {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #ffe082;
  background: #1a1500;
  border: 1px solid #ffca28;
  border-radius: 8px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
}

.step-poison-icon {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #81c784;
  background: #071a07;
  border: 1px solid #4caf50;
  border-radius: 8px;
  padding: 0px 5px;
  margin-left: 5px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

/* ── Player modal ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.drunk-setup-card { width: 360px; }
.drunk-setup-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
}
.drunk-setup-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.drunk-setup-hint {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
  margin: 0;
}
.modal-player-name { font-size: 17px; font-weight: 700; }
.modal-name-row { flex: 1; }
.modal-name-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  width: 100%;
  padding: 2px 4px;
  outline: none;
  font-family: inherit;
}
.modal-name-input:focus { border-bottom-color: var(--accent); }
.modal-name-input::placeholder { color: var(--text2); font-weight: 400; font-size: 14px; }

.modal-name-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.name-chip {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg3);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.name-chip:hover { background: #2d333b; border-color: #8b949e; color: var(--text); }
.name-chip.active { background: #1c2e1c; border-color: var(--green); color: #7ee787; }
.name-chip.taken { opacity: 0.4; cursor: default; }
.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }

.modal-section { display: flex; flex-direction: column; gap: 6px; }
.modal-character-row { flex-direction: row !important; align-items: center; gap: 14px; }
.modal-character-info { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.modal-char-icon { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid var(--border); }
.modal-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text2); }

.modal-select {
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
}
.modal-select-sm {
  flex: 1;
  padding: 4px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
}

.modal-status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-status-text { font-size: 13px; font-weight: 600; }
.modal-status-text.alive { color: var(--green); }
.modal-status-text.dead { color: var(--red); }

.modal-ability {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text2);
  font-style: italic;
  line-height: 1.5;
  border-left: 3px solid var(--accent);
}

.modal-reminders {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}
.reminder-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  background: #2a2206;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 11px;
}
.reminder-pill-remove {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
}
.reminder-pill-remove:hover { opacity: 1; }

.add-reminder-row { display: flex; gap: 6px; align-items: center; }

.modal-notes-textarea {
  width: 100%;
  height: 70px;
  padding: 6px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  resize: vertical;
  font-family: inherit;
}

/* ── Scrollbars ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Claude assistant modal ──────────────────────────────────────────── */
.claude-modal-card {
  width: 580px;
  border-color: #4c2a8a;
  box-shadow: 0 20px 60px rgba(100, 50, 200, 0.25);
}
.claude-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #c4b5fd;
}
.claude-question-input {
  width: 100%;
  min-height: 90px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid #4c2a8a;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  resize: vertical;
  line-height: 1.5;
  margin-bottom: 10px;
}
.claude-question-input:focus {
  outline: none;
  border-color: #8b5cf6;
}
.btn-claude-submit {
  width: 100%;
  background: #2d1a4a;
  border-color: #8b5cf6;
  color: #c4b5fd;
  font-weight: 600;
}
.btn-claude-submit:hover { background: #3d2460; }
.btn-claude-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.claude-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  color: #a78bfa;
  font-size: 13px;
}
.claude-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #4c2a8a;
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.claude-answer {
  background: var(--bg3);
  border: 1px solid #4c2a8a;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  max-height: 50vh;
  overflow-y: auto;
}
.claude-answer .md-p { margin: 0; }
.claude-answer .md-gap { height: 8px; }
.claude-answer .md-heading {
  color: #c4b5fd;
  font-size: 13px;
  font-weight: 700;
  margin: 4px 0 2px;
  letter-spacing: 0.02em;
}
.claude-answer h2.md-heading { font-size: 15px; }
.claude-answer .md-list {
  margin: 2px 0 2px 18px;
  padding: 0;
}
.claude-answer .md-list li { margin: 2px 0; }
.claude-answer .md-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}
.claude-answer strong { color: #e2e8f0; font-weight: 700; }
.claude-answer em { color: #a5b4fc; font-style: italic; }
.claude-answer code {
  background: #1e1030;
  border: 1px solid #4c2a8a;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 12px;
  color: #c4b5fd;
}

/* ── Privacy screen ──────────────────────────────────────────────────── */
.privacy-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.privacy-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  user-select: none;
}

.privacy-title {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.privacy-subtitle {
  font-size: 16px;
  color: var(--text2);
  letter-spacing: 0.12em;
}

.privacy-hint {
  margin-top: 24px;
  font-size: 12px;
  color: #3a3f47;
  letter-spacing: 0.04em;
}

/* ── Show to Player ──────────────────────────────────────────────────── */
.btn-show-player { background:#0d1f1a; border-color:#2d7a6e; color:#5ec4b8; }
.btn-show-player:hover { background:#1a3530; border-color:#5ec4b8; }

.show-player-card { width:560px; max-height:85vh; }
.show-player-title { font-size:15px; font-weight:700; color:#5ec4b8; }

.stp-text-palette { display:flex; flex-wrap:wrap; gap:8px; }
.stp-text-btn {
  padding:6px 14px; border-radius:20px; border:1px solid var(--border);
  background:var(--bg3); color:var(--text2); cursor:pointer;
  font-size:13px; font-weight:500; white-space:nowrap;
  transition:background 0.12s, border-color 0.12s, color 0.12s;
}
.stp-text-btn:hover { border-color:var(--text2); color:var(--text); background:#2d333b; }
.stp-text-btn.active { background:#0d2020; border-color:#5ec4b8; color:#5ec4b8; }

.stp-role-search {
  width:100%; padding:7px 10px; margin-bottom:8px;
  background:var(--bg3); border:1px solid var(--border);
  border-radius:var(--radius); color:var(--text); font-size:13px;
  display:block; box-sizing:border-box;
}
.stp-role-search:focus { outline:none; border-color:var(--accent); }
.stp-role-grid {
  display:grid; grid-template-columns:repeat(auto-fill,minmax(70px,1fr));
  gap:8px; max-height:220px; overflow-y:auto;
}
.stp-role-item {
  display:flex; flex-direction:column; align-items:center; gap:4px;
  padding:6px 4px; border-radius:var(--radius);
  border:1.5px solid transparent; cursor:pointer; background:var(--bg3);
  transition:border-color 0.12s, background 0.12s;
}
.stp-role-item:hover { border-color:var(--border); background:#2d333b; }
.stp-role-item.selected { border-color:var(--accent); background:#1a1505; }
.stp-role-item.at-limit { opacity:0.35; pointer-events:none; }
.stp-role-icon { width:48px; height:48px; border-radius:50%; object-fit:cover; border:2px solid var(--border); }
.stp-role-item.selected .stp-role-icon { border-color:var(--accent); }
.stp-role-item-name { font-size:10px; color:var(--text2); text-align:center; line-height:1.2; word-break:break-word; }
.stp-role-item.selected .stp-role-item-name { color:var(--accent); }

.stp-selection-preview { display:flex; flex-wrap:wrap; gap:6px; }
.stp-preview-chip {
  display:flex; align-items:center; gap:5px;
  padding:4px 10px 4px 6px; background:var(--bg3);
  border:1px solid var(--border); border-radius:20px;
  font-size:12px; color:var(--text2);
}
.stp-preview-chip img { width:22px; height:22px; border-radius:50%; object-fit:cover; }
.stp-preview-remove {
  background:none; border:none; color:var(--text2); cursor:pointer;
  font-size:14px; padding:0; margin-left:2px; line-height:1;
}
.stp-preview-remove:hover { color:var(--text); }

/* Player-facing overlay */
.stp-overlay {
  position:fixed; inset:0; background:#000; z-index:9999;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
}
.stp-overlay-content {
  display:flex; flex-direction:column; align-items:center; gap:40px;
  max-width:600px; width:100%; padding:24px;
}
.stp-display-text-row { display:flex; flex-direction:column; align-items:center; gap:16px; }
.stp-display-text-token {
  font-size:clamp(22px,5vw,40px); font-weight:700; color:#fff;
  background:#111; border:2px solid #333; border-radius:16px; padding:16px 32px;
  text-align:center;
}
.stp-display-text-token.is-number {
  font-size:clamp(48px,12vw,96px); padding:20px 40px; min-width:120px;
  border-color:var(--accent); color:var(--accent);
}
.stp-display-roles-row {
  display:flex; flex-direction:row; align-items:center;
  justify-content:center; gap:32px; flex-wrap:wrap;
}
.stp-display-role-item { display:flex; flex-direction:column; align-items:center; gap:12px; }
.stp-display-role-icon {
  width:120px; height:120px; border-radius:50%; object-fit:cover;
  border:4px solid var(--border); box-shadow:0 4px 20px rgba(0,0,0,0.6);
}
.stp-display-role-name { font-size:clamp(14px,3vw,20px); font-weight:700; color:#fff; text-align:center; }
.stp-done-btn {
  position:fixed; top:16px; right:16px;
  background:rgba(30,30,30,0.7); border:1px solid #444; color:#555;
  font-size:11px; padding:4px 10px; border-radius:6px; cursor:pointer; z-index:10000;
}

/* ── Mobile / touch responsive ─────────────────────────────────────────── */
@media (max-width: 700px) {
  /* ── Setup screen ── */
  .setup-row {
    grid-template-columns: 1fr;
  }
  .char-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  /* ── Grimoire header: wrap rows, bigger tap targets ── */
  .grimoire-header {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
  }
  .header-left  { flex: 1; min-width: 0; }
  .header-center { gap: 6px; }
  .header-right  { gap: 6px; flex-wrap: wrap; }
  .game-title { font-size: 12px; }
  #btn-export { display: none; }
  .grimoire-header .btn-sm { padding: 9px 12px; font-size: 13px; min-height: 40px; }

  /* ── Grimoire body: stack vertically ── */
  body { overflow-y: auto; }
  .grimoire-screen { height: auto; min-height: 100dvh; overflow: visible; }
  .grimoire-body   { flex-direction: column; overflow: visible; }
  .grimoire-main   { flex: none; }

  /* Circle: full-width square so tokens have room */
  .circle-wrapper   { height: 100vw; flex: none; }
  .circle-container { height: 100vw; flex: none; }
  .alive-count      { position: static; text-align: right; padding: 4px 12px; font-size: 12px; border-top: 1px solid var(--border); }

  /* Sidebar: full width below the circle */
  .sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 45vh;
    overflow: hidden;
  }

  /* ── Modals: slide up from bottom ── */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-card {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 85vh;
    overflow-y: auto;
  }
  .modal-status-row { flex-wrap: wrap; gap: 6px; }
  .modal-status-row .btn-sm { padding: 10px 14px; font-size: 13px; }

  /* Free-token remove button always visible on touch */
  .free-token-remove { opacity: 0.6; }
}
.stp-done-btn:hover { background:rgba(60,60,60,0.9); border-color:#888; color:#aaa; }
