/* Mobile-specific styles for touch devices */
/* Orientation-based layout: portrait (image grid below) / landscape (fullscreen + floating panel) */

/* ==========================================
   Pre-JS Loading Fix (media query, no JS dependency)
   Prevents layout shift by locking loading screen to viewport before JS runs
   ========================================== */
/* Mobile loading: use .mobile-device (set immediately by browser-detect.js)
   instead of media queries or orientation classes which may not be ready yet */
.mobile-device .loading-placeholder {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 1000 !important;
    padding-bottom: 8vh;
}
.mobile-device .loading-placeholder .loading-logo {
    font-size: 1.5rem;
}
.mobile-device .loading-placeholder .loading-text {
    font-size: 0.75rem;
}

/* ==========================================
   Mobile Loading State - hide UI until images loaded
   ========================================== */

/* During loading: kill transitions, and prevent ancestors from breaking position:fixed
   (backface-visibility:hidden and will-change:transform create containing blocks) */
.mobile-loading,
.mobile-loading * {
    transition: none !important;
    -webkit-backface-visibility: visible !important;
    backface-visibility: visible !important;
    will-change: auto !important;
}

.mobile-loading #mobile-image-section {
    opacity: 0 !important;
    pointer-events: none;
}

.mobile-device.mobile-portrait.mobile-loading .modern-title,
.mobile-device.mobile-loading .modern-title {
    opacity: 0 !important;
}

.mobile-device.mobile-portrait.mobile-loading #info-panel,
.mobile-device.mobile-loading #info-panel {
    opacity: 0 !important;
    transform: translateY(15px) !important;
}

/* Hide the top bar (PAN ARCADIA logo) during loading - it must wait for center logo to fade first */
.mobile-device.mobile-portrait.mobile-loading #streaming-controls,
.mobile-device.mobile-loading #streaming-controls {
    opacity: 0 !important;
    pointer-events: none;
}

/* Transitions for reveal when loading completes (mobile-loading removed) */
.mobile-device .modern-title {
    transition: opacity 0.5s ease;
}

.mobile-device #info-panel {
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#mobile-image-section {
    transition: opacity 0.5s ease;
}

/* ==========================================
   Mobile Device Base Styles
   ========================================== */
.mobile-device {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-device * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.mobile-device .chatbot-messages,
.mobile-device .modal-content {
    -webkit-user-select: text;
    user-select: text;
}
.mobile-device .modal-content input,
.mobile-device .modal-content textarea {
    -webkit-user-select: auto;
    user-select: auto;
}

/* Hide desktop-only elements */
.mobile-device .tips-section { display: none !important; }
.mobile-device .tip-item.desktop-only { display: none !important; }
.mobile-device .tip-text.desktop-text { display: none !important; }
.mobile-device .tip-text.mobile-text { display: inline !important; }
.tip-text.mobile-text { display: none; }
.mobile-device .tip-number.desktop-number { display: none !important; }
.mobile-device .tip-number.mobile-number { display: inline-flex !important; }
.tip-number.mobile-number { display: none; }

.mobile-device #action-buttons-container,
.mobile-device .keyboard-instructions,
.mobile-device .movement-tooltip,
.mobile-device .action-button[data-key="shift"],
.mobile-device .direction-button[data-key="w"],
.mobile-device .direction-button[data-key="a"],
.mobile-device .direction-button[data-key="s"],
.mobile-device .direction-button[data-key="d"],
.mobile-device .controls-section,
.mobile-device #keyboard-controls,
.mobile-device .button-group,
.mobile-device .wasd-group,
.mobile-device .action-group,
.mobile-device .arrow-group,
.mobile-device .direction-button,
.mobile-device .action-button {
    display: none !important;
}

.mobile-device .modern-title { display: none !important; }
.mobile-device #chatbot-container { display: none !important; }
.mobile-device .site-logo-link { top: 10px; left: 12px; z-index: 1500 !important; }
.mobile-device .site-logo { height: 30px; }
.mobile-device.mobile-landscape .site-logo { height: 26px; }

/* Pre-JS sizing: media queries apply at first paint, before JS classes are added.
   Prevents flash-of-large-logo during loading on mobile devices. */
@media (pointer: coarse) {
    .site-logo-link { top: 10px; left: 12px; z-index: 1500; }
    .site-logo { height: 30px; }
}
@media (pointer: coarse) and (orientation: landscape) {
    .site-logo { height: 26px; }
}

/* ==========================================
   Mobile Layout Base (Both Orientations)
   ========================================== */
.mobile-device .container {
    max-width: 100%;
    padding: 0;
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-device .game-wrapper {
    position: relative;
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    align-items: stretch;
    width: 100% !important;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.mobile-device #video-container {
    position: relative !important;
    display: block !important;
    flex: none !important;
    width: 100% !important;
    max-width: 100vw;
    margin: 0 !important;
    border-radius: 0 !important;
    background: #0a0a0a !important;
    box-shadow: none !important;
}

.mobile-device #imageDisplay { touch-action: manipulation; }

/* ==========================================
   Compact Top Bar (Both Orientations)
   ========================================== */
.mobile-device #streaming-controls {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 34px !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(10px) !important;
    display: none;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 14px !important;
    z-index: 100 !important;
    box-sizing: border-box !important;
}

.mobile-device #streaming-controls[style*="display: flex"],
.mobile-device #streaming-controls[style*="display:flex"] {
    display: flex !important;
}

