:root {
  --bg: #0b1220;
  --bg-2: #121b2e;
  --ink: #f4efe4;
  --muted: #b9c0ce;
  --line: rgba(255, 255, 255, 0.08);
  --gold: #f5c542;
  --gold-2: #ffe9a3;
  --win: #3dd68c;
  --loss: #ff6b6b;
  --mid: #e8d56a;
  --card: rgba(18, 27, 46, 0.92);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Source Han Sans TW", "Hiragino Sans CNS", "Microsoft JhengHei", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(245, 197, 66, 0.14), transparent 50%),
    var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100dvh;
}
.top {
  padding: calc(22px + var(--safe-top)) 20px 8px;
  max-width: 720px;
  margin: 0 auto;
}
.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.18em;
  text-transform: none;
  font-size: 11px;
  color: var(--gold);
}
h1 {
  margin: 0 0 6px;
  font-size: clamp(1.7rem, 6vw, 2.2rem);
  letter-spacing: 0.02em;
  font-weight: 700;
}
.player { margin: 0; color: var(--muted); font-size: 0.95rem; }
.badge {
  margin: 16px 0 8px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(245, 197, 66, 0.2), rgba(18, 27, 46, 0.9));
  border: 1px solid rgba(245, 197, 66, 0.35);
  box-shadow: var(--shadow);
}
.badge-kicker {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--gold-2);
}
.badge strong {
  display: block;
  margin-top: 2px;
  font-size: 1.35rem;
  color: var(--gold);
}
.badge p { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }

.map-wrap {
  position: relative;
  margin: 8px 12px 0;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: #0a1424;
}
#map {
  height: min(64vh, 560px);
  min-height: 280px;
  width: 100%;
  background: #0a1424;
}
.map-chips {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 500;
  pointer-events: none;
}
.map-chips button {
  pointer-events: auto;
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(11, 18, 32, 0.88);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.map-chips button:focus-visible { outline: 2px solid var(--gold); }
.legend {
  margin: 0;
  padding: 8px 12px 10px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: rgba(11, 18, 32, 0.92);
}
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: 1px;
}
.dot.win { background: var(--win); }
.dot.mid { background: var(--mid); }
.dot.loss { background: var(--loss); }
.dot.none { background: #3a465c; }

.disclaimer, footer p, .hint {
  color: var(--muted);
  font-size: 0.86rem;
}
.disclaimer {
  max-width: 720px;
  margin: 12px auto 0;
  padding: 0 20px;
}
main, footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px calc(28px + var(--safe-bottom));
}
.panel {
  margin-top: 22px;
  padding: 18px 16px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
h2 { margin: 0 0 10px; font-size: 1.15rem; }
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 1 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.86rem;
  white-space: nowrap;
}
.tab.is-on {
  background: var(--gold);
  color: #1a1406;
  border-color: var(--gold);
  font-weight: 700;
}
.rank-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}
.rank-list li {
  display: grid;
  grid-template-columns: 28px 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.rank-list li:first-child { border-top: 0; }
.rank-n { color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 700; }
.rank-list img { width: 28px; height: 20px; object-fit: cover; border-radius: 3px; background: #223; }
.rank-name { font-weight: 600; }
.rank-sub { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.rank-wr { font-variant-numeric: tabular-nums; font-weight: 700; }
.rank-wr.good { color: var(--win); }
.rank-wr.bad { color: var(--loss); }
.rank-wr.ok { color: var(--mid); }

.cards {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.cards li {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
}
.cards img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  background: #0a1424;
  border-radius: 10px;
}
.card-name { font-weight: 700; }
.card-en { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 400; }
.card-meta { color: var(--muted); font-size: 0.8rem; margin: 2px 0 0; }
.lift {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.lift small { display: block; font-weight: 500; color: var(--muted); font-size: 0.7rem; }

footer { color: var(--muted); font-size: 0.82rem; }
footer p { margin: 8px 0 0; }

/* Leaflet tweaks */
.leaflet-container { background: #0a1424; font-family: inherit; }
.leaflet-control-attribution {
  background: rgba(11,18,32,0.75) !important;
  color: #8b93a3 !important;
  font-size: 10px !important;
  max-width: 70%;
}
.leaflet-control-attribution a { color: #c9d0dc !important; }
.leaflet-control-zoom a {
  background: #121b2e !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}
.cr-marker {
  background: rgba(11, 18, 32, 0.92);
  border: 1px solid rgba(245, 197, 66, 0.45);
  border-radius: 14px;
  color: var(--ink);
  padding: 3px 6px 4px;
  min-width: 54px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
  line-height: 1.15;
}
.cr-marker img { width: 22px; height: 16px; object-fit: cover; border-radius: 2px; display: block; margin: 0 auto 2px; }
.cr-marker .wl { font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cr-marker .wl b.win { color: var(--win); font-weight: 800; }
.cr-marker .wl b.loss { color: var(--loss); font-weight: 800; }

.sheet { position: fixed; inset: 0; z-index: 2000; }
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
}
.sheet-body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: min(78vh, 640px);
  overflow: auto;
  background: #151e31;
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + var(--safe-bottom));
  box-shadow: var(--shadow);
}
.sheet-close {
  position: absolute;
  top: 12px; right: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  padding: 6px 8px;
}
.sheet-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-right: 48px;
}
.sheet-head img { width: 48px; height: 36px; object-fit: cover; border-radius: 4px; }
.sheet-head h2 { margin: 0; }
.sheet-head p { margin: 4px 0 0; color: var(--muted); }
.opp-list { list-style: none; margin: 16px 0 0; padding: 0; }
.opp-list li {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.opp-name { font-weight: 700; }
.opp-clan, .opp-tag { display: block; color: var(--muted); font-size: 0.8rem; }
.opp-wl { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.opp-last { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 400; }

@media (min-width: 800px) {
  #map { height: 620px; }
  .map-wrap { margin: 8px auto 0; max-width: 960px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
