:root {
  --bg: #0b1220;
  --bg-elev: #152238;
  --bg-row: #121c30;
  --bg-row-alt: #182640;
  --border: #2a3a55;
  --border-strong: #3d516f;
  --text: #f3f6fb;
  --text-dim: #c5d0e3;
  --text-mute: #a7b6ce;
  --accent: #c6ff4a;
  --accent-dim: #9ad42e;
  --accent-glow: rgba(198, 255, 74, 0.18);
  --accent-glow-strong: rgba(198, 255, 74, 0.35);
  --kd-high: #7dff9a;
  --kd-mid: #e4ebf7;
  --kd-low: #ff9b6b;
  --medal-1: #ffd700;
  --medal-2: #d7dde8;
  --medal-3: #e0a06a;
  --danger: #ff6b6b;
  --glass: rgba(21, 34, 56, 0.72);
  --glass-border: rgba(198, 255, 74, 0.12);
  --shadow-soft: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-lift: 0 14px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(198, 255, 74, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Menlo", "Consolas", "Roboto Mono", ui-monospace, monospace;
  --radius: 12px;
  --radius-lg: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --header-h: 44px;
  --ease-spring: cubic-bezier(0.22, 1.2, 0.36, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  padding-bottom: calc(12px + var(--safe-b));
  position: relative;
  overflow-x: hidden;
}

/* —— Background mesh + noise (CSS only) —— */
.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(198, 255, 74, 0.09), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(80, 140, 255, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 35% at 50% 100%, rgba(120, 60, 255, 0.08), transparent 55%),
    radial-gradient(ellipse 40% 30% at 70% 60%, rgba(198, 255, 74, 0.04), transparent 50%),
    var(--bg);
}

.bg-noise {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
}

/* —— Pressable micro-interaction —— */
.pressable {
  transition: transform 0.15s var(--ease-out), filter 0.15s ease;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}
.pressable:active {
  transform: scale(0.94);
}

/* —— Hero —— */
.hero {
  padding: 14px 12px 10px;
  perspective: 900px;
}

.hero-card {
  position: relative;
  padding: 14px 14px 12px;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(30, 48, 78, 0.85) 0%, rgba(18, 30, 52, 0.92) 55%, rgba(14, 22, 40, 0.95) 100%);
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--shadow-soft),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 40px rgba(198, 255, 74, 0.04);
  transform: rotateX(2deg) translateZ(0);
  transform-style: preserve-3d;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hero-specular {
  position: absolute;
  top: -40%;
  left: -20%;
  width: 70%;
  height: 80%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, transparent 55%);
  pointer-events: none;
  transform: rotate(-8deg);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-shadow: 0 0 24px rgba(198, 255, 74, 0.15);
}

.subtitle {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
}

