:root {
  /* deep, refined, near-black navy — less saturated, more premium */
  --bg: #0a0e1a;
  --bg2: #0f1528;
  --card: #141a2c;
  --card2: #1b2238;
  --line: #272f49;
  --line-soft: #1d2440;
  --txt: #f2f4fb;
  --muted: #98a1bd;
  --muted2: #6c779b;

  /* hero accent = champagne gold (championship / winner-takes-all) */
  --accent: #e9c46a;
  --accent-strong: #f4d68c;
  --accent-ink: #2b2207;
  /* cool secondary = info / links / active state */
  --cool: #5fb1e8;
  /* live / error */
  --live: #f0606f;
  --danger: #ec6577;

  --radius: 18px;
  --pot1: #e9c46a;
  --pot2: #6fb8da;
  --pot3: #a87fc4;
  --pot4: #e0926f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1100px 680px at 50% -28%, rgba(233,196,106,.07), transparent 62%),
    radial-gradient(900px 600px at 50% -10%, rgba(95,177,232,.05), transparent 55%),
    linear-gradient(180deg, #0c1122 0%, var(--bg) 42%);
  background-attachment: fixed;
  color: var(--txt);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

#app { max-width: 640px; margin: 0 auto; padding: env(safe-area-inset-top) 16px 100px; }
.loading { text-align: center; padding: 80px 0; color: var(--muted); }

/* ---- header ---- */
.app-header {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 2px 16px; position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--bg) 68%, transparent);
}
.app-header h1 { font-size: 20px; font-weight: 800; margin: 0; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header .ball { font-size: 24px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.5)); }
.app-header .spacer { flex: 1; }
.back-btn {
  width: 38px; height: 38px; flex: none; margin: 0; padding: 0;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--txt);
  border-radius: 50%; font-size: 22px; line-height: 1; display: grid; place-items: center;
  transition: background .2s;
}
.back-btn:active { background: rgba(255,255,255,.1); }

/* ---- dashboard ---- */
.dash-actions { display: flex; gap: 10px; margin-bottom: 20px; }
.dash-actions button { margin: 0; }
.section-h { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; margin: 0 0 12px 2px; }
.pool-card { position: relative; cursor: pointer; transition: transform .08s ease, border-color .2s; }
.pool-card:active { transform: scale(.985); }
.pool-card-top { display: flex; align-items: center; gap: 10px; }
.pool-card-name { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pool-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.pool-flags { font-size: 20px; letter-spacing: 2px; }
.pool-x {
  position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; margin: 0; padding: 0;
  background: transparent; color: var(--muted); border: 0; font-size: 14px; border-radius: 50%;
  display: grid; place-items: center; opacity: .45;
}
.pool-x:active { background: rgba(255,255,255,.08); }
.chip {
  background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--muted);
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* ---- cards ---- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0) 40%), var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
  box-shadow: 0 20px 40px -28px rgba(0,0,0,.9), inset 0 1px 0 rgba(255,255,255,.04);
}
.card h2 { margin: 0 0 5px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.card h3 { margin: 0; font-weight: 700; }
.card .sub { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 0 0 16px; }

/* ---- forms ---- */
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 7px; font-weight: 600; }
input[type=text], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 14px; border-radius: 13px; font-size: 16px;
  background: rgba(255,255,255,.035); border: 1px solid var(--line); color: var(--txt); outline: none;
  font-family: inherit; resize: vertical; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .55; }
input:focus, select:focus, textarea:focus { border-color: var(--cool); box-shadow: 0 0 0 3px rgba(95,177,232,.16); }
.link { color: var(--cool); font-weight: 600; cursor: pointer; text-decoration: none; }
.link:active { opacity: .7; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

button {
  font: inherit; font-weight: 700; cursor: pointer; border: none; letter-spacing: -0.01em;
  padding: 15px 18px; border-radius: 14px; width: 100%; font-size: 16px; margin-top: 16px;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 10px 24px -12px rgba(233,196,106,.6), inset 0 1px 0 rgba(255,255,255,.4);
  transition: transform .06s ease, box-shadow .2s, opacity .2s, filter .2s;
}
button:active { transform: translateY(1px) scale(.99); filter: brightness(.97); }
button:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
button.secondary { background: rgba(255,255,255,.05); color: var(--txt); border: 1px solid var(--line); box-shadow: none; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); box-shadow: none; }
button.danger { background: transparent; color: var(--danger); border: 1px solid rgba(236,101,119,.5); padding: 8px; font-size: 13px; width: auto; margin: 0; box-shadow: none; }
.btn-inline { width: auto; margin: 0; padding: 10px 14px; font-size: 14px; }

