* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  background:
    radial-gradient(ellipse 60% 40% at 12% -5%, rgba(34, 224, 255, 0.4), transparent 60%),
    radial-gradient(ellipse 55% 35% at 100% 10%, rgba(255, 138, 43, 0.32), transparent 60%),
    radial-gradient(ellipse 70% 50% at 50% 120%, rgba(34, 224, 255, 0.18), transparent 65%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 45%);
  color: var(--text);
  font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding-bottom: 92px;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(72deg, transparent 0 60px, rgba(34, 224, 255, 0.26) 60px 63px, transparent 63px 128px),
    repeating-linear-gradient(112deg, transparent 0 84px, rgba(255, 138, 43, 0.22) 84px 87px, transparent 87px 166px),
    repeating-linear-gradient(38deg, transparent 0 100px, rgba(34, 224, 255, 0.18) 100px 102px, transparent 102px 200px),
    repeating-linear-gradient(-52deg, transparent 0 140px, rgba(255, 138, 43, 0.14) 140px 142px, transparent 142px 240px),
    repeating-linear-gradient(20deg, transparent 0 160px, rgba(34, 224, 255, 0.12) 160px 162px, transparent 162px 260px);
  mask-image: radial-gradient(ellipse 95% 85% at 50% 0%, black 45%, transparent 95%);
  -webkit-mask-image: radial-gradient(ellipse 95% 85% at 50% 0%, black 45%, transparent 95%);
}

#app { position: relative; z-index: 1; }

/* ---------- loading splash: cyber football ---------- */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background:
    radial-gradient(ellipse 70% 45% at 50% 30%, rgba(34, 224, 255, 0.22), transparent 65%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 55%);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#loading-screen.loading-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-ball-bob {
  position: relative;
  width: 112px;
  height: 112px;
  animation: loading-bob 1.4s ease-in-out infinite;
}

.cyber-ball { width: 100%; height: 100%; filter: drop-shadow(0 0 14px rgba(34, 224, 255, 0.55)); }
.cyber-ball-spin { transform-origin: 50px 50px; animation: loading-spin 3.2s linear infinite; }

.seam { fill: none; stroke-linejoin: round; }
.seam-cyan { stroke: #7ceeff; stroke-width: 1.6; }
.seam-accent { stroke: var(--accent); stroke-width: 1.4; fill: rgba(255, 138, 43, 0.08); }
.ball-outline { fill: none; stroke: var(--primary); stroke-width: 2; }

.loading-ball-shadow {
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 70px;
  height: 12px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(34, 224, 255, 0.4), transparent 70%);
  animation: loading-shadow 1.4s ease-in-out infinite;
}

.loading-bar {
  width: 200px;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  border: 1.5px solid var(--border-dim);
  background: rgba(5, 7, 14, 0.6);
}

.loading-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) 48%, var(--accent) 52%, var(--accent) 100%);
  box-shadow: 0 0 10px rgba(34, 224, 255, 0.7), 0 0 10px rgba(255, 138, 43, 0.6);
  animation: loading-fill 1.8s ease-out forwards;
}

#loading-screen.loading-done .loading-bar-fill {
  width: 100% !important;
  animation: none;
}

.loading-text {
  margin: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

@keyframes loading-spin { to { transform: rotate(360deg); } }
@keyframes loading-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes loading-shadow { 0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.7; } 50% { transform: translateX(-50%) scale(0.7); opacity: 0.35; } }
@keyframes loading-fill { from { width: 0; } to { width: 88%; } }

@media (prefers-reduced-motion: reduce) {
  .loading-ball-bob, .cyber-ball-spin, .loading-ball-shadow, .loading-bar-fill { animation: none; }
  .loading-bar-fill { width: 88%; }
}

/* ---------- photo-backdrop mode (leaderboard tab): higgsfield-generated
   assets used as real pixels — a UI-free background plate, plus real
   button/card artwork with idle+active states. Scaled uniformly
   (aspect-ratio + background-size:100% 100%, never a fixed height that
   would stretch the art non-uniformly) so nothing distorts at any width. */
body.bg-photo::before {
  background-image: url('../assets/background.webp');
  background-size: cover;
  background-position: top center;
  background-repeat: no-repeat;
  mask-image: none;
  -webkit-mask-image: none;
}

body.bg-photo #tabs {
  background: none;
  backdrop-filter: none;
}

