/* === Base Reset & Theme === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #131a2b;
  --bg-tertiary: #1a2340;
  --bg-hover: #1f2b48;
  --border-color: #2a3a5c;
  --text-primary: #e8e6e3;
  --text-secondary: #8b9dc3;
  --text-muted: #5a6d8a;
  --accent: #4fc3f7;
  --accent-hover: #29b6f6;
  --danger: #ef5350;
  --success: #66bb6a;

  /* WCL parse colors */
  --parse-gold: #e5cc80;
  --parse-pink: #e268a8;
  --parse-orange: #ff8000;
  --parse-purple: #a335ee;
  --parse-blue: #0070ff;
  --parse-green: #1eff00;
  --parse-gray: #666666;

  /* WoW class colors */
  --class-warrior: #C79C6E;
  --class-paladin: #F58CBA;
  --class-hunter: #ABD473;
  --class-rogue: #FFF569;
  --class-priest: #FFFFFF;
  --class-dk: #C41F3B;
  --class-shaman: #0070DE;
  --class-mage: #69CCF0;
  --class-warlock: #9482C9;
  --class-monk: #00FF96;
  --class-druid: #FF7D0A;
  --class-dh: #A330C9;
  --class-evoker: #33937F;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.5;
  font-size: 14px;
  background-image: url('https://bnetcmsus-a.akamaihd.net/cms/blog_header/d8/D84JV9ZJWDS01772587429618.png');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

.bg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.85);
  z-index: 0;
  pointer-events: none;
}

/* === Header === */
.header {
  position: relative;
  text-align: center;
  padding: 30px 15px 20px;
  border-bottom: 1px solid var(--border-color);
  z-index: 1;
}

.title {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-shadow: 0 0 12px rgba(79, 195, 247, 0.4);
}

.season-week-banner {
  margin: 12px 12px 0;
  text-align: center;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #fff;
  background: linear-gradient(135deg, rgba(79, 195, 247, 0.15), rgba(124, 77, 255, 0.15));
  border: 1px solid rgba(79, 195, 247, 0.25);
  border-radius: 10px 10px 0 0;
  text-shadow: 0 0 8px rgba(79, 195, 247, 0.5);
  position: relative;
  z-index: 1;
}

