/* =========================================================
   Lobby — same visual language as the deck select / arena
   ========================================================= */
.next-lobby-page {
    --lobby-bg: #05070d;
    --lobby-panel: rgba(11, 16, 26, 0.84);
    --lobby-border: rgba(148, 163, 184, 0.18);
    --lobby-border-strong: rgba(226, 232, 240, 0.24);
    --lobby-text: #e5e7eb;
    --lobby-muted: #93a0b6;
    --lobby-blue: #5aa2ff;
    --lobby-red: #ff657f;
    --lobby-amber: #f6bd60;

    margin: 0;
    min-height: 100vh;
    background: var(--lobby-bg);
    color: var(--lobby-text);
    font-family: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}
.next-lobby-page *,
.next-lobby-page *::before,
.next-lobby-page *::after { box-sizing: border-box; }
.next-lobby-page button,
.next-lobby-page input { font: inherit; }
.next-lobby-page :focus-visible { outline: 2px solid var(--lobby-blue); outline-offset: 3px; }
.lobby-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.next-lobby-shell {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 22px clamp(16px, 4vw, 56px) 40px;
}

/* Background: the active arena scene, darkened, plus the game's grid and glows. */
.lobby-scene,
.lobby-grid { position: fixed; inset: 0; pointer-events: none; }
.lobby-scene {
    background:
        radial-gradient(circle at 18% 22%, rgba(90, 162, 255, 0.22), transparent 34%),
        radial-gradient(circle at 84% 78%, rgba(255, 101, 127, 0.2), transparent 32%),
        linear-gradient(180deg, rgba(5, 7, 13, 0.72), rgba(5, 7, 13, 0.94) 70%),
        var(--lobby-scene, none) center / cover no-repeat,
        var(--lobby-bg);
    filter: saturate(1.05);
}
.lobby-grid {
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.9), transparent 80%);
}

/* ---------- Top bar ---------- */
.lobby-topbar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(100%, 1240px);
    margin: 0 auto;
}
.lobby-brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--lobby-blue), #8b5cf6 60%, var(--lobby-red));
    color: #fff;
    font-family: Rajdhani, sans-serif;
    font-weight: 700;
    font-size: 22px;
    box-shadow: 0 10px 26px rgba(90, 162, 255, 0.3);
}
.lobby-brand-name { font-family: Rajdhani, sans-serif; font-size: 22px; font-weight: 700; letter-spacing: 0.08em; }
.lobby-topbar-spacer { flex: 1; }
.lobby-player-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 6px 14px 6px 6px;
    border-radius: 999px;
    border: 1px solid var(--lobby-border);
    background: rgba(11, 16, 26, 0.7);
    backdrop-filter: blur(8px);
}
.lobby-player-avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 999px;
    background: rgba(90, 162, 255, 0.18);
    color: #cfe3ff;
    font-weight: 700;
}
.lobby-player-text { display: grid; min-width: 0; line-height: 1.25; }
.lobby-player-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-player-key { color: var(--lobby-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-player-key strong { font-weight: 500; color: #b9c4d6; font-family: Consolas, monospace; }
.lobby-admin-link {
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--lobby-border);
    color: var(--lobby-text);
    text-decoration: none;
    font-size: 14px;
    background: rgba(11, 16, 26, 0.7);
}
.lobby-admin-link:hover { border-color: var(--lobby-border-strong); }

/* ---------- Layout ---------- */
.lobby-layout {
    position: relative;
    z-index: 2;
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 440px);
    gap: clamp(28px, 5vw, 72px);
    align-items: center;
    width: min(100%, 1240px);
    margin: 0 auto;
    padding-top: clamp(24px, 5vh, 56px);
}

/* ---------- Hero ---------- */
.lobby-kicker {
    margin: 0 0 12px;
    color: var(--lobby-blue);
    font-family: Rajdhani, sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.32em;
    text-transform: uppercase;
}
.lobby-title {
    margin: 0;
    font-family: Rajdhani, "IBM Plex Sans Thai", sans-serif;
    font-size: clamp(44px, 7vw, 92px);
    font-weight: 700;
    line-height: 0.92;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}
.lobby-title span {
    display: block;
    background: linear-gradient(100deg, #ffffff 10%, #bcd8ff 45%, #ffb3c1 90%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.lobby-subtitle {
    max-width: 520px;
    margin: 18px 0 0;
    color: #c2cbda;
    font-size: clamp(15px, 1.4vw, 18px);
    line-height: 1.65;
}

.lobby-fan {
    position: relative;
    height: clamp(170px, 22vw, 250px);
    margin: 30px 0 26px;
}
.lobby-fan-card {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    aspect-ratio: 25 / 34;
    object-fit: contain;
    border-radius: 10px;
    filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.65));
    transform-origin: 50% 100%;
    transition: transform 260ms ease;
}
.lobby-fan-card-1 { transform: rotate(-9deg); z-index: 1; }
.lobby-fan-card-2 { left: clamp(78px, 10vw, 118px); transform: translateY(-10px); z-index: 2; }
.lobby-fan-card-3 { left: clamp(156px, 20vw, 236px); transform: rotate(9deg); z-index: 1; }
.lobby-fan:hover .lobby-fan-card-1 { transform: rotate(-14deg) translateX(-10px); }
.lobby-fan:hover .lobby-fan-card-2 { transform: translateY(-22px); }
.lobby-fan:hover .lobby-fan-card-3 { transform: rotate(14deg) translateX(10px); }