.error { color: var(--live); font-size: 13px; margin-top: 10px; min-height: 1em; }
.notice { color: var(--cool); font-size: 13px; margin-top: 10px; }

/* ---- tabs ---- */
.tabs {
  display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(10,14,26,.82); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line-soft); padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
}
.tabs button {
  flex: 1; background: none; border: none; color: var(--muted); margin: 0; box-shadow: none;
  padding: 8px 4px; font-size: 11px; font-weight: 600; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: color .2s, background .2s;
}
.tabs button .ico { font-size: 20px; }
.tabs button.active { color: var(--cool); background: rgba(95,177,232,.1); }

/* ---- player list / draft ---- */
.player-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.player-row:last-child { border-bottom: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--card2); color: var(--txt);
}
.avatar-img { object-fit: cover; border: 1px solid var(--line); }
.club-sub { font-size: 11px; color: var(--accent); font-weight: 600; }
.club-row { display: flex; align-items: center; gap: 14px; margin: 6px 0 4px; }
.club-avatar {
  width: 64px; height: 64px; border-radius: 50%; flex: none; object-fit: cover;
  border: 2px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
.club-avatar-empty {
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
  background: var(--card2); color: var(--muted);
}
.player-row .name { font-weight: 700; flex: 1; }
.player-row .meta { color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.you { background: rgba(95,177,232,.16); color: var(--cool); }
.badge.host { background: rgba(233,196,106,.16); color: var(--accent); }
.badge.turn { background: var(--accent); color: var(--accent-ink); }

/* ---- pot pills ---- */
.pot-pill { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px; color: #0a0e1a; }
.pot-1 { background: var(--pot1); } .pot-2 { background: var(--pot2); }
.pot-3 { background: var(--pot3); } .pot-4 { background: var(--pot4); }

/* ---- tier pills (8 tiers, gold -> grey) ---- */
.tier-pill { font-size: 10px; font-weight: 800; padding: 3px 7px; border-radius: 6px; color: #0a0e1a; white-space: nowrap; }
.tier-pill.t1 { background: #e9c46a; }
.tier-pill.t2 { background: #e6c879; }
.tier-pill.t3 { background: #b3e07a; }
.tier-pill.t4 { background: #7fd6c2; }
.tier-pill.t5 { background: #6fc3e8; }
.tier-pill.t6 { background: #9fa8e8; }
.tier-pill.t7 { background: #c0a6d8; }
.tier-pill.t8 { background: #b9c2d6; }
.mt-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-odds { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }

/* ---- team chips ---- */
.team {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 13px; margin-bottom: 8px;
}
.team .flag { font-size: 22px; }
.team .tname { font-weight: 700; flex: 1; }
.team .rec { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---- live draw stage ---- */
.stage {
  text-align: center; padding: 24px 16px; border-radius: var(--radius);
  background: radial-gradient(440px 220px at 50% -10%, rgba(233,196,106,.14), transparent 70%), var(--card);
  border: 1px solid var(--line); margin-bottom: 16px;
}
.stage .turnline { color: var(--muted); font-size: 13px; }
.stage .turnname { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 14px; }
.reveal {
  font-size: 56px; line-height: 1; min-height: 64px;
  transition: transform .25s; transform: scale(1);
}
.reveal.pop { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.25); } 100% { transform: scale(1); opacity: 1; } }
.reveal-name { font-size: 20px; font-weight: 800; margin-top: 8px; min-height: 24px; }

.progress { height: 8px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden; margin: 16px 0 4px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--cool), var(--accent)); transition: width .4s; }

/* ---- pot board ---- */
.pot-board { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.pot-col h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.mini-team { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 0; }
.mini-team.taken { opacity: .3; text-decoration: line-through; }

/* ---- leaderboard / winner takes all ---- */
.wta-banner {
  display: flex; align-items: center; gap: 10px; margin: 0 0 14px;
  padding: 12px 14px; border-radius: 13px;
  background: linear-gradient(100deg, rgba(233,196,106,.16), rgba(233,196,106,.04));
  border: 1px solid rgba(233,196,106,.3); color: var(--accent); font-weight: 700; font-size: 13.5px;
}
.wta-banner .trophy { font-size: 20px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 13px 10px; border-bottom: 1px solid var(--line-soft); border-radius: 12px; }
.lb-row:last-child { border-bottom: none; }
.lb-row.top1 {
  background: linear-gradient(100deg, rgba(233,196,106,.14), rgba(233,196,106,.02));
  border: 1px solid rgba(233,196,106,.32); margin-bottom: 6px;
}
.lb-rank { width: 28px; font-weight: 800; color: var(--muted); text-align: center; font-size: 16px; }
.lb-row.top1 .lb-rank { color: var(--accent); font-size: 20px; }
.lb-name { flex: 1; font-weight: 700; letter-spacing: -0.01em; }
.lb-teams { color: var(--muted); font-size: 18px; letter-spacing: 1px; }
.lb-pts { font-weight: 800; font-size: 19px; font-variant-numeric: tabular-nums; }
.lb-row.top1 .lb-pts { color: var(--accent); }
.lb-sub { color: var(--muted); font-size: 12px; }

/* ---- misc ---- */
.share-box {
  display: flex; gap: 8px; align-items: center; background: rgba(255,255,255,.03);
  border: 1px dashed var(--line); border-radius: 13px; padding: 13px; margin-top: 10px;
}
.share-box .code { font-size: 27px; font-weight: 800; letter-spacing: 5px; color: var(--accent); flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 32px 10px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.date-head { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--accent); }
.match-row { display: flex; align-items: center; gap: 8px; padding: 10px 0 2px; font-size: 14px; }
.match-row .t { flex: 1; min-width: 0; }
.match-row .t.right { text-align: right; }
.match-row .sc { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 52px; text-align: center; }
.match-row .sc.vs { color: var(--muted); font-weight: 600; font-size: 13px; }
.match-row .sc.live { color: var(--live); }
.match-meta { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: center; gap: 5px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); display: inline-block; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.manual-tag { color: var(--accent); font-weight: 700; }
.mini-edit { width: auto; margin: 0; padding: 4px 8px; background: var(--card2); color: var(--muted); border: 1px solid var(--line); font-size: 13px; border-radius: 8px; box-shadow: none; }
.match-edit { display: flex; align-items: center; gap: 6px; padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
.match-edit input { width: 56px; padding: 8px; text-align: center; }
.match-edit .btn-inline { margin: 0; }

/* hero tagline on the entry screen */
.hero-tag { text-align: center; color: var(--muted); font-size: 13px; margin: -4px 0 18px; }
.hero-tag b { color: var(--accent); font-weight: 700; }

/* ---- full-screen SVG country announcement ---- */
.announce {
  position: fixed; inset: 0; z-index: 100; overflow: hidden;
  display: grid; place-items: center; color: #fff;
  animation: announceIn .4s cubic-bezier(.2,.9,.3,1.15) both;
}
.announce.out { animation: announceOut .38s ease forwards; }
@keyframes announceIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
@keyframes announceOut { to { opacity: 0; transform: scale(1.07); } }

.announce-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 34%, transparent 24%, rgba(4,8,28,.62) 100%),
    linear-gradient(160deg, var(--c1) 0%, var(--c2) 130%);
  background-size: 100% 100%, 220% 220%;
  animation: bgDrift 7s ease-in-out infinite alternate;
}
@keyframes bgDrift { from { background-position: 0 0, 0% 0%; } to { background-position: 0 0, 100% 100%; } }
.announce-bg::after {
  content: ''; position: absolute; inset: 0; opacity: .1; mix-blend-mode: overlay;
  background: repeating-linear-gradient(115deg, #fff 0 2px, transparent 2px 26px);
}

/* rotating light rays behind the flag */
.announce-rays {
  position: absolute; left: 50%; top: 38%; width: 160vmax; height: 160vmax;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(rgba(255,255,255,.14) 0deg 9deg, transparent 9deg 24deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 58%);
  mask-image: radial-gradient(circle, #000 0%, transparent 58%);
  animation: raysSpin 14s linear infinite; opacity: 0;
  transition: opacity .6s;
}
.announce.revealed .announce-rays { opacity: 1; animation-duration: 9s; }
@keyframes raysSpin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.announce-inner {
  position: relative; text-align: center; padding: 24px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-shadow: 0 2px 16px rgba(0,0,0,.5);
}
.announce-round {
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 3px;
  opacity: .9; margin-bottom: 14px;
  padding: 6px 14px; border: 1px solid rgba(255,255,255,.4); border-radius: 999px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px); background: rgba(0,0,0,.18);
}

.announce-stage { position: relative; perspective: 900px; margin-bottom: 24px; }
.announce-flagwrap {
  position: relative;
  width: min(74vw, 330px); aspect-ratio: 3 / 2;
  border-radius: 14px; overflow: hidden; display: grid; place-items: center;
  box-shadow: 0 18px 50px rgba(0,0,0,.55), 0 0 0 3px rgba(255,255,255,.55), 0 0 60px rgba(255,255,255,.18);
  background: rgba(0,0,0,.25);
  animation: flagFloat 4.5s ease-in-out infinite;
}
/* light sweep across the flag once it has assembled */
.announce.revealed .announce-flagwrap::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,.5) 50%, transparent 62%);
  transform: translateX(-130%);
  animation: flagShine 1s .75s ease both;
}
@keyframes flagShine { to { transform: translateX(130%); } }
@keyframes flagFloat {
  0%, 100% { transform: rotateY(-4deg) rotateX(2deg); }
  50% { transform: rotateY(4deg) rotateX(-2deg); }
}
.announce-flagwrap svg { width: 100%; height: 100%; display: block; }
.announce-flagwrap .fl {
  animation: flagLayerIn .5s cubic-bezier(.2,.85,.3,1.2) both;
  transform-box: fill-box; transform-origin: center;
}
@keyframes flagLayerIn {
  from { opacity: 0; transform: scale(1.25) translateY(-10px); }
  to { opacity: 1; transform: none; }
}
.announce-dice { font-size: 64px; animation: dicePulse .55s ease-in-out infinite alternate; }
@keyframes dicePulse { from { transform: scale(.85) rotate(-12deg); } to { transform: scale(1.15) rotate(12deg); } }

.announce-crest {
  position: absolute; left: 50%; bottom: -34px; transform: translateX(-50%) scale(.2);
  height: 88px; width: auto; opacity: 0;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.55));
  transition: opacity .35s, transform .55s cubic-bezier(.2,.9,.3,1.45);
}
.announce-crest.show { opacity: 1; transform: translateX(-50%) scale(1); }

.announce-name {
  font-size: clamp(32px, 9.5vw, 58px); font-weight: 800; text-transform: uppercase;
  letter-spacing: -0.01em; line-height: 1.04; margin-top: 16px;
  /* reserve space for up to two lines so filling text never shifts the layout */
  min-height: 2.1em; display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  text-align: center; padding: 0 8px;
}
.announce-name .ltr {
  display: inline-block; animation: ltrIn .45s cubic-bezier(.2,.9,.3,1.3) both;
}
@keyframes ltrIn {
  from { opacity: 0; transform: translateY(34px) scale(1.6) rotate(6deg); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}
.announce-name .drawing { font-size: 22px; font-weight: 700; opacity: .85; letter-spacing: 4px; }
.announce-name .drawing i { font-style: normal; animation: dotBlink 1s infinite; }
.announce-name .drawing i:nth-child(2) { animation-delay: .2s; }
.announce-name .drawing i:nth-child(3) { animation-delay: .4s; }
@keyframes dotBlink { 0%, 60%, 100% { opacity: .2; } 30% { opacity: 1; } }

.announce-odds { font-size: 15px; font-weight: 800; opacity: 0; letter-spacing: .5px; min-height: 1.2em; animation: fadeUp .5s .1s both; }
.announce-coach {
  display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; font-size: 18px;
  min-height: 40px; /* reserve the avatar row so it doesn't push the flag up */
  animation: fadeUp .5s both;
}
.announce-coach b { font-weight: 900; }
.announce-coach i { opacity: .9; }
.announce-coach-img {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,255,255,.8); box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.announce-coach-init {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.6);
  font-weight: 800; font-size: 14px;
}
.announce-odds:empty, .announce-coach:empty { animation: none; opacity: 0; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.announce-skip { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 0; right: 0; font-size: 12px; opacity: .55; }

.announce-confetti { position: absolute; inset: 0; pointer-events: none; }
.announce-confetti .cf {
  position: absolute; left: 50%; top: 40%; border-radius: 2px; opacity: 0;
  animation-name: cfBurst; animation-timing-function: cubic-bezier(.15,.65,.4,1); animation-fill-mode: both;
}
@keyframes cfBurst {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--tx), calc(var(--ty) + 70vh)) rotate(var(--rot)); }
}

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--line); color: var(--txt);
  padding: 12px 18px; border-radius: 12px; z-index: 50; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: rise .3s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