body.bg-photo .tier-switch button,
body.bg-photo #tabs .tab-button {
  aspect-ratio: 705 / 205;
  height: auto;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-color: transparent;
  border: none;
  box-shadow: none;
  color: transparent;
  clip-path: none;
}

/* Always the brighter "active" artwork on both buttons — no idle/pressed
   swap. Product decision: the dim idle state read as broken, not as an
   unselected tab. */
body.bg-photo .tier-switch button[data-status="gold"] { background-image: url('../assets/btn-gold-active.webp'); }
body.bg-photo .tier-switch button[data-status="vip"] { background-image: url('../assets/btn-vip-active.webp'); }

body.bg-photo #tabs .tab-button[data-tab="leaderboard"] { background-image: url('../assets/btn-tables-active.webp'); }
body.bg-photo #tabs .tab-button[data-tab="predictions"] { background-image: url('../assets/btn-predictions-active.webp'); }

body.bg-photo .lb-list .lb-row {
  aspect-ratio: 680 / 159;
  min-height: 0;
  height: auto;
  background-image: url('../assets/row-card.webp?v=20260904d');
  background-size: 100% 100%;
  background-color: transparent;
  border: none;
  box-shadow: none;
  clip-path: none;
  justify-content: space-between;
  /* NOTE: top/bottom padding percentages resolve against the element's
     WIDTH, not its own height (a CSS padding quirk) — these numbers are
     pre-divided by the card's own aspect ratio (680/159 ≈ 4.28) so the
     rendered result lands at ~16% / ~12% of the row's actual height.
     Image re-cropped a second time, now right at the soft-glow bound
     with almost no dead space beyond it. */
  padding: 3.8% 8% 2.9%;
}

body.bg-photo .lb-list .lb-row-bar {
  height: 13px;
}

/* ---------- hex/chamfer shape system ---------- */
.hex {
  clip-path: polygon(
    var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)),
    calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer)
  );
  border: 1.5px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hex-accent {
  border-color: rgba(255, 138, 43, 0.85);
  background: linear-gradient(120deg, rgba(255, 138, 43, 0.32), rgba(255, 138, 43, 0.14));
  box-shadow: var(--shadow-accent);
}

#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 10px;
}

#app-header h1 {
  margin: 0;
  font-family: 'Orbitron', 'Rajdhani', sans-serif;
  font-weight: 800;
  font-size: 30px;
  letter-spacing: 0.02em;
  color: #ffffff;
  display: inline-block;
  transform: skewX(-8deg);
  text-shadow:
    0 0 4px #fff,
    0 0 12px rgba(140, 245, 255, 1),
    0 0 26px rgba(34, 224, 255, 0.95),
    0 0 50px rgba(34, 224, 255, 0.7),
    0 0 84px rgba(34, 224, 255, 0.4);
}

#burger-button {
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--text);
  cursor: pointer;
  filter: drop-shadow(0 0 6px rgba(34, 224, 255, 0.7));
}

#tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(0deg, rgba(5, 6, 12, 0.96), rgba(5, 6, 12, 0.75));
  backdrop-filter: blur(6px);
}

.tab-button {
  flex: 1;
  padding: 12px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-muted);
  cursor: pointer;
  clip-path: polygon(
    var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)),
    calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer)
  );
  border: 1.5px solid var(--border-dim);
  background: var(--surface);
}

.tab-button.active {
  color: #eafcff;
  border-color: var(--border);
  box-shadow: var(--shadow);
}

#app-main {
  padding: 12px 16px;
}

.card {
  background: var(--surface);
  padding: 18px;
  clip-path: polygon(
    var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)),
    calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer)
  );
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}

.button-primary {
  background: linear-gradient(120deg, rgba(34, 224, 255, 0.3), rgba(34, 224, 255, 0.12));
  color: #eafcff;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  clip-path: polygon(
    var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)),
    calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer)
  );
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 12px 18px;
  cursor: pointer;
}

.button-primary:hover {
  color: #ffffff;
  border-color: var(--primary-hover);
}

.error {
  color: var(--danger);
}

.hint {
  color: var(--text-muted);
}

#burger-menu {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(5, 6, 12, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

#burger-menu button {
  width: 100%;
  font-family: 'Rajdhani', sans-serif;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border-dim);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
}