.lobby-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    max-width: 620px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.lobby-steps li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--lobby-border);
    background: rgba(11, 16, 26, 0.62);
    backdrop-filter: blur(6px);
}
.lobby-steps li > span {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex: none;
    border-radius: 999px;
    background: rgba(246, 189, 96, 0.16);
    color: var(--lobby-amber);
    font-family: Rajdhani, sans-serif;
    font-weight: 700;
}
.lobby-steps strong { display: block; font-size: 14px; font-weight: 600; }
.lobby-steps small { display: block; color: var(--lobby-muted); font-size: 12px; margin-top: 2px; }

/* ---------- Action panel ---------- */
.next-lobby-card.lobby-panel {
    display: grid;
    gap: 18px;
    padding: 28px;
    border-radius: 26px;
    border: 1px solid var(--lobby-border-strong);
    background: var(--lobby-panel);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(14px);
}
.lobby-panel-block h2 { margin: 0; font-size: 20px; }
.lobby-panel-block p { margin: 4px 0 14px; color: var(--lobby-muted); font-size: 14px; }
.next-lobby-form { margin: 0; }

.lobby-primary,
.lobby-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    cursor: pointer;
    font-weight: 700;
    transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.lobby-primary {
    width: 100%;
    min-height: 58px;
    border-radius: 16px;
    background: linear-gradient(135deg, #3b82f6, #6366f1 55%, #ec4899);
    color: #fff;
    font-size: 18px;
    box-shadow: 0 16px 34px rgba(99, 102, 241, 0.38);
}
.lobby-primary svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.lobby-primary:hover { transform: translateY(-2px); box-shadow: 0 20px 40px rgba(99, 102, 241, 0.5); }
.lobby-primary:active { transform: none; }

.lobby-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--lobby-muted);
    font-size: 13px;
}
.lobby-divider::before,
.lobby-divider::after { content: ""; flex: 1; height: 1px; background: var(--lobby-border); }

.lobby-join { display: flex; gap: 10px; }
.lobby-code-input {
    flex: 1;
    min-width: 0;
    height: 52px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1px solid var(--lobby-border-strong);
    background: rgba(5, 8, 15, 0.8);
    color: var(--lobby-text);
    font-family: Consolas, "SFMono-Regular", monospace !important;
    font-size: 18px !important;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}
