/* ═══════════════════════════════════════════════════════════════
   Empire Climb — Lobby Styles
   Matches the dark imperial palette used across the game
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700;900&family=Cinzel:wght@400;600;700;900&family=Rajdhani:wght@300;400;500;600;700&family=Orbitron:wght@400;500;600;700;800;900&display=swap');

/* ── CSS Variables ────────────────────────────────────────────── */
:root {
    --gold: #FFD700;
    --gold-light: #FFE566;
    --gold-dim: rgba(255, 215, 0, 0.3);
    --blue-glow: #00AAFF;
    --red-glow: #FF2D2D;
    --green-glow: #00FF88;
    --bg: #07070f;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-2: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.1);
    --border-gold: rgba(255, 215, 0, 0.35);
    --text: #f0f0f0;
    --text-dim: rgba(255, 255, 255, 0.45);
    --glass: rgba(255, 255, 255, 0.05);
    --yellow: #FFCC00;
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
    overflow-x: hidden;
}

/* Ambient grid overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 215, 0, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 215, 0, 0.025) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* ── Particles ────────────────────────────────────────────────── */
#particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    animation: floatUp linear infinite;
    bottom: -10px;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(-100vh) scale(0.5);
        opacity: 0;
    }
}

/* ── Page Wrapper ─────────────────────────────────────────────── */
.lobby-page {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

/* ── Shared Header ────────────────────────────────────────────── */
.lobby-logo {
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(1.4rem, 4vw, 2.4rem);
    font-weight: 900;
    color: var(--gold);
    text-align: center;
    letter-spacing: 0.18em;
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.5), 0 0 80px rgba(255, 215, 0, 0.2);
    margin-bottom: 6px;
    animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {

    0%,
    100% {
        text-shadow: 0 0 40px rgba(255, 215, 0, 0.5), 0 0 80px rgba(255, 215, 0, 0.2);
    }

    50% {
        text-shadow: 0 0 60px rgba(255, 215, 0, 0.8), 0 0 120px rgba(255, 215, 0, 0.35);
    }
}

.lobby-subtitle {
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.35em;
    color: var(--text-dim);
    text-align: center;
    text-transform: uppercase;
    margin-bottom: 40px;
}

/* ── States ───────────────────────────────────────────────────── */
.lobby-state {
    display: none;
    width: 100%;
    max-width: 860px;
}

.lobby-state.active {
    display: block;
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ══════════════════════════════════════════════════════════════
   STATE 1 — ENTRY (Create / Join)
══════════════════════════════════════════════════════════════ */
.entry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.entry-divider {
    display: none;
    /* shown on mobile */
}

.entry-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 36px 28px;
    backdrop-filter: blur(12px);
    transition: border-color 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.entry-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.entry-card.card-create::before {
    background: radial-gradient(circle at 50% 0%, rgba(255, 215, 0, 0.08) 0%, transparent 70%);
}

.entry-card.card-join::before {
    background: radial-gradient(circle at 50% 0%, rgba(0, 170, 255, 0.08) 0%, transparent 70%);
}

.entry-card:hover {
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.07);
}

.entry-card:hover::before {
    opacity: 1;
}

.entry-card.card-create:hover {
    border-color: var(--border-gold);
}

.entry-card.card-join:hover {
    border-color: rgba(0, 170, 255, 0.35);
}

.entry-card-icon {
    font-size: 2.8rem;
    text-align: center;
    margin-bottom: 14px;
    filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.4));
}

.entry-card-title {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: 0.08em;
}

.card-create .entry-card-title {
    color: var(--gold);
}

.card-join .entry-card-title {
    color: var(--blue-glow);
}

.entry-card-desc {
    font-size: 0.82rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* ── Form Elements ────────────────────────────────────────────── */
.lobby-label {
    display: block;
    font-family: 'Orbitron', monospace;
    font-size: 0.58rem;
    letter-spacing: 0.2em;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.lobby-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 12px;
    letter-spacing: 0.04em;
}

.lobby-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.12);
}

.lobby-input.input-code {
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    border-color: rgba(0, 170, 255, 0.3);
}

.lobby-input.input-code:focus {
    border-color: var(--blue-glow);
    box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.12);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.lobby-btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: 10px;
    border: 1px solid;
    font-family: 'Orbitron', monospace;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.lobby-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.06);
    opacity: 0;
    transition: opacity 0.2s;
}

