:root {
  --navy-900: #071230;
  --navy-800: #0b1b3f;
  --navy-700: #12285c;
  --blue: #1f4ea1;
  --blue-500: #2f6fe0;
  --blue-300: #7fb2ff;
  --orange: #f7941d;
  --orange-300: #ffc074;
  --white: #ffffff;
  --text: #e9efff;
  --muted: #9fb0d6;
  --card: rgba(255, 255, 255, 0.06);
  --card-2: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.12);
  --ok: #3ddc97;
  --bad: #ff6b6b;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(247, 148, 29, 0.18), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(47, 111, 224, 0.35), transparent 60%),
    linear-gradient(160deg, #2a2f3d 0%, var(--navy-800) 45%, #0d2a6b 100%) fixed var(--navy-900);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.bg-fx {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(247, 148, 29, 0.18), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(47, 111, 224, 0.35), transparent 60%),
    linear-gradient(160deg, #2a2f3d 0%, var(--navy-800) 45%, #0d2a6b 100%);
}
a { color: var(--orange-300); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: rgba(7, 18, 48, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--white); font-weight: 800; }
.brand img { height: 26px; background: #fff; border-radius: 6px; padding: 3px 6px; }
.brand span { color: var(--orange); font-style: italic; }
.topbar nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.topbar nav a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 8px 12px; border-radius: 999px; white-space: nowrap;
}
.topbar nav a.active { color: var(--navy-900); background: linear-gradient(135deg, var(--orange-300), var(--orange)); }
.me { border: 0; background: none; padding: 0; cursor: pointer; flex: none; }
.me img, .avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--orange); background: var(--navy-700);
  display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
}
@media (max-width: 640px) {
  .brand span { display: none; }
  .topbar { gap: 6px; padding: 8px 10px; }
  .topbar nav { margin-left: 0; flex: 1; justify-content: space-between; }
  .topbar nav a { padding: 7px 9px; font-size: 13px; }
}
@media (max-width: 440px) { .brand { display: none; } }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.loading { text-align: center; padding: 80px 0; color: var(--muted); }

/* ---------- common ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.section-title {
  font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: 0.5px;
  font-size: clamp(22px, 4vw, 32px); margin: 28px 0 6px;
  background: linear-gradient(180deg, #fff 30%, #bcd3ff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { color: var(--muted); margin: 0 0 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 12px 22px; cursor: pointer;
  font-weight: 800; color: var(--navy-900);
  background: linear-gradient(135deg, var(--orange-300), var(--orange));
  box-shadow: 0 6px 18px rgba(247, 148, 29, 0.35);
  text-decoration: none; transition: transform .1s ease, filter .2s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: var(--card-2); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.btn.blue { background: linear-gradient(135deg, var(--blue-300), var(--blue-500)); color: #fff; box-shadow: 0 6px 18px rgba(47, 111, 224, 0.35); }
.btn.small { padding: 7px 14px; font-size: 13px; }
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--card-2); color: var(--muted);
}
.pill.orange { background: rgba(247, 148, 29, 0.18); color: var(--orange-300); }
.pill.blue { background: rgba(47, 111, 224, 0.25); color: var(--blue-300); }
.pill.ok { background: rgba(61, 220, 151, 0.18); color: var(--ok); }
.pill.bad { background: rgba(255, 107, 107, 0.18); color: var(--bad); }
.grid { display: grid; gap: 16px; }
.muted { color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25); color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--orange); }
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
label small { color: var(--muted); font-weight: 400; }
select option { background: var(--navy-800); }

/* ---------- login ---------- */
.login {
  min-height: calc(100vh - 120px); display: grid; place-items: center; text-align: center; gap: 22px;
}
.login .banner { width: min(900px, 100%); border-radius: 22px; box-shadow: var(--shadow); }
.login .box { max-width: 460px; }
.login h1 { font-size: clamp(22px, 4vw, 30px); margin: 0 0 8px; font-weight: 900; }
.login p { color: var(--muted); margin: 0 0 18px; }
#gbtn { display: flex; justify-content: center; min-height: 44px; }
.dev-login { display: flex; gap: 8px; margin-top: 14px; }

