@media (max-width: 768px) {
    .app-container {
        padding: 0 12px 12px; /* Remove top padding so filters snug up to header */
    }

    .header h1 {
        font-size: 2.2rem;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-top: 4px;
    }

    .view-header h2 {
        font-size: 1.4rem; /* Prevent Wrapping */
    }

    /* .room-grid is now fully fluid from hall.css */

    .replay-controls {
        padding: 20px;
    }

    .transcript-panel {
        width: 100%;
        top: 0;
        bottom: 0;
    }

    .message {
        max-width: 95%;
    }

    .podcast-player-view {
        padding: 16px 20px;
    }

    .waveform-container {
        height: 80px;
    }

    .play-pause-btn {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .player-btn.secondary {
        width: 40px;
        height: 40px;
    }

    .lyrics-line {
        font-size: 1.4rem;
    }

    .settings-card {
        padding: 24px;
        border-radius: 24px;
    }

    .settings-card h3 {
        font-size: 1.5rem;
    }

    .character-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }

    .character-card {
        padding: 8px;
    }

    .character-card .avatar {
        font-size: 1.5rem;
    }

    .character-card .name {
        font-size: 0.75rem;
    }

    .input-container {
        padding: 8px 16px 16px;
    }

    .input-wrapper input {
        padding: 12px 20px;
    }

    .send-btn {
        width: 48px;
        height: 48px;
    }

    .live-topic {
        max-width: 180px;
    }

    /* Avatar Name Labels — Mobile */
    .live-avatar-name,
    .art-avatar-name {
        font-size: 0.7rem;
        max-width: 100px;
    }

    .live-avatar-overlay {
        gap: 16px;
        padding: 20px;
    }

    .art-avatar .avatar-img {
        animation: none;
        /* Conserve GPU on mobile */
    }

    /* Vertical Right-Aligned Action Bar for Mobile */
    .floating-toggle-btn {
        display: flex;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: var(--text-secondary);
        align-items: center;
        justify-content: center;
        font-size: 0.9rem;
        cursor: pointer;
        transition: all 0.3s ease;
        flex-shrink: 0;
        /* Use flex layout instead of absolute positioning to avoid overlap */
        position: relative;
        right: auto;
        bottom: auto;
        z-index: auto;
    }

    .action-bar {
        flex-direction: column;
        align-items: flex-end;
        position: absolute;
        right: 16px;
        bottom: calc(90px + env(safe-area-inset-bottom, 0px)); /* Just above the input row */
        transform-origin: right center;
        max-height: none;
        transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.4s;
        z-index: 1000; /* Prevent obscuring by game-overlay (z-index: 500) */
        
        /* Remove pill background to fix large blank space on the left */
        background: transparent !important;
        border: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        padding: 0 !important;
        gap: 12px;
    }

    .action-bar .action-btn {
        background: rgba(255, 255, 255, 0.08);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
    
    .room-lang-select {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    .action-bar.collapsed {
        transform: translateX(150%);
        opacity: 0;
        pointer-events: none;
        max-height: none; /* Undo PC override */
    }
}

@media (max-width: 480px) {
    .header {
        padding: 20px 0 10px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .room-list-container {
        padding: 4px 12px 60px; /* Reduced top padding for tighter header connection */
        gap: 16px;
    }

    .room-grid {
        grid-template-columns: 1fr; /* Force 1 column on very small screens for readability */
        gap: 14px 10px;
    }

    .room-title {
        font-size: 0.85rem;
    }

    /* Auth Profile - Hide Name */
    .user-info .user-name {
        display: none !important;
    }
    
    .search-container {
        position: absolute;
        left: 110px; /* clear logo */
        right: 60px; /* Stop before the user profile icon */
        margin: 0 !important;
        max-width: none !important;
        flex: none !important;
    }
    
    .search-box input {
        display: block !important; /* Restore input field on mobile since we freed up space */
    }

    /* Restore top right user menu so they can access credits and logout */
    .top-bar-actions {
        display: flex !important;
    }

    .mobile-lang-zone {
        display: none !important;
    }

    .player-action-pill {
        padding: 0 12px;
        font-size: 0.8rem;
    }

    /* DIGITAL HUMAN PLAZA OPTIMIZATIONS */
    #castingHallPanel .view-header h2 {
        display: none !important; /* Redundant title since bottom nav says it */
    }
    
    #castingHallPanel .view-header {
        margin-top: 0 !important;
        margin-bottom: 12px !important;
    }

    .character-marketplace-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        padding: 5px 0 !important;
    }
    
    .casting-card-inner {
        padding: 12px !important;
    }
    
    .casting-avatar {
        width: 56px !important;
        height: 56px !important;
        margin: 0 auto 8px auto !important;
    }
    
    .casting-info .char-name {
        font-size: 1rem !important;
        text-align: center !important;
    }
    
    .casting-info .char-occu {
        font-size: 0.7rem !important;
        text-align: center !important;
        margin-bottom: 8px !important;
    }
    
    .casting-info .char-desc {
        display: none !important; /* Save space on 2-col grid */
    }
    
    .char-stats {
        flex-direction: column !important;
        gap: 4px !important;
        align-items: center !important;
        padding-top: 8px !important;
        margin-bottom: 12px !important;
        border-top: none !important;
    }
    
    .casting-card-actions {
        flex-direction: column !important;
    }

    /* PLAYER PLAYBACK VIEW OPTIMIZATIONS */
    .player-hero-section {
        aspect-ratio: auto !important; /* Release the 16/9 lock */
        height: 50vh !important; /* Much taller on mobile */
        min-height: 350px !important;
    }
    
    .artwork-container {
        max-width: 60vw !important; /* prevent overflow */
        margin-bottom: 60px !important; /* clear space for controls */
    }
    
    .player-controls-area {
        padding: 20px 4vw 16px !important;
    }

    .player-room-title {
        font-size: 1.5rem !important; /* Shrunk from 2.2rem */
        line-height: 1.3 !important;
    }

    .category-tab {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .messages-container {
        padding: 80px 16px 20px;
        gap: 16px;
    }

    .message .avatar {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .message .bubble {
        padding: 12px 16px;
    }

    .message .sender {
        font-size: 0.75rem;
    }

    .message .content {
        font-size: 0.9rem;
    }

    /* Avatar Name Labels — Small Mobile */
    .live-avatar-name,
    .art-avatar-name {
        font-size: 0.65rem;
        max-width: 80px;
    }

    .live-avatar-overlay {
        gap: 12px;
        padding: 16px;
    }

    .live-avatar-item .avatar-img,
    .art-avatar .avatar-img {
        animation: none;
        /* Save battery and GPU */
    }
}