.lobby-btn:hover::after {
    opacity: 1;
}

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

.lobby-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-create {
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--gold);
    color: var(--gold);
}

.btn-create:hover:not(:disabled) {
    background: rgba(255, 215, 0, 0.18);
    box-shadow: 0 0 24px rgba(255, 215, 0, 0.25);
}

.btn-join {
    background: rgba(0, 170, 255, 0.1);
    border-color: var(--blue-glow);
    color: var(--blue-glow);
}

.btn-join:hover:not(:disabled) {
    background: rgba(0, 170, 255, 0.18);
    box-shadow: 0 0 24px rgba(0, 170, 255, 0.25);
}

.btn-start {
    background: rgba(0, 255, 136, 0.1);
    border-color: var(--green-glow);
    color: var(--green-glow);
    font-size: 0.85rem;
    padding: 16px 28px;
    width: auto;
    min-width: 220px;
}

.btn-start:hover:not(:disabled) {
    background: rgba(0, 255, 136, 0.18);
    box-shadow: 0 0 32px rgba(0, 255, 136, 0.3);
}

.btn-start:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

/* ── Error text ───────────────────────────────────────────────── */
.lobby-error {
    font-size: 0.8rem;
    color: var(--red-glow);
    text-align: center;
    min-height: 20px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 6px 0 0;
    animation: errorShake 0.35s ease;
}

@keyframes errorShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

/* ── Loading spinner on button ─────────────────────────────────── */
.btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}

.loading .btn-spinner {
    display: block;
}

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

/* ══════════════════════════════════════════════════════════════
   STATE 2 — WAITING ROOM (Lobby)
══════════════════════════════════════════════════════════════ */
.lobby-room-wrap {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 36px 32px;
    backdrop-filter: blur(16px);
    max-width: 640px;
    margin: 0 auto;
}

/* ── Room Code Display ────────────────────────────────────────── */
.room-code-section {
    text-align: center;
    margin-bottom: 32px;
}

.room-code-label {
    font-family: 'Orbitron', monospace;
    font-size: 0.58rem;
    letter-spacing: 0.3em;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.room-code-display {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 14px;
}

.code-digit {
    width: 48px;
    height: 60px;
    background: rgba(255, 215, 0, 0.06);
    border: 1px solid var(--border-gold);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', monospace;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.08);
    animation: codeGlow 2.5s ease-in-out infinite;
}

@keyframes codeGlow {

    0%,
    100% {
        box-shadow: 0 0 12px rgba(255, 215, 0, 0.08);
    }

    50% {
        box-shadow: 0 0 24px rgba(255, 215, 0, 0.2);
    }
}

.copy-code-btn {
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.25);
    color: var(--gold);
    padding: 8px 20px;
    border-radius: 8px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.06em;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.copy-code-btn:hover {
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.2);
}

.copy-code-btn.copied {
    color: var(--green-glow);
    border-color: rgba(0, 255, 136, 0.3);
    background: rgba(0, 255, 136, 0.08);
}

/* ── Player List ──────────────────────────────────────────────── */
.players-section-title {
    font-family: 'Orbitron', monospace;
    font-size: 0.58rem;
    letter-spacing: 0.25em;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-count-badge {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid var(--border-gold);
    color: var(--gold);
    font-size: 0.55rem;
    padding: 2px 8px;
    border-radius: 20px;
}

.players-list-lobby {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 28px;
}

/* Filled player slot */
.player-slot {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    animation: slotSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: border-color 0.3s;
}

.player-slot.is-host {
    border-color: rgba(255, 215, 0, 0.3);
    background: rgba(255, 215, 0, 0.04);
}

@keyframes slotSlideIn {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.player-slot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', monospace;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.player-slot-name {
    flex: 1;
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.player-slot-badge {
    font-family: 'Orbitron', monospace;
    font-size: 0.5rem;
    letter-spacing: 0.15em;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid;
    text-transform: uppercase;
    font-weight: 700;
}

.badge-host {
    color: var(--gold);
    border-color: var(--border-gold);
    background: rgba(255, 215, 0, 0.08);
}

.badge-ready {
    color: var(--green-glow);
    border-color: rgba(0, 255, 136, 0.3);
    background: rgba(0, 255, 136, 0.06);
}

/* Empty waiting slot */
.player-slot-empty {
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    opacity: 0.45;
}

.slot-empty-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 1.1rem;
    animation: waitPulse 2s ease-in-out infinite;
}

@keyframes waitPulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.7;
    }
}

