:root {
  --bg: #0b0d14;
  --surface: #141824;
  --surface-2: #1c2233;
  --border: #2a324b;
  --text: #eef2ff;
  --muted: #94a3b8;
  --gold: #eab308;
  --gold-soft: rgba(234, 179, 8, 0.16);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.16);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.16);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.16);
  --radius: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, #181f35 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100dvh;
}

.app-shell {
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px calc(24px + env(safe-area-inset-bottom));
}

.view { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }

/* Toast */
.toast-container {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(90vw, 400px);
  pointer-events: none;
}

.toast {
  background: rgba(20, 24, 36, 0.96);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: fadeInDown 0.2s ease;
}

.toast.error { border-color: var(--red); color: #fecaca; }

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero Landing */
.hero-card {
  text-align: center;
  padding: 20px 14px 16px;
}

.crest-badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid rgba(234, 179, 8, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.brand-title {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 2px;
}

.brand-title span {
  font-size: 16px;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 3px;
}

.brand-subtitle {
  margin: 6px 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.avatar-strip {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.avatar-strip img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
}

/* Panels & Inputs */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-header.collapsible-header {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

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

.collapse-indicator {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.panel.is-collapsed .panel-header {
  margin-bottom: 0;
}

.panel-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.text-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
  margin-bottom: 12px;
}

.text-input:focus { border-color: var(--gold); }

.code-input {
  text-transform: uppercase;
  letter-spacing: 6px;
  font-weight: 700;
  text-align: center;
  font-size: 20px;
}

/* Tabs */
.tab-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 10px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Mode Cards */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
}

.mode-card.active {
  border-color: var(--gold);
  background: rgba(234, 179, 8, 0.1);
}

.mode-icon { font-size: 20px; }
.mode-name { font-size: 14px; font-weight: 700; }
.mode-desc { font-size: 11px; color: var(--muted); line-height: 1.35; }

/* Pills & Segmented */
.count-pills {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.pill.active {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: #93c5fd;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.seg-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 9px 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

/* Buttons */
.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 12px; border-radius: 8px; }

.btn-primary {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: #111827;
}

.btn-blue {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
}

.btn-red {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
}

.btn-accent {
  background: var(--green-soft);
  border: 1px solid var(--green);
  color: #86efac;
}

.btn-ghost {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.top-bar-left { display: flex; align-items: center; gap: 8px; }
.top-bar-actions { display: flex; gap: 6px; }
.top-bar-menu { position: relative; }

.more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 148px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6);
  z-index: 850;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeInDown 0.14s ease;
}

.more-menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.more-menu-item:hover,
.more-menu-item:active {
  background: var(--surface-2);
}

.more-menu-item.danger {
  color: #fca5a5;
}

.room-badge {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 1.5px;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid rgba(234, 179, 8, 0.35);
  padding: 5px 10px;
  border-radius: 8px;
}

.mode-pill {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 9px;
  border-radius: 8px;
}

/* Voice Bar & Push-to-Talk */
.voice-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.voice-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.voice-status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.voice-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}
.voice-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }

.ptt-btn {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.55);
  background: linear-gradient(135deg, #1d4ed8, #1e3a8a);
  color: #eff6ff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ptt-btn.active {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-color: #86efac;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.35);
  transform: scale(0.99);
}

.ptt-btn:disabled {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}

.timer-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.timer-presets .seg-btn span {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.board-top-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.countdown-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.5);
  font-variant-numeric: tabular-nums;
}

.countdown-badge.urgent {
  background: var(--red-soft);
  color: #fca5a5;
  border-color: var(--red);
  animation: pulseUrgent 1s infinite;
}

.countdown-badge.paused {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: rgba(234, 179, 8, 0.6);
  animation: none;
}

.custom-timers-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.timer-input-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px;
  text-align: center;
}

.timer-input-item span {
  font-size: 11px;
  color: var(--muted);
}

.timer-input-item input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 4px 2px;
  outline: none;
}

.timer-input-item input:focus {
  border-color: var(--gold);
}

.timer-input-item input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.speak-progress-track {
  width: 100%;
  height: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 10px;
}

.speak-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22c55e, #3b82f6);
  transition: width 0.25s linear, background 0.2s ease;
}

