/* ============================================================
   CONTROVETRO – BRAWL / ARCADE THEME
   Vibrant, chunky, sticker-style UI inspired by Brawl Stars,
   Fortnite and modern mobile games.
   ============================================================ */

:root {
  /* Sky / background */
  --bg-deep:      #2b1c6b;
  --bg-surface:   #3c2a86;
  --bg-surface-2: #4b37a3;
  --bg-surface-3: #5a45b8;
  --border:       #241352;
  --border-glow:  #ffd93d;

  /* Vibrant palette */
  --bs-yellow:    #ffd93d;
  --bs-blue:      #4dabf7;
  --bs-purple:    #a06bff;
  --bs-pink:      #ff4d94;
  --bs-green:     #51cf66;
  --bs-orange:    #ff922b;
  --bs-red:       #ff5c5c;

  /* Legacy aliases (used inline in app.js) */
  --neon-cyan:    #4dabf7;
  --neon-green:   #51cf66;
  --neon-pink:    #ff4d94;
  --neon-yellow:  #ffd93d;
  --neon-purple:  #a06bff;
  --neon-orange:  #ff922b;

  /* Teams */
  --team-a:       #4dabf7;
  --team-b:       #ff4d94;

  /* Ranks */
  --rank-gold:    #ffcf40;
  --rank-silver:  #dfe6f5;
  --rank-bronze:  #ff9f5a;
  --rank-diamond: #7de3ff;

  /* Text */
  --text-main:    #ffffff;
  --text-dim:     #cfc6ff;
  --text-muted:   #9b8fd6;

  /* Fonts */
  --font-display: 'Lilita One', 'Trebuchet MS', -apple-system, sans-serif;
  --font-body:    'Nunito', -apple-system, sans-serif;

  /* Sticker look */
  --ink:          #241352;
  --shadow-hard:  0 7px 0 #1b0d3d;
  --radius:       20px;
  --radius-sm:    14px;

  /* Not used anymore – kept for compatibility */
  --clip-chamfer: none;
  --clip-badge:   none;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--text-main);
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(255, 217, 61, 0.28), transparent 38%),
    radial-gradient(circle at 88% 4%, rgba(255, 77, 148, 0.30), transparent 42%),
    radial-gradient(circle at 50% 100%, rgba(77, 171, 247, 0.35), transparent 55%),
    linear-gradient(180deg, #7b5cff 0%, #5a7cff 45%, #2b1c6b 100%);
  background-attachment: fixed;
}

/* Bolle / stelle decorative sullo sfondo */
.cyber-bg-lines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.16) 0 6px, transparent 7px),
    radial-gradient(circle at 72% 14%, rgba(255, 255, 255, 0.13) 0 9px, transparent 10px),
    radial-gradient(circle at 42% 62%, rgba(255, 255, 255, 0.10) 0 14px, transparent 15px),
    radial-gradient(circle at 88% 74%, rgba(255, 255, 255, 0.12) 0 7px, transparent 8px),
    radial-gradient(circle at 8% 84%, rgba(255, 255, 255, 0.10) 0 11px, transparent 12px);
  background-size: 100% 100%;
  z-index: 1;
}

#app {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Canvas particelle / coriandoli vittoria */
#fx-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* ── HEADER ─────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, #33207c, #2a1a66);
  border-bottom: 4px solid var(--ink);
  box-shadow: 0 6px 0 rgba(27, 13, 61, 0.55);
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
}

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

.logo {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-shadow: 0 3px 0 var(--ink), 0 0 14px rgba(0, 0, 0, 0.35);
}

.logo-ball {
  display: inline-block;
  filter: drop-shadow(0 3px 0 rgba(27, 13, 61, 0.6));
  animation: pulse-ball 2s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}
@keyframes pulse-ball {
  0%, 100% { transform: scale(1) rotate(-6deg); }
  50%      { transform: scale(1.15) rotate(8deg); }
}

