:root {
  --bg: #0b0b0f; --panel: #15151c; --panel2: #1d1d27; --line: #2a2a36;
  --text: #f2f2f5; --muted: #9a9aab; --live: #ff3b47; --accent: #ffcc33;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#topbar { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: linear-gradient(#111118, #0d0d13); border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; cursor: pointer; user-select: none; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.brand b { color: var(--live); font-weight: 700; }
#crumb { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#crumb b { color: var(--text); font-weight: 600; }
.spacer { flex: 1; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; }
.icon-btn:hover { background: var(--panel2); }
#search { width: 260px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 0 12px; outline: none; }
#search:focus { border-color: #555; }

.view { position: absolute; top: 60px; left: 0; right: 0; bottom: 0; overflow-y: auto; padding: 28px 32px 40px; }
.hero { font-size: 34px; margin: 4px 0 6px; font-weight: 700; letter-spacing: -0.5px; }
.hero.small { font-size: 26px; }
.sub { color: var(--muted); margin: 0 0 26px; }

/* home tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 22px; }
.tile { position: relative; height: 200px; border-radius: 18px; overflow: hidden; cursor: pointer; border: 1px solid var(--line);
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--c) 55%, transparent) 0%, transparent 55%), var(--panel);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; padding: 22px; display: flex; flex-direction: column; }
.tile:hover { transform: translateY(-3px) scale(1.01); border-color: var(--c); box-shadow: 0 12px 40px -12px color-mix(in srgb, var(--c) 60%, transparent); }
.tile .logo { width: 54px; height: 54px; border-radius: 14px; background: #0006; display: grid; place-items: center; overflow: hidden;
  font-weight: 800; font-size: 26px; color: var(--c); border: 1px solid #ffffff14; }
.tile .logo img { width: 36px; height: 36px; object-fit: contain; }
.tile .name { font-size: 26px; font-weight: 700; margin-top: auto; }
.tile .tag { color: var(--muted); font-size: 14px; margin-top: 4px; }
.tile .count { position: absolute; top: 22px; right: 22px; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: #0008; border: 1px solid #ffffff1a; }
.tile .count.live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--live); margin-right: 7px; animation: pulse 1.6s infinite; }
.tile .count.err { color: #ff9a9a; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* chips + cards */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 14px; font-size: 14px; color: var(--muted); }
.chip:hover { color: var(--text); }
.chip.on { background: var(--text); color: #111; border-color: var(--text); font-weight: 600; }
.chip .n { opacity: .6; margin-left: 6px; font-size: 12px; }
.status { color: var(--muted); margin: 6px 0 14px; min-height: 20px; }
.status.err { color: #ff9a9a; }
.group-title { grid-column: 1 / -1; font-size: 18px; font-weight: 700; margin: 14px 0 0; color: #ddd; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
  transition: transform .12s ease, border-color .12s ease; }
.card:hover { transform: translateY(-2px); border-color: #555; }
.card .art { height: 130px; background: linear-gradient(135deg, #1f1f2b, #121218); display: flex; align-items: center; justify-content: center; gap: 22px; position: relative; overflow: hidden; }
.card .art img.thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .85; }
.card .art img.badge { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 4px 10px #0009); position: relative; }
.card .art img.chlogo { max-width: 60%; max-height: 70px; object-fit: contain; position: relative; }
.card .art .vs { color: var(--muted); font-weight: 700; position: relative; }
.card .art .mono { font-size: 38px; font-weight: 800; color: #ffffff22; }
.card .meta { padding: 12px 14px 14px; }
.card .t { font-weight: 600; font-size: 15px; line-height: 1.3; }
.card .l { color: var(--muted); font-size: 13px; margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 6px; letter-spacing: .3px; }
.pill.live { background: var(--live); color: #fff; }
.pill.soon { background: #2d2d3a; color: #cfcfe0; }
.pill.hot { background: #ff8a00; color: #111; }
.card .art .pill { position: absolute; top: 10px; left: 10px; }

/* player */
.player-view { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.player-bar { display: flex; align-items: center; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: #0f0f15; flex-wrap: wrap; }
.now { min-width: 200px; max-width: 34%; }
.p-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.servers { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.srv { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 7px 13px; font-size: 13px; }
.srv:hover { background: var(--panel2); }
.srv.on { background: var(--live); border-color: var(--live); color: #fff; font-weight: 600; }
.srv.busy { opacity: .6; }
.p-actions { display: flex; gap: 8px; }
.ghost { border: 1px solid var(--line); background: transparent; border-radius: 9px; padding: 7px 12px; font-size: 13px; color: var(--muted); }
.ghost:hover { color: var(--text); background: var(--panel); }
.player-area { flex: 1; position: relative; background: #000; }
.p-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 15px; text-align: center; padding: 20px; }
body.fs #topbar, body.fs .player-bar { display: none; }
body.fs .view { top: 0; }

/* settings */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; max-width: 900px; }
.panel h2 { margin: 0 0 6px; font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; }
.hint a { color: #8db4ff; }
.check { display: flex; gap: 10px; align-items: center; }
.site-form { display: grid; grid-template-columns: 130px 1fr 150px auto auto; gap: 10px; align-items: center; margin-top: 12px; }
.site-form input[type=text] { height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #0d0d13; color: var(--text); padding: 0 10px; }
.site-form .sname { font-weight: 600; }
.row-end { max-width: 900px; display: flex; justify-content: flex-end; }
.primary { background: var(--live); border: 0; border-radius: 10px; padding: 10px 22px; font-weight: 700; color: #fff; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #22222d; border: 1px solid var(--line); padding: 12px 18px; border-radius: 12px; z-index: 20; max-width: 70%; }
::-webkit-scrollbar { width: 10px; } ::-webkit-scrollbar-thumb { background: #2c2c38; border-radius: 10px; } ::-webkit-scrollbar-track { background: transparent; }

/* ---------- phone / tablet ---------- */
html, body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#topbar { height: 56px; padding: 0 12px; gap: 8px; padding-top: env(safe-area-inset-top); }
.brand { font-size: 19px; }
.brand img { width: 28px; height: 28px; }
#crumb { font-size: 14px; }
.icon-btn { width: 40px; height: 40px; flex: none; }
#searchRow { position: absolute; top: 56px; left: 0; right: 0; padding: 8px 12px; background: #0d0d13; z-index: 4; border-bottom: 1px solid var(--line); }
#searchRow input { width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 0 12px; font-size: 16px; outline: none; }
body.searching .view { top: 113px; }
.view { top: 56px; padding: 18px 14px 40px; -webkit-overflow-scrolling: touch; }
.hero { font-size: 28px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tile { height: 150px; padding: 18px; }
.tile:hover { transform: none; }
.tile:active { transform: scale(0.98); }
.tile .name { font-size: 22px; }
.tile .logo { width: 44px; height: 44px; font-size: 22px; }
.tile .count { top: 18px; right: 18px; }
.chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px 12px; padding: 0 14px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; }
.cards { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.card:hover { transform: none; }
.card:active { transform: scale(0.98); border-color: #555; }
.card .art { height: 96px; gap: 12px; }
.card .art img.badge { width: 46px; height: 46px; }
.card .art .mono { font-size: 24px; }
.card .meta { padding: 9px 10px 11px; }
.card .t { font-size: 14px; }
.card .l { font-size: 12px; margin-top: 4px; }
.group-title { font-size: 16px; margin: 10px 0 0; }
.site-form { grid-template-columns: 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.site-form input[type=text] { height: 40px; font-size: 15px; }
.panel { padding: 14px; }
.loading { position: fixed; inset: 0; background: #000a; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 30; color: var(--text); }
.spin { width: 40px; height: 40px; border: 4px solid #ffffff33; border-top-color: var(--live); border-radius: 50%; animation: sp 0.9s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.toast { bottom: 20px; max-width: 90%; font-size: 14px; }
@media (min-width: 900px) {
  .cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .card .art { height: 120px; }
}
/* top bar on a phone: the logo text gives way to the site name */
@media (max-width: 600px) { body:not(.home) .brand span { display: none; } }
/* older web engines without color-mix: a plain tinted tile */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .tile { background: linear-gradient(135deg, var(--c) -60%, var(--panel) 55%); }
}
