/* ===== CROWN PALETTE ===== */
:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --card: #1a1a1a;
  --border: #252525;
  --gold: #c8a951;
  --gold-bright: #e0c470;
  --gold-dim: #8a7030;
  --text: #e8e6e3;
  --text-muted: #7a7a7a;
  --text-dim: #555;
  --win: #3a7d5a;
  --win-bg: rgba(58, 125, 90, 0.1);
  --loss: #b5443c;
  --loss-bg: rgba(181, 68, 60, 0.1);
  --accent: #c8a951;
  --radius: 6px;
  --font: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

/* ===== RESET ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== APP LAYOUT ===== */
.app {
  max-width: 780px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--gold);
  text-decoration: none;
  transition: color 0.2s;
}

.logo:hover {
  color: var(--gold-bright);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ===== SEARCH ===== */
.search-section {
  margin-bottom: 28px;
}

.search-box {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  transition: border-color 0.2s;
}

.search-box:focus-within {
  border-color: var(--gold-dim);
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  padding: 10px 12px;
  outline: none;
  font-family: var(--font);
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.search-box select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 10px 8px;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  font-family: var(--font);
  min-width: 70px;
}

.search-box select:focus {
  border-color: var(--gold-dim);
}

.search-box button {
  background: var(--gold);
  color: #0a0a0a;
  border: none;
  border-radius: 4px;
  padding: 10px 24px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: background 0.2s;
  font-family: var(--font);
}

.search-box button:hover {
  background: var(--gold-bright);
}

.search-box button:active {
  background: var(--gold-dim);
}

.error-msg {
  color: var(--loss);
  font-size: 0.85rem;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--loss-bg);
  border-radius: 4px;
  border: 1px solid rgba(181, 68, 60, 0.2);
}

.hidden {
  display: none !important;
}

/* ===== LOADING ===== */
.loading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 28px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ===== SUMMONER CARD ===== */
.summoner-card {
  margin-bottom: 24px;
}

.summoner-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.summoner-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  background: var(--surface);
}

.summoner-details h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.summoner-details .level {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== SECTION TITLES ===== */
.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ===== MATCH LIST ===== */
.match-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.match-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.match-item:hover {
  border-color: var(--gold-dim);
  background: var(--card);
}

.match-win {
  border-left: 3px solid var(--win);
}

.match-loss {
  border-left: 3px solid var(--loss);
}

.match-result {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  min-width: 44px;
}

.match-result.win {
  color: var(--win);
}

.match-result.loss {
  color: var(--loss);
}

.match-champion {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 130px;
}

.match-champion img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
}

.match-champion .champ-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.match-kda {
  font-size: 0.85rem;
  color: var(--text);
  min-width: 80px;
  text-align: center;
}

.match-kda .kda-ratio {
  font-weight: 600;
  font-size: 0.9rem;
}

.match-kda .kda-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.match-stats {
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: auto;
}

.match-stats span {
  text-align: center;
}

.match-stats .stat-val {
  display: block;
  color: var(--text);
  font-weight: 500;
  font-size: 0.85rem;
}

/* ===== ANALYSIS PANEL ===== */
.analysis-panel {
  margin-top: 20px;
  position: relative;
  border-color: var(--gold-dim);
}

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

.analysis-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--gold);
}

.close-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: color 0.2s, border-color 0.2s;
}

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

.analysis-content {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
}

.analysis-content p {
  margin-bottom: 10px;
}

.analysis-content strong {
  color: var(--gold-bright);
}

.analysis-loading {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== STATS GRID IN ANALYSIS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  text-align: center;
}

.stat-box .stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-box .stat-number {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.stat-box .stat-number.gold {
  color: var(--gold);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .app {
    padding: 16px 12px 40px;
  }

  .search-box {
    flex-wrap: wrap;
  }

  .search-box button {
    width: 100%;
  }

  .match-item {
    flex-wrap: wrap;
    gap: 8px;
  }

  .match-stats {
    margin-left: 0;
    width: 100%;
    justify-content: space-around;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
}