.lobby-code-input::placeholder { color: #5b6880; letter-spacing: 0.04em; text-transform: none; font-family: "IBM Plex Sans Thai", sans-serif; font-size: 15px; }
.lobby-code-input:focus { outline: none; border-color: var(--lobby-blue); box-shadow: 0 0 0 3px rgba(90, 162, 255, 0.22); }
.lobby-secondary {
    flex: none;
    height: 52px;
    padding: 0 20px;
    border-radius: 14px;
    border: 1px solid rgba(90, 162, 255, 0.5);
    background: rgba(90, 162, 255, 0.14);
    color: #dbeaff;
    font-size: 16px;
}
.lobby-secondary:hover { background: rgba(90, 162, 255, 0.26); }

.next-lobby-alert {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--lobby-border);
    background: rgba(15, 23, 42, 0.9);
    font-size: 14px;
}
.next-lobby-alert-danger { border-color: rgba(255, 101, 127, 0.5); background: rgba(127, 29, 29, 0.4); color: #ffd6de; }
.next-lobby-alert-success { border-color: rgba(66, 211, 146, 0.5); background: rgba(22, 101, 52, 0.35); color: #c9f7df; }
.next-lobby-alert-warning { border-color: rgba(246, 189, 96, 0.5); background: rgba(120, 53, 15, 0.35); color: #fde7c0; }

.lobby-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 12px;
    padding-top: 14px;
    border-top: 1px solid var(--lobby-border);
    color: #66738a;
    font-size: 12px;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .lobby-layout { grid-template-columns: 1fr; align-items: start; }
    .lobby-hero { text-align: center; }
    .lobby-subtitle { margin-left: auto; margin-right: auto; }
    .lobby-fan { width: calc(clamp(170px, 22vw, 250px) * 0.735 + clamp(156px, 20vw, 236px)); margin-left: auto; margin-right: auto; }
    .lobby-steps { margin: 0 auto; text-align: left; }
    .next-lobby-card.lobby-panel { width: min(100%, 520px); margin: 0 auto; }
}
@media (max-width: 640px) {
    .next-lobby-shell { padding: 14px 16px 28px; }
    .lobby-brand-name { display: none; }
    .lobby-layout { padding-top: 22px; gap: 22px; }
    .lobby-title { font-size: 46px; }
    .lobby-fan { height: 150px; width: 250px; margin: 22px auto 18px; }
    .lobby-fan-card-2 { left: 70px; }
    .lobby-fan-card-3 { left: 140px; }
    .lobby-steps { grid-template-columns: 1fr; }
    .next-lobby-card.lobby-panel { padding: 20px; border-radius: 20px; }
    .lobby-join { flex-direction: column; }
    .lobby-secondary { width: 100%; }
}
.lobby-fan { margin-left: 14px; }
@media (max-width: 980px) { .lobby-fan { margin-left: auto; } }
/* Small screens: title -> cards -> actions -> how-to, so "create room" is reachable without scrolling far. */
@media (max-width: 980px) {
    .lobby-layout { display: flex; flex-direction: column; align-items: stretch; }
    .lobby-hero { display: contents; }
    .lobby-kicker, .lobby-title, .lobby-subtitle, .lobby-fan { order: 1; text-align: center; }
    .lobby-panel { order: 2; }
    .lobby-steps { order: 3; width: 100%; max-width: 520px; }
    .lobby-kicker { margin-bottom: 0; }
    .lobby-subtitle { margin-top: 0; }
    .lobby-fan { margin-top: 0; margin-bottom: 0; }
}
@media (max-width: 640px) {
    .lobby-layout { gap: 16px; }
    .lobby-fan { height: 120px; width: 210px; }
    .lobby-fan-card-2 { left: 58px; }
    .lobby-fan-card-3 { left: 116px; }
    .lobby-subtitle { font-size: 14px; }
}
@media (max-width: 640px) { .lobby-code-input { flex: none; width: 100%; } }
