:root {
  --background: #090b10;
  --surface: #11141c;
  --surface-hover: #151a26;
  --text: #e9ebf2;
  --muted: #9da5b6;
  --subtle: #788296;
  --border: #242a36;
  --blue: #6f9cc4;
  --blue-strong: #89afcf;
  --live: #e5484d;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--background); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, Arial, sans-serif; -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
img { display: block; }

.top { display: flex; align-items: center; gap: 24px; padding: 14px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgb(9 11 16 / .92); backdrop-filter: blur(8px); z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; }
.brand img { border-radius: 7px; }
.brand b { color: var(--blue); font-weight: 600; }
.games { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.games button { border: 0; background: none; padding: 6px 12px; border-radius: 6px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.games button[aria-selected="true"] { background: var(--surface-hover); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.updated { margin: 0 0 0 auto; color: var(--subtle); font-size: 12px; white-space: nowrap; }
.updated.stale { color: #e0a458; }

.directory { flex: 1; display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 28px; padding: 24px; width: 100%; max-width: 1600px; margin: 0 auto; }
.servers { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 84px; align-self: start; }
.servers button { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; text-align: left; }
.servers button:hover { background: var(--surface); color: var(--text); }
.servers button[aria-current="true"] { background: var(--surface-hover); color: var(--text); box-shadow: inset 2px 0 0 var(--blue); }
.servers .count { font-size: 12px; color: var(--subtle); font-variant-numeric: tabular-nums; }
.servers .count.on::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--live); margin-right: 6px; vertical-align: 1px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar h1 { font-size: 24px; font-weight: 550; letter-spacing: -.02em; margin: 0 auto 0 0; }
.toolbar h1 small { font-size: 14px; color: var(--subtle); font-weight: 400; margin-left: 8px; letter-spacing: 0; }
input[type="search"], select { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; min-height: 38px; }
input[type="search"] { width: min(320px, 100%); }
input[type="search"]::placeholder { color: var(--subtle); }

.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color .15s, background .15s; }
.card:hover { border-color: #3a4a5e; background: var(--surface-hover); }
.card.selected { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, #1a2030, #11141c); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.badge { position: absolute; left: 8px; top: 8px; display: flex; gap: 6px; font-size: 12px; }
.badge span { background: rgb(0 0 0 / .72); padding: 2px 7px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.badge .live { background: var(--live); font-weight: 600; }
.pick { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; border-radius: 7px; border: 1px solid rgb(255 255 255 / .25); background: rgb(0 0 0 / .6); cursor: pointer; display: grid; place-items: center; font-size: 18px; line-height: 1; }
.card.selected .pick { background: var(--blue); border-color: var(--blue); color: var(--background); }
.meta { padding: 11px 13px 13px; }
.meta .who { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.meta .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .char { color: var(--blue); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .title { color: var(--muted); font-size: 13px; margin: 3px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .open { position: absolute; inset: 0; z-index: 0; }
.card .pick { z-index: 1; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

.recent { margin-top: 32px; border-top: 1px solid var(--border); padding-top: 16px; color: var(--muted); }
.recent summary { cursor: pointer; }
.recent ul { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 20px; }
.recent li { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.recent li a:hover { color: var(--text); }
.recent time { color: var(--subtle); white-space: nowrap; }

.tray { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; background: var(--surface-hover); border: 1px solid var(--border); border-radius: 12px; padding: 10px 10px 10px 18px; box-shadow: 0 10px 30px rgb(0 0 0 / .5); z-index: 6; white-space: nowrap; }
.button { display: inline-flex; align-items: center; min-height: 38px; padding: 8px 16px; border-radius: 8px; background: var(--blue); color: var(--background); font-weight: 600; border: 0; cursor: pointer; }
.button:hover { background: var(--blue-strong); }
.ghost { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: none; color: var(--muted); cursor: pointer; }
.ghost:hover { color: var(--text); border-color: #3a4a5e; }

.watch { flex: 1; display: flex; flex-direction: column; padding: 14px 20px 20px; gap: 14px; min-height: 0; }
.watch-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.watch-bar .hint { margin: 0 auto 0 0; color: var(--subtle); font-size: 12px; }
.layouts { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.layouts button { border: 0; background: none; padding: 7px 12px; color: var(--muted); cursor: pointer; }
.layouts button[aria-pressed="true"] { background: var(--surface-hover); color: var(--text); }
.watch-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; min-height: 0; }
.players { display: grid; gap: 10px; align-content: start; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
.players[data-layout="focus"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.players[data-layout="focus"] .tile.focused { grid-column: 1 / -1; }
.tile { background: #000; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.tile.focused { border-color: var(--blue); }
.tile header { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 10px; background: var(--surface); font-size: 13px; }
.tile header .focus { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 0; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile header .focus b { font-weight: 600; }
.tile header .focus span { color: var(--blue); margin-left: 6px; }
.tile header .sound { color: var(--subtle); font-size: 12px; }
.tile.focused header .sound { color: var(--blue); }
.tile header .remove { border: 0; background: none; color: var(--subtle); cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 5px; }
.tile header .remove:hover { color: var(--text); background: var(--surface-hover); }
.tile .frame { aspect-ratio: 16 / 9; }
.tile .frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.others { border-left: 1px solid var(--border); padding-left: 16px; overflow: auto; }
.others h2 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 4px 0 10px; }
.others ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.others button { width: 100%; display: flex; justify-content: space-between; gap: 8px; border: 0; background: none; padding: 7px 8px; border-radius: 7px; cursor: pointer; text-align: left; color: var(--muted); }
.others button:hover { background: var(--surface); color: var(--text); }
.others button span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.others button em { font-style: normal; color: var(--blue); }
.others .viewers { color: var(--subtle); font-size: 12px; font-variant-numeric: tabular-nums; }
.no-players { color: var(--muted); padding: 40px; text-align: center; grid-column: 1 / -1; }

.foot { padding: 18px 24px; color: var(--subtle); font-size: 12px; border-top: 1px solid var(--border); }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--blue); }

@media (max-width: 900px) {
  .top { flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px; }
  .updated { width: 100%; margin: 0; order: 3; }
  .directory { grid-template-columns: 1fr; padding: 16px; gap: 14px; }
  .servers { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .servers button { white-space: nowrap; flex-shrink: 0; }
  .servers button[aria-current="true"] { box-shadow: inset 0 -2px 0 var(--blue); }
  .toolbar input[type="search"] { flex: 1; width: auto; }
  .watch { padding: 12px 16px 16px; }
  .watch-body { grid-template-columns: 1fr; }
  .players, .players[data-layout="focus"] { grid-template-columns: 1fr; }
  .others { border-left: 0; border-top: 1px solid var(--border); padding: 12px 0 0; }
  .watch-bar .hint { display: none; }
  .tray { left: 16px; right: 16px; transform: none; justify-content: space-between; }
}