.mobile-device #streaming-controls[style*="display: none"],
.mobile-device #streaming-controls[style*="display:none"] {
    display: none !important;
}

/* Portrait: streaming-controls bar always visible (logo in idle, logo+timer+stop when streaming) */
.mobile-device.mobile-portrait #streaming-controls,
.mobile-device.mobile-portrait #streaming-controls[style*="display: none"],
.mobile-device.mobile-portrait #streaming-controls[style*="display:none"] {
    display: flex !important;
    position: relative !important;
    top: 10px !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    flex-shrink: 0 !important;
}

.mobile-device .mobile-top-logo {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 15px;
    color: #ffffff;
    /* margin-right: auto; */
    white-space: nowrap;
    text-shadow: none;
    transition: none !important;
}
.mobile-device .mobile-top-logo .pan { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 700; color: #ffffff; }
.mobile-device .mobile-top-logo .arcadia { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 400; color: #ffffff; }

/* Portrait idle: hide everything except logo */
.mobile-device.mobile-portrait #streaming-controls:not(.streaming-active) #network-status,
.mobile-device.mobile-portrait #streaming-controls:not(.streaming-active) #timer-container,
.mobile-device.mobile-portrait #streaming-controls:not(.streaming-active) #stopButton {
    display: none !important;
}

/* Portrait idle: right-align logo */
.mobile-device.mobile-portrait #streaming-controls:not(.streaming-active) {
    justify-content: flex-end !important;
}
.mobile-device.mobile-portrait #streaming-controls:not(.streaming-active) .mobile-top-logo {
    /* margin-right: 0 !important;
    margin-left: auto !important; */
}

.mobile-device #traffic-display { display: none !important; }

/* Portrait streaming: top bar simplifies to logo (center) + stop (right) */
.mobile-device.mobile-portrait #streaming-controls.streaming-active {
    justify-content: space-between !important;
    height: 34px !important;
}

.mobile-device.mobile-portrait #streaming-controls.streaming-active .mobile-top-logo {
    margin-top: 40px !important;
    /* margin-right: 0 !important;
    transform: none !important; */
}

.mobile-device.mobile-portrait #streaming-controls.streaming-active #stopButton {
    /* position: absolute !important;
    right: 14px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    padding: 4px 14px !important;
    font-size: 13px !important;
    height: auto !important;
    min-height: auto !important;
    min-width: auto !important;
    max-width: none !important;
    border-radius: 6px !important; */
}

/* Latency + timer hidden from top bar (moved into video overlay via JS) */
.mobile-device.mobile-portrait #streaming-controls.streaming-active #network-status,
.mobile-device.mobile-portrait #streaming-controls.streaming-active #timer-container {
    display: none !important;
}

/* Portrait stats overlay: latency left, timer right */
#portrait-stats-overlay {
    position: absolute;
    top: 40px;
    left: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

#portrait-stats-overlay .stat-item {
    background: rgba(0, 0, 0, 0.5) !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 2px 8px !important;
    min-width: 0 !important;
    height: auto !important;
}

#portrait-stats-overlay .stat-label {
    font-size: 11px !important;
    color: rgba(255, 255, 255, 0.45) !important;
}

#portrait-stats-overlay .stat-badge,
#portrait-stats-overlay #latency-value {
    font-size: 13px !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8) !important;
}

#portrait-stats-overlay #timer-container {
    background: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 2px 8px !important;
    min-width: 0 !important;
    height: auto !important;
    display: inline-flex !important;
    margin: 0 !important;
}

#portrait-stats-overlay #timer::before {
    display: none !important;
}

#portrait-stats-overlay #timer {
    font-size: 13px !important;
    color: rgba(255, 255, 255, 0.9) !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8) !important;
}

/* Portrait streaming: fade-in for controls + video */
@keyframes portraitStreamIn {
    from { opacity: 0; }
}

.mobile-device.mobile-portrait #streaming-controls.streaming-active #stopButton,
.mobile-device.mobile-portrait.is-streaming #portrait-stats-overlay,
.mobile-device.mobile-portrait.is-streaming #imageDisplay {
    animation: portraitStreamIn 0.4s ease !important;
}

.mobile-device #network-status {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    backdrop-filter: none !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    align-items: center !important;
    overflow: visible !important;
}

/* Single light-green box for latency (strip inner boxes) */
.mobile-device .stat-item {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 6px !important;
    padding: 2px 8px !important;
    backdrop-filter: none !important;
    gap: 4px !important;
    min-width: 120px !important;
}
.mobile-device .stat-label {
    font-size: 11px !important;
    color: rgba(255, 255, 255, 0.45) !important;
}
.mobile-device .stat-badge {
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
    font-size: 13px !important;
    transition: color 0.3s ease !important;
}
.mobile-device .stat-unit {
    font-size: 10px !important;
    transition: color 0.3s ease !important;
}
.mobile-device .stat-indicator {
    font-size: 8px !important;
    transition: color 0.3s ease !important;
}

.mobile-device #network-status[style*="display: block"],
.mobile-device #network-status[style*="display:block"] {
    display: flex !important;
}

.mobile-device #network-status[style*="display: none"],
.mobile-device #network-status[style*="display:none"] {
    display: none !important;
}

.mobile-device #network-status > div {
    flex-direction: row !important;
    gap: 6px !important;
    align-items: center !important;
    min-width: 0 !important;
}

