:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-elev: #1c2330;
  --border: #2d333b;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #f0b90b;
  --accent-2: #e58e26;
  --blue: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --purple: #bc8cff;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 60% 40% at 20% 0%, rgba(240, 185, 11, 0.06), transparent),
    radial-gradient(ellipse 50% 40% at 90% 10%, rgba(88, 166, 255, 0.06), transparent);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1203;
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(240, 185, 11, 0.3);
  letter-spacing: 1px;
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-text p {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
}

.tab {
  flex: 1;
  min-width: 100px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.tab:hover {
  color: var(--text);
  background: var(--bg-elev);
}

.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1203;
  font-weight: 700;
}

/* Panels */
.panel {
  display: none;
}

.panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

/* Search */
.search-bar {
  display: flex;
  gap: 10px;
}

.search-bar input,
.form-item input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus,
.form-item input:focus {
  border-color: var(--accent);
}

.hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1203;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(240, 185, 11, 0.35);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

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

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.form-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-item label {
  font-size: 12px;
  color: var(--text-dim);
}

/* Results */
.results {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.result-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.result-item img.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-elev);
  object-fit: cover;
}

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

.result-item .nickname {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-item .meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.result-item .arrow {
  color: var(--text-dim);
  font-size: 18px;
}

/* Result area */
.result-area {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.loading {
  text-align: center;
  padding: 32px;
  color: var(--text-dim);
}

.loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

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

.error-box {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Profile */
.profile-card {
  display: flex;
  gap: 16px;
  align-items: center;
}

.profile-card img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  object-fit: cover;
}

.profile-card .p-name {
  font-size: 20px;
  font-weight: 700;
}

.profile-card .p-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-card .p-rank {
  margin-top: 6px;
  display: inline-block;
  font-size: 12px;
  color: #1a1203;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

/* Section inside result */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

/* Battle list */
.battle-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--bg-elev);
  border-radius: 10px;
  margin-bottom: 10px;
}

.battle-item img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
}

.battle-item .b-result {
  font-weight: 700;
  font-size: 14px;
}

.battle-item .b-win { color: var(--green); }
.battle-item .b-lose { color: var(--red); }

.battle-item .b-hero {
  font-weight: 600;
  font-size: 14px;
}

.battle-item .b-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.battle-item .b-kda {
  text-align: right;
}

.battle-item .b-kda .kda {
  font-size: 15px;
  font-weight: 700;
}

.battle-item .b-kda .score {
  font-size: 12px;
  color: var(--accent);
  margin-top: 2px;
}

/* Hero rank table */
.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.rank-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.rank-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.rank-table tr:last-child td {
  border-bottom: none;
}

.rank-table tr:hover td {
  background: var(--bg-elev);
}

.rank-table .tier {
  font-weight: 700;
}

.tier-T0 { color: var(--red); }
.tier-T1 { color: var(--accent); }
.tier-T2 { color: var(--blue); }
.tier-T3 { color: var(--green); }
.tier-其他 { color: var(--text-dim); }

.rank-table img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  vertical-align: middle;
  margin-right: 8px;
  object-fit: cover;
}

/* Hero info */
.hero-detail {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.hero-detail img.hero-pic {
  width: 120px;
  height: 160px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.hero-detail .hero-desc {
  flex: 1;
}

.hero-attr {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.hero-attr .attr-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}

.hero-attr .attr-item .a-val {
  font-weight: 700;
  color: var(--accent);
}

.hero-attr .attr-item .a-name {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Skin grid */
.skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.skin-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.2s;
}

.skin-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.skin-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.skin-item .skin-info {
  padding: 10px;
}

.skin-item .skin-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skin-item .skin-hero {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.skin-item .skin-class {
  display: inline-block;
  font-size: 11px;
  margin-top: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  background: rgba(240, 185, 11, 0.15);
  color: var(--accent);
}

/* Hero list */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.hero-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.hero-item img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
}

.hero-item .h-name {
  font-weight: 600;
  font-size: 13px;
}

.hero-item .h-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 1000;
  box-shadow: var(--shadow);
}

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

/* Footer */
.footer {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* Responsive */
@media (max-width: 640px) {
  .app { padding: 16px 12px 32px; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .header-status { align-self: flex-end; }
  .tab { min-width: 45%; }
  .search-bar { flex-direction: column; }
  .hero-detail { flex-direction: column; }
  .battle-item { grid-template-columns: auto 1fr; }
  .battle-item .b-kda { grid-column: 1 / -1; text-align: left; padding-left: 56px; }
}