/* ---------- hero ---------- */
.hero { position: relative; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.hero img { display: block; width: 100%; }
.countdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 18px; }
.cd { text-align: center; }
.cd h3 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; }
.cd .digits { display: flex; justify-content: center; gap: 10px; }
.cd .digits div {
  min-width: 62px; padding: 8px 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line);
}
.cd .digits b { display: block; font-size: 28px; font-weight: 900; font-variant-numeric: tabular-nums; color: #fff; }
.cd .digits span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.cd.done .digits b { color: var(--orange); }

.activities { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 18px; }
.activity { position: relative; overflow: hidden; }
.activity h2 { margin: 6px 0 8px; font-weight: 900; font-style: italic; font-size: 24px; }
.activity ul { padding-left: 18px; color: var(--muted); line-height: 1.6; }
.activity .glow {
  position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
  filter: blur(40px); opacity: 0.45;
}
.activity.pb .glow { background: var(--blue-500); }
.activity.run .glow { background: var(--orange); }
.activity .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- scoreboard ---------- */
.scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); margin: 8px 0 20px;
}
.scoreboard .side { padding: 18px 12px; text-align: center; }
.scoreboard .side.white { background: linear-gradient(135deg, #ffffff, #dfe6f3); color: var(--navy-800); }
.scoreboard .side.blue { background: linear-gradient(135deg, #2f6fe0, #12285c); color: #fff; }
.scoreboard .side .label { font-weight: 900; font-style: italic; text-transform: uppercase; font-size: clamp(14px, 3vw, 20px); }
.scoreboard .side .num { font-weight: 900; font-size: clamp(42px, 9vw, 72px); line-height: 1; }
.scoreboard .vs {
  padding: 0 14px; font-weight: 900; font-style: italic; font-size: clamp(22px, 5vw, 36px);
  background: var(--navy-900); align-self: stretch; display: grid; place-items: center; color: var(--orange);
}

/* ---------- matches ---------- */
.round-head { display: flex; align-items: center; gap: 10px; margin: 26px 0 10px; }
.round-head h3 { margin: 0; font-weight: 900; font-style: italic; text-transform: uppercase; }
.round-head .line { flex: 1; height: 1px; background: var(--line); }
.matches { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; }
.match { padding: 0; overflow: hidden; }
.match .mh { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); gap: 8px; }
.match .mh b { font-weight: 800; }
.match .teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; }
.team-btn {
  border: 0; cursor: pointer; padding: 14px 10px; text-align: center; min-height: 92px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px; transition: all .15s ease;
  position: relative;
}
.team-btn.white { background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(220,228,243,.88)); color: var(--navy-800); }
.team-btn.blue { background: linear-gradient(135deg, rgba(47,111,224,.85), rgba(18,40,92,.9)); color: #fff; }
.team-btn .tname { font-size: 11px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; opacity: .7; }
.team-btn .players { font-weight: 700; font-size: 14px; line-height: 1.35; }
.team-btn .score { font-size: 30px; font-weight: 900; line-height: 1; }
.team-btn:disabled { cursor: default; }
.team-btn.dim { filter: grayscale(.6) brightness(.55); }
.team-btn.pick { box-shadow: inset 0 0 0 4px var(--orange); padding-bottom: 26px; }
.team-btn.pick::after {
  content: '✓ Bạn chọn'; position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 800; background: var(--orange); color: var(--navy-900); padding: 1px 8px; border-radius: 999px;
}
.match .vsx { display: grid; place-items: center; padding: 0 8px; font-weight: 900; font-style: italic; color: var(--orange); background: var(--navy-900); }
.match .pred { padding: 12px 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; border-top: 1px solid var(--line); }
.match .pred select { width: auto; padding: 6px 10px; }
.match .pred .big { font-weight: 900; font-size: 18px; }
.match .note { padding: 0 14px 12px; color: var(--muted); font-size: 13px; }
.bar { height: 6px; border-radius: 999px; background: var(--blue-500); overflow: hidden; margin-top: 2px; flex-basis: 100%; }
.bar i { display: block; height: 100%; background: #fff; }
.savebar {
  position: sticky; bottom: 12px; z-index: 10; margin-top: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-radius: 999px; background: rgba(7, 18, 48, .92); border: 1px solid var(--line);
  backdrop-filter: blur(10px); box-shadow: var(--shadow);
}
.savebar span { font-size: 14px; color: var(--muted); }
.savebar .btn { white-space: nowrap; flex: none; }

/* ---------- leaderboard ---------- */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; margin-bottom: 18px; }
.podium .p { text-align: center; padding: 14px 8px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.podium .p .avatar { width: 54px; height: 54px; font-size: 18px; }
.podium .p.r1 { order: 2; padding-top: 26px; border-color: #ffd36b; background: linear-gradient(180deg, rgba(255,211,107,.18), var(--card)); }
.podium .p.r2 { order: 1; }
.podium .p.r3 { order: 3; }
.podium .medal { font-size: 26px; }
.podium .nm { font-weight: 800; font-size: 14px; margin-top: 6px; word-break: break-word; }
.podium .st { font-size: 12px; color: var(--muted); }
table.lb { width: 100%; border-collapse: collapse; font-size: 14px; }
table.lb th, table.lb td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); }
table.lb th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
table.lb td.num, table.lb th.num { text-align: center; font-variant-numeric: tabular-nums; }
table.lb tr.me td { background: rgba(247, 148, 29, .12); }
.who { display: flex; align-items: center; gap: 8px; }
.who .avatar { width: 28px; height: 28px; font-size: 12px; flex: none; }
.table-wrap { overflow-x: auto; }

/* ---------- run ---------- */
.run-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.votebar { display: flex; align-items: center; gap: 10px; }
.vote-dots { display: flex; gap: 6px; }
.vote-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--orange); }
.vote-dots i.on { background: var(--orange); }
.entries { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.entry { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.entry .media { position: relative; aspect-ratio: 4 / 3; background: #000; }
.entry .media img, .entry .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.entry .media .nav { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.entry .media .nav button { width: 9px; height: 9px; padding: 0; border-radius: 50%; border: 0; background: rgba(255,255,255,.45); cursor: pointer; }
.entry .media .nav button.on { background: #fff; }
.entry .media .km {
  position: absolute; top: 10px; left: 10px; background: var(--orange); color: var(--navy-900);
  font-weight: 900; padding: 4px 10px; border-radius: 999px; font-size: 14px;
}
.entry .media .rank {
  position: absolute; top: 10px; right: 10px; background: #ffd36b; color: var(--navy-900);
  font-weight: 900; padding: 4px 10px; border-radius: 999px; font-size: 14px;
}
.entry .body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.entry h3 { margin: 0; font-size: 18px; font-weight: 800; }
.entry .wish { margin: 0; color: var(--text); white-space: pre-wrap; font-style: italic; opacity: .9; }
.entry .members { display: flex; flex-wrap: wrap; gap: 6px; }
.entry .members .pill { display: inline-flex; align-items: center; gap: 6px; }
.entry .foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.vote-btn.on { background: linear-gradient(135deg, #ffe0b3, var(--orange)); }
.vote-btn:not(.on) { background: var(--card-2); color: var(--text); box-shadow: none; border: 1px solid var(--line); }

.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { width: min(620px, 100%); max-height: 92vh; overflow: auto; background: var(--navy-800); border: 1px solid var(--line); border-radius: 22px; padding: 22px; }
.modal h2 { margin: 0 0 4px; font-weight: 900; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumbs .t { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: #000; }
.thumbs .t img, .thumbs .t video { width: 100%; height: 100%; object-fit: cover; }
.thumbs .t button { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 50%; width: 22px; height: 22px; background: rgba(0,0,0,.7); color: #fff; cursor: pointer; }
.thumbs .t .prog { position: absolute; inset: auto 0 0 0; height: 4px; background: var(--orange); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips .pill button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 4px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.tips { font-size: 13px; color: var(--muted); background: rgba(247,148,29,.08); border: 1px dashed rgba(247,148,29,.4); border-radius: 12px; padding: 10px 12px; margin-top: 10px; line-height: 1.55; }

/* ---------- admin ---------- */
.admin-match { display: grid; grid-template-columns: 50px 1fr 90px 90px 140px 90px; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.admin-match input, .admin-match select { padding: 8px; }
.admin-match .ppl { font-size: 13px; }
.admin-match .ppl input { margin-top: 4px; font-size: 12px; }
@media (max-width: 720px) {
  .admin-match { grid-template-columns: 1fr 1fr; }
  .admin-match .ppl { grid-column: 1 / -1; }
}

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px);
  background: #fff; color: var(--navy-900); padding: 12px 18px; border-radius: 999px; font-weight: 700;
  box-shadow: var(--shadow); transition: transform .3s ease, opacity .3s ease; z-index: 100; opacity: 0; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.error { background: var(--bad); color: #fff; }

.foot { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 24px 16px 32px; color: var(--muted); font-size: 13px; text-align: center; flex-wrap: wrap; }
.foot img { background: #fff; border-radius: 4px; padding: 2px 5px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
@media (max-width: 440px) { .hide-xs { display: none; } }

/* ---------- participants ---------- */
.hero { margin-bottom: 8px; }
.ph { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; font-size: 16px; }
.ph ~ .ph { margin-top: 20px; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.people.dim { opacity: .6; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(0,0,0,.2); min-width: 0; }
.person .avatar { width: 38px; height: 38px; flex: none; }
.person b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person small { color: var(--muted); font-size: 12px; }
.person > div { min-width: 0; }
.who small { font-size: 12px; }

/* ---------- results mode ---------- */
.section-title.small { font-size: clamp(18px, 3vw, 24px); margin-top: 24px; }
.waiting { text-align: center; padding: 34px 20px; margin: 10px 0 8px;
  background: radial-gradient(500px 200px at 50% 0%, rgba(247,148,29,.22), transparent 70%), var(--card); }
.waiting .trophy { font-size: 56px; filter: drop-shadow(0 6px 20px rgba(247,148,29,.6)); animation: bob 2.4s ease-in-out infinite; }
.waiting h2 { margin: 8px 0 6px; font-weight: 900; font-style: italic; text-transform: uppercase; }
.waiting p { margin: 0 auto; max-width: 560px; color: var(--muted); line-height: 1.6; }
.dots-anim { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.dots-anim i { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); animation: blink 1.2s infinite; }
.dots-anim i:nth-child(2) { animation-delay: .2s; } .dots-anim i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .2; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.preview-note { margin: 12px 0; padding: 10px 14px; border-radius: 12px; font-size: 14px;
  background: rgba(127,178,255,.12); border: 1px dashed var(--blue-300); color: var(--blue-300); }
.champion { text-align: center; font-weight: 900; font-style: italic; font-size: clamp(20px, 4vw, 30px); letter-spacing: 1px;
  padding: 14px; border-radius: 18px; margin: -8px 0 16px; box-shadow: var(--shadow); }
.champion.white { background: linear-gradient(135deg, #fff, #dfe6f3); color: var(--navy-800); }
.champion.blue { background: linear-gradient(135deg, #2f6fe0, #12285c); color: #fff; }
.podium .p .avatar { width: 64px; height: 64px; font-size: 22px; }
.entries.top3 .entry.winner { border: 2px solid #ffd36b; box-shadow: 0 0 0 4px rgba(255,211,107,.15), var(--shadow); }
.announce { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.announce a { text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border-color: rgba(255,211,107,.6); background: linear-gradient(135deg, rgba(255,211,107,.18), var(--card)); }
.announce a span { margin-left: auto; color: var(--orange-300); font-weight: 700; }
.pub-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
