:root {
  --bg: #f5f3ff;
  --ink: #1e1b4b;
  --muted: #6b7280;
  --card: #ffffff;
  --line: #e5e7eb;
  --brand: #6d28d9;
  --brand2: #db2777;
  --live: #ef4444;
  --ok: #059669;
  --stage: #0b0f1e;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(76, 29, 149, .12);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 0% -10%, #fde68a55, transparent 60%),
    radial-gradient(900px 600px at 100% 0%, #c4b5fd66, transparent 60%),
    radial-gradient(800px 600px at 50% 120%, #fbcfe866, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--live); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #ef444499; } 70% { box-shadow: 0 0 0 14px #ef444400; } 100% { box-shadow: 0 0 0 0 #ef444400; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.lcard {
  width: 100%; max-width: 380px; background: var(--card); border-radius: 24px; padding: 30px 26px;
  box-shadow: var(--shadow); animation: rise .5s ease both; position: relative; overflow: hidden;
}
.lcard::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 6px;
  background: linear-gradient(90deg, #f59e0b, #ec4899, #8b5cf6, #06b6d4, #f59e0b); background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: .3px; }
.logo .dot { width: 12px; height: 12px; }
.logo b { background: linear-gradient(90deg, var(--brand), var(--brand2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lcard p { color: var(--muted); margin: 6px 0 22px; }
.lcard label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.lcard input {
  width: 100%; padding: 13px 14px; border: 2px solid var(--line); border-radius: 12px; font-size: 16px; outline: none;
  transition: border-color .2s, box-shadow .2s; background: #fff; color: var(--ink);
}
.lcard input:focus { border-color: #a78bfa; box-shadow: 0 0 0 4px #ede9fe; }
.btn {
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand2)); box-shadow: 0 6px 18px #7c3aed44;
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.btn:hover, .btn:focus-visible { transform: translateY(-1px); box-shadow: 0 10px 24px #7c3aed55; }
.btn:disabled { opacity: .6; transform: none; }
.lcard .btn { width: 100%; margin-top: 22px; font-size: 16px; padding: 14px; }
.lerr { color: #b91c1c; font-size: 14px; min-height: 20px; margin-top: 12px; }
.lnote { background: #fef3c7; color: #92400e; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 8px; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: #ffffffcc; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid #ede9fe;
}
.top .logo { font-size: 19px; }
.top .sp { flex: 1; }
.who { font-size: 13px; color: var(--muted); text-align: right; line-height: 1.3; }
.who b { color: var(--ink); }
.ghost { border: 1px solid #ddd6fe; background: #fff; color: var(--brand); border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.ghost:hover, .ghost:focus-visible { background: #f5f3ff; }

/* list */
.wrap { max-width: 1280px; margin: 0 auto; padding: 22px 16px 120px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.hero h1 { margin: 0; font-size: clamp(22px, 3vw, 32px); }
.hero h1 small { display: block; font-size: 14px; font-weight: 500; color: var(--muted); margin-top: 4px; }
.mvbtn.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.ev {
  position: relative; text-align: left; border: 0; border-radius: var(--radius); padding: 18px 18px 16px; min-height: 150px;
  color: #fff; overflow: hidden; box-shadow: var(--shadow); animation: rise .45s ease both;
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  transition: transform .18s, box-shadow .18s, outline-color .18s; outline: 4px solid transparent; outline-offset: 3px;
}
.ev:hover, .ev:focus-visible { transform: translateY(-3px) scale(1.01); box-shadow: 0 16px 36px rgba(76, 29, 149, .25); }
.ev:focus-visible { outline-color: #facc15; }
.ev::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 150px; height: 150px; border-radius: 50%;
  background: #ffffff22; transition: transform .4s;
}
.ev:hover::after { transform: scale(1.3); }
.c0 { background: linear-gradient(135deg, #7c3aed, #db2777); }
.c1 { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.c2 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.c3 { background: linear-gradient(135deg, #10b981, #0ea5e9); }
.c4 { background: linear-gradient(135deg, #ec4899, #f97316); }
.c5 { background: linear-gradient(135deg, #6366f1, #14b8a6); }
.evtop { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
.live {
  display: inline-flex; align-items: center; gap: 6px; background: #fff; color: var(--live); font-weight: 800;
  font-size: 12px; letter-spacing: .6px; padding: 4px 10px; border-radius: 99px;
}
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 1.4s infinite; }
.sport { font-size: 26px; filter: drop-shadow(0 2px 4px #0003); }
.evtitle { position: relative; z-index: 1; font-size: clamp(19px, 2.2vw, 24px); font-weight: 800; line-height: 1.2; text-shadow: 0 1px 2px #0003; }
.evsub { position: relative; z-index: 1; font-size: 13px; opacity: .92; margin-top: 4px; }
.evplay {
  position: relative; z-index: 1; align-self: flex-start; background: #ffffff2e; border-radius: 99px; padding: 6px 14px;
  font-weight: 700; font-size: 14px; backdrop-filter: blur(4px);
}
.tick {
  position: absolute; z-index: 2; right: 12px; bottom: 12px; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid #fff; display: none; place-items: center; font-weight: 900; background: #ffffff33;
}
.picking .tick { display: grid; }
.picking .evplay { visibility: hidden; }
.ev.sel { outline-color: #fff; outline-offset: -4px; }
.ev.sel .tick { background: #fff; color: var(--brand); }

.empty {
  text-align: center; padding: 60px 16px; background: #ffffffaa; border-radius: 24px; box-shadow: var(--shadow); animation: rise .4s both;
}
.empty .rings { width: 90px; height: 90px; margin: 0 auto 18px; position: relative; display: grid; place-items: center; }
.empty .rings span { position: absolute; inset: 0; border-radius: 50%; border: 3px solid #c4b5fd; animation: ring 2.4s infinite; }
.empty .rings span:nth-child(2) { animation-delay: .8s; }
.empty .rings span:nth-child(3) { animation-delay: 1.6s; }
.empty .rings b { font-size: 34px; }
@keyframes ring { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
.empty h2 { margin: 0 0 6px; }
.empty p { color: var(--muted); margin: 0; }

.pickbar {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff; padding: 10px 10px 10px 18px;
  border-radius: 99px; box-shadow: 0 12px 30px #1e1b4b55; animation: rise .3s both; white-space: nowrap; max-width: calc(100% - 32px);
}
.pickbar .btn { padding: 10px 16px; border-radius: 99px; }

/* player stage */
.stage { position: fixed; inset: 0; z-index: 10; background: var(--stage); display: flex; flex-direction: column; color: #fff; }
.sbar {
  display: flex; align-items: center; gap: 10px; padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: #111633; border-bottom: 1px solid #ffffff14;
}
.sbar .sp { flex: 1; min-width: 0; }
.sbar h2 { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dark { border: 1px solid #ffffff2a; background: #ffffff12; color: #fff; border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.dark:hover, .dark:focus-visible { background: #ffffff26; }
.addwrap { position: relative; }
.addmenu {
  position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--ink); border-radius: 12px; padding: 6px;
  min-width: 240px; max-height: 60vh; overflow: auto; box-shadow: 0 12px 30px #0006; z-index: 3;
}
.addmenu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; }
.addmenu button:hover, .addmenu button:focus-visible { background: #f5f3ff; }

.tiles { flex: 1; min-height: 0; display: grid; gap: 6px; padding: 6px; }
.tiles.n1 { grid-template: 1fr / 1fr; }
.tiles.n2 { grid-template: 1fr / 1fr 1fr; }
.tiles.n3, .tiles.n4 { grid-template: 1fr 1fr / 1fr 1fr; }
.tile { position: relative; background: #000; border-radius: 10px; overflow: hidden; min-height: 0; animation: rise .35s both; }
.tile iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.tlabel {
  position: absolute; left: 8px; top: 8px; z-index: 2; max-width: calc(100% - 60px); background: #000a; padding: 4px 10px;
  border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; transition: opacity .3s;
}
.tclose {
  position: absolute; right: 8px; top: 8px; z-index: 2; width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: #000a; color: #fff; font-size: 16px; line-height: 1;
}
.treload {
  position: absolute; right: 44px; top: 8px; z-index: 2; width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: #000a; color: #fff; font-size: 16px; line-height: 1; opacity: .55;
}
.treload:hover, .treload:focus-visible { opacity: 1; }
.tiles.n1 .tlabel, .tiles.n1 .tclose { display: none; }
.tiles.n1 .treload { right: 8px; top: auto; bottom: 64px; }
.tile .tmsg { position: absolute; inset: 0; display: grid; place-items: center; color: #cbd5e1; font-size: 14px; text-align: center; padding: 10px; }

/* toasts */
#toasts { position: fixed; z-index: 30; left: 50%; top: 14px; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 11px 14px; border-radius: 12px; box-shadow: 0 10px 26px #0004; animation: rise .3s both; font-size: 14px; }
.toast.err { background: #b91c1c; }

/* phones */
@media (max-width: 640px) {
  .who { font-size: 11px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .ev { min-height: 128px; }
  .sbar h2 { font-size: 14px; }
  .hide-sm { display: none; }
}
/* phone held upright: players one under the other (16:9 each), page scrolls */
@media (max-width: 760px) and (orientation: portrait) {
  .tiles { display: block; overflow-y: auto; }
  .tile { width: 100%; aspect-ratio: 16 / 9; margin-bottom: 6px; }
  .tiles.n1 { display: grid; }
  .tiles.n1 .tile { aspect-ratio: auto; margin: 0; }
}
/* big screens / TV: larger cards */
@media (min-width: 1600px) {
  .wrap { max-width: 1700px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 22px; }
  .ev { min-height: 190px; padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
