/* ═══════════════════════════════════════════════════════════════════════════
   LOBBY OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */

.lobby-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 80px; /* offset for sticky game header */
    background: radial-gradient(ellipse at 50% 30%, #1e0c05 0%, #0E0906 65%);
    transition: opacity 0.45s ease;
    overflow: hidden;
    overscroll-behavior: none;
}

.lobby-overlay.lobby-hidden {
    opacity: 0;
    pointer-events: none;
}

/* ── Card ────────────────────────────────────────────────────────────────── */

.lobby-card {
    width: clamp(280px, 94%, 600px); /* Aligned with header width on desktop */
    height: fit-content;
    max-height: calc(100dvh - 96px);
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 4vw, 24px);
    padding: clamp(20px, 6vw, 32px) clamp(16px, 5vw, 28px);
    background: rgba(10, 6, 3, 0.94);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(197, 160, 89, 0.15);
    border-radius: 16px;
    box-shadow:
        0 0 0 1px rgba(197, 160, 89, 0.05) inset,
        0 24px 70px rgba(0, 0, 0, 0.72),
        0 0 60px rgba(192, 57, 43, 0.04);
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* ── Brand ───────────────────────────────────────────────────────────────── */

.lobby-brand {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.lobby-brand-zh {
    font-family: 'Noto Serif', serif;
    font-size: 1.5rem;
    color: rgba(197, 160, 89, 0.50);
    letter-spacing: 5px;
    line-height: 1;
    margin-bottom: 4px;
}

.lobby-title {
    font-family: 'Noto Serif', serif;
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--dragon-red);
    text-shadow: 0 0 28px rgba(192, 57, 43, 0.28);
    margin: 0;
    text-transform: uppercase;
    white-space: nowrap;
}

.lobby-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 0.66rem;
    letter-spacing: 4px;
    color: var(--gold);
    text-transform: uppercase;
    opacity: 0.60;
    margin: 0;
}

/* ── Steps ───────────────────────────────────────────────────────────────── */

.lobby-step           { display: flex; flex-direction: column; gap: 12px; }
.lobby-step-hidden    { display: none !important; }

/* ── Input field ─────────────────────────────────────────────────────────── */

/* ── Lobby Category Rules ───────────────────────────────────────────────────── */
.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lobby-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 4px;
}

.lobby-category-title {
    font-family: 'Noto Serif', serif;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--gold);
    opacity: 0.65;
    margin-bottom: 2px;
    white-space: nowrap;
}

.lobby-btn-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.lobby-btn-row .lobby-btn {
    flex: 1;
}

/* ── Commander section wrapper ──────────────────────────────── */
/* Commander section wrapper is now transparent/layout only */
.lobby-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    padding: 0;
    background: transparent;
    border: none;
    margin-bottom: 8px;
}

.lobby-signin-teaser {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(197, 160, 89, 0.15);
    border-radius: 10px;
    color: var(--gold);
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.lobby-section-label {
    font-family: 'Noto Serif', serif;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--gold);
    opacity: 0.7;
    margin-bottom: 10px;
    user-select: none;
    white-space: nowrap;
}

.lobby-field { display: flex; flex-direction: column; gap: 6px; }