/* Admin button moved to filter row */
.btn-admin-inline {
  margin-left: auto;
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-admin-inline.admin-active {
  background: rgba(79, 195, 247, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* === Section === */
.section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin: 12px;
  position: relative;
  z-index: 1;
}

.section-title {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* === Form === */
.form-row {
  margin-bottom: 10px;
}

.form-group {
  width: 100%;
}

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

.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  -webkit-appearance: none;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.15);
}

/* Server dropdown */
.server-wrapper {
  position: relative;
}

.server-dropdown {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  right: 0;
  max-height: 50vh;
  overflow-y: auto;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 6px 6px;
  z-index: 100;
}

.server-dropdown.hidden {
  display: none;
}

.server-option {
  padding: 12px;
  font-size: 14px;
  border-bottom: 1px solid rgba(42, 58, 92, 0.5);
  cursor: pointer;
  transition: background 0.15s;
}

.server-option:active {
  background: var(--bg-hover);
}

.server-slug {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 4px;
}

.btn-submit {
  width: 100%;
  margin-top: 12px;
  padding: 12px 0;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.btn-submit:active {
  opacity: 0.85;
  transform: scale(0.98);
}

.btn-submit:disabled {
  opacity: 0.4;
  transform: none;
}

.form-message {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.form-message.hidden { display: none; }
.form-message.error {
  background: rgba(239, 83, 80, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 83, 80, 0.3);
}
.form-message.success {
  background: rgba(102, 187, 106, 0.15);
  color: var(--success);
  border: 1px solid rgba(102, 187, 106, 0.3);
}

/* === Stats Bar === */
.stats-bar {
  margin: 0 12px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  position: relative;
  z-index: 1;
}

.stats-info {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stats-info strong {
  color: var(--text-primary);
  font-weight: 600;
}

.divider {
  color: var(--text-muted);
  margin: 0 4px;
}

.filter-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 36px;
}

.filter-btn:active {
  opacity: 0.8;
}

.filter-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.btn-refresh-all {
  margin-left: auto;
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

.btn-refresh-all.hidden { display: none; }

/* === Signup Cards === */
.list-section {
  padding: 12px;
  position: relative;
  z-index: 1;
}

.empty-state {
  text-align: center;
  padding: 50px 15px;
  color: var(--text-muted);
}

.empty-state.hidden { display: none; }

.signup-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  transition: opacity 0.25s, border-color 0.2s;
}

/* Card header: character info */
.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

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

.char-name {
  font-size: 16px;
  font-weight: 700;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.char-name a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(79, 195, 247, 0.4);
  text-underline-offset: 3px;
}

.char-name a::after {
  content: ' ↗';
  font-size: 10px;
  opacity: 0.5;
}

.char-server {
  font-size: 12px;
  color: var(--text-muted);
}

.card-spec {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  flex-shrink: 0;
}

.spec-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: inherit;
  font-size: 12px;
  padding: 2px 4px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  max-width: 70px;
}

.spec-select:focus {
  border-color: var(--accent);
}

.spec-select option {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.spec-icon {
  width: 20px;
  height: 20px;
  border-radius: 3px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  min-height: 26px;
}

.role-tank {
  background: rgba(79, 195, 247, 0.2);
  color: var(--accent);
}

.role-healer {
  background: rgba(102, 187, 106, 0.2);
  color: var(--success);
}

.role-dps {
  background: rgba(239, 83, 80, 0.2);
  color: var(--danger);
}

/* === Boss Scores (H+M dual difficulty) === */
.boss-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 8px;
  white-space: nowrap;
}

.boss-scores {
  display: inline-flex;
  gap: 6px;
}

.boss-score-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  padding: 6px 8px;
  background: var(--bg-tertiary);
  border-radius: 6px;
}

.boss-name {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  white-space: nowrap;
}

.difficulty-scores {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

.diff-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.diff-label {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  min-width: 14px;
  text-align: center;
}

.diff-h {
  background: #1e3a5f;
  color: #64b5f6;
}

.diff-m {
  background: #4a1e1e;
  color: #ef5350;
}

.diff-value {
  font-size: 13px;
  font-weight: 700;
  min-width: 25px;
  text-align: center;
}

/* === Actions === */
.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.action-btn {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  cursor: pointer;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  min-height: 36px;
  transition: opacity 0.15s, transform 0.1s;
}

.action-btn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.action-refresh {
  background: rgba(79, 195, 247, 0.15);
  color: var(--accent);
  border: 1px solid rgba(79, 195, 247, 0.3);
}

.action-delete {
  background: rgba(239, 83, 80, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 83, 80, 0.3);
}

.action-sign {
  background: rgba(79, 195, 247, 0.15);
  color: #4fc3f7;
  border: 1px solid rgba(79, 195, 247, 0.3);
}

.action-attended {
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.4);
}

.attend-locked {
  opacity: 0.5;
  cursor: default;
}

.stat-attend {
  color: #4caf50;
}

.card-unattended {
  opacity: 0.4;
  transition: opacity 0.25s;
}
.card-unattended:active {
  opacity: 0.7;
}

/* Class colors */
.class-1 { color: var(--class-warrior); }
.class-2 { color: var(--class-paladin); }
.class-3 { color: var(--class-hunter); }
.class-4 { color: var(--class-rogue); }
.class-5 { color: var(--class-priest); }
.class-6 { color: var(--class-dk); }
.class-7 { color: var(--class-shaman); }
.class-8 { color: var(--class-mage); }
.class-9 { color: var(--class-warlock); }
.class-10 { color: var(--class-monk); }
.class-11 { color: var(--class-druid); }
.class-12 { color: var(--class-dh); }
.class-13 { color: var(--class-evoker); }

/* Parse colors */
.parse-gold { color: var(--parse-gold); }
.parse-pink { color: var(--parse-pink); }
.parse-orange { color: var(--parse-orange); }
.parse-purple { color: var(--parse-purple); }
.parse-blue { color: var(--parse-blue); }
.parse-green { color: var(--parse-green); }
.parse-gray { color: var(--parse-gray); }
.parse-none { color: var(--text-muted); }

/* === Loading === */
.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.loading-mask.hidden { display: none; }

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.loading-spinner {
  width: 30px;
  height: 30px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 10px;
}

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

.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
}

/* === Footer (备案信息) === */
.site-footer {
  text-align: center;
  padding: 16px 12px;
  margin-top: 20px;
  font-size: 11px;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
  line-height: 1.8;
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text-secondary);
}

.footer-divider {
  margin: 0 6px;
  color: var(--text-muted);
}

.beian-icon {
  width: 12px;
  height: 12px;
  vertical-align: text-bottom;
  margin-right: 2px;
}

/* === Admin class select (mobile card) === */
.class-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: inherit;
  font-size: 12px;
  padding: 2px 4px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  max-width: 80px;
  margin-top: 2px;
}

