:root {
  --bg: #000;
  --text: #f2f4f8;
  --muted: rgba(235, 240, 250, 0.58);
  --faint: rgba(235, 240, 250, 0.36);
  --glass: rgba(18, 18, 20, 0.42);
  --glass-strong: rgba(40, 40, 44, 0.42);
  --edge: rgba(255, 255, 255, 0.12);
  --edge-soft: rgba(255, 255, 255, 0.07);
  --shine: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 -1px 0 rgba(255, 255, 255, 0.03);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.9);
  --green: #5ee59a;
  --red: #ff7a7a;
  --blur: blur(26px) saturate(120%);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); color: var(--text); }

body {
  min-height: 100vh;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

a { color: inherit; text-decoration: none; }

h1 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 600; }

svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  background: #000;
  opacity: 0;
  transition: opacity 1.6s var(--ease);
}
.backdrop.ready { opacity: 1; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes ping {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(3); opacity: 0; }
}

.login form,
header,
.stats,
.summary,
.panel,
.game-card {
  background: linear-gradient(160deg, var(--glass-strong), var(--glass) 60%);
  border: 1px solid var(--edge);
  box-shadow: var(--shine), var(--shadow);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}

button, input { font: inherit; color: inherit; }

button,
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--edge-soft);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.35s var(--spring), color 0.25s;
}
button:hover,
.back:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--edge); }
button:active,
.back:active { transform: scale(0.96); }
button:disabled { opacity: 0.45; cursor: default; transform: none; }

.back { padding-left: 9px; color: var(--muted); }
.back:hover { color: var(--text); }
.back svg { transition: transform 0.35s var(--spring); }
.back:hover svg { transform: translateX(-3px); }

input {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--edge-soft);
  border-radius: 12px;
  padding: 9px 13px;
  outline: none;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}
input::placeholder { color: var(--faint); }
input:focus { border-color: rgba(255, 255, 255, 0.35); background: rgba(0, 0, 0, 0.45); box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 24px 22px;
  border-radius: 24px;
  animation: rise 0.7s var(--ease) both;
}
.login h1 { font-size: 22px; margin-bottom: 4px; text-align: center; }
.login button { justify-content: center; padding: 10px 14px; background: rgba(255, 255, 255, 0.14); }
.login button:hover { background: rgba(255, 255, 255, 0.2); }
.error { color: var(--red); font-size: 13px; min-height: 18px; text-align: center; }

.app { max-width: 1120px; margin: 0 auto; padding: 18px 16px 48px; }

header {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 10px 10px 18px;
  border-radius: 999px;
  animation: rise 0.6s var(--ease) both;
}
header:has(.back:not([hidden])) { padding-left: 10px; }
header nav { display: flex; gap: 6px; margin-left: auto; }
.status { font-size: 12px; color: var(--faint); }
.status.stale { color: var(--red); }

.stats,
.summary {
  display: grid;
  margin-top: 18px;
  border-radius: 22px;
  overflow: hidden;
}
.stats { grid-template-columns: repeat(3, 1fr); }
.summary { grid-template-columns: repeat(2, 1fr); }
.stats > div,
.summary > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 22px;
}
.stats > div + div,
.summary > div + div { border-left: 1px solid var(--edge-soft); }
.label { font-size: 12px; color: var(--muted); }
.value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.note { font-size: 12px; color: var(--faint); }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.panel { border-radius: 22px; min-width: 0; overflow: hidden; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 20px;
  border-bottom: 1px solid var(--edge-soft);
  min-height: 54px;
}
.panel-head input { width: 170px; padding: 6px 12px; font-size: 13px; border-radius: 999px; }

.list { max-height: 600px; overflow-y: auto; padding: 6px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 14px;
  transition: background 0.25s var(--ease);
}
.row:hover { background: rgba(255, 255, 255, 0.06); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); flex-shrink: 0; object-fit: cover; box-shadow: 0 0 0 1px var(--edge-soft); }
.who { flex: 1; min-width: 0; }
.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.name .user { color: var(--faint); margin-left: 6px; font-weight: 400; }
.meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.tag { padding: 0 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); }
.tag.on { color: var(--green); background: rgba(94, 229, 154, 0.12); }
.side { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { padding: 32px 14px; text-align: center; color: var(--faint); font-size: 13px; }
.join { padding: 4px 12px; font-size: 12px; flex-shrink: 0; }

.games { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 16px; }

.game-card {
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  overflow: hidden;
  transition: transform 0.5s var(--spring), box-shadow 0.5s var(--ease), border-color 0.3s;
}
.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: var(--shine), 0 28px 60px -24px rgba(0, 0, 0, 0.85);
  outline: none;
}
.game-card:active { transform: translateY(-1px) scale(0.99); }

.banner { position: relative; aspect-ratio: 2 / 1; margin: 8px 8px 0; border-radius: 17px; overflow: hidden; background: rgba(255, 255, 255, 0.05); }
.banner img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.9s var(--ease); }
.game-card:hover .banner img { transform: scale(1.04); }

.live {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 9px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(10, 12, 18, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.live .dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.live.on .dot { background: var(--green); }
.live.on .dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--green);
  animation: ping 2s var(--ease) infinite;
}

.game-body { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.game-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.game-title h2 { font-size: 16px; font-weight: 600; }
.arrow {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--edge-soft);
  transition: transform 0.45s var(--spring), color 0.25s, background 0.25s;
}
.game-card:hover .arrow { color: var(--text); background: rgba(255, 255, 255, 0.14); transform: translateX(3px); }

.game-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.game-stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--edge-soft);
}
.game-stat-value { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

.enter .summary,
.enter .stats,
.enter .panel,
.enter .game-card,
.enter.games .game-card { animation: rise 0.7s var(--ease) both; }
.enter .panel:nth-child(2),
.enter .game-card:nth-child(2) { animation-delay: 0.08s; }
.enter .game-card:nth-child(3) { animation-delay: 0.16s; }
.enter .game-card:nth-child(4) { animation-delay: 0.24s; }
.enter .row { animation: rise 0.5s var(--ease) both; }

@media (max-width: 800px) {
  .panels, .games { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .app { padding-top: 12px; }
  header { flex-wrap: wrap; gap: 8px 10px; border-radius: 22px; padding: 12px 14px; top: 8px; }
  header:has(.back:not([hidden])) { padding-left: 12px; }
  header nav { margin-left: 0; width: 100%; }
  header nav button { flex: 1; justify-content: center; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats > div:nth-child(3) { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--edge-soft); }
  .stats > div, .summary > div { padding: 14px 16px; }
  .value { font-size: 24px; }
  .panel-head input { width: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