.sb-btn-label {
    font-size: 0.76rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.lobby-label {
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(197, 160, 89, 0.58);
    white-space: nowrap;
}

.lobby-input {
    width: 100%;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(197, 160, 89, 0.22);
    border-radius: 8px;
    padding: 14px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;      /* Industry standard for mobile stability */
    color: var(--text-main);
    outline: none;
    transition: border-color 0.18s;
    text-align: center;   /* Centered for Commander name */
}

.lobby-input::placeholder { color: rgba(240, 237, 232, 0.22); }
.lobby-input:focus        { border-color: rgba(197, 160, 89, 0.55); }

.lobby-input-code {
    text-transform: uppercase;
    letter-spacing: 8px;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    padding: 14px 14px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.lobby-actions { display: flex; flex-direction: column; gap: 8px; }

.lobby-btn {
    width: 100%;
    padding: 14px 12px;
    border: none;
    border-radius: 8px;
    font-family: 'Noto Serif', serif;
    font-size: clamp(0.78rem, 3.2vw, 0.95rem);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, transform 0.08s, opacity 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lobby-btn svg {
    flex-shrink: 0;
    opacity: 0.85;
}

.lobby-btn:active { transform: scale(0.97); }

.lobby-btn-primary {
    background: linear-gradient(135deg, #992a1a 0%, var(--dragon-red) 100%);
    color: #fff;
    box-shadow: 0 4px 18px rgba(192, 57, 43, 0.26);
}

.lobby-btn-primary:hover { background: linear-gradient(135deg, #b83020 0%, #d44030 100%); }

.lobby-btn-ghost {
    background: rgba(197, 160, 89, 0.07);
    border: 1px solid rgba(197, 160, 89, 0.24);
    color: var(--gold);
}

.lobby-btn-ghost:hover {
    background: rgba(197, 160, 89, 0.14);
    border-color: rgba(197, 160, 89, 0.44);
}

/* Practice vs AI — gold-accented, clearly distinct from ghost buttons */
.lobby-btn-ai {
    background: linear-gradient(135deg, rgba(197, 160, 89, 0.18) 0%, rgba(197, 160, 89, 0.10) 100%);
    border: 1px solid rgba(197, 160, 89, 0.55);
    color: #d4ae64;
    box-shadow: 0 0 0 0 rgba(197, 160, 89, 0);
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}

.lobby-btn-ai:hover {
    background: linear-gradient(135deg, rgba(197, 160, 89, 0.28) 0%, rgba(197, 160, 89, 0.16) 100%);
    border-color: rgba(197, 160, 89, 0.80);
    box-shadow: 0 0 14px rgba(197, 160, 89, 0.18);
    color: #e0c07a;
}

.lobby-btn-ai:active { transform: scale(0.97); }

.lobby-btn-sm          { padding: 9px 16px; font-size: 0.73rem; opacity: 0.70; }
.lobby-btn-sm:hover    { opacity: 1; }

.tutorial-menu-row {
    position: relative;
    width: 100%;
}

/* Training category once the tutorial button has been dismissed */
.lobby-category--compact {
    gap: 4px;
}

#tutorialHint {
    margin: 10px 0 0;
    padding-top: 10px;
    border-top: 1px solid rgba(197, 160, 89, 0.12);
}

.tutorial-dismiss-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(197, 160, 89, 0.45);
    font-family: 'Inter', sans-serif;
    font-size: 1.35rem;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 0;
    padding: 0;
}

.tutorial-dismiss-btn:hover {
    background: rgba(192, 57, 43, 0.85);
    color: #fff;
    box-shadow: 0 0 12px rgba(192, 57, 43, 0.4);
}

/* ── OR divider ──────────────────────────────────────────────────────────── */

.lobby-or {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(240, 237, 232, 0.20);
    font-size: 0.65rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 2px 0;
}

.lobby-or::before,
.lobby-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(197, 160, 89, 0.12);
}

/* ── Waiting step ────────────────────────────────────────────────────────── */

.lobby-hint {
    font-size: 0.76rem;
    color: rgba(240, 237, 232, 0.45);
    text-align: center;
    margin: 0;
}

.lobby-room-code {
    font-family: 'Noto Serif', serif;
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 10px;
    color: var(--gold);
    text-align: center;
    text-shadow: 0 0 22px rgba(197, 160, 89, 0.35);
    /* letter-spacing shifts text right; compensate with left padding */
    padding: 14px 8px 14px 18px;
    border: 1px solid rgba(197, 160, 89, 0.22);
    border-radius: 10px;
    background: rgba(197, 160, 89, 0.05);
    cursor: pointer;
    user-select: all;
    transition: background 0.16s, border-color 0.16s;
}

.lobby-room-code:hover {
    background: rgba(197, 160, 89, 0.10);
    border-color: rgba(197, 160, 89, 0.40);
}

.lobby-copy-hint {
    font-size: 0.64rem;
    color: rgba(197, 160, 89, 0.38);
    text-align: center;
    margin: -6px 0 0;
    letter-spacing: 0.5px;
    min-height: 14px;
}

.lobby-waiting-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.78rem;
    color: rgba(240, 237, 232, 0.42);
    padding: 4px 0;
}

.lobby-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(197, 160, 89, 0.18);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: lobby-spin 0.85s linear infinite;
    flex-shrink: 0;
}

@keyframes lobby-spin { to { transform: rotate(360deg); } }

/* ── Error ───────────────────────────────────────────────────────────────── */

.lobby-error {
    font-size: 0.74rem;
    color: #e07070;
    text-align: center;
    min-height: 16px;
    margin: -2px 0 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
/* ═══════════════════════════════════════════════════════════════════════════
   LOBBY IDENTITY BAR
═══════════════════════════════════════════════════════════════════════════ */
.lobby-identity-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(197, 160, 89, 0.2);
    border-radius: 12px;
    margin: 4px 0 12px;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: visible;
}

.lobby-avatar-container {
    position: relative;
    flex-shrink: 0;
}

.lobby-reroll-overlay {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gold);
    color: #1a0f08;
    border: 2px solid #1a0f08;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    transition: transform 0.2s, background 0.2s;
    z-index: 10;
}

