:root {
  --bg0: #0b1026;
  --bg1: #141a3c;
  --bg2: #1b2150;
  --panel: rgba(20, 26, 62, 0.72);
  --panel-2: rgba(255, 255, 255, 0.04);
  --stroke: rgba(255, 255, 255, 0.10);
  --text: #eef1ff;
  --muted: #9aa2cc;
  --home: #3aa0ff;
  --away: #ff5a8a;
  --cyan: #37e1f0;
  --win: #ffd23f;
  --live: #ff3b54;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -10%, #232a63 0%, rgba(35, 42, 99, 0) 60%),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 55%, var(--bg0) 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.app { width: 100%; min-height: 100dvh; }

a { color: inherit; text-decoration: none; }

/* ---------------- loading ---------------- */
.loading-screen {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; color: var(--muted);
}
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.12); border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= HOME ================= */
.home { max-width: 1040px; margin: 0 auto; padding: 22px 16px 48px; }

.home-head {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; margin-bottom: 18px;
}
.home-title { display: flex; align-items: center; gap: 14px; }
.home-title .cup { font-size: 38px; filter: drop-shadow(0 4px 10px rgba(255, 210, 63, 0.5)); }
.home-title h1 { margin: 0; font-size: 28px; letter-spacing: -0.5px; }
.home-title .sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.home-status { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.status { font-size: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; }
.status--live { background: rgba(54, 224, 192, 0.12); color: #5ff2cf; }
.status--off { background: rgba(255, 255, 255, 0.07); color: var(--muted); }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: #36e0c0; box-shadow: 0 0 0 0 rgba(54, 224, 192, 0.7); animation: pulse 1.8s infinite; }
.done-count { font-size: 12px; color: var(--muted); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(54, 224, 192, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(54, 224, 192, 0); }
  100% { box-shadow: 0 0 0 0 rgba(54, 224, 192, 0); }
}

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--stroke); background: var(--panel-2); color: var(--muted);
  padding: 8px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: 0.15s;
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }
.chip.active { background: linear-gradient(180deg, var(--home), #2b7fd8); color: #fff; border-color: transparent; }
.chip-n { font-size: 11px; background: rgba(0, 0, 0, 0.25); padding: 1px 7px; border-radius: 999px; }
.chip.active .chip-n { background: rgba(255, 255, 255, 0.25); }

.search {
  flex: 1; min-width: 180px; max-width: 280px; background: var(--panel-2);
  border: 1px solid var(--stroke); color: var(--text); padding: 10px 14px;
  border-radius: 12px; font-size: 14px; outline: none;
}
.search:focus { border-color: var(--cyan); }
.search::placeholder { color: var(--muted); }

.stage { margin-bottom: 26px; }
.stage-title {
  display: flex; align-items: baseline; gap: 10px; font-size: 16px;
  margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--stroke);
}
.stage-count { font-size: 12px; color: var(--muted); font-weight: 400; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 760px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 13px 15px; display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  position: relative; overflow: hidden;
}
.card:hover { transform: translateY(-3px); border-color: rgba(255, 255, 255, 0.22); box-shadow: var(--shadow); }
.card--live::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--home), var(--away));
}
.card-top { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.card-meta { font-weight: 600; letter-spacing: 0.2px; }
.card-date { white-space: nowrap; }

/* teams stacked one per row — names get the full card width and wrap (no ellipsis) */
.card-body { display: flex; flex-direction: column; gap: 7px; }
.team { display: flex; align-items: center; gap: 9px; }
.flag { font-size: 22px; line-height: 1; flex-shrink: 0; }
.flag--ph {
  font-size: 10px; font-weight: 700; background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--stroke); border-radius: 6px; padding: 3px 5px; color: var(--muted);
}
.t-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; line-height: 1.25; overflow-wrap: break-word; }
.t-score { flex-shrink: 0; font-size: 19px; font-weight: 800; min-width: 16px; text-align: right; color: var(--muted); }
.t-score.win { color: var(--win); }
.team.is-winner .t-name { color: #fff; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tag { font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; letter-spacing: 0.3px; }
.tag--ft { background: rgba(255, 255, 255, 0.07); color: var(--muted); }
.tag--predict { background: linear-gradient(180deg, var(--away), #d83d6e); color: #fff; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.home-foot { margin-top: 30px; text-align: center; color: var(--muted); font-size: 11.5px; }

/* ================= MATCH ================= */
.match { max-width: 460px; margin: 0 auto; padding: 14px 14px 22px; }
.match--play { height: 100dvh; padding-bottom: 8px; display: flex; flex-direction: column; }

.m-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.back { color: var(--muted); font-size: 13px; align-self: flex-start; padding: 4px 0; }
.back:hover { color: var(--text); }
.m-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12px; color: var(--muted); }
.m-stage { font-weight: 700; color: var(--text); }

/* finished result view */
.result-card {
  background: var(--panel); border: 1px solid var(--stroke); border-radius: 22px;
  padding: 22px 18px; text-align: center; box-shadow: var(--shadow);
}
.ft-tag { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.result-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 16px 0; }
.result-team { display: flex; flex-direction: column; align-items: center; gap: 8px; opacity: 0.85; }
.result-team.win { opacity: 1; }
.rt-name { font-size: 15px; font-weight: 700; }
.mflag { font-size: 30px; }
.mflag--big { font-size: 50px; line-height: 1; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4)); }
.mflag--ph { font-size: 14px; font-weight: 800; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--stroke); border-radius: 8px; padding: 8px 10px; color: var(--muted); }
.result-score { display: flex; align-items: center; gap: 8px; font-size: 46px; font-weight: 800; }
.result-score .win { color: var(--win); }
.rs-dash { color: var(--muted); font-weight: 400; }
.ft-banner { margin-top: 6px; font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: rgba(255, 210, 63, 0.12); color: var(--win); }
.ft-banner.draw { background: rgba(255, 255, 255, 0.07); color: var(--muted); }
.ft-flag { font-size: 20px; }
.result-note { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 16px; }

