/* ============================================================
   Lobby dialog: queue spinner, match-found seat card, rooms.

   Lives on its own because two different shells render this dialog: the
   account lobby (/play) and the public landing page, where a visitor can
   start matchmaking without ever signing up. Keeping the rules here means
   the landing page does not have to pull in all of club.css just to show
   the "finding an opponent" popup.
   ============================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(12, 16, 22, .58);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.modal-backdrop[hidden] { display: none; }

.modal {
    position: relative;
    width: min(100%, 420px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 26px 24px 22px;
    border-radius: 18px;
    background: var(--paper, #fffdf7);
    box-shadow: 0 26px 70px rgba(8, 14, 12, .34);
    text-align: center;
    animation: modal-in .22s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } }

/* The queue dialog is tinted by the mode the player is waiting in, so the
   popup itself answers "which queue am I in?" without reading the badge.
   lobby.js adds modal--casual / modal--ranked when it opens the dialog; the
   class lands on the backdrop (#lobby-modal), so the tint has to be scoped
   from there rather than off .modal.
   Red = instant (casual) pairing, gold = competitive (ranked). */
.modal-backdrop.modal--casual .modal {
    background: linear-gradient(168deg, #b32828 0%, #8f2020 100%);
    border-color: #8f2020;
}
.modal-backdrop.modal--ranked .modal {
    background: linear-gradient(168deg, #a97c13 0%, #7d5a08 100%);
    border-color: #7d5a08;
}
.modal-backdrop.modal--casual .modal h3,
.modal-backdrop.modal--ranked .modal h3 { color: #fff; }
.modal-backdrop.modal--casual .modal-sub,
.modal-backdrop.modal--ranked .modal-sub { color: rgba(255, 255, 255, .84); }
/* The badge keeps a light chip so the mode name stays readable on the
   saturated background. lobby.js never adds is-casual / is-ranked to the
   badge, so the tone has to come from the backdrop class. */
.modal-backdrop.modal--casual .lobby-mode-badge {
    background: rgba(255, 255, 255, .93);
    color: #8f2020;
}
.modal-backdrop.modal--ranked .lobby-mode-badge {
    background: rgba(255, 255, 255, .93);
    color: #6d4d05;
}
/* Spinner and any inline error sit on colour now, so lift the contrast. */
.modal-backdrop.modal--casual .queue-spinner span,
.modal-backdrop.modal--ranked .queue-spinner span { border-color: rgba(255, 255, 255, .3); border-top-color: #fff; }
.modal-backdrop.modal--casual .modal-error,
.modal-backdrop.modal--ranked .modal-error {
    background: rgba(255, 255, 255, .95);
    color: #8f2020;
}
/* Cancel is a plain button; on colour it needs to read as a light ghost. */
.modal-backdrop.modal--casual .btn-ghost,
.modal-backdrop.modal--ranked .btn-ghost {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .5);
    color: #fff;
}

.modal h3 {
    margin: 0 0 6px;
    font-size: 19px;
    font-weight: 800;
    color: #12241d;
}
.modal-sub {
    margin: 0 0 18px;
    font-size: 13.5px;
    line-height: 1.6;
    color: #6b7683;
}
.modal-error {
    margin: 14px 0 0;
    padding: 9px 12px;
    border-radius: 9px;
    background: #fdecea;
    color: #a3261b;
    font-size: 13px;
}
.modal-error[hidden] { display: none; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}
/* When the last action is hidden (e.g. the pair is final and cannot be
   cancelled) the wrapper would otherwise leave an empty 20px gap. */
.modal-actions:has(.btn[hidden]) { display: none; }
.modal-actions .btn { min-width: 120px; }
.modal-actions .btn[hidden] { display: none; }

/* Mode badge above the title: casual vs ranked. */
.lobby-mode-badge {
    display: inline-block;
    margin-bottom: 10px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .04em;
}
.lobby-mode-badge[hidden] { display: none; }
.lobby-mode-badge.is-casual { background: #fbe9e7; color: #8f2020; }
.lobby-mode-badge.is-ranked { background: #fdf3d6; color: #8a6212; }

/* Spinning search indicator. */
.queue-spinner {
    display: flex;
    justify-content: center;
    padding: 6px 0 14px;
}
.queue-spinner[hidden] { display: none; }
.queue-spinner span {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid #e7ece9;
    border-top-color: #1c5d4a;
    animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .queue-spinner span { animation-duration: 2.4s; } }

/* ---- Match found: the VS card ---- */
.seat-card {
    margin: 4px 0 0;
    padding: 18px 16px 16px;
    border-radius: 15px;
    background: linear-gradient(160deg, #143d31, #0d2a22);
    color: #fff;
    animation: seat-in .3s cubic-bezier(.2, .8, .2, 1) both;
}
.seat-card[hidden] { display: none; }
@keyframes seat-in {
    from { opacity: 0; transform: scale(.96); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .seat-card { animation: none; } }

.seat-title {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 800;
    color: #7fe3b4;
    letter-spacing: .01em;
}

.seat-vs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: start;
    gap: 10px;
}
.seat-player {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.seat-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 62px;
    height: 62px;
    margin-bottom: 3px;
    border-radius: 50%;
    background: #24382f;
    border: 2px solid rgba(255, 255, 255, .18);
    overflow: hidden;
    font-size: 22px;
    font-weight: 800;
    color: #cfe8db;
    line-height: 1;
}
.seat-player--you .seat-avatar { border-color: #7fe3b4; }
.seat-player--them .seat-avatar { border-color: #e8c677; }
.seat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.seat-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
}
.seat-player strong {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.35;
}
.seat-elo {
    font-size: 12.5px;
    font-weight: 700;
    color: #e8c677;
    font-variant-numeric: tabular-nums;
}
.seat-vs-mark {
    align-self: center;
    margin-top: -6px;
    font-size: 15px;
    font-weight: 900;
    font-style: italic;
    color: #e8c677;
}

.seat-meta {
    margin: 14px 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, .62);
}
.seat-status {
    margin: 6px 0 0;
    font-size: 12.5px;
    font-weight: 700;
    color: #7fe3b4;
    font-variant-numeric: tabular-nums;
}