.mobile-device #network-status > div > div {
    flex-direction: row !important;
    align-items: center !important;
    gap: 3px !important;
    min-width: 0 !important;
}

.mobile-device #network-status span[style*="text-transform"] { display: none !important; }
.mobile-device #latency-value { font-size: 13px !important; font-weight: 500 !important; font-variant-numeric: tabular-nums !important; transition: color 0.3s ease !important; }
.mobile-device #connection-status { font-size: 8px !important; margin-left: 3px !important; }

.mobile-device #timer-container {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 6px !important;
    padding: 2px 8px !important;
    margin: 0 !important;
    height: auto !important;
    min-width: 78px !important;
    justify-content: center !important;
    display: flex !important;
    align-items: center !important;
}

.mobile-device #timer {
    font-size: 13px !important;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500 !important;
    line-height: 1 !important;
    font-variant-numeric: tabular-nums !important;
    transition: color 0.3s ease !important;
}

/* Timer warning states */
.mobile-device #timer.timer-warning {
    color: #f39c12 !important;
    font-weight: bold !important;
}

.mobile-device #timer-container.timer-warning {
    border-color: rgba(243, 156, 18, 0.4) !important;
}

.mobile-device #timer.timer-critical {
    color: #e74c3c !important;
    font-weight: bold !important;
    animation: timerPulse 1s ease-in-out infinite !important;
}

.mobile-device #timer-container.timer-critical {
    border-color: rgba(231, 76, 60, 0.5) !important;
}

.mobile-device #stopButton {
    background: rgba(231, 76, 60, 0.6) !important;
    border: 1px solid rgba(231, 76, 60, 0.8) !important;
    color: rgba(255, 255, 255, 1) !important;
    padding: 3px 11px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    height: 28px !important;
    min-height: 28px !important;
    width: auto !important;
    min-width: 70px !important;
    max-width: 90px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
}

.mobile-device #stopButton:active {
    transform: scale(0.98) !important;
    background: rgba(231, 76, 60, 0.8) !important;
}

.mobile-device .controls-container {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    display: inline-block !important;
}

/* ==========================================
   Portrait Mode Styles
   ========================================== */
.mobile-device.mobile-portrait #video-container {
    width: 100% !important;
    height: calc(100vw * 2 / 3) !important;
    max-height: none !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

/* Portrait streaming: container stays same size/position as idle (no layout shift) */

.mobile-device.mobile-portrait #mobile-image-section {
    position: relative;
    display: block;
    width: 100%;
    padding: 0 12px 8px;
    box-sizing: border-box;
    flex: 1 1 0px;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    background: #0a0a0a;
}

.mobile-device.mobile-portrait .mobile-upload-btn {
    padding: 12px 16px !important;
    margin-top: 5px !important;
}

/* Queue overlay: covers image section during queuing.
   Lives in .game-wrapper (not #mobile-image-section) so it doesn't scroll with the image list. */
#mobile-queue-overlay {
    position: absolute;
    top: calc(100vw * 2 / 3 + 34px - 1px); /* starts at bottom of video-container (34px for streaming-controls bar, -1px to prevent sub-pixel gap) */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(3px);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: all;
}

.mobile-device .mobile-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 6px 16px;
    margin-bottom: 8px;
    background: transparent;
    border: 2px dashed rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    min-height: 0;
    box-sizing: border-box;
}

.mobile-device .mobile-upload-btn:active {
    background: rgba(120, 255, 60, 0.08);
    border-color: rgba(255, 255, 255, 0.7);
}

.mobile-device .mobile-upload-btn svg {
    stroke: #a0ff50;
    flex-shrink: 0;
}

.mobile-device.mobile-portrait #image-selector-panel {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    transform: none !important;
    transition: none !important;
    z-index: auto;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
}

.mobile-device.mobile-portrait #image-selector-panel .panel-header {
    display: none !important;
}

.mobile-device.mobile-portrait #category-view {
    flex: none !important;
    overflow: visible !important;
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    padding: 0 !important;
}

/* gallery-view-hidden must override the grid display above */
.mobile-device.mobile-portrait #category-view.gallery-view-hidden {
    display: none !important;
}

.mobile-device.mobile-portrait .category-card {
    flex: none !important;
    min-height: 0 !important;
    aspect-ratio: 16/9 !important;
}

.mobile-device.mobile-portrait #image-grid-view {
    margin-top: 4px !important;
}

.mobile-device.mobile-portrait #image-list-content {
    padding: 0 !important;
    background: transparent !important;
    overflow: visible !important;
}

/* Back row is only for portrait; hide in landscape and desktop */
#mobile-back-row {
    display: none !important;
}
.mobile-device.mobile-portrait #mobile-back-row {
    display: flex !important;
}

.mobile-device.mobile-portrait #image-grid-container {
    padding: 0 !important;
    margin: 0 !important;
    max-height: none !important;
    min-height: 0 !important;
    flex: none !important;
    overflow-y: visible !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}
.mobile-device.mobile-portrait #image-grid-container::-webkit-scrollbar {
    display: none !important;
}

.mobile-device.mobile-portrait #image-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 0 !important;
    align-content: start !important;
}

.mobile-device.mobile-portrait #image-grid .image-item {
    width: 100% !important;
    aspect-ratio: 16/10 !important;
    height: auto !important;
    padding-bottom: 0 !important;
    position: relative !important;
    touch-action: pan-y;
}

.mobile-device.mobile-portrait #image-grid .image-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 6px;
    -webkit-user-drag: none;
    pointer-events: none;
}

