:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242836;
  --text: #e4e6f0;
  --text-muted: #8b8fa3;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --green: #00d68f;
  --red: #ff6b6b;
  --gold: #ffd43b;
  --radius: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --text: #1a1d27;
    --text-muted: #5c6078;
    --accent-glow: rgba(108, 92, 231, 0.15);
  }
}

* { box-sizing: border-box; }

body {
  background: var(--bg) url("/img/back.webp") no-repeat center center fixed;
  background-size: cover;
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  margin: 0;
  transition: background 0.3s, color 0.3s;
}

.section {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
}

.container {
  max-width: 520px;
  width: 100%;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* Form */
.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.search-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.search-row .search-input {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  flex: 1;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-row .search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-row select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  outline: none;
  width: auto;
  align-self: flex-start;
}

.region-badge {
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 0.4rem;
  text-transform: uppercase;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

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

.btn-secondary:hover {
  background: var(--surface);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

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

/* Result Card */
.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  margin-top: 1.5rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  animation: fade-in 0.4s ease;
}

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

.result-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.champ-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  object-fit: cover;
}

.result-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}

.result-header .tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.header-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

.cache-timestamp {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Main stat */
.stat-main {
  text-align: center;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--surface-2);
  margin-bottom: 1.5rem;
}

.stat-number {
  display: block;
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.3rem;
}

/* Stat row */
.stat-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-small {
  flex: 1;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.stat-small span:first-child {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--green);
}

.stat-small span:last-child {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

/* Verdict */
.verdict {
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
}

.verdict::before {
  content: '"';
  position: absolute;
  top: -8px;
  left: 12px;
  font-size: 2.5rem;
  color: var(--accent);
  opacity: 0.4;
  font-family: Georgia, serif;
  line-height: 1;
}

.verdict p {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
  font-style: italic;
  color: var(--text);
}

/* Top champs */
.top-champs {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.top-champs h4,
.wr-by-tier h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 0.8rem;
  font-weight: 600;
}

.champ-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.champ-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
}

.champ-item img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.champ-item .champ-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.champ-item .champ-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Back link */
.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: opacity 0.2s;
}

.back-link:hover {
  opacity: 0.8;
}

/* Error */
.error-box {
  background: var(--surface);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
  text-align: center;
}

.error-box h3 {
  color: var(--red);
  margin: 0 0 0.5rem;
}

.error-box p {
  color: var(--text-muted);
  margin: 0;
}

/* Loading indicator */
.loading {
  display: none;
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.loading.htmx-request {
  display: block;
}

.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.5rem;
}

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

/* Tooltip hover hint */
.tooltip {
  cursor: help;
  border-bottom: 1px dashed var(--text-muted);
  transition: border-color 0.2s, color 0.2s;
}

.tooltip:hover {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.stat-label.tooltip {
  border-bottom-style: dotted;
}

/* Tier bars */
.tier-bar {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}

.tier-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.tier-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.3rem 0;
}

.tier-label {
  min-width: 80px;
  font-size: 0.85rem;
  color: var(--text);
}

.tier-games {
  min-width: 60px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tier-wr {
  min-width: 40px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: right;
}

/* Not Jungler Card */
.not-jungler-card {
  text-align: center;
  padding: 3rem 2rem;
}

.not-jungler-emoji {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.not-jungler-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.not-jungler-card p {
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.not-jungler-sub {
  font-size: 0.9rem;
  margin-bottom: 1.5rem !important;
}

.search-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.rank-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gold);
  background: rgba(255, 212, 59, 0.1);
  border: 1px solid rgba(255, 212, 59, 0.3);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  margin: 0.2rem 0;
}

.footer {
  text-align: center;
  padding: 2rem 1rem;
  margin-top: 2rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  opacity: 0.7;
}

.footer p {
  margin: 0;
  line-height: 1.6;
}

.footer {
  text-align: center;
  padding: 2rem 1rem;
  margin-top: 2rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.footer-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  transform: translateY(-1px);
}

.footer-legal {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.6;
  margin: 0;
  line-height: 1.6;
}