/* ================= PLINKO ================= */
.play-host { flex: 1; min-height: 0; display: flex; }
.pk { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.pk-live {
  align-self: center; display: inline-flex; align-items: center; gap: 8px;
  background: var(--live); color: #fff; font-weight: 700; font-size: 13px;
  padding: 7px 16px; border-radius: 999px; margin-bottom: 10px;
  box-shadow: 0 6px 16px rgba(255, 59, 84, 0.35);
}
.pk-live .dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: pulse-w 1.4s infinite; }
@keyframes pulse-w { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.pk-scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
}
.pk-team { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pk-flag {
  font-size: 34px; line-height: 1; width: 58px; height: 40px; display: flex;
  align-items: center; justify-content: center; border-radius: 8px;
  background: rgba(255, 255, 255, 0.05); overflow: hidden;
}
.pk-flag--ph { font-size: 14px; font-weight: 800; color: var(--muted); }
.pk-code { font-size: 15px; font-weight: 800; letter-spacing: 0.5px; }
.pk-team--home .pk-code { color: var(--home); }
.pk-team--away .pk-code { color: var(--away); }

.pk-center { text-align: center; }
.pk-bestof { font-size: 12px; color: var(--muted); font-weight: 600; }
.pk-score { font-size: 42px; font-weight: 800; line-height: 1.05; display: flex; align-items: center; justify-content: center; gap: 10px; }
.pk-score .dash { color: var(--muted); font-weight: 300; font-size: 34px; }
.pk-score .lead { color: var(--win); text-shadow: 0 0 14px rgba(255, 210, 63, 0.5); }
.pk-firstto { font-size: 11px; color: var(--muted); }

.pk-board {
  position: relative; flex: 1; min-height: 0;
  border: 1px solid var(--stroke); border-radius: 22px; overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(58, 80, 170, 0.20), rgba(10, 14, 36, 0) 60%),
    rgba(10, 14, 36, 0.55);
  cursor: pointer;
}
.pk-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.pk-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  font-size: 13px; color: var(--text); background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--stroke); padding: 8px 16px; border-radius: 999px;
  pointer-events: none; backdrop-filter: blur(4px); animation: bob 1.6s ease-in-out infinite;
}
.pk-hint.hide { opacity: 0; transition: opacity 0.25s; }
@keyframes bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -4px); } }