.mobile-device.mobile-portrait #upload-section { display: none !important; }
.mobile-device.mobile-portrait #image-count-badge { display: none !important; }

.mobile-device.mobile-portrait #image-selector-panel::before,
.mobile-device.mobile-portrait #image-selector-panel::after {
    display: none !important;
}

.mobile-device.mobile-portrait #info-panel {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    z-index: 50 !important;
    background: rgba(15, 15, 15, 0.95) !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
    opacity: 1 !important;
    max-height: none !important;
    min-height: auto !important;
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0) !important;
}

.mobile-device.mobile-portrait #keyboard-controls,
.mobile-device.mobile-portrait .bar-divider {
    display: none !important;
}


/* ==========================================
   Landscape Mode Styles
   ========================================== */
.mobile-device.mobile-landscape .container { overflow: hidden; }

.mobile-device.mobile-landscape .game-wrapper {
    /* position:fixed anchors directly to viewport - bypasses all flex height chain issues */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    flex: unset !important;
    min-height: unset !important;
    background: #0a0a0a;
}

/* body prefix raises specificity to (1,2,1) — beats safari.css (1,2,0).
   Height fills viewport, width = height × 1.5 (explicit calc, not auto+aspect-ratio
   which breaks with left:50% on fixed elements). Capped at 100vw. */
body.mobile-device.mobile-landscape #video-container {
    position: fixed !important;
    top: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    width: calc(100vh * 3 / 2) !important;
    width: min(calc(100dvh * 3 / 2), 100vw) !important;
    aspect-ratio: auto !important;
    flex: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
}

/* Landscape streaming HUD: horizontal bar at top of video */
.mobile-device.mobile-landscape #streaming-controls {
    position: absolute !important;
    top: 0 !important;
    left: 180px !important;
    right: 0 !important;
    bottom: auto !important;
    width: auto !important;
    height: auto !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 6px 10px !important;
    gap: 8px !important;
    background: transparent !important;
    border: none !important;
    backdrop-filter: none !important;
    z-index: 100 !important;
}

/* Landscape: always show streaming-controls (logo always visible in top-left) */
.mobile-device.mobile-landscape #streaming-controls,
.mobile-device.mobile-landscape #streaming-controls[style*="display: none"],
.mobile-device.mobile-landscape #streaming-controls[style*="display:none"] {
    display: flex !important;
}

/* Landscape idle: hide everything except logo */
.mobile-device.mobile-landscape #streaming-controls:not(.streaming-active) #network-status,
.mobile-device.mobile-landscape #streaming-controls:not(.streaming-active) #timer-container,
.mobile-device.mobile-landscape #streaming-controls:not(.streaming-active) #stopButton {
    display: none !important;
}

.mobile-device.mobile-landscape .mobile-top-logo {
    display: inline !important;
    font-size: 13px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

/* Landscape idle: right-align PAN ARCADIA */
.mobile-device.mobile-landscape #streaming-controls:not(.streaming-active) {
    justify-content: flex-end !important;
}
.mobile-device.mobile-landscape #streaming-controls:not(.streaming-active) .mobile-top-logo {
    margin-right: 0 !important;
    margin-left: auto !important;
}

/* Video top-left: latency only (traffic hidden) */
.mobile-device.mobile-landscape #network-status {
    order: 1 !important;
    flex-direction: row !important;
    gap: 8px !important;
}

.mobile-device.mobile-landscape #traffic-display {
    display: none !important;
}

/* Fixed-width digits to prevent layout jumping */
.mobile-device.mobile-landscape #latency-value,
.mobile-device.mobile-landscape #timer {
    font-variant-numeric: tabular-nums !important;
}

.mobile-device.mobile-landscape #latency-value {
    display: inline-block !important;
    min-width: 2.4em !important;
    text-align: right !important;
}

.mobile-device.mobile-landscape #timer {
    display: inline-block !important;
    min-width: 5.2em !important;
    text-align: right !important;
    font-size: 13px !important;
    color: white !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.5) !important;
}

/* Video top-right: timer pushed right via auto margin */
.mobile-device.mobile-landscape #timer-container {
    order: 2 !important;
    /* margin-left: auto !important; */
    background: rgba(0, 0, 0, 0.45) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 6px !important;
    padding: 2px 8px !important;
    min-width: 0 !important;
    height: 26px !important;
    box-sizing: border-box !important;
}

/* Video top-right: stop button next to timer */
.mobile-device.mobile-landscape #stopButton {
    order: 3 !important;
    margin-left: 8px !important;
}

/* Landscape: unify stat-item and timer-container appearance */
.mobile-device.mobile-landscape .stat-item {
    background: rgba(0, 0, 0, 0.45) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 6px !important;
    padding: 2px 8px !important;
    min-width: 0 !important;
    height: 26px !important;
    box-sizing: border-box !important;
}

.mobile-device.mobile-landscape .stat-label {
    color: rgba(255, 255, 255, 0.85) !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
}

.mobile-device.mobile-landscape .stat-badge {
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
}

.mobile-device.mobile-landscape .stat-unit,
.mobile-device.mobile-landscape .stat-indicator {
    color: rgba(255, 255, 255, 0.7) !important;
}

.mobile-device.mobile-landscape #latency-value {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
}

.mobile-device.mobile-landscape #mobile-image-section { display: none !important; }

