/* ═══════════════════════════════════════════
   WORM GAME STYLES
   ═══════════════════════════════════════════ */

#view-worm.active {
    display: flex !important;
}

/* ── Lobby ── */
#worm-lobby {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
    background: radial-gradient(ellipse at 50% 0%, rgba(34,197,94,0.15) 0%, transparent 65%), #0a0c14;
}

/* ── Room List ── */
.worm-room-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    margin-bottom: 0.5rem;
    gap: 1rem;
}
.worm-room-row:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(34,197,94,0.3);
    transform: translateX(4px);
}

/* ── Waiting Room Overlay ── */
#worm-waiting {
    display: none;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: radial-gradient(ellipse at 50% 0%, rgba(34,197,94,0.15) 0%, transparent 65%), #0a0c14;
    text-align: center;
}

.worm-room-code {
    font-size: 2.8rem;
    font-weight: 900;
    color: var(--gold, #f59e0b);
    letter-spacing: 6px;
    font-family: 'Courier New', monospace;
    background: rgba(0,0,0,0.4);
    padding: 1rem 2.5rem;
    border-radius: 16px;
    border: 2px solid rgba(245,158,11,0.3);
    box-shadow: 0 0 40px rgba(245,158,11,0.15), inset 0 1px 0 rgba(255,255,255,0.08);
    user-select: all;
    cursor: copy;
    transition: box-shadow 0.2s;
    margin: 1rem 0 2rem;
}
.worm-room-code:hover {
    box-shadow: 0 0 60px rgba(245,158,11,0.3), inset 0 1px 0 rgba(255,255,255,0.08);
}

.worm-players-grid {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}
.worm-player-slot {
    width: 120px;
    height: 100px;
    border-radius: 16px;
    border: 2px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: border-color 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}
.worm-player-slot.filled {
    border-color: var(--slot-color, #3b82f6);
    box-shadow: 0 0 20px color-mix(in srgb, var(--slot-color, #3b82f6) 30%, transparent);
}
.worm-player-slot.empty {
    border-style: dashed;
    opacity: 0.5;
}
.worm-player-slot .avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #374151 center/cover;
    border: 2px solid var(--slot-color, #3b82f6);
}
.worm-player-slot .alias {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.worm-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    box-shadow: 0 0 8px currentColor;
}

/* ── Game Canvas ── */
#worm-game {
    display: none;
    flex: 1;
    flex-direction: column;
    background: #070810;
    position: relative;
}

#worm-canvas-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

#worm-canvas {
    display: block;
    border: 2px solid rgba(255,255,255,0.06);
    box-shadow: 0 0 60px rgba(0,0,0,0.8), inset 0 0 60px rgba(0,0,0,0.3);
    background: #0a0c14;
    image-rendering: pixelated;
    max-width: 100%;
    max-height: 100%;
}

/* ── HUD (score bar) ── */
#worm-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    gap: 0.75rem;
    flex-wrap: wrap;
}
.worm-hud-player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.07);
    transition: opacity 0.3s;
}
.worm-hud-player.dead {
    opacity: 0.35;
    text-decoration: line-through;
}
.worm-hud-score {
    color: var(--gold, #f59e0b);
    font-size: 0.95rem;
    font-weight: 800;
}
.worm-hud-pot {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-left: auto;
}

/* ── Game Over Overlay ── */
#worm-gameover {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(7,8,16,0.92);
    backdrop-filter: blur(8px);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}
.worm-gameover-card {
    background: linear-gradient(145deg, #111827, #1f2937);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px;
    padding: 2.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

/* ── Mobile D-Pad ── */
#worm-dpad {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    gap: 0;
    grid-template-columns: 56px 56px 56px;
    grid-template-rows: 56px 56px 56px;
    user-select: none;
}
.worm-dpad-btn {
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    color: rgba(255,255,255,0.8);
    transition: background 0.1s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.worm-dpad-btn:active {
    background: rgba(34,197,94,0.35);
    transform: scale(0.92);
}
.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-center{ grid-column: 2; grid-row: 2; background: transparent; border: none; pointer-events: none; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }

/* ── Worm Game Modal ── */
.worm-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(6px);
    z-index: 1050;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.worm-modal.active {
    display: flex;
}
.worm-modal-card {
    background: linear-gradient(145deg, #111827, #1f2937);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

/* ── Search Input ── */
.worm-search-input {
    width: 100%;
    max-width: 400px;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.12);
    background: #141624;
    color: white;
    outline: none;
    font-size: 1rem;
    transition: border-color 0.2s;
}
.worm-search-input:focus {
    border-color: #22c55e;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    #worm-lobby {
        padding: 1rem;
    }
    #worm-dpad {
        display: grid;
    }
    .worm-room-code {
        font-size: 1.8rem;
        letter-spacing: 4px;
        padding: 0.75rem 1.25rem;
    }
    .worm-player-slot {
        width: 90px;
        height: 80px;
    }
    #worm-hud {
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    .worm-hud-player {
        font-size: 0.72rem;
        padding: 0.25rem 0.5rem;
    }
}