.speak-progress-fill.urgent {
  background: linear-gradient(90deg, #ef4444, #f97316);
}

.speak-progress-fill.paused {
  background: linear-gradient(90deg, #eab308, #ca8a04);
}

.host-mini-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.host-offline-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@keyframes pulseUrgent {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.speak-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 12px;
}

.speak-chip {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.speak-chip.done { opacity: 0.55; }
.speak-chip.active {
  background: var(--green-soft);
  border-color: var(--green);
  color: #86efac;
  font-weight: 700;
}

.player-tile.speaking-turn {
  border-color: var(--gold);
  background: rgba(234, 179, 8, 0.1);
}

.warn-banner {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #fde047;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 10px;
}

/* Role Config Grid */
.ratio-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.role-toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.role-toggle-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  opacity: 0.6;
}

.role-toggle-card.active { opacity: 1; }
.role-toggle-card.active.good { border-color: var(--blue); background: var(--blue-soft); }
.role-toggle-card.active.evil { border-color: var(--red); background: var(--red-soft); }

.role-toggle-card img {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
}

.role-toggle-info { min-width: 0; }
.role-toggle-name { font-size: 13px; font-weight: 700; }
.role-toggle-team { font-size: 11px; color: var(--muted); }

.deck-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.deck-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.deck-chip.good { border-color: rgba(59, 130, 246, 0.5); color: #93c5fd; }
.deck-chip.evil { border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.deck-chip img { width: 18px; height: 18px; border-radius: 4px; object-fit: cover; }

.error-text { color: #fca5a5; font-size: 12px; margin: 6px 0 0; }
.muted { color: var(--muted); font-size: 13px; }
.center-text { text-align: center; }

/* Lobby Players */
.lobby-players {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.lobby-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.lobby-player-left { display: flex; align-items: center; gap: 8px; }
.seat-num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}

/* Board & Quest Track */
.board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}

.board-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.phase-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.reject-tracker { display: flex; align-items: center; gap: 6px; }
.reject-label { font-size: 11px; color: var(--muted); }
.reject-pips { display: flex; gap: 4px; }
.reject-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.reject-pip.active { background: var(--red); border-color: #fca5a5; }

.quest-track {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.quest-node {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 4px;
  text-align: center;
}

.quest-node.current { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.35); }
.quest-node.success { background: var(--blue-soft); border-color: var(--blue); }
.quest-node.fail { background: var(--red-soft); border-color: var(--red); }

.quest-num { font-size: 10px; color: var(--muted); }
.quest-size { font-size: 18px; font-weight: 800; margin: 2px 0; }
.quest-sub { font-size: 10px; color: var(--muted); }

.last-vote-banner {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.45;
}

/* Secret Role Card */
.role-drawer { margin-bottom: 10px; }

.secret-card {
  background: linear-gradient(145deg, #171c2c, #111522);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
}

.secret-card-locked-view {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lock-icon { font-size: 24px; }
.lock-title { font-size: 14px; font-weight: 700; color: var(--gold); }
.lock-sub { font-size: 11px; color: var(--muted); }

.my-role-header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.my-role-avatar {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--gold);
  flex-shrink: 0;
}

.my-role-name-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.my-role-name-row strong { font-size: 18px; }
.my-role-desc { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.4; }

.team-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.team-badge.good { background: var(--blue-soft); color: #93c5fd; border: 1px solid var(--blue); }
.team-badge.evil { background: var(--red-soft); color: #fca5a5; border: 1px solid var(--red); }

.vision-box {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.vision-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 8px;
  margin: 4px 6px 0 0;
  font-size: 12px;
}

/* Game Players Grid */
.game-players-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.player-tile {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.player-tile.selectable { cursor: pointer; }
.player-tile.selected { border-color: var(--gold); background: rgba(234, 179, 8, 0.12); }
.player-tile.on-team { border-color: var(--blue); }
.player-tile.speaking { box-shadow: 0 0 0 2px var(--green); }

.player-avatar-box {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--gold);
  overflow: hidden;
  flex-shrink: 0;
}

.player-avatar-box img { width: 100%; height: 100%; object-fit: cover; }

.player-meta { min-width: 0; flex: 1; }
.player-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }

.mini-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
}
.mini-tag.leader { background: var(--gold-soft); color: var(--gold); }
.mini-tag.team { background: var(--blue-soft); color: #93c5fd; }
.mini-tag.voted { background: var(--green-soft); color: #86efac; }
.mini-tag.good { background: var(--blue-soft); color: #93c5fd; }
.mini-tag.evil { background: var(--red-soft); color: #fca5a5; }

/* Action Panel */
.action-panel h3 { margin: 0 0 8px; font-size: 15px; }
.action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.offline-controls { display: flex; flex-direction: column; gap: 10px; }
.offline-quest-btns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.narrator-box {
  background: var(--surface-2);
  border: 1px solid rgba(234, 179, 8, 0.35);
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  color: #fde68a;
}

.win-banner {
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 10px;
}
.win-banner.good { background: var(--blue-soft); border: 1px solid var(--blue); }
.win-banner.evil { background: var(--red-soft); border: 1px solid var(--red); }
.win-banner h3 { margin: 0 0 4px; font-size: 18px; }
.win-banner p { margin: 0; font-size: 13px; }

/* Clickable Quest Track & History Bar */
.quest-node {
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.quest-node:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}
.quest-vote-count {
  display: inline-block;
  margin-top: 3px;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(234, 179, 8, 0.16);
  color: var(--gold);
}

.quest-history-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
}

.quest-history-hint {
  font-size: 11px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(6, 8, 14, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeInBackdrop 0.18s ease;
}

@keyframes fadeInBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: min(100%, 440px);
  max-height: 85dvh;
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  animation: popInModal 0.18s ease;
}

.modal-card-tall {
  border-color: var(--border);
}

@keyframes popInModal {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.modal-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  color: var(--text);
  border-color: var(--gold);
}

.modal-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-team-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-team-chip {
  font-size: 13px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  border: 1px solid rgba(59, 130, 246, 0.55);
  color: #bfdbfe;
}

.modal-info-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}

.modal-warn-box {
  background: var(--red-soft);
  border: 1px solid rgba(239, 68, 68, 0.55);
  color: #fecaca;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}

.modal-vote-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.modal-vote-actions .btn {
  padding: 14px 12px;
  font-size: 16px;
}

.modal-voted-banner {
  background: var(--green-soft);
  border: 1px solid rgba(34, 197, 94, 0.55);
  color: #bbf7d0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  text-align: center;
  font-weight: 600;
}

/* Vote History Tabs & Cards */
.history-round-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.history-tab-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 9px;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.history-tab-btn.active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

.history-tab-btn.success { border-color: rgba(59, 130, 246, 0.5); }
.history-tab-btn.fail { border-color: rgba(239, 68, 68, 0.5); }
.history-tab-sub { font-size: 10px; font-weight: 500; opacity: 0.85; }

.history-round-summary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
}

.vote-record-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vote-record-card.approved { border-color: rgba(59, 130, 246, 0.55); }
.vote-record-card.rejected { border-color: rgba(239, 68, 68, 0.45); }

.vote-record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.vote-record-meta {
  font-size: 12px;
  color: var(--muted);
}

.vote-record-split {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.vote-approve-line { color: #93c5fd; }
.vote-reject-line { color: #fca5a5; }

/* Floating Secret Role Button */
.fab-role {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: linear-gradient(135deg, rgba(24, 30, 48, 0.96), rgba(15, 19, 32, 0.98));
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(234, 179, 8, 0.25);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.fab-role:active {
  transform: scale(0.95);
}

/* Role Codex & Rules Guide */
.hero-guide-btn {
  margin-top: 12px;
  border-color: rgba(234, 179, 8, 0.4);
  color: var(--gold);
}

#landing-avatar-strip img {
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

#landing-avatar-strip img:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
}

.guide-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.guide-section-title {
  font-size: 13px;
  font-weight: 800;
  margin: 4px 0 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.guide-section-title.good { color: #93c5fd; }
.guide-section-title.evil { color: #fca5a5; }

.codex-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

.codex-card.good { border-left: 3px solid var(--blue); }
.codex-card.evil { border-left: 3px solid var(--red); }

.codex-avatar {
  width: 50px;
  height: 50px;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

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

.codex-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.codex-head strong {
  font-size: 14px;
}

.codex-desc {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.codex-vision {
  margin-top: 5px;
  font-size: 11px;
  color: #fde68a;
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.28);
  border-radius: 6px;
  padding: 3px 7px;
  display: inline-block;
}

.rules-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
}

.rules-block h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--gold);
}

.rules-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
}

.rules-list li {
  margin-bottom: 3px;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 6px;
}

.rules-table th,
.rules-table td {
  border: 1px solid var(--border);
  padding: 6px 4px;
  text-align: center;
}

.rules-table th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.rules-note {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
}