.mobile-device.mobile-landscape #image-selector-panel {
    position: absolute !important;
    top: 5% !important;
    left: 10px !important;
    right: auto !important;
    bottom: 5% !important;
    width: calc(20vw + 18px) !important;
    max-height: none !important;
    background: rgba(10, 10, 10, 0.92) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 8px !important;
    z-index: 50;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease !important;
}

.mobile-device.mobile-landscape #image-selector-panel.collapsed {
    opacity: 0 !important;
    pointer-events: none !important;
}

.mobile-device.mobile-landscape #image-selector-panel .panel-header {
    display: grid !important;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    padding: 6px 10px !important;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 2px 4px !important;
}

.mobile-device.mobile-landscape #panel-back-btn {
    grid-row: 1;
    grid-column: 1;
}

.mobile-device.mobile-landscape #image-selector-panel .panel-header .panel-title {
    color: #fff !important;
    grid-row: 2;
    grid-column: 1 / -1;
}

.mobile-device.mobile-landscape #image-toggle-btn {
    grid-row: 1;
    grid-column: 3;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    justify-self: end;
    padding: 0 !important;
    min-height: 0 !important;
    min-width: 0 !important;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.mobile-device.mobile-landscape #image-grid-container {
    padding: 6px !important;
    margin: 0 !important;
    max-height: none !important;
    min-height: 100px !important;
    flex: 1 1 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

.mobile-device.mobile-landscape #image-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 6px !important;
    width: 100% !important;
    padding: 0 !important;
    align-content: start !important;
}

/* Landscape panel: 2 columns × 10vw thumbnails (1/10 of screen long edge) */

.mobile-device.mobile-landscape #image-grid .image-item {
    width: 100% !important;
    aspect-ratio: 5/2 !important;
    height: auto !important;
    padding-bottom: 0 !important;
}

.mobile-device.mobile-landscape #image-grid .image-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 4px;
}

/* Landscape: category view matches desktop – flex column, cards share height equally */
.mobile-device.mobile-landscape #category-view {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    padding: 6px !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

.mobile-device.mobile-landscape #category-view.gallery-view-hidden {
    display: none !important;
}

.mobile-device.mobile-landscape .category-card {
    flex: 1 !important;
    min-height: 0 !important;
}

.mobile-device.mobile-landscape .category-card-overlay {
    padding: 12px 8px 6px !important;
}
.mobile-device.mobile-landscape .category-card-name {
    font-size: 10px !important;
}
.mobile-device.mobile-landscape .category-card-desc {
    font-size: 8px !important;
}

/* Landscape: title on its own row below buttons */
.mobile-device.mobile-landscape #image-selector-panel .panel-header .panel-title {
    font-size: 9px !important;
    letter-spacing: 0.3px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.mobile-device.mobile-landscape #upload-section {
    padding: 6px 8px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
}

.mobile-device.mobile-landscape #upload-section .action-btn {
    padding: 6px 10px !important;
    font-size: 10px !important;
    border-radius: 16px !important;
}

.mobile-device.mobile-landscape #upload-section .action-btn .btn-icon { width: 12px !important; height: 12px !important; }
.mobile-device.mobile-landscape #upload-section .action-btn .btn-text { font-size: 9px !important; }

.mobile-device.mobile-landscape #image-selector-panel::before,
.mobile-device.mobile-landscape #image-selector-panel::after {
    display: none !important;
}

.mobile-device.mobile-landscape #image-count-badge {
    position: absolute !important;
    top: 45px !important;
    left: 10px !important;
    z-index: 50;
    background: rgba(10, 10, 10, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 6px !important;
    min-width: 0 !important;
    width: 32px !important;
    height: 32px !important;
    box-sizing: border-box !important;
    cursor: pointer;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Hide text, show album icon */
.mobile-device.mobile-landscape #image-count-badge .badge-count,
.mobile-device.mobile-landscape #image-count-badge .badge-label {
    display: none !important;
}

.mobile-device.mobile-landscape #image-count-badge::before {
    content: '';
    display: block;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2' ry='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpolyline points='21 15 16 10 5 21'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.mobile-device.mobile-landscape #image-selector-panel:not(.collapsed) ~ #image-count-badge {
    display: none !important;
}

/* Landscape: hide info-panel by default, show as floating HUD when streaming */
/* Landscape: always hide info-panel / status bar (including during streaming) */
.mobile-device.mobile-landscape #info-panel,
.mobile-device.mobile-landscape.is-streaming #info-panel {
    display: none !important;
}

/* ==========================================
   Mobile Touch Controls
   ========================================== */
.mobile-controls-container {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none; z-index: 100;
}

