/* ============ Reset / base ============ */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1d24;
  color: #e6e9ef;
  min-height: 100vh;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}
body.centered {
  display: flex; flex-direction: column; align-items: center;
  padding: 1rem;
  min-height: 100vh;
}
button {
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ============ Common UI ============ */
.card {
  background: #232730;
  border: 1px solid #2f333d;
  border-radius: 10px;
  padding: 1rem;
}
.card.narrow { max-width: 480px; width: 100%; }
.card h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: #cad0d9;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
h1 { margin: 0 0 0.5rem; font-size: 1.25rem; }
.muted { color: #9099a8; font-size: 0.9rem; }
.muted.small { font-size: 0.8rem; }
.big { font-size: 1.2rem; }
.error { color: #ff6b6b; }
.error-banner {
  background: #5a1a1a; color: #ffd1d1;
  padding: 0.6rem 0.8rem; border-radius: 6px;
  margin-bottom: 0.75rem; font-size: 0.9rem;
}
code { background: #1a1d24; padding: 0.15rem 0.4rem; border-radius: 3px; font-family: ui-monospace, Menlo, monospace; font-size: 0.85em; }
.hidden { display: none !important; }

/* Touch-friendly inputs */
input[type="text"], input[type="password"], select, textarea {
  padding: 0.85rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #3a3f4b;
  background: #1a1d24;
  color: #e6e9ef;
  font-family: inherit;
  width: 100%;
  resize: vertical;
  font-size: 1rem;
  width: 100%;
  margin-bottom: 0.75rem;
  font-family: inherit;
}
input:focus, select:focus { outline: 2px solid #6b7fff; outline-offset: -2px; }

.field-label {
  display: block;
  margin: 0.75rem 0 0.4rem;
  font-size: 0.85rem;
  color: #cad0d9;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Buttons */
button.primary, button.big-btn, button:not(.ghost):not(.small):not(.swatch):not(.avatar-btn):not(.target-btn):not(.chat-tab) {
  background: #5365e8;
  color: white;
  border: none;
  padding: 0.85rem 1.4rem;
  border-radius: 8px;
  font-weight: 600;
  min-height: 44px;
}
button.primary:hover, button.big-btn:hover { background: #6577f0; }
button.primary:disabled, button.big-btn:disabled, button:disabled {
  background: #3a3f4b; color: #6b7180; cursor: not-allowed;
}
button.ghost {
  background: transparent;
  border: 1px solid #3a3f4b;
  color: #cad0d9;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  min-height: 44px;
}
button.ghost:hover { background: #2a2d35; }
button.ghost.small {
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  min-height: 0;
}
button.small {
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  min-height: 0;
  border-radius: 6px;
  border: none;
}

form.inline { display: inline-flex; gap: 0.5rem; align-items: center; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.row { display: flex; gap: 0.5rem; align-items: center; }

/* ============ Login / profile picker ============ */
.palette {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.palette-colors {
  grid-template-columns: repeat(8, 1fr);
}
.palette-avatars {
  grid-template-columns: repeat(8, 1fr);
}
@media (max-width: 480px) {
  .palette-colors { grid-template-columns: repeat(6, 1fr); }
  .palette-avatars { grid-template-columns: repeat(6, 1fr); }
}
.swatch {
  aspect-ratio: 1 / 1;
  border: 3px solid transparent;
  background: var(--color);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  transition: transform 0.1s;
  min-width: 36px;
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--color); }
.avatar-btn {
  aspect-ratio: 1 / 1;
  background: #1a1d24;
  border: 2px solid #3a3f4b;
  border-radius: 8px;
  font-size: 1.5rem;
  padding: 0;
  cursor: pointer;
  transition: all 0.1s;
  min-width: 36px;
}
.avatar-btn:hover { border-color: #6b7fff; background: #2a2d35; }
.avatar-btn.selected { border-color: #5365e8; background: #2a2d3f; transform: scale(1.05); box-shadow: 0 0 12px rgba(83, 101, 232, 0.4); }
.preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #1a1d24;
  border-radius: 6px;
  margin: 0.75rem 0;
  font-size: 1.1rem;
}
.avatar-prev { font-size: 1.4rem; }
.name-prev { font-weight: 600; }

/* ============ Play page layout ============ */
.play-body { background: #1a1d24; }
.play-header {
  padding: 0.75rem 1rem;
  background: #0f1115;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #2a2d35;
  gap: 0.5rem;
  position: sticky; top: 0; z-index: 10;
}
.play-header h1 { font-size: 1rem; }
.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.me-chip, .room-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: #1a1d24;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
.room-chip strong { font-family: ui-monospace, Menlo, monospace; letter-spacing: 0.15em; color: #ffd43b; }

/* Phase-progress / waiting-on indicator */
.ready-bar {
  position: relative;
  height: 28px;
  background: #1a1d24;
  border: 1px solid #3a3f4b;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}
.ready-bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: #5a6dd9;
  transition: width 0.3s ease;
}
.ready-bar.ready-bar-done .ready-bar-fill { background: #3a8b3a; }
.ready-bar-label {
  position: relative;
  z-index: 1;
  line-height: 28px;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: #e6e9ef;
}
.waiting-row {
  padding: 0.35rem 0.45rem;
  display: flex; gap: 0.4rem; align-items: center;
  border-bottom: 1px solid #2a2d35;
}
.waiting-row:last-child { border-bottom: none; }

/* Page footer (admin link visible on every page) */
.version-tag {
  font-size: 0.7rem;
  color: #6b7280;
  letter-spacing: 0.04em;
  margin-left: auto;
  margin-right: 0.4rem;
  user-select: none;
}
.page-footer {
  padding: 1rem;
  font-size: 0.85rem;
  border-top: 1px solid #2a2d35;
  margin-top: auto;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}
.footer-link {
  color: #6b7fff;
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
}
.footer-link:hover { background: #2a2d35; text-decoration: underline; }

.play-main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  max-width: 720px;
  margin: 0 auto;
}

/* On wider screens, two-column layout */
@media (min-width: 1024px) {
  .play-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 1200px;
  }
  .you-card { grid-column: 1 / 3; }
  .action-card { grid-column: 1 / 3; }
}

/* ============ Players list ============ */
.list { list-style: none; padding: 0; margin: 0; }
.list li.player {
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  background: #1a1d24;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.list li.self { border-left: 3px solid #6b7fff; }
.list li.teammate-wolf {
  background: linear-gradient(90deg, rgba(255, 107, 107, 0.18), #1a1d24 60%);
  border-left: 3px solid #ff6b6b;
}
.list li.self.teammate-wolf { border-left: 3px solid #ff6b6b; box-shadow: inset 3px 0 0 #6b7fff; }
.list li.dead { opacity: 0.6; }
.swatch.unavailable, .avatar-btn.unavailable {
  opacity: 0.22;
  cursor: not-allowed;
  filter: grayscale(0.6);
}
.swatch.unavailable::after, .avatar-btn.unavailable::after {
  content: '✕';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #ff6b6b;
  pointer-events: none;
}
.swatch, .avatar-btn { position: relative; }
.tag-dead-btn {
  background: transparent;
  border: 1px solid #5a2828;
  color: #ff9b9b;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.4rem;
  cursor: pointer;
  font-family: inherit;
}
.tag-dead-btn:hover { background: rgba(255,107,107,0.1); }
.phase-info-card {
  padding: 0.9rem 1.1rem;
  background: linear-gradient(135deg, #2a2d35 0%, #1a1d24 100%);
  border-left: 4px solid #5a6dd9;
}
.phase-info-card.phase-night { border-left-color: #5a6dd9; background: linear-gradient(135deg, #1f2233 0%, #0f1118 100%); }
.phase-info-card.phase-day { border-left-color: #ffd43b; background: linear-gradient(135deg, #2d2922 0%, #1a1815 100%); }
.phase-info-card.phase-voting { border-left-color: #ff8585; background: linear-gradient(135deg, #2d1f22 0%, #1a1416 100%); }
.phase-info-card.phase-lobby { border-left-color: #66bb6a; }
.phase-info-card.phase-ended { border-left-color: #999; }
.phase-info-card .phase-banner-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}
.phase-info-card .phase-banner-detail {
  font-size: 0.95rem;
  color: #cad0d9;
  margin-top: 0.3rem;
}
.status-effects-card {
  background: linear-gradient(135deg, #2d1f2d 0%, #1a1018 100%);
  border-left: 4px solid #cc5de8;
}
.status-effects-card h2 { margin-top: 0; }
.status-effect-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  margin-bottom: 0.4rem;
}
.status-effect-row:last-child { margin-bottom: 0; }
.status-effect-icon { font-size: 1.3rem; line-height: 1.2; }
.status-effect-body { flex: 1; }
.status-effect-title { font-weight: 700; color: #fff; }
.status-effect-desc { font-size: 0.9rem; color: #cad0d9; margin-top: 0.15rem; }
/* Big phase banner on the GM panel */
.gm-phase-banner {
  background: linear-gradient(135deg, #2a2d35 0%, #1a1d24 100%);
  border-left: 4px solid #5a6dd9;
  padding: 1rem 1.2rem;
  margin-bottom: 0.5rem;
}
.gm-phase-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}
.gm-phase-detail {
  font-size: 0.95rem;
  color: #cad0d9;
  margin-top: 0.3rem;
}
.gm-advance-top {
  margin-top: 0.8rem;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.7rem 1.2rem;
  width: 100%;
}
.role-preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.role-preview-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: #1a1d24;
  border-left: 3px solid #555;
  border-radius: 4px;
}
.role-preview-row.team-evil { border-left-color: #ff8585; }
.role-preview-row.team-neutral { border-left-color: #ffcc66; }
.role-preview-row.team-good { border-left-color: #74c0fc; }
.role-preview-icon { font-size: 1.1rem; }
.role-preview-name { flex: 1; font-weight: 600; }
.role-preview-count { color: #cad0d9; font-variant-numeric: tabular-nums; }
/* Prominent story-prompt card */
.gm-story-card {
  background: #1a1d24;
  border-left: 4px solid #ffd43b;
  padding: 1rem 1.2rem;
}
.gm-story-card .story-text {
  font-size: 1.15rem;
  line-height: 1.5;
  margin: 0.5rem 0;
  font-weight: 500;
  color: #ffe066;
}

.night-report {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
  padding: 0.6rem;
  background: #1a1d24;
  border: 1px solid #2a2d35;
  border-left: 3px solid #ffd43b;
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.45;
}
.lg-peek-panel { margin-top: 0.6rem; }
.lg-peek-log {
  max-height: 200px;
  overflow-y: auto;
  background: #1a1d24;
  border: 1px solid #3a3f4b;
  border-radius: 6px;
  padding: 0.5rem;
}
.lg-peek-row {
  padding: 0.25rem 0;
  font-style: italic;
  color: #cad0d9;
}
.chat-tab.watched, .chatlog.watched {
  outline: 2px solid #ff6b6b;
  outline-offset: -2px;
  animation: watched-pulse 1.4s ease-in-out infinite;
}
@keyframes watched-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,107,0.0); }
  50% { box-shadow: 0 0 0 6px rgba(255,107,107,0.18); }
}
.chat-tab.watched::after { content: ' 👁️'; }
.history-block {
  margin-top: 0.5rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid #2a2d35;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
}
.history-block summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: #cad0d9;
  user-select: none;
}
.history-block summary:hover { color: #fff; }
.history-list {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
}
.history-list li { margin: 0.2rem 0; }

/* Setup card */
.setup-row {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid #2a2d35;
}
.setup-row:first-of-type { margin-top: 0.4rem; border-top: none; padding-top: 0; }
.setup-pillset { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.setup-pill {
  background: #1a1d24;
  color: #cad0d9;
  border: 1px solid #3a3f4b;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
}
.setup-pill.active {
  background: #5a6dd9;
  color: #fff;
  border-color: #5a6dd9;
}
.setup-pill:disabled { opacity: 0.5; cursor: not-allowed; }
.setup-check {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem; cursor: pointer;
}
.setup-check input[type="checkbox"] { width: auto; }

/* Big toggle pill for Simple/Advanced view (header) */
.view-toggle {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  background: #1a1d24;
  border: 1px solid #3a3f4b;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  user-select: none;
  font-family: inherit;
}
.view-toggle input[type="checkbox"] {
  width: 20px; height: 20px;
  margin: 0;
  cursor: pointer;
}
.view-toggle span { font-weight: 600; }
.view-toggle:has(input:checked) {
  background: #2a2d35;
  border-color: #5a6dd9;
  color: #fff;
}
.role-picker-block { padding: 0.5rem 0; }
.role-picker-block summary { cursor: pointer; font-weight: 600; padding: 0.2rem 0; }
.role-group-header {
  margin-top: 0.6rem;
  padding: 0.2rem 0.4rem;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid #2a2d35;
}
.role-group-header.team-evil { color: #ff8585; }
.role-group-header.team-neutral { color: #ffcc66; }
.role-group-header.team-good { color: #74c0fc; }
.role-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid #2a2d35;
}
.role-row .role-name { font-size: 0.9rem; }
.role-counter {
  display: flex; align-items: center; gap: 0.4rem;
}
.role-counter button {
  width: 28px; height: 28px;
  background: #2a2d35;
  border: 1px solid #3a3f4b;
  color: #e6e9ef;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}
.role-counter button:hover:not(:disabled) { background: #3a3f4b; }
.role-counter button:disabled { opacity: 0.4; cursor: not-allowed; }
.role-counter .role-count {
  min-width: 1.6rem; text-align: center; font-weight: 600;
}
.alignment-quotas {
  display: flex; flex-wrap: wrap; gap: 0.6rem;
  margin: 0.5rem 0;
}
.quota-input {
  display: flex; flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  flex: 1;
  min-width: 110px;
}
.quota-input > span { font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.quota-stepper {
  display: flex; align-items: stretch; gap: 0.25rem;
}
.quota-stepper input[type="number"] {
  width: 3rem;
  flex: 0 0 auto;
  padding: 0.45rem 0.3rem;
  font-size: 1rem;
  text-align: center;
}
.quota-step {
  width: 32px;
  background: #2a2d35;
  border: 1px solid #3a3f4b;
  color: #e6e9ef;
  border-radius: 4px;
  font-size: 1.1rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}
.quota-step:hover:not(:disabled) { background: #3a3f4b; }
.quota-step:disabled { opacity: 0.4; cursor: not-allowed; }
.team-evil { color: #ff8585; }
.team-neutral { color: #ffcc66; }
.team-good { color: #74c0fc; }

/* Simple vs Advanced view (GM panel) */
.advanced-only { display: none !important; }
body.gm-advanced .advanced-only { display: revert !important; }
.list li.offline { opacity: 0.6; }
.list li.host .name::after { content: ' ★'; color: #ffcc66; }
.tag-host { color: #ffcc66; font-weight: 700; }
.tag-dead { color: #ff6b6b; }
.tag-off { color: #8a8f9a; }
.list .avatar { font-size: 1.2rem; flex-shrink: 0; }
.list .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list .tag { font-size: 0.7rem; color: #9099a8; text-transform: uppercase; letter-spacing: 0.04em; display: flex; gap: 0.3rem; align-items: center; }

/* Role pills */
.role {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  background: #2f333d;
}
.role-werewolf { background: #5a1a1a; color: #ffb3b3; }
.role-villager { background: #1f3a2a; color: #b6e6c4; }
.role-seer { background: #2a2255; color: #c2b0ff; }
.role-doctor { background: #1f3554; color: #a8d3ff; }
.tag-host { color: #ffcc66; }

.role-card {
  border-radius: 8px;
  padding: 1rem;
  background: #1a1d24;
}
.role-card.role-werewolf { background: linear-gradient(135deg, #2a1010, #1a1d24); }
.role-card.role-villager { background: linear-gradient(135deg, #102a18, #1a1d24); }
.role-card.role-seer { background: linear-gradient(135deg, #1a1438, #1a1d24); }
.role-card.role-doctor { background: linear-gradient(135deg, #102236, #1a1d24); }
.role-card .role-name { font-size: 1.1rem; letter-spacing: 0.05em; }
.role-card p { margin: 0.5rem 0 0; font-size: 0.9rem; color: #cad0d9; }
.dead-badge { color: #ff6b6b; font-size: 0.8rem; margin-left: 0.5rem; }

/* ============ Action area ============ */
.action-area { min-height: 120px; }
.action-heading { margin: 0 0 0.75rem; font-size: 1rem; }
.target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.target-btn {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.8rem;
  background: #1a1d24;
  border: 2px solid #3a3f4b;
  color: #e6e9ef;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  min-height: 50px;
  transition: all 0.1s;
}
.target-btn:hover { background: #2a2d35; border-color: #6b7fff; }
.target-btn .avatar { font-size: 1.2rem; }
.target-btn .name { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; }

/* Selected (pending confirmation): blue glow */
.target-btn.selected {
  border-color: #5365e8;
  background: #2a2d3f;
  box-shadow: 0 0 0 2px rgba(83, 101, 232, 0.4);
}
/* Submitted to server: green border + check */
.target-btn.submitted {
  border-color: #38d9a9;
  background: #1f3a2e;
}
.target-btn.submitted::after {
  content: ' ✓';
  color: #38d9a9;
  margin-left: auto;
  font-weight: bold;
}

.confirm-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #15171c;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}
.confirm-status {
  flex: 1;
  font-size: 0.95rem;
  color: #cad0d9;
  min-width: 200px;
}

.ready-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #2f333d;
  flex-wrap: wrap;
}
.host-bar {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #2f333d;
}

.mod-bar {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #1a1d24;
  border: 1px solid #4a3a6a;
  border-left: 3px solid #c2b0ff;
  border-radius: 4px;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr;
}
.mod-bar > button {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
}
/* Per-role action block — visual rhythm matching .mod-bar */
.action-block {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #1a1d24;
  border: 1px solid #3a3f4b;
  border-left: 3px solid #cad0d9;
  border-radius: 4px;
}
.action-block .action-label {
  display: block;
  font-size: 0.85rem;
  color: #cad0d9;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
}
/* Per-role themes — left border + label color */
.action-block.action-wolf      { border-left-color: #ff6b6b; }
.action-block.action-wolf .action-label      { color: #ff6b6b; }
.action-block.action-seer      { border-left-color: #c2b0ff; }
.action-block.action-seer .action-label      { color: #c2b0ff; }
.action-block.action-doctor    { border-left-color: #74c0fc; }
.action-block.action-doctor .action-label    { color: #74c0fc; }
.action-block.action-witch     { border-left-color: #ff922b; }
.action-block.action-witch .action-label     { color: #ff922b; }
.action-block.action-bodyguard { border-left-color: #66d9e8; }
.action-block.action-bodyguard .action-label { color: #66d9e8; }
.action-block.action-sorcerer  { border-left-color: #845ef7; }
.action-block.action-sorcerer .action-label  { color: #845ef7; }
.action-block.action-vigilante { border-left-color: #cad0d9; }
.action-block.action-vigilante .action-label { color: #cad0d9; }
.action-block.action-fox       { border-left-color: #ff922b; }
.action-block.action-fox .action-label       { color: #ff922b; }
.action-block.action-dentist   { border-left-color: #66d9e8; }
.action-block.action-dentist .action-label   { color: #66d9e8; }
.action-block.action-guesser   { border-left-color: #94d82d; }
.action-block.action-guesser .action-label   { color: #94d82d; }
.action-block.action-piper     { border-left-color: #e599f7; }
.action-block.action-piper .action-label     { color: #e599f7; }
.action-block.action-cupid     { border-left-color: #f783ac; }
.action-block.action-cupid .action-label     { color: #f783ac; }
.action-block.action-littlegirl{ border-left-color: #f783ac; }
.action-block.action-littlegirl .action-label{ color: #f783ac; }
.action-block.action-vote      { border-left-color: #ffd43b; background: #1f1d18; }
.action-block.action-vote .action-label      { color: #ffd43b; }
.action-block.action-passive   { border-left-color: #b8c0c8; }
.action-block.action-passive .action-label   { color: #b8c0c8; }
.action-block.action-assassin  { border-left-color: #ff8585; background: #1f0e0e; }
.action-block.action-assassin .action-label  { color: #ff8585; }

.mod-bar-label {
  font-size: 0.85rem;
  color: #c2b0ff;
  font-weight: 700;
  margin-right: 0.5rem;
}
.tag-mod {
  display: inline-block;
  background: #4a3a6a;
  color: #e0d3ff;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.3rem;
}

/* Landing pages: index, create, join */
.landing {
  max-width: 540px;
  margin: 3rem auto 1rem;
  padding: 2rem 1.5rem;
  text-align: center;
}
.landing-title {
  font-size: 2.4rem;
  margin: 0 0 0.5rem;
}
.landing-tagline {
  margin: 0 0 2rem;
  font-size: 1.05rem;
}
.landing-choices {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}
@media (min-width: 640px) {
  .landing-choices { flex-direction: row; }
  .landing-choices > * { flex: 1; }
}
.big-choice {
  display: block;
  background: #1a1d24;
  border: 2px solid #2f333d;
  border-radius: 12px;
  padding: 1.5rem 1.25rem;
  color: inherit;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  font: inherit;
  width: 100%;
}
.big-choice:hover {
  border-color: #c2b0ff;
  transform: translateY(-2px);
}
.big-choice-button { /* form button variant — no underline, native button reset */
  -webkit-appearance: none;
  appearance: none;
}
.big-choice-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.big-choice-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: #fff;
}
.big-choice-sub {
  font-size: 0.9rem;
  color: #9ca0aa;
  line-height: 1.35;
}
.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: #9ca0aa;
  text-decoration: none;
  font-size: 0.9rem;
}
.back-link:hover { color: #c2b0ff; text-decoration: underline; }
.card.narrow { max-width: 460px; margin: 3rem auto 1rem; }
.field-label {
  display: block;
  font-size: 0.85rem;
  color: #9ca0aa;
  margin: 1rem 0 0.4rem;
  font-weight: 600;
}
.big-btn { width: 100%; padding: 0.85rem; font-size: 1rem; margin-top: 1rem; }
.error-banner {
  background: #3a2424;
  border: 1px solid #6e2a2a;
  color: #ffb3b3;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.seer-result {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #1a1d24;
  border-left: 3px solid #c2b0ff;
  border-radius: 4px;
  font-size: 1rem;
}
.seer-result .avatar { font-size: 1.1rem; }

/* Role config (setup phase) */
.role-config-list {
  display: flex; flex-direction: column; gap: 0.4rem;
  margin: 0.5rem 0;
}
.role-config-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  background: #1a1d24; border-radius: 6px;
}
.role-config-name {
  display: flex; align-items: center; gap: 0.4rem;
  flex: 1; min-width: 0;
}
.role-config-name .avatar { font-size: 1.2rem; }
.role-config-name .name { font-weight: 600; }
.role-config-row select {
  width: auto; margin-bottom: 0;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
}

/* ============ Event log ============ */
.eventlog {
  background: #1a1d24;
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.85rem;
  max-height: 200px;
  overflow-y: auto;
}
.eventlog .event {
  padding: 0.3rem 0;
  border-bottom: 1px solid #2a2d35;
  color: #cad0d9;
}
.eventlog .event:last-child { border-bottom: none; }
.eventlog .event-night { color: #b0aedb; }
.eventlog .event-day, .eventlog .event-voting { color: #d3c9b0; }
.eventlog .event-ended { color: #ffd866; }
.eventlog .event-setup { color: #9bd0a6; }

/* ============ Chat ============ */
.chat-card {
  display: flex; flex-direction: column;
  min-height: 320px;
}
.chat-tabs {
  display: flex; gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.chat-tab {
  background: #1a1d24;
  border: 1px solid #2f333d;
  color: #cad0d9;
  padding: 0.5rem 0.9rem;
  border-radius: 6px 6px 0 0;
  font-size: 0.85rem;
  cursor: pointer;
}
.chat-tab.active {
  background: #2a2d35;
  border-bottom-color: #5365e8;
  color: #fff;
}
.chat-tab:hover { background: #2a2d35; }

.chatlog {
  flex: 1;
  overflow-y: auto;
  background: #1a1d24;
  border-radius: 6px;
  padding: 0.6rem;
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
  min-height: 180px;
  max-height: 360px;
}
.chatlog .msg {
  margin-bottom: 0.4rem;
  word-wrap: break-word;
  display: flex; flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem;
}
.chatlog .msg .avatar { font-size: 1rem; }
.chatlog .msg .from { font-weight: 700; }
.chatlog .msg.system { color: #9099a8; font-style: italic; }

.chat-form {
  display: flex; gap: 0.4rem;
  margin: 0;
}
.chat-form input[type="text"] {
  flex: 1; margin: 0;
}
.chat-form button { padding: 0.85rem 1rem; }

/* ============ Admin layout ============ */
main.grid-admin {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-auto-rows: auto;
  gap: 1rem;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 900px) {
  main.grid-admin { grid-template-columns: 1fr; }
}

header:not(.play-header) {
  padding: 1rem 1.5rem;
  background: #0f1115;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #2a2d35;
  flex-wrap: wrap;
  gap: 0.5rem;
}
header:not(.play-header) h1 { margin: 0; font-size: 1.25rem; }

.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.admin-table th, .admin-table td {
  padding: 0.55rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #2a2d35;
  font-size: 0.9rem;
}
.admin-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9099a8;
}
.admin-table .avatar { font-size: 1.1rem; margin-right: 0.4rem; }
.admin-table .name { font-weight: 600; }
.admin-table select { width: auto; padding: 0.3rem 0.5rem; margin-bottom: 0; font-size: 0.85rem; }
.admin-table .online { color: #7fdba0; }
.admin-table .offline { color: #888c95; }
.admin-table tr.row-dead td { opacity: 0.55; }

/* ---- Tracker: condition buttons (full-highlight when active) ---- */
.cond-btn {
  display: inline-block;
  margin: 0.08rem 0.2rem 0.08rem 0;
  padding: 0.08rem 0.4rem;
  border: 1px solid #3a3f4b;
  border-radius: 6px;
  background: #20242e;
  color: #aeb4bf;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, box-shadow 0.1s;
}
/* Inline condition badge next to a name — never adds row height. */
.cond-badge { display: inline; margin-left: 0.15rem; font-size: 0.85rem; vertical-align: baseline; }
.cond-btn:hover { border-color: #5a6172; }
.cond-btn.active { color: #fff; border-color: transparent; box-shadow: 0 0 0 2px rgba(255,255,255,0.2) inset, 0 1px 6px rgba(0,0,0,0.4); }
.cond-btn.cond-mayor.active    { background: #b8860b; }  /* gold */
.cond-btn.cond-charmed.active  { background: #7c3aed; }  /* purple */
.cond-btn.cond-love.active     { background: #db2777; }  /* pink */
.cond-btn.cond-silenced.active { background: #d97706; }  /* amber */

/* ---- Mayor / known-role badges + pinned wolf-chat identity ---- */
.badge-mayor { display: inline-block; background: #b8860b; color: #fff; border-radius: 6px; padding: 0.05rem 0.4rem; font-size: 0.72rem; font-weight: 700; }
.badge-known { display: inline-block; background: #2a2d35; color: #cad0d9; border: 1px solid #3a3f4b; border-radius: 6px; padding: 0.05rem 0.4rem; font-size: 0.72rem; }
.wolf-pin { background: rgba(184,134,11,0.14); border-left: 3px solid #e0a800; padding: 0.2rem 0.45rem; border-radius: 4px; margin-bottom: 0.25rem; }

/* ---- Tracker: alive/dead toggle + dead row (dramatic) ---- */
.alive-toggle {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #3a3f4b;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.alive-toggle.is-alive { background: #14361f; border-color: #2f7d46; color: #8ef0ad; }
.alive-toggle.is-dead {
  background: #b91c1c;
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 0 12px rgba(239,68,68,0.55);
}
.admin-table tr.tracker-dead-row td {
  background: rgba(127,29,29,0.32);
  border-top: 1px solid rgba(239,68,68,0.45);
  border-bottom: 1px solid rgba(239,68,68,0.45);
}
.admin-table tr.tracker-dead-row td:first-child { text-decoration: line-through; text-decoration-color: rgba(239,68,68,0.8); }

/* ---- Tracker: exact-role picker grid ---- */
.role-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.4rem 0.75rem;
  margin-top: 0.5rem;
}
.role-pick {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid #2a2d35;
  border-left-width: 3px;
  border-radius: 6px;
  background: #1b1e27;
  cursor: pointer;
}
.role-pick:hover { border-color: #3a3f4b; border-left-color: inherit; }
.role-pick input[type="checkbox"] { flex: none; width: 1.05rem; height: 1.05rem; accent-color: #7c8cff; cursor: pointer; }
.role-pick.team-evil    { border-left-color: #ff8585; }
.role-pick.team-neutral { border-left-color: #ffcc66; }
.role-pick.team-good    { border-left-color: #74c0fc; }
.role-pick-name { font-size: 0.85rem; font-weight: 600; }
.role-pick.role-pick-disabled { opacity: 0.4; cursor: not-allowed; }
.role-picker-grid .role-group-header { grid-column: 1 / -1; margin-top: 0.4rem; font-weight: 700; font-size: 0.8rem; }
.admin-controls { margin-top: 1rem; flex-wrap: wrap; }
.admin-eventlog { max-height: 360px; }
.admin-chatlog { min-height: 200px; max-height: 320px; }
dl { display: grid; grid-template-columns: 100px 1fr; gap: 0.3rem 1rem; margin: 0; font-size: 0.9rem; }
dt { color: #9099a8; }

/* Game over banner (admin) */
.gameover-banner {
  margin: 1rem auto 0;
  max-width: 1400px;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #2a1f00, #1a1d24);
  border: 2px solid #ffd43b;
  border-radius: 10px;
  font-size: 1.25rem;
  text-align: center;
  color: #ffe066;
}

/* Story-mode prompt panel (admin) */
.story-panel {
  margin: 1rem auto 0;
  max-width: 1400px;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #1a2438, #1a1d24);
  border: 2px solid #6b7fff;
  border-radius: 10px;
}
.story-panel .story-step { margin-bottom: 0.5rem; }
.story-panel .story-text {
  font-size: 1.15rem;
  line-height: 1.4;
  margin-bottom: 0.75rem;
  color: #e6e9ef;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  background: #1a1d24;
  border: 1px solid #3a3f4b;
  padding: 0.75rem 1.2rem;
  border-radius: 6px;
  font-size: 0.9rem;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 100;
}
.toast.hidden { display: none; }
.toast.error { border-color: #ff6b6b; color: #ffb3b3; }
.toast.info { border-color: #6b7fff; color: #c2cfff; }

/* Full-screen phase-change pop-up — announces each new phase on every phone. */
.phase-popup {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 14, 0.72);
  opacity: 0;
  transition: opacity 0.25s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.phase-popup.show { opacity: 1; }
.phase-popup-card {
  text-align: center;
  padding: 2rem 2.5rem;
  border-radius: 18px;
  background: #12151d;
  border: 2px solid #3a3f4b;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
  transform: scale(0.86);
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  max-width: 90vw;
}
.phase-popup.show .phase-popup-card { transform: scale(1); }
.phase-popup-icon { font-size: 3.4rem; line-height: 1; margin-bottom: 0.6rem; }
.phase-popup-title { font-size: 2rem; font-weight: 800; letter-spacing: 0.02em; margin-bottom: 0.35rem; }
.phase-popup-sub { font-size: 1rem; color: #b9c0cf; }
/* Per-phase accent on the card border. */
.phase-popup-night  .phase-popup-card { border-color: #4a6bff; }
.phase-popup-day    .phase-popup-card { border-color: #ffcc4d; }
.phase-popup-voting .phase-popup-card { border-color: #ff6b6b; }
.phase-popup-ended  .phase-popup-card { border-color: #51cf66; }

/* ============ Mobile tweaks ============ */
@media (max-width: 480px) {
  body { font-size: 15px; }
  .play-header { padding: 0.5rem 0.6rem; }
  .play-header h1 { font-size: 0.95rem; }
  .play-main { padding: 0.5rem; gap: 0.5rem; }
  .card { padding: 0.75rem; }
  .palette-colors { grid-template-columns: repeat(6, 1fr); }
  .palette-avatars { grid-template-columns: repeat(6, 1fr); }
  .target-grid { grid-template-columns: 1fr 1fr; }
  .target-btn { padding: 0.75rem; font-size: 0.95rem; }
  .me-chip { font-size: 0.8rem; padding: 0.25rem 0.5rem; }
  .toast { right: 0.5rem; left: 0.5rem; max-width: none; bottom: 0.5rem; }
}

/* ============ Accounts + achievements ============ */
.account-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.25rem 0 1.5rem;
}
.stat-card {
  background: #1a1d24;
  border: 1px solid #2f333d;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.stat-num { font-size: 2rem; font-weight: 700; color: #ffd43b; }
.stat-label { color: #9ca0aa; font-size: 0.85rem; }

.section-h2 { margin: 1.5rem 0 0.75rem; font-size: 1.2rem; }

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.ach-card {
  background: #1a1d24;
  border: 1px solid #2f333d;
  border-radius: 10px;
  padding: 1rem;
  display: flex; flex-direction: column; gap: 0.35rem;
  position: relative;
}
.ach-card.ach-locked { opacity: 0.4; }
.ach-card.ach-earned { border-color: #ffd43b; box-shadow: 0 0 12px rgba(255, 212, 59, 0.15); }
.ach-icon { font-size: 1.8rem; }
.ach-title { font-weight: 700; }
.ach-desc { color: #9ca0aa; font-size: 0.85rem; line-height: 1.3; }
.ach-count {
  position: absolute; top: 0.5rem; right: 0.6rem;
  background: rgba(255, 212, 59, 0.18);
  color: #ffd43b;
  font-size: 0.75rem; font-weight: 700;
  padding: 0.15rem 0.45rem; border-radius: 999px;
}
