/* DBD Queue — page styles. Theme tokens and the site menu come from theme.css. */

:root {
  --role-killer: #cf222e;
  --role-survivor: #3f63d6;
}

:root[data-theme="dark"] {
  --role-killer: #f85149;
  --role-survivor: #9db7ff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  padding: 56px 24px 84px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  line-height: 1.65;
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  animation: fadeIn 0.55s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.18s ease;
}

a:hover {
  color: var(--accent-hover);
}

button {
  font-family: inherit;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 500;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-secondary);
}

.skip:focus {
  left: 12px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ------------------------------------------------------------------ *
 * Hero
 * ------------------------------------------------------------------ */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px var(--accent-glow);
}

h1 {
  margin-top: 10px;
  color: var(--text-primary);
  font-size: clamp(2rem, 4.4vw, 2.6rem);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-shadow: var(--shadow-text);
}

h1 .alias {
  display: inline-block;
  margin-left: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 450;
  letter-spacing: 0;
}

.lede {
  max-width: 680px;
  margin-top: 12px;
  color: var(--text-tertiary);
  font-size: 0.92rem;
  line-height: 1.75;
}

.status-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: 0 0 auto;
}

.status-dot.live {
  background: var(--status-ok);
  box-shadow: 0 0 0 3px var(--status-ok-soft);
}

.status-dot.cached {
  background: var(--status-warn);
  box-shadow: 0 0 0 3px var(--status-warn-soft);
}

.status-dot.error {
  background: var(--status-err);
  box-shadow: 0 0 0 3px var(--status-err-soft);
}

.status-dot.loading {
  background: var(--text-muted);
  animation: pulse 1.15s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.sep {
  color: var(--text-dimmed);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-secondary);
  border-radius: 9px;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--border-hover);
  color: var(--accent);
  background: var(--bg-hover);
}

.icon-btn:disabled {
  cursor: default;
  opacity: 0.65;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.icon-btn.loading svg {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.source-note {
  margin-top: 7px;
  color: var(--text-dimmed);
  font-size: 0.7rem;
  line-height: 1.6;
}

.event-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  color: var(--text-tertiary);
  font-size: 0.72rem;
  line-height: 1.5;
}

.event-note[hidden] {
  display: none;
}

.event-note::before {
  content: "◆";
  color: var(--accent);
  font-size: 0.5rem;
  line-height: 1;
}

/* ------------------------------------------------------------------ *
 * Summary
 * ------------------------------------------------------------------ */

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 24px 0 26px;
}