.virtual-joystick { touch-action: none; }
.joystick-base { background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.05) 100%); box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.joystick-knob { background: linear-gradient(135deg, #667eea 0%, #4a69bd 100%); box-shadow: 0 4px 8px rgba(0,0,0,0.3); }

.joystick-backward-overlay {
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
}

.action-button-mobile { transition: transform 0.1s, box-shadow 0.1s; }
.action-button-mobile img { transition: opacity 0.1s; }
.action-button-mobile:active { transform: scale(0.95) !important; box-shadow: 0 2px 4px rgba(0,0,0,0.3) !important; }
.action-button-mobile:active img { opacity: 0.8; }
.action-button-mobile.action-jump { background: linear-gradient(135deg, #4CAF50, #45a049); }
.action-button-mobile.action-attack { background: linear-gradient(135deg, #f44336, #da190b); }
.action-button-mobile.action-run { background: linear-gradient(135deg, #2196F3, #0d47a1); }

/* ==========================================
   Mobile Buttons and Inputs
   ========================================== */
.mobile-device button, .mobile-device .control-button, .mobile-device .start-button, .mobile-device .stop-button {
    min-height: 44px; min-width: 44px; font-size: 16px;
}

.mobile-device input, .mobile-device textarea, .mobile-device select {
    font-size: 16px; padding: 12px; touch-action: manipulation;
}

/* ==========================================
   Mobile Game Control Buttons
   ========================================== */
.mobile-device #startButton {
    background: rgba(20, 20, 20, 0.9) !important; border: 1px solid rgba(255, 255, 255, 0.3) !important; color: #ffffff !important;
    padding: 12px 20px !important; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important; font-size: 15px !important; font-weight: 700 !important;
    border-radius: 8px !important; min-height: 44px !important; min-width: auto !important;
    width: auto !important; transition: all 0.2s ease !important;
    box-shadow: 0 2px 10px rgba(120, 255, 60, 0.15) !important;
}
.mobile-device #startButton:not(:disabled):active { transform: scale(0.98) !important; background: rgba(30, 30, 30, 0.95) !important; border-color: rgba(255, 255, 255, 0.5) !important; }
.mobile-device #startButton:disabled { background: rgba(255, 255, 255, 0.05) !important; border-color: rgba(255, 255, 255, 0.1) !important; color: rgba(255, 255, 255, 0.3) !important; opacity: 0.7 !important; }

.mobile-device #cancelFindButton, .mobile-device #cancelQueueButton {
    background: rgba(255, 255, 255, 0.1) !important; border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: rgba(255, 255, 255, 0.8) !important; padding: 6px 14px !important; font-size: 13px !important;
    font-weight: 400 !important; border-radius: 6px !important; min-height: 36px !important;
    transition: all 0.2s ease !important; margin-top: 0 !important;
}
.mobile-device #cancelFindButton:active, .mobile-device #cancelQueueButton:active { transform: scale(0.98) !important; background: rgba(255, 255, 255, 0.15) !important; }

.mobile-device .start-main-controls { display: flex !important; gap: 12px !important; justify-content: center !important; align-items: center !important; padding: 8px !important; }
.mobile-device .prompt-edit-btn { background: rgba(255, 255, 255, 0.1) !important; border: 1px solid rgba(255, 255, 255, 0.2) !important; padding: 0 !important; width: 40px !important; height: 40px !important; min-width: 40px !important; min-height: 40px !important; font-size: 18px !important; border-radius: 50% !important; display: flex !important; align-items: center !important; justify-content: center !important; transition: all 0.2s ease !important; }
.mobile-device .prompt-edit-btn:active { transform: scale(0.95) !important; background: rgba(255, 255, 255, 0.15) !important; }

.mobile-device .server-finding-content, .mobile-device .queue-content { padding: 16px !important; text-align: center !important; }
.mobile-device #server-finding-overlay, .mobile-device #queue-overlay { padding: 10px !important; }
.mobile-device .loading-message, .mobile-device .queue-message { font-size: 16px !important; margin-bottom: 20px !important; color: rgba(255, 255, 255, 0.9) !important; }
.mobile-device #blog-button { top: 15px !important; left: 15px !important; width: 40px !important; height: 40px !important; opacity: 0.8; }
.mobile-device #blog-button span { width: 40px !important; height: 40px !important; }
.mobile-device #blog-button svg { width: 20px !important; height: 20px !important; }

/* ==========================================
   Mobile Prompt Edit Modal
   ========================================== */
.mobile-device .prompt-edit-modal-content { width: 95% !important; max-width: none !important; margin: 10px auto !important; padding: 15px !important; }
.mobile-device .prompt-input-section textarea { font-size: 14px !important; line-height: 1.4 !important; padding: 10px !important; height: 120px !important; resize: none !important; }
.mobile-device .modal-footer { display: flex !important; justify-content: space-between !important; gap: 10px !important; padding-top: 15px !important; }
.mobile-device .modal-footer button { flex: 1 !important; min-width: 0 !important; height: 44px !important; font-size: 14px !important; font-weight: 500 !important; border-radius: 8px !important; display: flex !important; align-items: center !important; justify-content: center !important; padding: 0 15px !important; text-transform: none !important; letter-spacing: normal !important; transition: all 0.2s !important; }
.mobile-device .btn-generate { background: linear-gradient(135deg, #667eea, #4a69bd) !important; color: white !important; border: none !important; box-shadow: 0 2px 8px rgba(74, 105, 189, 0.3) !important; }
.mobile-device .btn-generate:active { transform: scale(0.98) !important; }
.mobile-device .btn-generate:not(.loading) .generate-loading { display: none !important; }
.mobile-device .btn-generate.loading .generate-content { display: none !important; }
.mobile-device .btn-cancel { background: rgba(255, 255, 255, 0.08) !important; color: #a0c4ff !important; border: 1px solid rgba(74, 105, 189, 0.3) !important; }
.mobile-device .btn-cancel:active { background: rgba(255, 255, 255, 0.15) !important; }
.mobile-device .btn-confirm { background: #4a69bd !important; color: white !important; border: none !important; box-shadow: 0 2px 8px rgba(74, 105, 189, 0.2) !important; }
.mobile-device .btn-confirm:active { transform: scale(0.98) !important; }
.mobile-device .btn-generate .generate-content { display: inline-flex !important; align-items: center !important; justify-content: center !important; gap: 8px !important; }
.mobile-device .btn-generate .generate-loading { display: inline-flex !important; align-items: center !important; justify-content: center !important; gap: 8px !important; }
.mobile-device .btn-generate .loading-spinner { width: 14px !important; height: 14px !important; }
.mobile-device .modal-header h2 { font-size: 18px !important; margin: 0 !important; }
.mobile-device .modal-subtitle { font-size: 12px !important; margin-top: 5px !important; }
.mobile-device .input-hint { padding: 8px 10px !important; font-size: 12px !important; margin-top: 10px !important; }

/* ==========================================
   Mobile Modal Adjustments
   ========================================== */
.mobile-device .modal-content { width: 95%; max-width: none; margin: 10px auto; padding: 20px; max-height: 90vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.mobile-device .modal-close { width: 44px; height: 44px; top: 10px; right: 10px; }

/* ==========================================
   Mobile Download Panel
   ========================================== */
/* Panel: centered pill floating over lower video area */
.mobile-device .download-panel {
    position: absolute !important;
    bottom: 10px !important;
    left: 0 !important;
    right: 0 !important;
    width: fit-content !important;
    max-width: calc(100% - 20px) !important;
    margin: 0 auto !important;
    transform: none !important;
    padding: 3px 14px !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    z-index: 110 !important;
    background: rgba(10, 10, 10, 0.92) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 20px !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(16px) !important;
    animation: fadeInPanel 0.35s ease-out !important;
}
@keyframes fadeInPanel {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ios-safari.mobile-device .download-panel { position: absolute !important; bottom: 10px !important; }

/* Close button: hidden on mobile */
.mobile-device .download-panel-close-btn { display: none !important; }
.mobile-device .download-panel-close-btn::after { display: none !important; }
.mobile-device .download-panel-close-btn svg { display: none !important; }

.mobile-device .video-player-close svg, .mobile-device .video-player-mute-btn svg { display: none !important; }
.mobile-device .video-player-close { width: 36px !important; height: 36px !important; border-radius: 50% !important; display: flex !important; align-items: center !important; justify-content: center !important; background: rgba(255, 255, 255, 0.1) !important; border: 1px solid rgba(255, 255, 255, 0.2) !important; transition: all 0.2s ease !important; }
.mobile-device .video-player-close::after { content: "\2715" !important; font-size: 18px !important; line-height: 1 !important; font-weight: 400 !important; color: rgba(255, 255, 255, 0.9) !important; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important; }
.mobile-device .video-player-close:active { background: rgba(239, 68, 68, 0.3) !important; border-color: rgba(239, 68, 68, 0.4) !important; transform: scale(0.95) !important; }
.mobile-device .video-player-mute-btn { width: 36px !important; height: 36px !important; border-radius: 50% !important; display: flex !important; align-items: center !important; justify-content: center !important; background: rgba(255, 255, 255, 0.1) !important; border: 1px solid rgba(255, 255, 255, 0.2) !important; transition: all 0.2s ease !important; }
.mobile-device .video-player-mute-btn::after { content: "\1F50A" !important; font-size: 15px !important; line-height: 1 !important; color: rgba(255, 255, 255, 0.9) !important; }
.mobile-device .video-player-mute-btn.muted::after { content: "\1F507" !important; }
.mobile-device .video-player-mute-btn:active { background: rgba(255, 255, 255, 0.2) !important; transform: scale(0.95) !important; }

/* Hide share button on mobile */
.mobile-device .share-button { display: none !important; }

/* Download button: slim, subtle border */
.mobile-device .video-action-button { padding: 3px 12px !important; font-size: 13px !important; margin: 0 !important; background: transparent !important; border: 1px solid rgba(255, 255, 255, 0.15) !important; color: #ffffff !important; border-radius: 10px !important; gap: 5px !important; white-space: nowrap !important; flex-shrink: 0 !important; overflow: visible !important; }
.mobile-device .video-action-button::before { display: none !important; }
.mobile-device .video-action-button:active { background: rgba(120, 255, 60, 0.1) !important; border-color: rgba(255, 255, 255, 0.3) !important; }
.mobile-device .video-action-button svg { width: 14px !important; height: 14px !important; stroke: #a0ff50 !important; flex-shrink: 0 !important; }

/* Divider hidden, controls centered */
.mobile-device .download-divider { display: none !important; }
.mobile-device .controls-option { gap: 6px !important; flex-shrink: 0 !important; white-space: nowrap !important; margin: 0 auto !important; border-top: none !important; padding-top: 0 !important; width: auto !important; }
.mobile-device .controls-option-title { font-size: 12px !important; color: rgba(255, 255, 255, 0.4) !important; white-space: nowrap !important; }
.mobile-device .controls-option-subtitle { display: none !important; }
.mobile-device .compact-toggle { width: 30px !important; height: 16px !important; border-radius: 8px !important; flex-shrink: 0 !important; }
.mobile-device .compact-toggle-handle { width: 12px !important; height: 12px !important; top: 2px !important; left: 2px !important; }
.mobile-device .compact-toggle.active .compact-toggle-handle { transform: translateX(14px) !important; }

.mobile-device .prompt-selector-btn { display: flex !important; align-items: center !important; justify-content: center !important; width: 44px !important; height: 44px !important; min-width: 44px !important; color: rgba(255, 255, 255, 0.7) !important; position: relative !important; font-size: 0 !important; overflow: hidden !important; border-radius: 50% !important; background: rgba(255, 255, 255, 0.1) !important; border: 1px solid rgba(255, 255, 255, 0.2) !important; }
.mobile-device .prompt-selector-btn::after { content: "\2630" !important; position: absolute !important; font-size: 20px !important; line-height: 1 !important; color: rgba(255, 255, 255, 0.7) !important; }
.mobile-device .prompt-selector-btn:hover, .mobile-device .prompt-selector-btn:active { background: rgba(255, 255, 255, 0.15) !important; border-color: rgba(255, 255, 255, 0.3) !important; }
.mobile-device .prompt-selector-btn svg { display: none !important; }

/* ==========================================
   Mobile Performance Optimizations
   ========================================== */
.mobile-device * { -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.mobile-device .game-wrapper { will-change: transform; }
.mobile-device * { transition-duration: 0.3s !important; }
.mobile-device .bar-status-dot { animation-duration: 2s !important; }
.mobile-device .loading-placeholder .loading-text { animation-duration: 1.5s !important; }
.mobile-device .spinner { animation-duration: 1s !important; }
.mobile-device .tips-icon.pulse { animation-duration: 2s !important; }

/* ==========================================
   Loading States for Mobile
   ========================================== */

/* Loading placeholder: no transitions until fade-out starts */
.mobile-device .loading-placeholder .loading-logo,
.mobile-device .loading-placeholder .loading-text {
    transition: none !important;
}
.mobile-device .loading-placeholder.fade-out .loading-logo {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease !important;
}
.mobile-device .loading-placeholder.fade-out .loading-text {
    transition: opacity 0.3s ease !important;
}

/* Landscape loading: no bottom padding (portrait uses 8vh to shift text up) */
.mobile-device.mobile-landscape .loading-placeholder {
    padding-bottom: 0 !important;
}

.mobile-device .loading-overlay { background: rgba(0, 0, 0, 0.95); }
.mobile-device .spinner { width: 50px !important; height: 50px !important; border-radius: 50% !important; display: block !important; box-sizing: border-box !important; flex-shrink: 0 !important; flex-grow: 0 !important; margin-bottom: 10px !important; }
.ios.mobile-device .spinner, .ios-safari.mobile-device .spinner { -webkit-transform-style: flat !important; transform-style: flat !important; }
.android.mobile-device .spinner { transform-style: flat !important; -webkit-transform-style: flat !important; }
.mobile-device .loading-spinner { width: 60px; height: 60px; border-width: 4px; border-radius: 50%; display: inline-block; box-sizing: border-box; }

@-webkit-keyframes spin { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(360deg); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.mobile-device .loading-message { font-size: 14px !important; margin-top: 0 !important; margin-bottom: 12px !important; }

/* ==========================================
   Mobile Upload Crop Container
   ========================================== */
.mobile-device #upload-crop-container { max-height: 300px; }
.mobile-device .upload-modal-content { max-width: none; width: 95%; }

/* ==========================================
   iOS Specific Fixes
   ========================================== */
.ios.mobile-device { position: fixed; width: 100%; height: 100%; overflow: hidden; }
.ios.mobile-device .modal-content { -webkit-overflow-scrolling: touch; overflow-y: scroll; }
.ios.mobile-device { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.ios-safari.mobile-device { padding-bottom: calc(env(safe-area-inset-bottom, 0) + 44px); }

/* ==========================================
   Android Specific Fixes
   ========================================== */
.android.mobile-device { min-height: 100vh; }
.android.mobile-device input:focus, .android.mobile-device textarea:focus { position: fixed; bottom: 0; }

/* ==========================================
   Mobile Responsive Breakpoints
   ========================================== */
@media screen and (max-width: 320px) {
    .mobile-device.mobile-portrait #image-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 6px !important; }
    .mobile-device .mobile-upload-btn { font-size: 11px; padding: 10px 12px; }
}

@media screen and (max-width: 375px) {
    .mobile-device .modal-content { padding: 15px; }
    .mobile-device .virtual-joystick { transform: scale(0.85); }
    .mobile-device .action-buttons-mobile { transform: scale(0.85); }
}


/* Tablet portrait (iPad ~810px wide): better use of wider screen */
@media screen and (min-width: 600px) and (orientation: portrait) {
    .mobile-device.mobile-portrait #video-container {
        max-height: 45vh;
    }
    .mobile-device.mobile-portrait #mobile-image-section {
        max-width: 80vw;
        margin: 0 auto;
        padding: 8px 16px;
    }
    .mobile-device.mobile-portrait #image-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }
    .mobile-device.mobile-portrait .mobile-upload-btn {
        max-width: 80vw;
        margin: 0 auto;
        padding: 12px 16px;
    }
}

/* Large tablet portrait (iPad Pro 12.9" ~1024px wide) */
@media screen and (min-width: 900px) and (orientation: portrait) {
    .mobile-device.mobile-portrait #image-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media screen and (min-width: 769px) and (max-width: 1024px) {
    .mobile-device.tablet #video-container { max-width: 80vw; height: calc(80vw * 2 / 3) !important; margin: 0 auto !important; }
    .mobile-device.tablet .virtual-joystick { width: 140px; height: 140px; }
    .mobile-device.tablet .action-button-mobile { width: 70px; height: 70px; font-size: 28px; }
}