#menu-summary { display: flex; flex-direction: column; gap: 14px; margin-bottom: 6px; }

.menu-avatar-row { display: flex; align-items: center; gap: 12px; }
.menu-name { font-family: 'Orbitron', sans-serif; font-size: 16px; }

.menu-stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border: 1.5px solid var(--border-dim);
  border-radius: 10px;
  background: var(--surface);
}
.menu-stats > div { text-align: center; flex: 1; }
.menu-stat-value { display: block; font-family: 'Orbitron', sans-serif; font-size: 18px; color: #fff; }
.menu-stat-label { display: block; font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* ---------- avatars & crests ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; object-fit: cover;
  border: 1.5px solid var(--border-dim);
}
.avatar-lg { width: 56px; height: 56px; }
.avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: #fff;
  font-family: 'Orbitron', sans-serif;
}
.crest { width: 20px; height: 20px; object-fit: contain; flex: none; margin-right: 6px; vertical-align: middle; }
.crest-fallback { display: inline-block; width: 20px; height: 20px; margin-right: 6px; }

/* ---------- predictions match card ---------- */
.match-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-dim);
}

.match-star { font-size: 11px; color: var(--accent); }

.match-teams { display: flex; flex-direction: column; gap: 4px; }
.team-line { display: flex; align-items: center; font-size: 14px; }

.match-score { display: flex; align-items: center; justify-content: center; gap: 10px; }

.score-input {
  width: 46px;
  text-align: center;
  font-family: 'Orbitron', sans-serif;
  font-size: 15px;
  border: 1.5px solid var(--border-dim);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  padding: 8px 4px;
  background: rgba(5, 7, 14, 0.6);
  color: var(--text);
}
.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.score-input { -moz-appearance: textfield; }
.score-sep { color: var(--text-muted); }

.profile-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.history-teams { display: flex; align-items: center; flex-wrap: wrap; }

.profile { position: relative; }
.profile-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border-dim);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.lb-total { margin-top: 12px; font-size: 12px; text-align: center; }

/* ---------- leaderboard: row cards (see leaderboard.js) ---------- */
.tier-switch {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.tier-switch button {
  flex: 1;
  padding: 12px;
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  cursor: pointer;
  clip-path: polygon(
    var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)),
    calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer)
  );
  border: 1.5px solid var(--border-dim);
  background: var(--surface);
}

.tier-switch button.active {
  color: #eafcff;
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.lb-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 18px;
  margin-bottom: 1px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1.5px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  clip-path: polygon(
    var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)),
    calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer)
  );
}

.lb-row-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lb-row-bar {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) 48%, var(--accent) 52%, var(--accent) 100%);
  box-shadow: 0 0 14px rgba(34, 224, 255, 0.75), 0 0 14px rgba(255, 138, 43, 0.65);
}

.my-rank-pinned {
  position: relative;
  padding-top: 22px;
  margin-top: 4px;
}

.my-rank-pinned::before {
  content: '';
  position: absolute;
  top: 0;
  left: 4px;
  right: 4px;
  border-top: 1.5px dashed rgba(255, 154, 60, 0.55);
}

.my-rank-pinned .lb-row {
  border-color: rgba(255, 200, 120, 0.95);
  background: linear-gradient(120deg, #ffb648 0%, #ff7a1a 55%, #ff9636 100%);
  box-shadow: 0 0 26px rgba(255, 154, 43, 0.9), 0 0 54px rgba(255, 138, 43, 0.55), inset 0 0 20px rgba(255, 220, 150, 0.35);
}

.my-rank-pinned .lb-row-bar { background: linear-gradient(90deg, #fff3d6, #ffe1a3); box-shadow: 0 0 14px rgba(255, 235, 180, 0.85); }

.my-rank-pinned .lb-name {
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.03em;
  font-size: 20px;
  color: #fffaf0;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.65);
}

.lb-rank {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  width: 22px;
  text-align: center;
  color: var(--text-muted);
}

.lb-name {
  flex: 1;
  font-weight: 600;
  font-size: 16px;
}

.lb-stats {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.3;
}

/* ---------- profile ---------- */
.history-round { margin-top: 14px; }
.history-round h3 { font-family: 'Orbitron', sans-serif; font-size: 14px; letter-spacing: 0.03em; }
.history-match {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-dim);
  font-size: 13px;
}