/* GOAL! starburst */
.pk-burst {
  position: absolute; transform: translate(-50%, -50%) scale(0); opacity: 0;
  font-size: 24px; font-weight: 900; color: #b3261e; pointer-events: none;
  padding: 26px 22px; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  background:
    radial-gradient(circle at 50% 45%, #ffe169 0%, #ffd23f 45%, #ff9d2e 100%);
  --burst-color: var(--home);
  clip-path: polygon(50% 0%, 61% 22%, 87% 13%, 78% 39%, 100% 50%, 78% 61%, 87% 87%, 61% 78%, 50% 100%, 39% 78%, 13% 87%, 22% 61%, 0% 50%, 22% 39%, 13% 13%, 39% 22%);
  filter: drop-shadow(0 0 12px var(--burst-color));
  z-index: 4;
}
.pk-burst.show { animation: burst 0.9s ease-out forwards; }
@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-30deg); opacity: 0; }
  35% { transform: translate(-50%, -50%) scale(1.15) rotate(0deg); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1) rotate(4deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.9) rotate(0deg); opacity: 0; }
}

/* winner overlay */
.pk-result {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(7, 10, 28, 0.78); backdrop-filter: blur(6px); z-index: 5;
  animation: fade 0.3s ease;
}
.pk-result[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.pk-result-card { text-align: center; padding: 22px; animation: pop 0.4s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.pk-trophy { font-size: 54px; filter: drop-shadow(0 6px 14px rgba(255, 210, 63, 0.6)); }
.pk-result-label { color: var(--muted); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; margin-top: 6px; }
.pk-result-team { font-size: 26px; font-weight: 800; margin: 8px 0 18px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.pk-result-flag { font-size: 34px; }
.pk-replay {
  background: linear-gradient(180deg, var(--cyan), #1aa6c4); color: #04222a;
  border: none; font-weight: 800; font-size: 15px; padding: 12px 26px;
  border-radius: 999px; cursor: pointer; box-shadow: 0 8px 20px rgba(55, 225, 240, 0.35);
}
.pk-replay:hover { filter: brightness(1.07); }
.pk-replay:active { transform: translateY(1px); }

/* prediction split bar — shared by the Plinko result overlay and the finished view */
.pk-stats { margin: 2px 0 18px; min-height: 20px; }
.pk-stats-loading { color: var(--muted); font-size: 12px; }
.pk-stats-title, .rstats-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.pk-bar {
  display: flex; height: 12px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, 0.08); width: 220px; max-width: 100%; margin: 0 auto;
}
.pk-bar-home { background: linear-gradient(90deg, #2b7fd8, var(--home)); transition: width 0.5s ease; }
.pk-bar-away { background: linear-gradient(90deg, var(--away), #d83d6e); transition: width 0.5s ease; }
.pk-bar-legend {
  display: flex; justify-content: space-between; width: 220px; max-width: 100%;
  margin: 7px auto 0; font-size: 12.5px; font-weight: 800;
}
.bl-home { color: var(--home); }
.bl-away { color: var(--away); }

/* finished-match community stats card */
.result-stats { margin-top: 14px; }
.rstats { background: var(--panel); border: 1px solid var(--stroke); border-radius: 16px; padding: 16px; text-align: center; }
.rstats .pk-bar, .rstats .pk-bar-legend { width: 100%; }
.rstats--empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px; }
.rstats-note { margin-top: 12px; font-size: 13px; font-weight: 600; }
.rstats-note.ok { color: #5ff2cf; }
.rstats-note.no { color: var(--muted); }

/* homepage card play count */
.foot-left { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.card-plays { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* server-rendered (pre-hydration) content */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.ssr-predict { max-width: 460px; margin: 0 auto; text-align: center; padding-top: 6px; }
.ssr-h1 { font-size: 22px; margin: 6px 0 12px; }
.ssr-lead { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0 auto 12px; max-width: 40ch; }
.ssr-predict .play-host { min-height: 320px; }

@media (max-width: 380px) {
  .pk-flag { width: 50px; font-size: 30px; }
  .pk-score { font-size: 36px; }
  .home-title h1 { font-size: 24px; }
  /* give long team names more room in the narrow 2-column grid */
  .card { padding: 12px 12px; }
  .team { gap: 7px; }
  .flag { font-size: 19px; }
  .t-name { font-size: 14px; }
}