.class-select option {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* === Batch delete & checkbox === */
.btn-batch-delete {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

.btn-batch-delete.hidden { display: none; }

.card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
}

.row-check {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.signup-card {
  position: relative;
}

.signup-card.admin-mode {
  padding-left: 34px;
}

/* === Class Distribution Pie Chart & Buff === */
.chart-section {
  z-index: 1;
  border-top: none;
  border-radius: 0 0 10px 10px;
  margin-top: 0;
}

.chart-row {
  display: flex;
  gap: 0;
}

.chart-left-m {
  flex: 1;
  min-width: 0;
}

.chart-pie-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.chart-divider-m {
  width: 1px;
  background: var(--border-color);
  margin: 0 8px;
  align-self: stretch;
}

.chart-right-m {
  flex: 0 0 auto;
}

.chart-pie {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
}

.chart-pie svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
}

.chart-pie .pie-label {
  pointer-events: none;
  font-size: 9px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: central;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-count {
  color: var(--text-primary);
  font-weight: 600;
}

/* Buff coverage */
.buff-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.buff-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 4px;
}

.buff-item.covered {
  color: var(--success);
  background: rgba(102, 187, 106, 0.08);
}

.buff-item.missing {
  color: var(--danger);
  background: rgba(239, 83, 80, 0.08);
}

.buff-icon {
  font-size: 12px;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.buff-name {
  white-space: nowrap;
}

/* === Class filter strip === */
.class-filter-bar {
  overflow: hidden;
  padding: 8px 0;
  margin: 8px 12px 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.class-filter-bar.hidden { display: none; }

.cf-track {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  will-change: transform;
  transform: translate3d(0,0,0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.cf-item {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 0.5;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  /* no transition — avoid per-frame cost during scroll */
}
.cf-item.cf-active {
  opacity: 1;
  box-shadow: 0 0 8px rgba(79, 195, 247, 0.5);
}
.cf-item.cf-all {
  color: var(--accent);
  font-size: 13px;
  line-height: 36px;
  border-color: var(--accent);
}
.cf-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* === User Type Modal === */
.ut-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.ut-modal.hidden { display: none; }
.ut-box {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: 12px; padding: 28px 24px; width: 88%; max-width: 360px; text-align: center;
}
.ut-box h3 { color: var(--accent); margin-bottom: 6px; font-size: 1.1rem; }
.ut-box p { color: var(--text-secondary); margin-bottom: 20px; font-size: 0.85rem; }
.ut-btns { display: flex; gap: 12px; }
.ut-btn {
  flex: 1; padding: 12px; border-radius: 8px; border: 1px solid var(--border-color);
  background: var(--bg-tertiary); color: var(--text-primary); font-size: 0.9rem;
  font-weight: 600; cursor: pointer;
}
.ut-btn.ut-guild { border-color: #f0b232; color: #f0b232; }
.ut-pwd { margin-top: 14px; }
.ut-pwd.hidden { display: none; }
.ut-input {
  width: 100%; padding: 10px; border-radius: 6px; border: 1px solid var(--border-color);
  background: var(--bg-primary); color: var(--text-primary); font-size: 0.9rem;
  text-align: center; margin-bottom: 10px;
}
.ut-input:focus { outline: none; border-color: var(--accent); }
.ut-submit {
  width: 100%; padding: 10px; border-radius: 6px; border: none;
  background: #f0b232; color: #000; font-weight: 600; font-size: 0.9rem; cursor: pointer;
}
.ut-err { color: #ff5252; font-size: 0.8rem; margin-top: 6px; }
.ut-err.hidden { display: none; }

/* User Type Badge (Admin toggle) */
.user-type-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.7rem; padding: 4px 10px; border-radius: 10px;
  cursor: pointer; margin-right: 6px; font-weight: 600; line-height: 1.4;
  min-height: 26px; vertical-align: middle;
  transition: background 0.2s, border-color 0.2s;
}
.user-type-badge:active { opacity: 0.7; }
.user-type-badge::after { content: '⇄'; font-size: 0.65rem; opacity: 0.6; }
.ut-guild { background: rgba(255,152,0,0.15); color: #ff9800; border: 1.5px solid rgba(255,152,0,0.5); }
.ut-independent { background: rgba(120,144,156,0.15); color: #90a4ae; border: 1.5px solid rgba(120,144,156,0.4); }

/* === Identity Switch Button === */
.btn-switch-identity {
  display: block;
  margin: 8px auto 0;
  padding: 4px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.identity-guild {
  background: rgba(255,152,0,0.12);
  color: #ff9800;
  border-color: rgba(255,152,0,0.35);
}
.identity-independent {
  background: rgba(120,144,156,0.12);
  color: #90a4ae;
  border-color: rgba(120,144,156,0.25);
}