.slot-empty-text {
    font-size: 0.82rem;
    color: var(--text-dim);
    font-style: italic;
}

/* ── Bottom Action Area ───────────────────────────────────────── */
.lobby-action-area {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.waiting-message {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.9rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}

.waiting-dots span {
    display: inline-block;
    animation: dotBounce 1.2s ease-in-out infinite;
    color: var(--gold);
    font-size: 1.1rem;
}

.waiting-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.waiting-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    50% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

.min-players-note {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: 'Orbitron', monospace;
    letter-spacing: 0.1em;
}

.leave-room-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-dim);
    padding: 8px 18px;
    border-radius: 8px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.05em;
}

.leave-room-btn:hover {
    border-color: var(--red-glow);
    color: var(--red-glow);
    background: rgba(255, 45, 45, 0.06);
}

/* ── Top-right controls container (theme toggle + connection chip) ─── */
.top-right-controls {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 200;
}

/* ── Theme Toggle Button ──────────────────────────────────────── */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 50px;
    color: #FFD700;
    font-family: 'Orbitron', monospace;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.theme-toggle-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 215, 0, 0.12);
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: inherit;
}

.theme-toggle-btn:hover::before {
    opacity: 1;
}

.theme-toggle-btn:hover {
    border-color: rgba(255, 215, 0, 0.7);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.25);
    transform: translateY(-1px);
}

.theme-toggle-btn:active {
    transform: scale(0.96);
}

.theme-icon {
    font-size: 0.9rem;
    line-height: 1;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle-btn:hover .theme-icon {
    transform: rotate(20deg) scale(1.2);
}

.theme-label {
    font-size: 0.55rem;
}

/* Light mode overrides for the toggle button */
[data-theme="light"] .theme-toggle-btn {
    background: rgba(165, 117, 12, 0.08);
    border-color: rgba(165, 117, 12, 0.45);
    color: #7a5500;
}

[data-theme="light"] .theme-toggle-btn::before {
    background: rgba(165, 117, 12, 0.1);
}

[data-theme="light"] .theme-toggle-btn:hover {
    border-color: rgba(165, 117, 12, 0.7);
    box-shadow: 0 0 16px rgba(165, 117, 12, 0.2);
}

/* ── Connection status chip ───────────────────────────────────── */
.connection-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-family: 'Orbitron', monospace;
    font-size: 0.55rem;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    backdrop-filter: blur(8px);
    transition: all 0.3s;
}

.connection-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #555;
    transition: background 0.3s;
}

.connection-chip.connected {
    border-color: rgba(0, 255, 136, 0.3);
    color: var(--green-glow);
}

.connection-chip.connected .connection-dot {
    background: var(--green-glow);
    box-shadow: 0 0 6px var(--green-glow);
    animation: connPulse 1.8s ease-in-out infinite;
}

.connection-chip.disconnected {
    border-color: rgba(255, 45, 45, 0.3);
    color: var(--red-glow);
}

.connection-chip.disconnected .connection-dot {
    background: var(--red-glow);
}

@keyframes connPulse {

    0%,
    100% {
        box-shadow: 0 0 6px var(--green-glow);
    }

    50% {
        box-shadow: 0 0 14px var(--green-glow);
    }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile Landscape
══════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
    .entry-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .entry-card {
        padding: 24px 20px;
    }

    .lobby-room-wrap {
        padding: 24px 18px;
    }

    .code-digit {
        width: 38px;
        height: 50px;
        font-size: 1.25rem;
        gap: 5px;
    }

    .room-code-display {
        gap: 5px;
    }
}

@media (max-width: 480px) {
    .lobby-logo {
        font-size: 1.2rem;
        letter-spacing: 0.1em;
    }

    .code-digit {
        width: 34px;
        height: 44px;
        font-size: 1.1rem;
    }

    .room-code-display {
        gap: 4px;
    }
}

