:root {
  --bg: #050710;
  --bg-elevated: #0c0f1c;
  --accent: #35c9ff;
  --accent-soft: rgba(53, 201, 255, 0.15);
  --text: #f7f8ff;
  --muted: #9aa0c6;
  --danger: #ff6578;
  --ok: #4dff9a;
  --radius-lg: 16px;
  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.45);
  --border-subtle: 1px solid rgba(255, 255, 255, 0.06);
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #111633 0, var(--bg) 45%);
  color: var(--text);
}

code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  border-bottom: var(--border-subtle);
  backdrop-filter: blur(20px);
  background: linear-gradient(to bottom, rgba(10, 12, 30, 0.9), rgba(5, 7, 16, 0.95));
  gap: 18px;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.team-logo {
  width: 64px; height: 64px;
  border-radius: 18px;
  object-fit: cover;
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-soft);
  background: rgba(255,255,255,0.04);
}
#team-name { margin: 0; font-size: 1.7rem; letter-spacing: 0.05em; }
.team-region { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.team-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 0.85rem; }

.header-right { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

.stat-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(53, 201, 255, 0.4);
  display: flex;
  flex-direction: column;
  min-width: 140px;
}
.stat-pill .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.stat-pill .value { font-size: 1rem; font-weight: 700; }

main { padding: 24px 32px 40px; }
.section { margin-bottom: 26px; }

.section-head {
  display:flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h2 { margin: 12px 0 0; }

.controls { display:flex; gap: 10px; align-items:center; }

.btn {
  appearance: none;
  border: 1px solid rgba(53, 201, 255, 0.55);
  background: rgba(5, 10, 20, 0.92);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}
.btn:hover { background: rgba(53, 201, 255, 0.14); transform: translateY(-1px); }
.btn:active { transform: translateY(0px); }
.btn-ghost { border-color: rgba(255,255,255,0.12); color: var(--muted); }
.btn-ghost:hover { background: rgba(255,255,255,0.06); }

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.player-card {
  background: linear-gradient(145deg, var(--bg-elevated), #070a16);
  border-radius: var(--radius-lg);
  padding: 16px 16px 14px;
  border: var(--border-subtle);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.player-header { display:flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.player-name { font-weight: 700; font-size: 1.1rem; }
.player-role { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.player-platform { font-size: 0.8rem; color: var(--muted); display:flex; justify-content: space-between; gap: 10px; align-items:center; }

.badges { display:flex; gap: 8px; align-items:center; flex-wrap: wrap; justify-content: flex-end;}
.badge {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.06);
}
.badge.live {
  color: #06100a;
  background: rgba(77,255,154,0.9);
  border-color: rgba(77,255,154,0.9);
}
.badge.offline { color: var(--muted); }

.rank-row { display:flex; justify-content: space-between; align-items: center; font-size: 0.9rem; margin-top: 4px; gap: 8px; flex-wrap: wrap; position: relative;}
.rank-row span.label { color: var(--muted); flex: 0 0 auto; }
.rank-row span.value { font-weight: 600; }
.mmr { font-size: 0.85rem; color: var(--muted); flex: 0 0 auto; }
.rank-edit-btn { font-size: 0.75rem; background: rgba(53, 201, 255, 0.2); border: 1px solid rgba(53, 201, 255, 0.4); color: var(--accent); border-radius: 4px; padding: 2px 4px; cursor: pointer; transition: background 120ms; }
.rank-edit-btn:hover { background: rgba(53, 201, 255, 0.4); }
.rank-edit-inline { display: none; flex-direction: row; gap: 4px; margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.05); width: 100%; }
.rank-edit-input { padding: 4px 6px; border-radius: 4px; border: 1px solid rgba(53, 201, 255, 0.3); background: rgba(0,0,0,0.3); color: var(--text); font-size: 0.8rem; }
.rank-edit-input.rank-text { flex: 1 1 auto; min-width: 100px; }
.rank-edit-input.rank-mmr { flex: 0 1 70px; }
.rank-edit-input:focus { outline: none; border-color: var(--accent); background: rgba(53, 201, 255, 0.1); }
.rank-save-btn, .rank-cancel-btn { font-size: 0.75rem; padding: 4px 6px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer; transition: background 120ms; }
.rank-save-btn:hover { background: rgba(77, 255, 154, 0.2); }
.rank-cancel-btn:hover { background: rgba(255, 101, 120, 0.2); }

.tracker-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.player-footer { display:flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 10px;}
.profile-link {
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(53, 201, 255, 0.45);
  background: rgba(5, 10, 20, 0.9);
}
.profile-link:hover { background: rgba(53, 201, 255, 0.15); }
.small-link { font-size: 0.8rem; color: var(--muted); text-decoration: none; }
.small-link:hover { color: var(--text); }

.twitch-embed {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.25);
}
.twitch-embed .embed-shell { height: 240px; width: 100%; }

.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.match-card {
  background: linear-gradient(145deg, rgba(12,15,28,0.95), rgba(7,10,22,0.98));
  border-radius: 16px;
  border: var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 14px;
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.match-head { display:flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.match-title { font-weight: 800; }
.match-meta { color: var(--muted); font-size: 0.85rem; }
.kv { display:flex; justify-content: space-between; gap: 10px; font-size: 0.92rem; }
.kv .k { color: var(--muted); }
.pills { display:flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  color: var(--muted);
  font-size: 0.78rem;
}

.team-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.team-panel {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.team-name {
  font-weight: 700;
}

.team-player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.team-player-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.84rem;
}

.team-player-row .name {
  color: var(--text);
  font-weight: 600;
}

.team-player-row .stats {
  color: var(--muted);
  text-align: right;
}

.callout {
  margin-top: 12px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
}

.footer {
  border-top: var(--border-subtle);
  padding: 10px 32px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.api-status-row {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.api-status-item {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}

.api-status-item.ok {
  color: #8fffc3;
  border-color: rgba(143,255,195,0.35);
}

.api-status-item.warn {
  color: #ffe18f;
  border-color: rgba(255,225,143,0.35);
}

.api-status-item.err {
  color: #ff9fa9;
  border-color: rgba(255,159,169,0.35);
}

.muted { color: var(--muted); }
.tiny { font-size: 0.82rem; }

.modal-backdrop{
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display:flex; align-items:center; justify-content:center;
  padding: 18px;
}
.modal{
  width: min(640px, 100%);
  background: linear-gradient(145deg, rgba(12,15,28,0.98), rgba(7,10,22,0.98));
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 26px 90px rgba(0,0,0,0.6);
  padding: 14px;
}
.modal-head{ display:flex; justify-content: space-between; align-items:center; gap: 10px; }
.modal-head h3{ margin: 6px 0; }
.icon-btn{
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
}
.icon-btn:hover{ background: rgba(255,255,255,0.10); }
.field{ display:flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.field span{ color: var(--muted); font-size: 0.85rem; }
.field input, .field select{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.25);
  color: var(--text);
}
.grid-2{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.modal-actions{ display:flex; justify-content:flex-end; gap: 10px; margin-top: 14px; }

@media (max-width: 880px) {
  .header { flex-direction: column; align-items: flex-start; }
  .header-right { justify-content: flex-start; }
  main { padding: 18px 16px 30px; }
  .footer { padding: 10px 16px; }
  .grid-2{ grid-template-columns: 1fr; }
}

.btn.btn--ghost--PH {
  border-color: rgba(255,255,255,0.12);
  color: var(--muted);
  margin-left: 25px;
  margin-top: 25px;

}