.logo-text { color: #fff; }

.logo-accent {
  color: var(--bs-yellow);
  text-shadow: 0 3px 0 #a5620a, 0 0 18px rgba(255, 217, 61, 0.55);
}

.logo-tag {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  background: var(--bs-yellow);
  border: 3px solid var(--ink);
  color: #4a2c00;
  border-radius: 999px;
  box-shadow: 0 3px 0 #a5620a;
  transform: rotate(-4deg);
}

/* ── NAV ────────────────────────────────────────────────────── */
.nav {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-btn { flex: 0 0 auto; white-space: nowrap; }

.nav-btn {
  font-family: var(--font-display);
  background: var(--bg-surface);
  border: 3px solid var(--ink);
  color: var(--text-dim);
  padding: 8px 13px;
  cursor: pointer;
  font-size: 0.85rem;
  letter-spacing: 0.01em;
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.12s ease;
}

.nav-btn:hover {
  background: var(--bg-surface-2);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
}

.nav-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.nav-btn.active {
  background: linear-gradient(180deg, #ffd93d, #ffb300);
  border-color: var(--ink);
  color: #4a2c00;
  box-shadow: 0 4px 0 #a5620a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.nav-btn.active::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 999px;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5);
  pointer-events: none;
}

/* ── HEADER CONTROLS ────────────────────────────────────────── */
.btn-icon-audio, .btn-icon-cloud {
  background: var(--bg-surface);
  border: 3px solid var(--ink);
  color: var(--text-dim);
  width: 40px;
  height: 40px;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
}

.btn-icon-audio:hover, .btn-icon-cloud:hover {
  background: var(--bg-surface-2);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
}

.btn-icon-audio:active, .btn-icon-cloud:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn-sync-quick {
  font-family: var(--font-display);
  background: var(--bs-blue);
  border: 3px solid var(--ink);
  color: #062a4d;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  box-shadow: 0 4px 0 #1a5c9e;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease;
}

.btn-sync-quick:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #1a5c9e;
}

.btn-sync-quick:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #1a5c9e;
}

.sync-icon {
  display: inline-block;
  font-size: 0.95rem;
}
.sync-icon.spinning {
  animation: spin 0.8s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(6, 42, 77, 0.35);
}
.sync-dot.synced  { background: var(--bs-green); box-shadow: 0 0 0 2px #062a4d; }
.sync-dot.syncing { background: var(--bs-yellow); box-shadow: 0 0 0 2px #062a4d; }
.sync-dot.error   { background: var(--bs-red); box-shadow: 0 0 0 2px #062a4d; }

/* ── MAIN ───────────────────────────────────────────────────── */
.main {
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  flex: 1 0 auto;
  padding: 26px 18px 100px;
}

.app-footer {
  position: relative;
  z-index: 2;
  border-top: 4px solid var(--ink);
  background: linear-gradient(180deg, #33207c, #241352);
  box-shadow: 0 -6px 0 rgba(27, 13, 61, 0.35);
}
.footer-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer-brand {
  font-family: var(--font-display);
  color: var(--text-dim);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.footer-brand small {
  color: var(--bs-yellow);
  font-size: 0.68rem;
  margin-left: 6px;
}
.footer-sync-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.footer-sync-label {
  color: var(--text-dim);
  font-size: 0.82rem;
  white-space: nowrap;
}

.page { display: none; }
.page.active {
  display: block;
  animation: popIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

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

.badge-header {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--bs-yellow);
  text-transform: uppercase;
  display: inline-block;
  margin-bottom: 4px;
  text-shadow: 0 2px 0 var(--ink);
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow: 0 4px 0 var(--ink), 0 0 20px rgba(0, 0, 0, 0.25);
  line-height: 1.15;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.92rem;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(27, 13, 61, 0.6);
}

.section-label {
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 0 2px 0 var(--ink);
}

.live-label {
  color: var(--bs-pink);
  text-shadow: 0 2px 0 var(--ink);
}

.live-pulse-dot {
  width: 12px;
  height: 12px;
  background: var(--bs-pink);
  border: 2px solid var(--ink);
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 0.9s ease-in-out infinite alternate;
}
@keyframes pulse-dot {
  from { opacity: 0.5; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1.15); }
}

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-display);
  padding: 12px 22px;
  cursor: pointer;
  font-size: 1rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn:active {
  transform: translateY(4px) !important;
  box-shadow: 0 1px 0 var(--ink) !important;
}

.btn-primary.btn-arcade {
  background: linear-gradient(180deg, #ffe066, #ffc400);
  color: #4a2c00;
  box-shadow: 0 6px 0 #a5620a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.btn-primary.btn-arcade:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #a5620a;
}

.btn-glow-text { display: inline-block; }

.btn-secondary {
  background: var(--bg-surface-2);
  color: #fff;
  box-shadow: 0 5px 0 var(--ink);
}
.btn-secondary:hover {
  background: var(--bg-surface-3);
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--ink);
}

.btn-danger {
  background: linear-gradient(180deg, #ff6b6b, #ee3b3b);
  color: #fff;
  box-shadow: 0 6px 0 #8c1414;
}
.btn-danger:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #8c1414;
}

.btn-icon {
  padding: 7px 11px;
  border-radius: 12px;
  border: 3px solid var(--ink);
  cursor: pointer;
  font-size: 0.95rem;
  background: var(--bg-surface-2);
  color: var(--text-dim);
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease;
}
.btn-icon:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}
.btn-icon-edit:hover  { background: var(--bs-blue);   color: #062a4d; }
.btn-icon-del:hover   { background: var(--bs-red);    color: #fff; }
.btn-icon-score {
  font-family: var(--font-display);
  background: linear-gradient(180deg, #63e07a, #35b84b);
  border: 3px solid var(--ink);
  color: #fff;
  font-size: 0.85rem;
  padding: 7px 13px;
  border-radius: 999px;
  box-shadow: 0 4px 0 #1d742d;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.btn-icon-score:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #1d742d;
}

/* ── TOGGLE GROUP ───────────────────────────────────────────── */
.toggle-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.toggle-btn {
  font-family: var(--font-display);
  background: var(--bg-surface);
  border: 3px solid var(--ink);
  color: var(--text-dim);
  padding: 9px 15px;
  cursor: pointer;
  font-size: 0.88rem;
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.12s ease, background 0.2s ease, color 0.2s ease;
}
.toggle-btn:hover {
  background: var(--bg-surface-2);
  color: #fff;
}
.toggle-btn.active {
  background: linear-gradient(180deg, #ffe066, #ffc400);
  color: #4a2c00;
  border-color: var(--ink);
  box-shadow: 0 4px 0 #a5620a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.toggle-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.toggle-btn small { font-family: var(--font-body); font-weight: 800; opacity: 0.8; }

/* ── RANKING / LEADERBOARD ──────────────────────────────────── */
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rank-card {
  background: var(--bg-surface);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  box-shadow: var(--shadow-hard);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.2s ease;
}
.rank-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 0 #1b0d3d;
  background: var(--bg-surface-2);
}

.rank-card.rank-1 {
  background: linear-gradient(135deg, #ffdf5e, #ffb400);
  border-color: var(--ink);
  box-shadow: 0 7px 0 #a5620a;
}
.rank-card.rank-1::before {
  content: '👑 CHAMPION';
  position: absolute;
  top: -14px;
  left: 18px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: #6b3d00;
  background: #fff4c2;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  box-shadow: 0 3px 0 #a5620a;
}
.rank-card.rank-1 .rank-name,
.rank-card.rank-1 .rank-elo-label { color: #4a2c00; }
.rank-card.rank-1 .rank-stats   { color: #6b3d00; }
.rank-card.rank-1 .rank-elo     { color: #fff; text-shadow: 0 3px 0 #a5620a; }
.rank-card.rank-1 .rank-power-bar-wrap { background: rgba(74, 44, 0, 0.28); }

.rank-card.rank-2 {
  background: linear-gradient(135deg, #e9efff, #c3d0ee);
  border-color: var(--ink);
  box-shadow: 0 7px 0 #7d8bab;
}
.rank-card.rank-2 .rank-name,
.rank-card.rank-2 .rank-elo-label { color: #2a3348; }
.rank-card.rank-2 .rank-stats   { color: #48536e; }
.rank-card.rank-2 .rank-elo     { color: #2a3348; text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7); }
.rank-card.rank-2 .rank-power-bar-wrap { background: rgba(42, 51, 72, 0.22); }

.rank-card.rank-3 {
  background: linear-gradient(135deg, #ffc596, #ff9f5a);
  border-color: var(--ink);
  box-shadow: 0 7px 0 #b25f22;
}
.rank-card.rank-3 .rank-name,
.rank-card.rank-3 .rank-elo-label { color: #54270a; }
.rank-card.rank-3 .rank-stats   { color: #7a3d12; }
.rank-card.rank-3 .rank-elo     { color: #fff; text-shadow: 0 3px 0 #b25f22; }
.rank-card.rank-3 .rank-power-bar-wrap { background: rgba(84, 39, 10, 0.25); }

.rank-pos {
  font-family: var(--font-display);
  font-size: 1.9rem;
  min-width: 46px;
  text-align: center;
  color: var(--text-dim);
  text-shadow: 0 2px 0 var(--ink);
}
.rank-card.rank-1 .rank-pos { color: #fff; text-shadow: 0 3px 0 #a5620a; }
.rank-card.rank-2 .rank-pos { color: #fff; text-shadow: 0 3px 0 #7d8bab; }
.rank-card.rank-3 .rank-pos { color: #fff; text-shadow: 0 3px 0 #b25f22; }

.rank-avatar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 3px solid var(--ink);
  flex-shrink: 0;
}
.rank-card.rank-1 .rank-avatar-wrap,
.rank-card.rank-2 .rank-avatar-wrap,
.rank-card.rank-3 .rank-avatar-wrap {
  background: #fff;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}
.rank-emoji {
  font-size: 2.1rem;
  line-height: 1;
}

.rank-info {
  flex: 1;
  min-width: 0;
}

.rank-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rank-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow: 0 2px 0 var(--ink);
}
.rank-card.rank-1 .rank-name,
.rank-card.rank-2 .rank-name,
.rank-card.rank-3 .rank-name { text-shadow: none; }

.rank-tier-badge {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  padding: 2px 9px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  text-transform: uppercase;
  box-shadow: 0 2px 0 var(--ink);
}
.tier-diamond { background: #b9f3ff; color: #075a6e; }
.tier-gold    { background: #ffe07a; color: #6b3d00; }
.tier-silver  { background: #eef2fb; color: #3b4663; }
.tier-bronze  { background: #ffbe8a; color: #6b3208; }

.rank-power-bar-wrap {
  width: 100%;
  max-width: 280px;
  height: 10px;
  background: rgba(27, 13, 61, 0.55);
  border: 2px solid var(--ink);
  border-radius: 999px;
  margin: 7px 0;
  overflow: hidden;
}
.rank-power-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7de3ff, #51cf66);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.45);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rank-stats {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-dim);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.rank-stat {
  display: flex;
  gap: 4px;
  align-items: center;
}
.stat-highlight {
  color: var(--bs-green);
  font-weight: 900;
}
.rank-card.rank-1 .stat-highlight,
.rank-card.rank-2 .stat-highlight,
.rank-card.rank-3 .stat-highlight { color: inherit; }

.rank-elo-wrap {
  text-align: right;
  min-width: 80px;
}
.rank-elo-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.rank-elo {
  font-family: var(--font-display);
  font-size: 1.9rem;
  letter-spacing: 0.01em;
  color: var(--bs-yellow);
  text-shadow: 0 3px 0 var(--ink), 0 0 16px rgba(255, 217, 61, 0.45);
  line-height: 1.1;
}

/* ── MATCHES ────────────────────────────────────────────────── */
.matches-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.match-card {
  background: var(--bg-surface);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 16px 20px;
  position: relative;
  box-shadow: var(--shadow-hard);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.2s ease;
}
.match-card:hover {
  background: var(--bg-surface-2);
  transform: translateY(-2px);
  box-shadow: 0 9px 0 #1b0d3d;
}

.match-card.ongoing {
  background: linear-gradient(135deg, #4b37a3, #5f3fb5);
  box-shadow: 0 7px 0 #1b0d3d, 0 0 0 3px rgba(255, 77, 148, 0.35);
  animation: pulse-border 1.6s ease-in-out infinite alternate;
}
@keyframes pulse-border {
  from { box-shadow: 0 7px 0 #1b0d3d, 0 0 0 3px rgba(255, 77, 148, 0.2); }
  to   { box-shadow: 0 7px 0 #1b0d3d, 0 0 0 6px rgba(255, 77, 148, 0.45); }
}

.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 3px dashed rgba(255, 255, 255, 0.16);
}
.match-date {
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.match-type-badge {
  font-family: var(--font-display);
  font-size: 0.72rem;
  padding: 3px 10px;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  border-radius: 999px;
}
.match-actions { display: flex; gap: 8px; align-items: center; }
.match-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.match-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
}

.match-team {
  text-align: center;
  padding: 10px;
  background: rgba(27, 13, 61, 0.28);
  border-radius: var(--radius-sm);
  border: 3px solid transparent;
}
.match-team-a { border-color: rgba(77, 171, 247, 0.55); background: rgba(77, 171, 247, 0.16); }
.match-team-b { border-color: rgba(255, 77, 148, 0.55); background: rgba(255, 77, 148, 0.16); }

.match-team-name {
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  text-shadow: 0 2px 0 var(--ink);
}
.team-a-label { color: #9dd3ff; }
.team-b-label { color: #ffa8c9; }

.match-player {
  font-size: 0.98rem;
  font-weight: 800;
  color: #fff;
  padding: 1px 0;
  text-shadow: 0 1px 0 rgba(27, 13, 61, 0.8);
}

.vs-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}
.vs-text {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-style: italic;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 3px 0 var(--ink), 0 0 18px rgba(255, 77, 148, 0.6);
  transform: rotate(-6deg);
}

.match-score {
  text-align: center;
  background: rgba(27, 13, 61, 0.45);
  border: 3px solid var(--ink);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  min-width: 118px;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.08);
}
.score-display {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.1;
}
.score-a { color: #7cc4ff; text-shadow: 0 2px 0 var(--ink); }
.score-b { color: #ff86b3; text-shadow: 0 2px 0 var(--ink); }
.score-divider { color: var(--text-muted); }
.score-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.match-winner-badge {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  padding: 3px 10px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  margin-top: 6px;
  display: inline-block;
  box-shadow: 0 3px 0 var(--ink);
}
.winner-a { background: #4dabf7; color: #062a4d; }
.winner-b { background: #ff4d94; color: #4a0722; }

/* ── TOURNAMENTS ────────────────────────────────────────────── */
.tourn-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tourn-card {
  background: var(--bg-surface);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 18px 22px;
  position: relative;
  box-shadow: var(--shadow-hard);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.tourn-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 9px 0 #1b0d3d;
}
.tourn-card.ongoing {
  background: linear-gradient(135deg, #4b37a3, #5a45b8);
  box-shadow: 0 7px 0 #1b0d3d, 0 0 0 3px rgba(255, 217, 61, 0.35);
}

.tourn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.tourn-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow: 0 2px 0 var(--ink);
}
.tourn-date {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-dim);
}

.tourn-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.tourn-badge {
  font-family: var(--font-display);
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.24);
  color: var(--text-dim);
}
.tourn-badge.live {
  background: var(--bs-pink);
  border-color: var(--ink);
  color: #4a0722;
  box-shadow: 0 2px 0 var(--ink);
}
.tourn-badge.done {
  background: var(--bs-green);
  border-color: var(--ink);
  color: #0b3d16;
  box-shadow: 0 2px 0 var(--ink);
}

.tourn-progress {
  margin: 14px 0;
}
.progress-bar-track {
  background: rgba(27, 13, 61, 0.55);
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  border: 3px solid var(--ink);
}
.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7de3ff, #51cf66, #ffd93d);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.45);
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.progress-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 6px;
}

.tourn-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
  margin-top: 10px;
}
.tourn-table th {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  border-bottom: 3px solid rgba(255, 255, 255, 0.18);
}
.tourn-table td {
  padding: 9px 10px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
}
.tourn-table .t-pos {
  font-family: var(--font-display);
  text-align: center;
  width: 38px;
}
.tourn-table .t-pts {
  font-family: var(--font-display);
  color: var(--bs-yellow);
  text-shadow: 0 2px 0 var(--ink);
}

.matchup-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.matchup-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  padding: 12px 14px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 0 rgba(27, 13, 61, 0.7);
}
.matchup-row.done {
  background: rgba(81, 207, 102, 0.14);
}
.matchup-couple {
  font-size: 0.94rem;
  font-weight: 800;
  text-align: center;
}
.matchup-score {
  font-family: var(--font-display);
  font-size: 1.3rem;
  min-width: 64px;
  text-align: center;
}

/* ── PLAYERS ────────────────────────────────────────────────── */
.players-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.player-card {
  background: var(--bg-surface);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  box-shadow: var(--shadow-hard);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.2s ease;
}
.player-card:hover {
  background: var(--bg-surface-2);
  transform: translateY(-4px);
  box-shadow: 0 11px 0 #1b0d3d;
}
.player-avatar {
  font-size: 3rem;
  line-height: 1;
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 3px solid var(--ink);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.15);
}
.player-card-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow: 0 2px 0 var(--ink);
}
.player-card-elo {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--bs-yellow);
  text-shadow: 0 2px 0 var(--ink);
}

/* ── MODALS ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 8, 48, 0.78);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(6px);
  animation: popIn 0.2s ease;
}
.modal-overlay.hidden { display: none !important; }

#modal-match, #modal-tournament, #modal-tourn-detail, #modal-player { z-index: 200; }
#modal-sync    { z-index: 240; }
#modal-result  { z-index: 280; }
#modal-confirm { z-index: 320; }

.modal {
  background: linear-gradient(180deg, #4b37a3, #3c2a86);
  border: 4px solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 12px 0 #1b0d3d, 0 24px 50px rgba(0, 0, 0, 0.55);
  width: 100%;
  max-width: 660px;
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-sm   { max-width: 460px; }
.modal-wide { max-width: 840px; }

.modal-header {
  padding: 16px 22px;
  border-bottom: 3px solid rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.06);
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow: 0 2px 0 var(--ink);
}
.modal-close {
  background: rgba(255, 255, 255, 0.12);
  border: 3px solid var(--ink);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.12s ease, background 0.2s ease;
}
.modal-close:hover { background: var(--bs-red); }
.modal-close:active { transform: translateY(3px); box-shadow: none; }

.modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-footer {
  padding: 16px 22px;
  border-top: 3px solid rgba(255, 255, 255, 0.14);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(27, 13, 61, 0.3);
  flex-wrap: wrap;
}

.teams-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
}
.team-card {
  background: rgba(255, 255, 255, 0.08);
  padding: 14px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.team-card.team-a { border-color: var(--team-a); background: rgba(77, 171, 247, 0.16); }
.team-card.team-b { border-color: var(--team-b); background: rgba(255, 77, 148, 0.16); }
.team-label {
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 var(--ink);
}

.player-select-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.player-select-group label {
  font-size: 0.85rem;
  color: #e9e2ff;
  font-weight: 800;
}

select, input[type="text"], input[type="password"], input[type="number"], input[type="date"] {
  background: #2a1a66;
  border: 3px solid var(--ink);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 1rem;
  font-family: var(--font-body);
  font-weight: 800;
  width: 100%;
  outline: none;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s, box-shadow 0.2s;
}
select:focus, input:focus {
  border-color: var(--bs-yellow);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.25), 0 0 0 4px rgba(255, 217, 61, 0.3);
}
select option { background: #2a1a66; }

.score-section {
  background: rgba(27, 13, 61, 0.3);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 3px solid rgba(255, 255, 255, 0.14);
}
.score-section h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
  color: #e9e2ff;
}
.score-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.score-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.score-box label { font-family: var(--font-display); font-size: 0.85rem; color: var(--text-dim); }
.score-box input {
  font-family: var(--font-display);
  font-size: 1.8rem;
  text-align: center;
  width: 84px;
  background: #2a1a66;
  border-color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 6px;
}
.score-sep {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--text-muted);
}
.score-hint {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-family: var(--font-display);
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  color: #e9e2ff;
}

.couple-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 10px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
}
.couple-row-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--bs-yellow);
  grid-column: 1 / -1;
  margin-bottom: 2px;
  text-shadow: 0 2px 0 var(--ink);
}
.couple-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.couple-actions .btn { flex: 0 0 auto; }
.couple-actions .score-hint { margin-top: 0; text-align: left; }

.result-preview {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.1rem;
  border: 3px solid rgba(255, 255, 255, 0.16);
  line-height: 1.5;
}

.sync-info-box {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  font-size: 0.92rem;
  font-weight: 700;
}
.volume-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.volume-label output {
  color: var(--bs-yellow);
  font-family: var(--font-display);
}
.volume-control {
  display: flex;
  align-items: center;
  gap: 12px;
}
.volume-control input[type="range"] {
  flex: 1;
  accent-color: var(--bs-yellow);
  cursor: pointer;
}
.sync-status-badge-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 3px dashed rgba(255, 255, 255, 0.16);
  font-family: var(--font-display);
  font-size: 0.8rem;
  gap: 8px;
  flex-wrap: wrap;
}
.sync-badge {
  color: var(--bs-green);
}
.sync-time { color: var(--text-muted); }
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-dim);
}
.checkbox-container input {
  width: 22px;
  height: 22px;
  accent-color: var(--bs-yellow);
  flex-shrink: 0;
}
.sync-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: rgba(27, 13, 61, 0.3);
  border-radius: var(--radius-sm);
  border: 3px solid rgba(255, 255, 255, 0.14);
}
.emoji-option {
  font-size: 1.6rem;
  padding: 5px;
  border-radius: 12px;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.12s ease, background 0.15s;
  line-height: 1;
}
.emoji-option:hover { background: rgba(255, 255, 255, 0.14); transform: scale(1.12); }
.emoji-option.selected { border-color: var(--bs-yellow); background: rgba(255, 217, 61, 0.22); }

/* ── TOAST ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bs-blue);
  border: 4px solid var(--ink);
  box-shadow: 0 7px 0 #1a5c9e;
  color: #062a4d;
  padding: 13px 30px;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.02em;
  z-index: 99999;
  border-radius: 999px;
  white-space: nowrap;
  animation: toastPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes toastPop {
  from { transform: translate(-50%, 24px) scale(0.9); opacity: 0; }
  to   { transform: translate(-50%, 0) scale(1); opacity: 1; }
}
.toast.hidden { display: none; }
.toast.success { background: #51cf66; box-shadow: 0 7px 0 #1d742d; color: #0b3d16; }
.toast.error   { background: #ff6b6b; box-shadow: 0 7px 0 #8c1414; color: #4a0707; }

/* ── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-dim);
  background: rgba(27, 13, 61, 0.22);
  border: 3px dashed rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
}
.empty-state .empty-icon {
  font-size: 3.4rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 0 rgba(27, 13, 61, 0.55));
}
.empty-state p {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.02em;
  line-height: 1.6;
}

/* ── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #2a1a66; }
::-webkit-scrollbar-thumb { background: #6b53c9; border: 2px solid #2a1a66; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--bs-yellow); }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 620px) {
  .header-inner { flex-direction: column; align-items: stretch; gap: 9px; }
  .header-brand { justify-content: space-between; padding-right: 50px; }
  .nav { justify-content: flex-start; width: 100%; padding: 0 2px 4px; }
  .logo { font-size: 1.35rem; }
  .nav-btn { padding: 8px 11px; font-size: 0.8rem; }
  .page-header h2 { font-size: 1.55rem; }
  .teams-grid { grid-template-columns: 1fr; }
  .vs-divider { margin: 4px 0; }
  .form-row   { grid-template-columns: 1fr; }
  .players-list { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .matchup-row  { font-size: 0.82rem; padding: 10px; }
  .tourn-table  { font-size: 0.82rem; }
  .sync-actions-row { grid-template-columns: 1fr; }
  .rank-card { padding: 12px 14px; gap: 10px; }
  .rank-avatar-wrap { width: 52px; height: 52px; }
  .rank-emoji { font-size: 1.7rem; }
  .rank-name { font-size: 1.05rem; }
  .rank-elo { font-size: 1.5rem; }
  .match-teams { gap: 8px; }
  .match-card { padding: 14px; }
  .modal-footer { justify-content: stretch; }
  .modal-footer .btn { flex: 1; }
  .footer-inner { align-items: stretch; flex-direction: column; gap: 12px; padding: 16px 18px 20px; }
  .footer-brand { text-align: center; }
  .footer-sync-tools { justify-content: center; }
  .couple-actions { align-items: stretch; flex-direction: column; }
  .couple-actions .btn { width: 100%; }
}

@media (max-width: 420px) {
  .main { padding: 20px 12px 72px; }
  .header-inner { padding: 10px 12px; }
  .logo { font-size: 1.18rem; gap: 5px; }
  .logo-tag { font-size: 0.62rem; padding: 3px 7px; }
  .nav { gap: 6px; }
  .nav-btn { padding: 7px 9px; font-size: 0.74rem; border-width: 2px; box-shadow: 0 3px 0 var(--ink); }
  .nav-icon { display: none; }
  .page-header { align-items: stretch; }
  .page-header > .btn { width: 100%; }
  .footer-sync-label { display: none; }
  .footer-sync-tools { gap: 10px; }
}

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