/* Party lobby. AndrewNet look (Styling Guide.md). */
:root {
  --bg: #0d1020;
  --bg2: #151a33;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hi: rgba(255, 255, 255, 0.09);
  --text: #f2f3fa;
  --muted: #9aa0bf;
  --accent: #8fb0ff;
  --border: rgba(255, 255, 255, 0.1);
  --glow: rgba(110, 120, 255, 0.45);
  --sun: #ffd45e;
  --pill: linear-gradient(135deg, #8fd8ff, #a98bff);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(47, 111, 228, 0.35), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(123, 63, 228, 0.3), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
h1, h2 { letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
.back { position: absolute; top: 12px; left: 14px; color: var(--accent); text-decoration: none; font-size: 0.9rem; z-index: 2; }
.back:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- phone / desktop ---------- */
.wrap { width: 100%; max-width: 480px; margin: 0 auto; padding: 52px 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 52px; height: 52px; border-radius: 14px; }
.brand h1 { font-size: clamp(1.7rem, 5vw, 2.2rem); font-weight: 800; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); font-weight: 700; }
.hint { color: var(--muted); font-size: 0.92rem; margin: 0; }
.input { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; font-size: 1.1rem; width: 100%; }
.input.code { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800; text-align: center; font-size: 1.6rem; }
.btn { border: 1px solid var(--border); border-radius: 999px; padding: 12px 18px; min-height: 48px; font-weight: 700; background: var(--surface); cursor: pointer; transition: transform 0.18s ease, background 0.18s ease; }
.btn:hover { background: var(--surface-hi); }
.btn.primary { background: var(--pill); color: var(--bg); border: 0; }
.btn.danger { color: #ff8b9b; }
.btn.small { padding: 6px 12px; min-height: 40px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; background: var(--c); cursor: pointer; }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 3px var(--bg) inset; }
.swatch:disabled { opacity: 0.2; cursor: default; }
.code-big { font-size: 3.2rem; font-weight: 800; letter-spacing: 0.18em; color: var(--sun); line-height: 1; }

.players { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 4px; font-weight: 600; }
button.chip { cursor: pointer; }
.chip .dot { width: 30px; height: 30px; border-radius: 50%; background: var(--c); display: grid; place-items: center; color: var(--bg); font-weight: 800; flex: none; overflow: hidden; }
.chip .dot img { width: 100%; height: 100%; object-fit: cover; }
.chip.away { opacity: 0.6; }
.chip.inactive { opacity: 0.35; }
.chip .tag { font-size: 0.75em; color: var(--muted); font-weight: 600; }
.chip .crown { color: var(--sun); }
.chip.me { border-color: rgba(143, 176, 255, 0.6); }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.game { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 14px 10px; cursor: pointer; transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease; }
.game img { width: 64px; height: 64px; border-radius: 16px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35); }
.game b { font-size: 0.98rem; }
.game small { color: var(--muted); font-size: 0.78rem; line-height: 1.3; }
.game.off { opacity: 0.45; cursor: default; }
.game:not(.off):hover, .game:not(.off):focus-visible { transform: translateY(-4px); background: var(--surface-hi); border-color: rgba(143, 176, 255, 0.45); box-shadow: 0 18px 40px -18px var(--glow); }

.standings { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.standings li { display: flex; align-items: center; gap: 10px; }
.standings .pos { width: 1.6em; color: var(--muted); font-weight: 700; }
.standings .pts { margin-left: auto; font-weight: 800; }

.banner { background: rgba(255, 212, 94, 0.12); border: 1px solid rgba(255, 212, 94, 0.4); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }

[hidden] { display: none !important; }
#overlay { position: fixed; inset: 0; z-index: 50; background: rgba(13, 16, 32, 0.94); display: grid; place-items: center; text-align: center; padding: 24px; }
#overlay .starting { display: flex; flex-direction: column; align-items: center; gap: 18px; }
#overlay img { width: 140px; height: 140px; border-radius: 32px; box-shadow: 0 18px 40px -10px var(--glow); }
#overlay h2 { font-size: 2.2rem; }
.sheet { background: var(--bg2); border: 1px solid var(--border); border-radius: 22px; padding: 20px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: left; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; z-index: 60; max-width: 90vw; }
.conn { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); background: #ff8b9b; color: var(--bg); padding: 6px 14px; border-radius: 999px; font-weight: 700; z-index: 60; }

/* ---------- TV lobby (1920x1080, read from 3 m) ---------- */
.tvl { height: 100vh; padding: 5vh 5vw; display: grid; grid-template-columns: 30vw 1fr 22vw; grid-template-rows: auto 1fr auto auto; gap: 2.5vh 3vw; }
.tvl header { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: center; gap: 1.5vw; position: relative; }
.tvl header .label { font-size: 1.6vw; }
.tvl header .code { font-size: 3.4vw; font-weight: 800; letter-spacing: 0.3em; color: var(--sun); }
.tvl header .played { position: absolute; right: 0; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.3vw; }
.tvl .join { grid-row: 2 / 4; display: flex; flex-direction: column; gap: 1.6vh; align-items: flex-start; }
.tvl .join img.qr { width: 19vw; height: 19vw; background: #fff; border-radius: 1.4vw; padding: 0.8vw; }
.tvl .join p { margin: 0; font-size: 1.5vw; color: var(--muted); }
.tvl .join .addr { font-size: 1.8vw; color: var(--text); font-weight: 700; }
.tvl .join .code-big { font-size: 6.5vw; }
.tvl .players-box { display: flex; flex-direction: column; gap: 1.5vh; min-height: 0; }
.tvl .players { gap: 1vw; }
.tvl .chip { font-size: 1.6vw; padding: 0.5vw 1.3vw 0.5vw 0.5vw; }
.tvl .chip.new { animation: pop 0.35s ease; }
.tvl .chip .dot { width: 3vw; height: 3vw; font-size: 1.4vw; }
.tvl .label { font-size: 1.1vw; }
.tvl .side { display: flex; flex-direction: column; gap: 1.5vh; }
.tvl .standings li { font-size: 1.4vw; }
.tvl .standings .dot { width: 2.2vw; height: 2.2vw; font-size: 1vw; }
.tvl .history { color: var(--muted); font-size: 1.1vw; margin: 0; padding-left: 1.2em; }
.tvl .pick { grid-column: 2 / 4; display: flex; flex-direction: column; gap: 1.2vh; min-width: 0; }
.tvl .games { display: flex; gap: 1.2vw; overflow-x: auto; padding: 1vh 0.4vw 1.4vh; grid-template-columns: none; }
.tvl .game { flex: 0 0 11vw; padding: 1.2vw 0.6vw; border-radius: 1.4vw; }
.tvl .game img { width: 6vw; height: 6vw; border-radius: 1.4vw; }
.tvl .game b { font-size: 1.2vw; }
.tvl .game small { font-size: 0.9vw; }
.tvl .gameinfo { font-size: 1.3vw; color: var(--muted); min-height: 1.6em; }
.tvl footer { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 2vw; font-size: 1.3vw; color: var(--muted); }
.tvl footer .btn { font-size: 1.2vw; padding: 0.6vw 1.6vw; }
.tvl .warn { color: var(--sun); font-weight: 700; }
html.tv .back { font-size: 1.2vw; top: 2vh; left: 2.5vw; padding: 0.3vw 0.8vw; border-radius: 999px; }
html.tv .back:focus { background: var(--accent); color: var(--bg); }
html.tv :focus-visible, html.tv :focus { outline: 0.25vw solid var(--accent); outline-offset: 0.25vw; }
html.tv .wrap { max-width: 900px; font-size: 1.6rem; }
html.tv #overlay h2 { font-size: 4vw; }
html.tv #overlay img { width: 14vw; height: 14vw; border-radius: 3vw; }
html.tv #overlay p { font-size: 1.6vw; }

@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (max-width: 420px) {
  .code-big { font-size: 2.6rem; }
  .games { grid-template-columns: repeat(2, 1fr); }
}
