/* ── Lobby root ────────────────────────────────────────────────────────── */
.lobby-root {
    background: radial-gradient(ellipse at 50% 25%, #1a2a4a 0%, #0a0f1e 100%);
}

/* ── Scroll area ───────────────────────────────────────────────────────── */
.lobby-scroll {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: calc(20px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
}

/* ── Title ─────────────────────────────────────────────────────────────── */
.lobby-title {
    font-size: clamp(2.8rem, 15vw, 4.5rem);
    font-weight: 900;
    background: linear-gradient(135deg, #FF9800 0%, #F44336 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -2px;
    line-height: 1;
    text-align: center;
    padding: 4px 0;
    user-select: none;
    -webkit-user-select: none;
}
.lobby-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: -6px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* ── Name bar ──────────────────────────────────────────────────────────── */
.name-bar {
    width: 100%;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    transition: border-color 0.15s;
}
.name-bar:focus-within { border-color: var(--border-hi); }
.name-bar label {
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}
.name-bar input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    outline: none;
    min-width: 0;
}
.name-bar input::placeholder { color: var(--text-muted); font-weight: 400; }

/* ── Action cards ──────────────────────────────────────────────────────── */
.action-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 14px 16px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.card-title {
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    margin-bottom: 10px;
}
.card-buttons {
    display: flex;
    gap: 10px;
}
.card-buttons > * { flex: 1; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 56px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    padding: 0 18px;
    text-align: center;
    text-decoration: none;
    color: inherit;
}
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-primary {
    background: linear-gradient(135deg, #FF9800 0%, #F44336 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(244, 67, 54, 0.3);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 22px rgba(244, 67, 54, 0.5); }

.btn-secondary {
    background: var(--surface-hi);
    color: var(--text);
    border: 1px solid var(--border-hi);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.18); }

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    min-height: 44px;
    font-size: 0.85rem;
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-hi); }

.btn-success {
    background: linear-gradient(135deg, #43A047 0%, #2E7D32 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.3);
}

.btn-wide { width: 100%; max-width: 420px; }
.btn-lg   { min-height: 60px; font-size: 1.05rem; }

/* ── Mode tabs ─────────────────────────────────────────────────────────── */
.mode-selector {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.mode-selector > label {
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-dim);
}
.mode-tabs {
    display: flex;
    gap: 5px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius);
    padding: 4px;
}
.mode-tab {
    flex: 1;
    min-height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.mode-tab.active {
    background: var(--surface-hi);
    color: var(--text);
}
.mode-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

/* ── Code entry (home screen inline) ──────────────────────────────────── */
.code-entry-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.code-input {
    width: 128px;
    background: rgba(0, 0, 0, 0.28);
    border: 2px solid var(--border-hi);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 2rem;
    font-weight: 900;
    text-align: center;
    letter-spacing: 0.35em;
    padding: 8px 4px 8px 12px;
    outline: none;
    transition: border-color 0.15s;
    /* Prevent zoom on iOS (font-size ≥ 16px for inputs avoids zoom) */
}
.code-input:focus { border-color: var(--accent-1); }
.code-input::placeholder { color: var(--text-muted); letter-spacing: 0.25em; font-size: 1.5rem; }

/* ── Setup screens (bots, create) ──────────────────────────────────────── */
.setup-wrap {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.setup-screen {
    flex: 1;
    overflow-y: auto;
    padding: calc(56px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
}
.setup-title {
    font-size: 1.35rem;
    font-weight: 900;
    text-align: center;
}
.setup-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.setup-section > label {
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-dim);
}

/* ── Chip row (bot count / difficulty) ─────────────────────────────────── */
.chip-row { display: flex; gap: 8px; }
.chip {
    flex: 1;
    min-height: 48px;
    background: rgba(0, 0, 0, 0.25);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chip.active {
    border-color: var(--accent-1);
    color: var(--accent-1);
    background: rgba(255, 152, 0, 0.1);
}
.chip:hover:not(.active) {
    border-color: var(--border-hi);
    color: var(--text);
}

/* ── Back button ───────────────────────────────────────────────────────── */
.back-btn {
    position: absolute;
    top: calc(10px + var(--safe-top));
    left: calc(12px + var(--safe-left));
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 10;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.back-btn:hover { background: var(--surface-hi); color: var(--text); }

/* ── Text input field ──────────────────────────────────────────────────── */
.field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.field label {
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
}
.field input {
    background: rgba(0, 0, 0, 0.25);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 14px;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
    min-height: 50px;
}
.field input:focus { border-color: var(--accent-1); }
.field input::placeholder { color: var(--text-muted); font-weight: 400; }

/* ── Rooms list ────────────────────────────────────────────────────────── */
.rooms-wrap {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.rooms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: calc(var(--safe-top) + 56px) 16px 8px;
    background: linear-gradient(to bottom, var(--bg-deep) 70%, transparent);
    flex-shrink: 0;
    z-index: 5;
}
.rooms-header h2 { font-size: 1.1rem; font-weight: 900; }
.rooms-header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}
.rooms-filter select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 8px 28px 8px 10px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(240,244,255,0.45)'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-height: 36px;
}
.rooms-list-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 16px calc(24px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.room-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.room-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
    box-shadow: 0 0 6px var(--success);
}
.room-dot.almost { background: var(--warning); box-shadow: 0 0 6px rgba(255,235,59,0.6); }
.room-info { flex: 1; min-width: 0; }
.room-id   { font-size: 1rem; font-weight: 900; }
.room-meta { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }
.rooms-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 40px 16px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* ── Join-code screen ──────────────────────────────────────────────────── */
.join-code-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 24px 16px calc(24px + var(--safe-bottom));
}
.join-code-input-big {
    width: 200px;
    background: rgba(0, 0, 0, 0.3);
    border: 2.5px solid var(--border-hi);
    border-radius: var(--radius-lg);
    color: var(--text);
    font-size: 3rem;
    font-weight: 900;
    text-align: center;
    letter-spacing: 0.45em;
    padding: 16px 6px 16px 20px;
    outline: none;
    transition: border-color 0.15s;
    min-height: 80px;
}
.join-code-input-big:focus { border-color: var(--accent-1); }
.join-code-input-big::placeholder { color: var(--text-muted); letter-spacing: 0.35em; font-size: 2.5rem; }

/* ── Waiting room ──────────────────────────────────────────────────────── */
.waiting-wrap {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: calc(24px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
}

/* ── Room code display ─────────────────────────────────────────────────── */
.room-code-block {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.room-code-label {
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-dim);
}
.room-code-big {
    font-size: clamp(4rem, 22vw, 6.5rem);
    font-weight: 900;
    letter-spacing: 0.35em;
    padding-left: 0.35em; /* compensate letter-spacing */
    background: linear-gradient(135deg, #FFEB3B 0%, #FF9800 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.05;
}
.room-code-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.btn-copy {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 6px 16px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    min-height: 32px;
}
.btn-copy:hover { border-color: var(--border-hi); color: var(--text); }
.btn-copy.copied { border-color: var(--success); color: #81c784; }

/* ── Players list ──────────────────────────────────────────────────────── */
.players-list-title {
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.players-list { width: 100%; }
.player-slots { display: flex; flex-direction: column; gap: 8px; }
.player-slot {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 14px;
    min-height: 56px;
    transition: border-color 0.25s;
}
.player-slot.empty {
    opacity: 0.4;
    border-style: dashed;
}
.player-slot.joined { border-color: rgba(255, 255, 255, 0.18); }
.player-slot.ready  { border-color: rgba(76, 175, 80, 0.5); }
.player-avatar {
    font-size: 1.25rem;
    width: 30px;
    text-align: center;
    flex-shrink: 0;
}
.player-name {
    flex: 1;
    font-weight: 700;
    font-size: 0.95rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.player-name.empty-label {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
    font-size: 0.85rem;
}
.player-badge {
    font-size: 0.62rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: rgba(255, 152, 0, 0.18);
    color: var(--accent-1);
    border-radius: 4px;
    padding: 2px 7px;
    flex-shrink: 0;
}
.player-badge.bot { background: rgba(156, 39, 176, 0.18); color: #ce93d8; }
.player-ready-icon {
    font-size: 1rem;
    flex-shrink: 0;
    color: var(--text-muted);
}
.player-ready-icon.yes { color: var(--success); }

/* ── Waiting status ────────────────────────────────────────────────────── */
.waiting-status {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: center;
}

/* ── Waiting actions ───────────────────────────────────────────────────── */
.waiting-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Responsive: widen on desktop ──────────────────────────────────────── */
@media (min-width: 480px) {
    .lobby-scroll { padding-left: 24px; padding-right: 24px; }
}