/* ── Ready States & Custom Badges ────────────────────────────── */
.badge-not-ready {
    color: var(--red-glow);
    border-color: rgba(255, 45, 45, 0.35);
    background: rgba(255, 45, 45, 0.08);
}

.lobby-btn.ready-active {
    background: rgba(0, 255, 136, 0.1) !important;
    border-color: var(--green-glow) !important;
    color: var(--green-glow) !important;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.2);
}

/* ── Toast Notifications ──────────────────────────────────────── */
.lobby-toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.lobby-toast {
    background: rgba(7, 7, 15, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px 20px;
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    animation: toastIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), toastOut 0.35s 3.5s forwards;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lobby-toast.success {
    border-color: rgba(0, 255, 136, 0.4);
    color: var(--green-glow);
}

.lobby-toast.error {
    border-color: rgba(255, 45, 45, 0.4);
    color: var(--red-glow);
}

.lobby-toast.info {
    border-color: rgba(0, 170, 255, 0.4);
    color: var(--blue-glow);
}

.lobby-toast.warning {
    border-color: rgba(255, 215, 0, 0.4);
    color: var(--gold);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-24px) scale(0.9);
    }
}

/* ===== LIGHT MODE OVERRIDES — Lobby Page ===== */
[data-theme="light"] html,
[data-theme="light"] body {
    background: #F5F0E8;
    color: #1A1408;
}

[data-theme="light"] body::before {
    background-image:
        linear-gradient(rgba(165, 117, 12, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(165, 117, 12, 0.04) 1px, transparent 1px);
}

[data-theme="light"] .entry-card {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(165, 117, 12, 0.2);
}

[data-theme="light"] .entry-card:hover {
    box-shadow: 0 0 30px rgba(165, 117, 12, 0.08);
}

[data-theme="light"] .entry-card-desc {
    color: rgba(26, 20, 8, 0.55);
}

[data-theme="light"] .lobby-label {
    color: rgba(26, 20, 8, 0.55);
}

[data-theme="light"] .lobby-input {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(165, 117, 12, 0.25);
    color: #1A1408;
}

[data-theme="light"] .lobby-input:focus {
    border-color: rgba(165, 117, 12, 0.6);
    box-shadow: 0 0 0 3px rgba(165, 117, 12, 0.1);
}

[data-theme="light"] .lobby-room-wrap {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(165, 117, 12, 0.2);
}

[data-theme="light"] .room-code-label {
    color: rgba(26, 20, 8, 0.55);
}

[data-theme="light"] .players-section-title {
    color: rgba(26, 20, 8, 0.55);
}

[data-theme="light"] .player-slot {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(165, 117, 12, 0.18);
}

[data-theme="light"] .player-slot.is-host {
    background: rgba(165, 117, 12, 0.06);
    border-color: rgba(165, 117, 12, 0.3);
}

[data-theme="light"] .player-slot-name {
    color: #1A1408;
}

[data-theme="light"] .player-slot-empty {
    border-color: rgba(165, 117, 12, 0.2);
}

[data-theme="light"] .connection-chip {
    background: rgba(245, 240, 232, 0.92);
    border-color: rgba(165, 117, 12, 0.25);
    color: rgba(26, 20, 8, 0.6);
}

[data-theme="light"] .connection-chip.disconnected {
    border-color: rgba(220, 50, 50, 0.4);
    color: #CC2020;
    background: rgba(245, 240, 232, 0.92);
}

[data-theme="light"] .connection-chip.disconnected .connection-dot {
    background: #CC2020;
}

[data-theme="light"] .lobby-toast {
    background: rgba(245, 240, 232, 0.95);
    border-color: rgba(165, 117, 12, 0.2);
    color: #1A1408;
}

[data-theme="light"] .waiting-message {
    color: rgba(26, 20, 8, 0.55);
}

[data-theme="light"] .min-players-note {
    color: rgba(26, 20, 8, 0.45);
}

[data-theme="light"] .lobby-subtitle {
    color: rgba(26, 20, 8, 0.5);
}

/* ======================== ALLIANCE CHAT WIDGET ======================== */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Rajdhani', sans-serif;
}