.stat {
  padding: 14px 16px;
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: inset 0 1px 0 var(--inset-highlight), var(--shadow-card);
  min-width: 0;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 5px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-sub {
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.73rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat.stat-bonus .stat-value {
  color: var(--status-warn);
}

.stat.stat-bonus .stat-value.high {
  color: var(--status-ok);
}

.stat.stat-bonus .stat-value.none {
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ *
 * Filters
 * ------------------------------------------------------------------ */

.panel {
  padding: 18px;
  border: 1px solid var(--border-primary);
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: inset 0 1px 0 var(--inset-highlight), var(--shadow-card);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel h2 {
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.panel-desc {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.selected-count {
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin-top: 16px;
  padding: 11px 13px;
  border: 1px solid var(--border-secondary);
  border-radius: 9px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.filter-toggle:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.filter-toggle-label svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--accent);
}

.filter-toggle-value {
  min-width: 0;
  margin-left: auto;
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-toggle .chev {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.filter-toggle[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 9px 16px;
  border: 1px solid var(--border-secondary);
  border-radius: 9px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn:active {
  transform: none;
}

.btn.primary,
.btn.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.btn.primary:hover,
.btn.is-active:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: var(--on-accent);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.btn.ghost:hover {
  border-color: var(--border-secondary);
  background: var(--bg-secondary);
}

#saveFilter.has-changes {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.filter-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 24px;
  margin-top: 16px;
}

.filter-groups[hidden] {
  display: none;
}

.filter-group {
  min-width: 0;
}

.filter-group h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.filter-group h3 span {
  color: var(--text-dimmed);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0;
}

.region-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.region-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.region-option:hover {
  border-color: var(--border-secondary);
  background: var(--bg-hover);
}

.region-option:has(input:checked) {
  border-color: var(--border-hover);
  background: var(--accent-soft);
  color: var(--text-primary);
}

.region-option input {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}

.region-option .region-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 22px;
  height: 16px;
  padding: 0 4px;
  border: 1px solid var(--border-secondary);
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1;
}

.region-option .opt-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.region-option .opt-state {
  margin-left: auto;
  color: var(--text-dimmed);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  white-space: nowrap;
}

.region-option.offline {
  opacity: 0.58;
}

.filter-note {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.71rem;
  line-height: 1.6;
}

.filter-note.dirty {
  color: var(--status-warn);
}

/* ------------------------------------------------------------------ *
 * Mode tabs + regions
 * ------------------------------------------------------------------ */

.mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 28px 0 14px;
}

.mode-tabs {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--border-secondary);
  border-radius: 999px;
  background: var(--bg-secondary);
}

.mode-tabs[hidden] {
  display: none;
}

.mode-tab {
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.mode-tab:hover:not(.active) {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.mode-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

:root[data-theme="dark"] .mode-tab.active {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.mode-note {
  color: var(--text-dimmed);
  font-size: 0.71rem;
}

.region-group {
  margin-bottom: 22px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px 2px;
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.group-title .count {
  color: var(--text-dimmed);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0;
}

.region-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.region-card {
  position: relative;
  min-width: 0;
  padding: 14px 15px;
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: inset 0 1px 0 var(--inset-highlight);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

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

.region-card.is-best {
  border-color: var(--border-hover);
}

.region-card.inactive {
  opacity: 0.62;
}

.region-head {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.region-card .region-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 27px;
  height: 20px;
  margin-top: 1px;
  padding: 0 5px;
  border: 1px solid var(--border-secondary);
  border-radius: 5px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1;
}

.region-title-wrap {
  min-width: 0;
}

.region-title {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.region-id {
  margin-top: 1px;
  color: var(--text-dimmed);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.02em;
}

.status-pill {
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--status-ok-soft);
  color: var(--status-ok);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  white-space: nowrap;
}

.status-pill.offline {
  background: var(--bg-tertiary);
  color: var(--text-dimmed);
}

.status-pill.nodata {
  background: var(--status-warn-soft);
  color: var(--status-warn);
}

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

.role {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  background: var(--bg-secondary);
}

.role-label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.role-label::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.role-killer .role-label {
  color: var(--role-killer);
}

.role-survivor .role-label {
  color: var(--role-survivor);
}

.role-time {
  display: block;
  margin-top: 3px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.12rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.role-time.fast {
  color: var(--status-ok);
}

.role-time.slow {
  color: var(--status-warn);
}

.role-time.none {
  color: var(--text-dimmed);
  font-size: 1rem;
}

.bonus {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
}

.bonus .bp {
  opacity: 0.62;
}

.bonus.hot {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--status-warn-soft);
  color: var(--status-warn);
  font-weight: 600;
}

.bonus.high {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--status-ok-soft);
  color: var(--status-ok);
  font-weight: 600;
}

/* Initial skeleton */
.skeleton-card {
  height: 128px;
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 37%, var(--bg-secondary) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

.empty {
  padding: 46px 20px;
  border: 1px dashed var(--border-secondary);
  border-radius: 14px;
  text-align: center;
}

.empty[hidden] {
  display: none;
}

.empty h3 {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 650;
}

.empty p {
  max-width: 460px;
  margin: 6px auto 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.empty-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

/* ------------------------------------------------------------------ *
 * Footer + toast
 * ------------------------------------------------------------------ */

.site-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--border-primary);
  color: var(--text-muted);
  font-size: 0.73rem;
  line-height: 1.65;
}

.site-footer a {
  color: var(--accent);
}


.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 300;
  max-width: min(90vw, 460px);
  padding: 9px 14px;
  border-radius: 9px;
  background: var(--text-primary);
  color: var(--bg-primary);
  font-size: 0.76rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */

@media (max-width: 960px) {
  .filter-groups {
    grid-template-columns: 1fr;
  }

  .region-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  body {
    padding: 40px 16px 68px;
  }

  h1 .alias {
    display: block;
    margin: 4px 0 0;
  }

  .summary {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stat {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 12px;
    padding: 11px 14px;
  }

  .stat .stat-label {
    grid-column: 1;
  }

  .stat .stat-value {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
    font-size: 1.12rem;
  }

  .stat .stat-sub {
    grid-column: 1;
  }

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

  .panel {
    padding: 15px;
  }

  .filter-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-actions .btn {
    width: 100%;
  }

  #presetChina {
    grid-column: 1 / -1;
  }

  .panel-head {
    flex-direction: column;
    gap: 8px;
  }

  .region-options {
    grid-template-columns: 1fr;
  }

  .status-line {
    font-size: 0.72rem;
    gap: 6px;
  }

  .mode-row {
    align-items: flex-start;
  }

  .mode-note {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
