:where(.page-lobby) header {
    margin-bottom: 12px;
}

:where(.page-lobby) h1 {
    font-size: 30px;
    margin-bottom: 8px;
}

:where(.page-lobby) .subtitle {
    color: var(--ink);
    font-size: 16px;
    font-weight: 400;
    opacity: 0.95;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

:where(.page-lobby) .lobby-content {
    background: white;
    border-radius: 22px;
    padding: 24px 20px;
    border: 1px solid var(--line);
    box-shadow: 0 4px 16px #17334c06;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

:where(.page-lobby) .action-section {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

:where(.page-lobby) .input-group {
    margin-bottom: 12px;
}

:where(.page-lobby) .input-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 6px;
    display: block;
}

:where(.page-lobby) .input-field {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #a7adb1;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

:where(.page-lobby) .input-field:focus {
    outline: none;
    border-color: var(--ink);
}

:where(.page-lobby) .input-field::placeholder {
    color: #aaa;
}

:where(.page-lobby) #nickname::placeholder {
    color: #757575;
    font-style: italic;
    opacity: 1;
}

:where(.page-lobby) #nickname:focus::placeholder {
    opacity: 0;
}

:where(.page-lobby) .btn {
    margin-bottom: 12px;
}

:where(.page-lobby) .btn-primary:hover {
    opacity: 0.9;
}

:where(.page-lobby) .btn-primary.loading {
    position: relative;
    color: transparent;
}

:where(.page-lobby) .btn-primary.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

:where(.page-lobby) .player-count {
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink);
    margin-top: 8px;
}

:where(.page-lobby) .how-to-play-link {
    display: block;
    margin: 0;
    background: none;
    border: 0;
    color: var(--ink);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
    min-height: 44px;
    padding: 8px 0;
}

:where(.page-lobby) .how-to-play-modal {
    margin: auto;
    width: calc(100% - 32px);
    max-width: 420px;
    max-height: calc(100dvh - 32px);
    padding: 20px;
    border: 0;
    border-radius: 22px;
    color: var(--ink);
    box-shadow: 0 12px 32px rgba(0,0,0,0.2);
}

:where(.page-lobby) .how-to-play-modal[open] {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

:where(.page-lobby) .how-to-play-modal::backdrop {
    background: rgba(0,0,0,0.6);
}

:where(.page-lobby) .how-to-play-content {
    min-height: 0;
    overflow-y: auto;
    line-height: 1.5;
    font-size: 15px;
}

:where(.page-lobby) .how-to-play-content h2 {
    font-size: 20px;
    color: var(--ink);
    opacity: 1;
    text-shadow: none;
}

:where(.page-lobby) .how-to-play-content p {
    margin-top: 12px;
}

:where(.page-lobby) .how-to-play-modal form {
    flex-shrink: 0;
    text-align: center;
}

:where(.page-lobby) .how-to-play-modal .btn {
    margin: 0;
    min-width: 120px;
}

:where(.page-lobby) .divider {
    display: flex;
    align-items: center;
    margin: 8px 0 20px 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

:where(.page-lobby) .divider::before,
:where(.page-lobby) .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}

:where(.page-lobby) .divider span {
    padding: 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-height: 700px) {
    :where(.page-lobby) header {
        margin-bottom: 16px;
    }

    :where(.page-lobby) h1 {
        font-size: 32px;
    }

    :where(.page-lobby) .subtitle {
        font-size: 14px;
    }

    :where(.page-lobby) .lobby-content {
        padding: 20px 16px;
    }

}

@media (max-height: 600px) {
    :where(.page-lobby) header {
        margin-bottom: 12px;
    }

    :where(.page-lobby) h1 {
        font-size: 28px;
    }

    :where(.page-lobby) .input-field,
    :where(.page-lobby) .input-group {
        margin-bottom: 10px;
    }

    :where(.page-lobby) .btn {
        padding: 12px 16px;
        margin-bottom: 16px;
    }

    :where(.page-lobby) .divider {
        margin: 4px 0 16px 0;
    }

}

@media (max-height: 500px) {
    :where(.page-lobby) .container {
        padding: 8px;
    }

    :where(.page-lobby) .lobby-content {
        padding: 16px;
    }

    :where(.page-lobby) .input-field,
    :where(.page-lobby) .input-group {
        margin-bottom: 8px;
    }

    :where(.page-lobby) .btn {
        padding: 10px;
        font-size: 13px;
        margin-bottom: 12px;
    }

    :where(.page-lobby) .divider {
        margin: 0 0 12px 0;
    }

}

:where(.page-lobby) .divider, :where(.page-lobby) .player-count {
    flex-shrink: 0;
}

/* The introduction stays inside the existing scrollable create/join card. */
.lobby-intro { flex-shrink: 0; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 18px; }
.lobby-intro-heading { display: grid; grid-template-columns: minmax(0, 1fr) 82px; align-items: center; gap: 8px; }
.lobby-intro h2 { font-size: 24px; line-height: 1.18; font-weight: 700; letter-spacing: -.6px; opacity: 1; margin: 0; color: var(--ink); text-shadow: none; }
.lobby-illustration { width: 82px; height: 82px; position: relative; overflow: hidden; }
.lobby-illustration img { position: absolute; width: 200%; height: 100%; max-width: none; left: 0; top: 0; }
.lobby-intro p { color: var(--secondary); font-size: 15px; line-height: 1.5; margin: 8px 0; }
.lobby-intro .player-count { color: var(--muted); margin: 9px 0 0; }
.lobby-intro .how-to-play-link { font-size: 14px; font-weight: 600; text-underline-offset: 4px; }
.page-lobby .lobby-content { flex: 0 1 auto; }
.page-lobby #joinGame { margin-bottom: 0; }
@media (max-width: 400px) { .lobby-intro h2 { font-size: 22px; } }