/* Chat Toggle Button */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(17, 17, 19, 0.85);
    border: 1px solid var(--border);
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.15);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.chat-toggle-btn:hover {
    transform: scale(1.08) rotate(5deg);
    border-color: var(--blue-glow);
    box-shadow: 0 0 25px rgba(0, 170, 255, 0.3);
}

.chat-icon {
    font-size: 1.6rem;
}

/* Chat Badge */
.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff2d2d;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 3px 7px;
    border-radius: 10px;
    min-width: 15px;
    text-align: center;
    box-shadow: 0 0 10px rgba(255, 45, 45, 0.6);
    display: none;
}

/* Chat Panel Drawer */
.chat-panel {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 320px;
    height: 400px;
    background: rgba(11, 11, 13, 0.95);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(15px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
    transform: scale(1);
    opacity: 1;
}

.chat-panel.collapsed {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* Header */
.chat-header {
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    font-weight: bold;
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.2s;
}

.chat-close-btn:hover {
    color: #ff5555;
}

/* Messages List */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.15);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.3);
}

/* Chat Message Bubbles */
.chat-msg-bubble {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: slideUpFade 0.3s ease;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg-sender {
    font-size: 0.75rem;
    margin-bottom: 3px;
    font-weight: 600;
}

.chat-msg-text {
    font-size: 0.85rem;
    padding: 8px 12px;
    border-radius: 12px;
    line-height: 1.35;
    word-break: break-word;
}

/* Self alignment */
.chat-msg-bubble.self {
    align-self: flex-end;
}

.chat-msg-bubble.self .chat-msg-sender {
    display: none;
    /* Hide our own name badge */
}

.chat-msg-bubble.self .chat-msg-text {
    background: rgba(0, 170, 255, 0.15);
    border: 1px solid rgba(0, 170, 255, 0.3);
    color: #fff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 0 10px rgba(0, 170, 255, 0.05);
}

/* Others alignment */
.chat-msg-bubble.other {
    align-self: flex-start;
}

.chat-msg-bubble.other .chat-msg-text {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    border-bottom-left-radius: 2px;
}

/* System Notifications */
.chat-system-message {
    font-size: 0.75rem;
    color: var(--yellow);
    opacity: 0.75;
    text-align: center;
    font-style: italic;
    margin: 4px 0;
    letter-spacing: 0.05em;
    animation: fadeIn 0.4s ease;
}

/* Input Area */
.chat-input-area {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

#chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 8px 12px;
    color: white;
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

#chat-input:focus {
    outline: none;
    border-color: var(--blue-glow);
}

.chat-send-btn {
    background: rgba(0, 170, 255, 0.15);
    border: 1px solid var(--blue-glow);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    background: rgba(0, 170, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.25);
}

/* Mobile responsive adjustments for Chat Widget */
@media (max-width: 600px) {
    .chat-widget {
        bottom: 12px;
        right: 12px;
    }

    .chat-toggle-btn {
        width: 52px;
        height: 52px;
    }

    .chat-icon {
        font-size: 1.4rem;
    }

    .chat-panel {
        bottom: 64px;
        width: calc(100vw - 24px);
        height: 320px;
        border-radius: 8px;
    }

    .chat-messages {
        padding: 10px;
        gap: 8px;
    }

    .chat-msg-text {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    .chat-input-area {
        padding: 8px 12px;
    }

    #chat-input {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    .chat-send-btn {
        padding: 6px 12px;
        font-size: 0.7rem;
    }
}

/* ============================================================
   MUSIC TOGGLE BUTTON
   ============================================================ */
.music-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 50px;
    color: #FFD700;
    font-family: 'Orbitron', monospace;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.music-toggle-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 215, 0, 0.12);
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: inherit;
}

.music-toggle-btn:hover::before {
    opacity: 1;
}

.music-toggle-btn:hover {
    border-color: rgba(255, 215, 0, 0.7);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.25);
    transform: translateY(-1px);
}

.music-toggle-btn:active {
    transform: scale(0.96);
}

.music-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.music-toggle-btn:hover .music-icon {
    transform: scale(1.2);
}

.music-label {
    font-size: 0.55rem;
}

/* Playing state — subtle glow pulse */
.music-toggle-btn.playing {
    border-color: rgba(255, 215, 0, 0.7);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.15);
    animation: musicPulse 2s ease-in-out infinite;
}