.season-switch {
  display: flex;
  background: rgba(11, 18, 32, 0.65);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.season-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.season-btn.active {
  background: var(--accent);
  color: #0a1200;
  box-shadow: 0 0 16px var(--accent-glow-strong);
}

/* —— Hero top-3 (gold / silver / bronze) —— */
.hero-tops {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 8px;
  align-items: end;
}

.hero-top-card {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 8px 9px;
  text-align: center;
  cursor: pointer;
  background: var(--glass);
  color: var(--text);
  font: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 16px rgba(0, 0, 0, 0.28);
  transition: transform 0.15s var(--ease-out), border-color 0.15s, box-shadow 0.15s;
}

.hero-top-card:active {
  transform: scale(0.96);
}

.hero-top-card .ht-place {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.hero-top-card .ht-kd {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.hero-top-card .ht-kd.counting {
  animation: none;
}

.hero-top-card .ht-nick {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}

.hero-top-card.place-1 {
  background: linear-gradient(160deg, rgba(255, 215, 0, 0.22), rgba(255, 180, 40, 0.08));
  border-color: rgba(255, 215, 0, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 6px 22px rgba(255, 200, 40, 0.18);
  padding-top: 14px;
  padding-bottom: 12px;
  transform: translateY(-4px);
}
.hero-top-card.place-1 .ht-place { color: var(--medal-1); }
.hero-top-card.place-1 .ht-kd {
  font-size: 22px;
  color: var(--medal-1);
  text-shadow: 0 0 18px rgba(255, 215, 0, 0.35);
  animation: kdGlow 2.8s ease-in-out infinite;
}
.hero-top-card.place-1 .ht-nick { color: var(--text); font-size: 12px; }

.hero-top-card.place-2 {
  background: linear-gradient(160deg, rgba(200, 210, 230, 0.18), rgba(140, 160, 190, 0.06));
  border-color: rgba(200, 210, 230, 0.4);
}
.hero-top-card.place-2 .ht-place { color: var(--medal-2); }
.hero-top-card.place-2 .ht-kd { color: var(--medal-2); }

.hero-top-card.place-3 {
  background: linear-gradient(160deg, rgba(224, 160, 106, 0.2), rgba(160, 100, 60, 0.06));
  border-color: rgba(224, 160, 106, 0.4);
}
.hero-top-card.place-3 .ht-place { color: var(--medal-3); }
.hero-top-card.place-3 .ht-kd { color: var(--medal-3); }

.hero-top-card.empty {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

@keyframes kdGlow {
  0%, 100% { text-shadow: 0 0 14px rgba(255, 215, 0, 0.25); filter: brightness(1); }
  50% { text-shadow: 0 0 28px rgba(255, 215, 0, 0.45); filter: brightness(1.08); }
}

/* —— Tabs —— */
.tabs {
  display: flex;
  gap: 0;
  padding: 0 8px;
  margin: 0 8px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: sticky;
  top: 6px;
  z-index: 20;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  position: relative;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
}

/* —— Panels / crossfade —— */
.panel {
  display: none;
  padding: 10px 0 24px;
  opacity: 0;
}
.panel.active {
  display: block;
  animation: panelIn 0.28s var(--ease-out) both;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.toolbar {
  padding: 0 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search {
  width: 100%;
  appearance: none;
  border: 1px solid var(--border-strong);
  background: rgba(21, 34, 56, 0.85);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 14px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search::placeholder { color: #9aacc8; }
.search:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: rgba(21, 34, 56, 0.9);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a1200;
  box-shadow: 0 0 14px var(--accent-glow-strong);
}

.map-chips .chip { font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em; }

/* —— Top-3 podium —— */
.podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 8px;
  align-items: end;
  padding: 4px 12px 14px;
  perspective: 800px;
}

.podium[hidden] { display: none !important; }

.podium-card {
  position: relative;
  padding: 12px 8px 10px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(30, 48, 78, 0.9), rgba(16, 26, 44, 0.95));
  border: 1px solid var(--border);
  text-align: center;
  cursor: pointer;
  transform-style: preserve-3d;
  box-shadow:
    var(--shadow-soft),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.2s var(--ease-out), border-color 0.15s, box-shadow 0.2s;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.podium-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent);
  pointer-events: none;
}

.podium-card:active {
  transform: scale(0.96) translateY(2px);
}

.podium-card.place-1 {
  transform: translateY(-10px) rotateX(4deg);
  border-color: rgba(255, 215, 0, 0.45);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.5),
    0 0 28px rgba(255, 215, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  order: 2;
  padding-top: 16px;
  padding-bottom: 14px;
}

.podium-card.place-2 {
  transform: rotateY(4deg) rotateX(2deg);
  border-color: rgba(215, 221, 232, 0.35);
  order: 1;
}

.podium-card.place-3 {
  transform: rotateY(-4deg) rotateX(2deg);
  border-color: rgba(224, 160, 106, 0.4);
  order: 3;
}

.podium-card.place-1:active { transform: translateY(-6px) scale(0.97); }
.podium-card.place-2:active { transform: rotateY(2deg) scale(0.96); }
.podium-card.place-3:active { transform: rotateY(-2deg) scale(0.96); }

.podium-place {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.podium-card.place-1 .podium-place { color: var(--medal-1); }
.podium-card.place-2 .podium-place { color: var(--medal-2); }
.podium-card.place-3 .podium-place { color: var(--medal-3); }

.podium-nick {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  margin-bottom: 4px;
}

.podium-card.place-1 .podium-nick { font-size: 13px; }

.podium-kd {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.podium-card.place-1 .podium-kd { font-size: 22px; }

.podium-meta {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
}

/* —— Table —— */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-height: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-table.rating-table {
  min-width: 720px;
}

.stats-table thead th {
  position: sticky;
  top: var(--header-h);
  z-index: 10;
  background: linear-gradient(180deg, #243650 0%, #1e2d48 100%);
  color: #dce6f5;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.tabs ~ main .stats-table thead th,
main .stats-table thead th {
  top: 0;
}

body .stats-table thead th {
  top: 52px;
}

.stats-table tbody tr {
  background: var(--bg-row);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s, transform 0.12s;
  opacity: 0;
  animation: rowIn 0.32s var(--ease-out) both;
}

.stats-table tbody tr:nth-child(even) { background: var(--bg-row-alt); }
.stats-table tbody tr:active,
.stats-table tbody tr:hover { background: #243552; }

/* Stagger up to ~20 rows; rest still animate with base delay */
.stats-table tbody tr:nth-child(1) { animation-delay: 0.02s; }
.stats-table tbody tr:nth-child(2) { animation-delay: 0.04s; }
.stats-table tbody tr:nth-child(3) { animation-delay: 0.06s; }
.stats-table tbody tr:nth-child(4) { animation-delay: 0.08s; }
.stats-table tbody tr:nth-child(5) { animation-delay: 0.1s; }
.stats-table tbody tr:nth-child(6) { animation-delay: 0.12s; }
.stats-table tbody tr:nth-child(7) { animation-delay: 0.14s; }
.stats-table tbody tr:nth-child(8) { animation-delay: 0.16s; }
.stats-table tbody tr:nth-child(9) { animation-delay: 0.18s; }
.stats-table tbody tr:nth-child(10) { animation-delay: 0.2s; }
.stats-table tbody tr:nth-child(11) { animation-delay: 0.22s; }
.stats-table tbody tr:nth-child(12) { animation-delay: 0.24s; }
.stats-table tbody tr:nth-child(n+13) { animation-delay: 0.26s; }

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

.stats-table td {
  padding: 9px 8px;
  vertical-align: middle;
  white-space: nowrap;
}

.col-rank { width: 36px; text-align: center !important; color: var(--text-dim); font-family: var(--mono); font-size: 12px; }
.col-nick { min-width: 100px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.col-kd { font-family: var(--mono); font-weight: 800; font-size: 15px; letter-spacing: -0.02em; }
.col-kdstr { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.col-adr { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.col-maps { font-family: var(--mono); font-size: 12px; color: var(--text-dim); text-align: right !important; }
.col-wr { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--text-dim); }
.col-wl { font-family: var(--mono); font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.col-dmg { font-family: var(--mono); font-size: 12px; color: var(--text-dim); text-align: right !important; }

.kd-high { color: var(--kd-high); }
.kd-mid { color: var(--kd-mid); }
.kd-low { color: var(--kd-low); }

.rank-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 11px;
  position: relative;
  overflow: hidden;
}

.rank-1 {
  color: #1a1400;
  background: linear-gradient(145deg, #ffe566, #ffd700 45%, #c9a000);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.45);
}
.rank-2 {
  color: #1a1c20;
  background: linear-gradient(145deg, #f0f3f8, #d7dde8 45%, #a8b0be);
  box-shadow: 0 0 8px rgba(215, 221, 232, 0.35);
}
.rank-3 {
  color: #1a1008;
  background: linear-gradient(145deg, #f0b878, #e0a06a 45%, #b07840);
  box-shadow: 0 0 8px rgba(224, 160, 106, 0.4);
}

.rank-medal::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -60%;
  width: 50%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  animation: medalShine 3.2s ease-in-out infinite;
}

@keyframes medalShine {
  0%, 70% { left: -60%; opacity: 0; }
  75% { opacity: 1; }
  100% { left: 120%; opacity: 0; }
}

/* —— Empty / loading —— */
.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 0 12px var(--accent-glow));
  opacity: 0.85;
}

.empty-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
}

.empty-sub {
  font-size: 12px;
  color: var(--text-mute);
  max-width: 240px;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 20px;
  color: var(--text-dim);
}

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

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

/* —— Matches list —— */
.matches-list {
  padding: 4px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 14px;
  background: linear-gradient(145deg, rgba(30, 48, 78, 0.9), rgba(18, 30, 52, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.18s var(--ease-out), border-color 0.15s, box-shadow 0.18s;
  -webkit-tap-highlight-color: transparent;
  animation: rowIn 0.3s var(--ease-out) both;
}

.match-card:nth-child(1) { animation-delay: 0.02s; }
.match-card:nth-child(2) { animation-delay: 0.05s; }
.match-card:nth-child(3) { animation-delay: 0.08s; }
.match-card:nth-child(4) { animation-delay: 0.11s; }
.match-card:nth-child(5) { animation-delay: 0.14s; }
.match-card:nth-child(n+6) { animation-delay: 0.16s; }

.match-card:active {
  transform: translateY(-3px) scale(1.01);
  border-color: var(--accent-dim);
  box-shadow: var(--shadow-lift);
}

.match-date {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.match-meta { font-size: 12px; color: var(--text-dim); }

.match-detail { padding: 0 0 16px; }

.back-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  text-shadow: 0 0 10px var(--accent-glow);
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  padding: 0 14px 8px;
}

.league-note {
  margin: 4px 14px 10px;
  padding: 9px 11px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(21, 34, 56, 0.8);
  border-left: 3px solid var(--accent-dim);
  border-radius: 0 8px 8px 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.footer {
  padding: 16px 14px 8px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

/* —— Bottom sheet —— */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 40;
  animation: fadeIn 0.22s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 88vh;
  max-width: 640px;
  margin: 0 auto;
  background: linear-gradient(180deg, #1a2c48 0%, #152238 40%, #101a2c 100%);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--border-strong);
  border-bottom: 0;
  z-index: 50;
  padding: 8px 14px calc(18px + var(--safe-b));
  overflow-y: auto;
  box-shadow:
    0 -16px 48px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(198, 255, 74, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: sheetSpring 0.42s var(--ease-spring);
}

.sheet.closing {
  animation: sheetDown 0.22s ease-in forwards;
}

@keyframes sheetSpring {
  0% { transform: translateY(105%); opacity: 0.5; }
  60% { transform: translateY(-3%); opacity: 1; }
  80% { transform: translateY(1.5%); }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes sheetDown {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(100%); opacity: 0.4; }
}

.sheet-handle {
  width: 40px; height: 4px;
  background: linear-gradient(90deg, transparent, var(--accent-dim), transparent);
  border-radius: 2px;
  margin: 4px auto 10px;
  opacity: 0.7;
}

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

.sheet-header h2 {
  font-size: 18px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  text-shadow: 0 0 16px var(--accent-glow);
}

.sheet-title-block {
  min-width: 0;
  flex: 1;
  padding-right: 8px;
}

.sheet-display {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-extra {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: -4px 0 14px;
}

.sheet-steam {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #0b1220;
  background: linear-gradient(135deg, #c6ff4a, #8fd3ff);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 14px rgba(198, 255, 74, 0.28);
  transition: transform 0.12s, filter 0.12s;
}

.sheet-steam:active {
  transform: scale(0.96);
  filter: brightness(0.95);
}

.sheet-prize-warn {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  color: #ffe0cc;
  background: rgba(255, 110, 64, 0.18);
  border: 1px solid rgba(255, 155, 107, 0.45);
}

.sheet-close {
  appearance: none;
  border: 0;
  background: rgba(11, 18, 32, 0.7);
  color: var(--text-dim);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border: 1px solid var(--border);
}

.sheet-overall {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-box {
  position: relative;
  background: rgba(11, 18, 32, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.stat-box::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(198, 255, 74, 0.25), transparent);
}

.stat-box .lbl {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
}

.stat-box .lbl .ico {
  font-size: 12px;
  opacity: 0.9;
}

.stat-box .val {
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
}

.sheet-section {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  margin: 8px 0 8px;
}

.permap-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.pmap {
  background: rgba(11, 18, 32, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.15s, transform 0.15s;
}

.pmap:active {
  transform: scale(0.97);
  border-color: var(--accent-dim);
}

.pmap .mname {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
}

.pmap .mkd {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 800;
  margin-top: 2px;
}

.pmap .meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  margin-top: 2px;
}

.sheet-matches { display: flex; flex-direction: column; gap: 6px; }

.sm-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: rgba(11, 18, 32, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  width: 100%;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.sm-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sm-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.sm-date { font-family: var(--mono); font-weight: 700; font-size: 11px; color: var(--text-mute); }
.sm-map { font-weight: 700; }
.sm-kd { font-family: var(--mono); font-weight: 800; }
.sm-meta { font-family: var(--mono); font-size: 11px; color: var(--text-mute); }

[hidden] { display: none !important; }

/* —— Reduced motion —— */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .hero-top-card.place-1 .ht-kd { animation: none; }
  .rank-medal::after { animation: none; display: none; }
  .stats-table tbody tr,
  .match-card,
  .panel.active {
    opacity: 1;
    transform: none;
    animation: none;
  }
  .podium-card.place-1,
  .podium-card.place-2,
  .podium-card.place-3 {
    transform: none;
  }
  .sheet { animation: none; }
  .loading-spinner { animation: spin 1.2s linear infinite; }
}

/* —— Me card —— */

.me-card.me-clickable {
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.me-card.me-clickable:active {
  transform: scale(0.985);
  border-color: rgba(198, 255, 74, 0.55);
  box-shadow: 0 0 18px rgba(198, 255, 74, 0.18);
}
.me-card {
  margin: 0 12px 10px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(198, 255, 74, 0.12), rgba(80, 140, 255, 0.1));
  border: 1px solid rgba(198, 255, 74, 0.28);
  box-shadow: var(--shadow-soft);
}
.me-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.me-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(198, 255, 74, 0.15);
  padding: 2px 8px;
  border-radius: 999px;
}
.me-name {
  font-weight: 700;
  font-size: 16px;
}
.me-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.me-stat {
  background: rgba(11, 18, 32, 0.45);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
}
.me-stat .lbl {
  font-size: 10px;
  color: var(--text-mute);
  margin-bottom: 4px;
}
.me-stat .val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}
.me-warn {
  margin-top: 8px;
  font-size: 12px;
  color: var(--kd-low);
  background: rgba(255, 155, 107, 0.12);
  border-radius: 8px;
  padding: 6px 10px;
}
.me-unlinked {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 4px;
}

/* —— Prizes —— */
.prize-hero {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
.prize-deadline {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
.prize-deadline strong {
  color: var(--accent);
}
.prize-rule {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}
.flag-bang {
  display: inline-block;
  color: var(--kd-low);
  font-weight: 800;
  background: rgba(255, 155, 107, 0.18);
  padding: 0 5px;
  border-radius: 4px;
}
.prize-winners {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.prize-win-card {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg-row);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
  cursor: default;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
button.prize-win-card {
  cursor: pointer;
}
button.prize-win-card:hover,
button.prize-win-card:active {
  background: #243552;
}
button.prize-win-card:active {
  transform: scale(0.97);
}
.prize-win-card.empty {
  opacity: 0.45;
}
.prize-win-card .pw-place {
  font-size: 11px;
  color: var(--text-mute);
  margin-bottom: 4px;
}
.prize-win-card.place-1 { border-color: rgba(255, 215, 0, 0.45); box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.12); }
.prize-win-card.place-2 { border-color: rgba(215, 221, 232, 0.35); }
.prize-win-card.place-3 { border-color: rgba(224, 160, 106, 0.4); }
.prize-win-card .pw-nick {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
  word-break: break-word;
}
.prize-win-card .pw-amount {
  color: var(--accent);
  font-weight: 800;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.prize-win-card .pw-meta {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 4px;
}
.nick-flag {
  color: var(--kd-low);
  font-weight: 800;
  margin-left: 3px;
}
.amount-cell {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.amount-preview {
  color: var(--text-mute);
  font-weight: 500;
  font-size: 12px;
}
.row-ineligible {
  opacity: 0.92;
}
.row-ineligible .col-nick {
  vertical-align: top;
}
.nick-line {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 4px;
}
.prize-warn {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.25;
  color: var(--kd-low);
  font-weight: 600;
}
.prize-elig-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: rgba(90, 200, 250, 0.14);
  border: 1px solid rgba(90, 200, 250, 0.35);
  white-space: nowrap;
}
.row-prize-winner {
  background: rgba(90, 200, 250, 0.06);
}
.row-prize-winner td {
  border-color: rgba(90, 200, 250, 0.18);
}
.section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 4px 12px 10px;
  letter-spacing: 0.01em;
}

@media (max-width: 380px) {
  .me-grid { grid-template-columns: repeat(2, 1fr); }
  .prize-winners { grid-template-columns: 1fr; }
}


/* —— Me row highlight —— */
.stats-table tbody tr.row-me,
.stats-table tbody tr.row-me:nth-child(even) {
  outline: 2px solid rgba(88, 166, 255, 0.95);
  outline-offset: -2px;
  background: linear-gradient(90deg, rgba(56, 132, 255, 0.28), rgba(56, 132, 255, 0.08)) !important;
  box-shadow: inset 4px 0 0 #58a6ff;
}
.stats-table tbody tr.row-me:hover,
.stats-table tbody tr.row-me:active {
  background: linear-gradient(90deg, rgba(198, 255, 74, 0.22), rgba(198, 255, 74, 0.1));
}
.podium-card.row-me {
  outline: 1px solid rgba(198, 255, 74, 0.55);
}

/* —— League CS W/L sides —— */
.league-sides {
  display: grid;
  gap: 12px;
  padding: 0 12px 16px;
}
.league-side {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.league-side-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.league-side-title.win { color: var(--kd-high); }
.league-side-title.lose { color: var(--kd-low); }
.league-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.league-pill {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.55);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.league-pill.win { border-color: rgba(125, 255, 154, 0.35); }
.league-pill.lose { border-color: rgba(255, 155, 107, 0.35); }
.league-pill:active { transform: scale(0.96); }

/* pmap as button */
button.pmap {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
}

.nick-cell { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.nick-cell .nick-main { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.nick-cell .nick-sub { font-size: 10px; font-weight: 500; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; }
.col-nick { min-width: 110px; max-width: 160px; }

/* —— Monday CS session maps in Лига —— */
.match-card-monday {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 12px;
  align-items: center;
}
.match-card-monday .match-date { grid-column: 1; grid-row: 1; }
.match-card-monday .match-series {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--accent, #c6ff4a);
  text-shadow: 0 0 18px rgba(198, 255, 74, 0.25);
}
.match-card-monday .match-meta {
  grid-column: 1;
  grid-row: 2;
  color: var(--text-dim);
}
.match-card-monday .match-maps-preview {
  grid-column: 1 / -1;
  grid-row: 3;
  font-size: 11px;
  color: var(--text-mute);
  line-height: 1.35;
  padding-top: 2px;
}
.match-session-maps { margin: 4px 0 10px; }
.match-maps-row td { padding: 0 !important; border: none !important; }
.league-series-header {
  background: linear-gradient(145deg, rgba(30, 48, 78, 0.95), rgba(18, 30, 52, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: center;
  margin-bottom: 4px;
}
.league-series-score {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 36px;
  letter-spacing: 0.04em;
  color: var(--accent, #c6ff4a);
  line-height: 1.1;
}
.league-series-label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.league-mvp-line {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text);
}
.league-mvp-line strong { color: var(--accent, #c6ff4a); }
.league-pill.mvp {
  border-color: rgba(198, 255, 74, 0.55);
  box-shadow: 0 0 12px rgba(198, 255, 74, 0.18);
  padding-right: 6px;
}
.mvp-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  vertical-align: middle;
  color: #0b1220;
  background: var(--accent, #c6ff4a);
}
.league-map-row.decided .league-map-name { color: var(--text); font-weight: 600; }
.league-maps {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.league-map-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
}
.league-map-row:last-child { border-bottom: none; }
.league-map-row.final .league-map-name { color: var(--kd-high); font-weight: 700; }
.league-map-name { font-weight: 600; }
.league-map-score { font-variant-numeric: tabular-nums; font-weight: 700; }
.league-map-meta { font-size: 11px; color: var(--text-mute); }


/* —— Zero score highlight (series 5–0 / map shutouts) —— */
.score-zero {
  color: #ff4d4d;
  font-weight: 800;
  text-shadow: 0 0 12px rgba(255, 77, 77, 0.35);
}
.match-card-monday .match-series .score-zero,
.league-series-score .score-zero {
  color: #ff3b3b;
  text-shadow: 0 0 16px rgba(255, 59, 59, 0.45);
}
.league-map-row.draw {
  opacity: 0.85;
}
.league-map-row.draw .league-map-meta {
  color: var(--text-mute);
  font-style: italic;
}
