:root {
  --purple: #4d148c;
  --purple-dark: #38096b;
  --orange: #ff6600;
  --bg: #120a1e;
  --card: #1e1330;
  --card-head: #251740;
  --text: #f2eefa;
  --muted: #a698c2;
  --under: #ff8c3a;
  --over: #7fd1ff;
  --line: rgba(255, 255, 255, 0.08);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  padding-bottom: 40px;
}

header {
  background: linear-gradient(135deg, var(--purple-dark), var(--purple));
  border-bottom: 3px solid var(--orange);
  padding: 22px 16px 16px;
  text-align: center;
}

h1 {
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}
h1 .fed { color: #fff; }
h1 .ex { color: var(--orange); }

.subtitle {
  color: var(--orange);
  font-style: italic;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
}

.event-line {
  margin-top: 10px;
  font-size: 0.95rem;
  font-weight: 600;
}

.meta-line {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 3px;
}
.meta-line span + span::before { content: " · "; }

.view-toggle {
  margin-top: 12px;
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  overflow: hidden;
}
.view-toggle button {
  background: transparent;
  border: none;
  color: #d9cdef;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 16px;
  cursor: pointer;
}
.view-toggle button.active {
  background: var(--orange);
  color: #fff;
}

#error {
  background: #5c1a1a;
  color: #ffd9d9;
  text-align: center;
  font-size: 0.85rem;
  padding: 8px;
}

main {
  max-width: 760px;
  margin: 18px auto 0;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.team.leader { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange); }

.team-head {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto 3.6rem 1.2rem;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  background: var(--card-head);
  border: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.team-head:hover { background: #2c1c4c; }

.rank {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--orange);
}
.leader .rank { color: #ffd700; }

.owner { font-weight: 700; font-size: 0.98rem; }

.tb {
  color: var(--muted);
  font-size: 0.72rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
}

.total { font-weight: 800; font-size: 1.25rem; text-align: right; }
.chev { color: var(--muted); font-size: 0.8rem; text-align: right; }

.under { color: var(--under); }
.over { color: var(--over); }
.even { color: var(--text); }

.players { padding: 4px 10px 10px; }

.prow {
  display: grid;
  grid-template-columns: 2.2rem 1fr 3.2rem 4.6rem 3.2rem;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.prow:last-child { border-bottom: none; }

.phead {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-top: 8px;
}

.pic img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  display: block;
}

.pname { font-weight: 600; }
.ppos, .pthru { color: var(--muted); font-size: 0.85rem; }
.pscore { font-weight: 700; text-align: right; }

.tag {
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #5c1a1a;
  color: #ffb3b3;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
}
.drop-tag { background: #3a3a3a; color: #cfcfcf; }

.prow.dropped .pname,
.prow.dropped .pscore,
.prow.dropped .ppos,
.prow.dropped .pthru { opacity: 0.45; }
.prow.dropped .pname { text-decoration: line-through; text-decoration-thickness: 1px; }
.prow.dropped .drop-tag { text-decoration: none; }

/* ---------- Grid view ---------- */

.grid-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.grid {
  border-collapse: collapse;
  width: 100%;
  min-width: 640px;
}

.grid th, .grid td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: center;
  vertical-align: middle;
}
.grid tbody tr:last-child th,
.grid tbody tr:last-child td { border-bottom: none; }

.ghead, .ghead-team {
  background: var(--card-head);
  color: var(--muted);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 6px;
}

.gteam {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card-head);
  text-align: left;
  min-width: 150px;
  max-width: 180px;
  padding: 8px 10px;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.35);
}
.ghead-team { z-index: 3; }

.gtop {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.grank {
  color: var(--orange);
  font-weight: 800;
  font-size: 0.95rem;
}
.gleader .grank { color: #ffd700; }
.gleader .gteam { box-shadow: inset 3px 0 0 var(--orange), 2px 0 4px rgba(0,0,0,0.35); }

.gowner {
  display: block;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.25;
  margin-top: 3px;
  text-align: left;
}
.gtotal {
  font-weight: 800;
  font-size: 1.05rem;
}

.gcell { min-width: 86px; }
.gname {
  display: block;
  font-weight: 600;
  font-size: 0.74rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 106px;
  margin: 0 auto;
}
.gline {
  display: block;
  font-size: 0.82rem;
  margin-top: 2px;
}
.gline b { font-weight: 700; }
.gthru {
  color: var(--muted);
  font-size: 0.66rem;
  margin-left: 5px;
}

.gws {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 52px;
}
.gws-win {
  color: #ffd700;
  position: relative;
}
.gws-win::after {
  content: "🏆";
  font-size: 0.7rem;
  margin-left: 3px;
}

.gdropped { opacity: 0.4; }
.gdropped .gname { text-decoration: line-through; text-decoration-thickness: 1px; }

.grid-note {
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
  margin-top: 8px;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 22px;
  padding: 0 16px;
}

@media (max-width: 480px) {
  .team-head { grid-template-columns: 1.8rem 1fr auto 3.2rem 1rem; padding: 10px 10px; }
  .owner { font-size: 0.88rem; }
  .tb { display: none; }
  .prow { grid-template-columns: 2rem 1fr 2.8rem 4rem 3rem; font-size: 0.88rem; }
}