@keyframes musicPulse {

    0%,
    100% {
        box-shadow: 0 0 12px rgba(255, 215, 0, 0.15);
    }

    50% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.3), 0 0 40px rgba(255, 215, 0, 0.1);
    }
}

/* Light mode overrides */
[data-theme="light"] .music-toggle-btn {
    background: rgba(165, 117, 12, 0.08);
    border-color: rgba(165, 117, 12, 0.45);
    color: #7a5500;
}

[data-theme="light"] .music-toggle-btn::before {
    background: rgba(165, 117, 12, 0.1);
}

[data-theme="light"] .music-toggle-btn:hover {
    border-color: rgba(165, 117, 12, 0.7);
    box-shadow: 0 0 16px rgba(165, 117, 12, 0.2);
}

[data-theme="light"] .music-toggle-btn.playing {
    border-color: rgba(165, 117, 12, 0.7);
    box-shadow: 0 0 12px rgba(165, 117, 12, 0.2);
}

/* Mobile responsive */
@media (max-width: 600px) {
    .music-toggle-btn {
        padding: 4px 10px;
        font-size: 0.45rem;
        gap: 4px;
    }

    .music-icon {
        width: 14px;
        height: 14px;
    }

    .music-label {
        font-size: 0.4rem;
    }
}

/* ============================================================
   SETTINGS PANEL & DROPDOWN
   ============================================================ */
.settings-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.settings-toggle-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 215, 0, 0.35);
    background: linear-gradient(135deg, rgba(15, 15, 25, 0.85) 0%, rgba(25, 20, 40, 0.85) 100%);
    color: #ffd700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(8px);
}

.settings-toggle-btn:hover {
    border-color: rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.25);
    transform: scale(1.05);
}

.settings-toggle-btn:hover .settings-icon {
    transform: rotate(45deg);
}

.settings-icon {
    transition: transform 0.4s ease;
}

.settings-panel {
    position: absolute;
    top: 50px;
    right: 0;
    width: 260px;
    padding: 16px;
    background: linear-gradient(145deg, rgba(12, 12, 20, 0.96) 0%, rgba(18, 14, 30, 0.96) 100%);
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 10100;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.25s ease;
    transform-origin: top right;
}

.settings-panel.collapsed {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.9) translateY(-10px);
    pointer-events: none;
}

.settings-title {
    font-family: 'Orbitron', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: #ffd700;
    margin: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
    text-transform: uppercase;
}

.settings-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-label {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: #bbb;
    letter-spacing: 0.05em;
}

.settings-panel .theme-toggle-btn,
.settings-panel .music-toggle-btn,
.settings-panel .sfx-toggle-btn {
    margin: 0;
    width: auto;
    flex-grow: 0;
}

/* Light Theme Overrides */
[data-theme="light"] .settings-toggle-btn {
    border-color: rgba(180, 140, 50, 0.4);
    background: linear-gradient(135deg, rgba(245, 240, 230, 0.9) 0%, rgba(235, 225, 210, 0.9) 100%);
    color: #8B6914;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .settings-panel {
    background: linear-gradient(145deg, rgba(255, 252, 245, 0.98) 0%, rgba(245, 238, 225, 0.98) 100%);
    border-color: rgba(180, 140, 50, 0.25);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .settings-title {
    color: #8B6914;
    border-bottom-color: rgba(180, 140, 50, 0.15);
}

[data-theme="light"] .settings-label {
    color: #555;
}

/* SFX toggle button style */
.sfx-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(0, 170, 255, 0.08);
    border: 1px solid rgba(0, 170, 255, 0.4);
    border-radius: 50px;
    color: #00e5ff;
    font-family: 'Orbitron', monospace;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.sfx-toggle-btn:hover {
    border-color: rgba(0, 170, 255, 0.7);
    box-shadow: 0 0 16px rgba(0, 170, 255, 0.25);
    transform: translateY(-1px);
}

.sfx-toggle-btn:active {
    transform: scale(0.96);
}

.sfx-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.sfx-label {
    font-size: 0.55rem;
}

[data-theme="light"] .sfx-toggle-btn {
    background: rgba(0, 120, 200, 0.08);
    border-color: rgba(0, 120, 200, 0.45);
    color: #007799;
}