.lobby-reroll-overlay:hover {
    transform: scale(1.1);
    background: #fff;
}

.lobby-reroll-overlay:active {
    transform: scale(0.9);
}

.lobby-identity-bar .avatar-disc {
    width: 56px;
    height: 56px;
    margin: 4px;
}

.lobby-identity-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.lobby-info-meta {
    display: flex;
    align-items: center;
}

.lobby-info-role {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: rgba(197, 160, 89, 0.4);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
}

.lobby-info-badge {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold);
    background: rgba(197, 160, 89, 0.1);
    padding: 2px 8px 3px;
    border-radius: 5px;
    font-weight: 700;
    border: 1px solid rgba(197, 160, 89, 0.15);
    margin-top: 4px;
}

.lobby-identity-tag {
    display: block;
    font-family: 'Noto Serif', serif;
    font-weight: 700;
    font-size: clamp(0.75rem, 4.5vw, 1.15rem); 
    letter-spacing: 0.3px;
    color: var(--text-main);
    line-height: 1.1;
    word-break: break-word; 
    margin: 1px 0;
}

.status-indicator {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-green {
    background-color: #4ade80;        /* emerald green */
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.status-yellow {
    background-color: #fbbf24;        /* amber yellow */
    box-shadow: 0 0 6px rgba(251, 191, 36, 0.5);
}

/* Small icon-only button used for the reroll control */
/* Move reroll to a more subtle position beside the name info */
.lobby-btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(197, 160, 89, 0.15);
    color: rgba(197, 160, 89, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.lobby-btn-icon:hover {
    background: rgba(197, 160, 89, 0.1);
    border-color: rgba(197, 160, 89, 0.3);
    color: var(--gold);
}

.lobby-btn-icon:active { transform: scale(0.93); }

/* ── Connect account teaser (disabled until Supabase connected) ─────────── */

/* ── Connect Account — Refined to match lobby button style ───────────── */
.lobby-signin-teaser {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(197, 160, 89, 0.08);
    border: 1px solid rgba(197, 160, 89, 0.35);
    color: var(--gold);
    font-family: 'Noto Serif', serif;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
    transition: all 0.2s ease;
}

.lobby-signin-teaser:hover {
    background: rgba(197, 160, 89, 0.15);
    border-color: rgba(197, 160, 89, 0.55);
    box-shadow: 0 0 15px rgba(197, 160, 89, 0.1);
}

.lobby-signin-teaser:active { 
    transform: scale(0.98); 
}

.lobby-btn:disabled {
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.12) contrast(1.05);
    opacity: 0.82;
    border: 1px solid rgba(197, 160, 89, 0.15);
}

/* Network-offline: more visually distinct than ordinary "coming soon" disabled */
.lobby-btn[data-net-req]:disabled {
    opacity: 0.38;
    filter: grayscale(0.6);
}

.lobby-coming-soon-badge {
    font-size: 0.62rem;
    background: rgba(197, 160, 89, 0.15);
    color: var(--gold);
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    font-weight: 600;
}
