/* ========================================================================
   Thru My Eyes Virtual Gallery - Styles
   ======================================================================== */


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: #000;
}

#canvas-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

#info {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 14px;
    max-width: 300px;
    z-index: 100;
    backdrop-filter: blur(10px);
}

#info h2 {
    margin-bottom: 10px;
    font-size: 18px;
    color: #7bab98;  /* Natural sage green */
}

#info p {
    margin: 5px 0;
    line-height: 1.6;
}

#gallery-logo {
    width: 120px;
    height: auto;
    margin-bottom: 20px;
    margin-left: 50px;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

#cart-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #7bab98;  /* Natural sage green */
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(123, 171, 152, 0.3);
}

#cart-button:hover {
    background: #618c7e;  /* Darker sage on hover */
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(123, 171, 152, 0.4);
}

#cart-count {
    background: #e94560;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

#hide-ui-btn {
    position: fixed;
    bottom: 90px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 1001;
    font-size: 13px;
    font-weight: bold;
    display: none;  /* Hidden on desktop */
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
}

#hide-ui-btn:active {
    transform: scale(0.95);
}

#night-mode-toggle {
    position: absolute;
    top: 80px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

#night-mode-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

#brightness-control {
    position: absolute;
    top: 145px;
    right: 20px;
    background: rgba(0, 0, 0, 0.85);
    padding: 15px 20px;
    border-radius: 8px;
    z-index: 100;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#brightness-control label {
    color: white;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

#brightness-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #333, #7bab98);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

#brightness-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #7bab98;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}

#brightness-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(123, 171, 152, 0.5);
}

#brightness-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #7bab98;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}

#brightness-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(123, 171, 152, 0.5);
}

#brightness-value {
    color: #7bab98;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
}

/* Glow Control - positioned below brightness */
#glow-control {
    position: absolute;
    top: 250px;  /* Below brightness control */
    right: 20px;
    background: rgba(0, 0, 0, 0.85);
    padding: 15px 20px;
    border-radius: 8px;
    z-index: 100;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#glow-control label {
    color: white;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.glow-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.glow-toggle button {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #7bab98;
    background: rgba(123, 171, 152, 0.1);
    color: #7bab98;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.2s;
}

.glow-toggle button:hover {
    background: rgba(123, 171, 152, 0.2);
    transform: translateY(-1px);
}

.glow-toggle button.active {
    background: #7bab98;
    color: white;
    box-shadow: 0 2px 8px rgba(123, 171, 152, 0.4);
}

#glow-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #333, #7bab98);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

#glow-slider:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#glow-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #7bab98;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}

#glow-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(123, 171, 152, 0.5);
}

#glow-slider:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

#glow-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #7bab98;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}

#glow-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(123, 171, 152, 0.5);
}

#glow-slider:disabled::-moz-range-thumb {
    cursor: not-allowed;
}

#glow-value {
    color: #7bab98;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
}

/* Gallery Switcher - positioned below info box */
#gallery-switcher {
    position: absolute;
    top: 350px;  /* Below info box */
    left: 20px;
    background: rgba(0, 0, 0, 0.85);
    padding: 12px 16px;
    border-radius: 8px;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#gallery-switcher select {
    background: rgba(123, 171, 152, 0.2);
    color: white;
    border: 2px solid #7bab98;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    outline: none;
    min-width: 180px;
}

#gallery-switcher select:hover {
    background: rgba(123, 171, 152, 0.3);
    border-color: #8bc5a8;
}

#gallery-switcher select option {
    background: #1a1a1a;
    color: white;
    padding: 8px;
}

#gallery-switcher label {
    color: #7bab98;
    font-size: 12px;
    font-weight: bold;
    display: block;
    margin-bottom: 6px;
}

#controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    text-align: center;
    backdrop-filter: blur(10px);
    z-index: 100;
}

.control-row {
    margin: 5px 0;
}

.key {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 4px;
    margin: 0 3px;
    font-family: monospace;
    font-size: 12px;
}

#photo-info {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    padding: 20px 30px;
    border-radius: 12px;
    color: white;
    font-size: 14px;
    text-align: center;
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 100;
    max-width: 500px;
}

#photo-info.visible {
    opacity: 1;
    pointer-events: auto;
}

#photo-info h3 {
    margin-bottom: 10px;
    color: #7bab98;  /* Natural sage green */
    font-size: 20px;
}

#photo-info p {
    margin: 5px 0;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.price-display {
    font-size: 16px;
    color: #7bab98;  /* Natural sage green */
    margin: 10px 0;
    font-weight: bold;
}

.action-buttons {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.action-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
}

.btn-preview {
    background: #9b59b6;
    color: white;
}

.btn-preview:hover {
    background: #8e44ad;
}

.btn-add-cart {
    background: #7bab98;  /* Natural sage green */
    color: white;
}

.btn-add-cart:hover {
    background: #618c7e;  /* Darker sage on hover */
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 18px;
    text-align: center;
    z-index: 200;
}

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #4fc3f7;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading Progress Bar */
#loading-progress-container {
    width: 300px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin: 20px auto 10px;
    overflow: hidden;
}

#loading-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4fc3f7, #7bab98);
    border-radius: 10px;
    transition: width 0.3s ease;
}

#loading-percentage {
    color: #4fc3f7;
    font-size: 24px;
    font-weight: bold;
    margin-top: 10px;
}

#loading-status {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    margin-top: 5px;
}

.hidden {
    display: none;
}

/* Cart Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.visible {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

/* Offset cart modal to avoid covering controls */
#cart-modal .modal-content {
    transform: translateY(-80px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.modal-header h2 {
    color: #333;
    font-size: 24px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.cart-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #eee;
    align-items: center;
}

.cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
}

.cart-item-details {
    flex: 1;
}

.cart-item-details h4 {
    margin: 0 0 5px 0;
    color: #333;
}

.cart-item-details p {
    margin: 3px 0;
    color: #666;
    font-size: 14px;
}

.cart-item-price {
    font-weight: bold;
    color: #7bab98;  /* Natural sage green */
    font-size: 18px;
}

.remove-btn {
    background: #e94560;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

.remove-btn:hover {
    background: #d63447;
}

.cart-total {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #eee;
    text-align: right;
}

.cart-total h3 {
    color: #333;
    font-size: 24px;
}

.checkout-btn {
    width: 100%;
    background: #7bab98;  /* Natural sage green */
    color: white;
    border: none;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    margin-top: 15px;
}

.checkout-btn:hover {
    background: #618c7e;  /* Darker sage on hover */
}

.checkout-btn:hover {
    background: #3da5c7;
}

.empty-cart {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* Preview Modal */
#preview-modal .modal-content {
    max-width: 90%;
    max-height: 90%;
    padding: 20px;
}

#preview-container {
    position: relative;
    max-width: 100%;
    max-height: 60vh;
    width: 800px;
    height: 600px;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f8f8;
}

.preview-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;  /* Changed from cover to contain - shows full image without cropping */
}

#preview-photo-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

#preview-photo {
    position: relative;
    max-width: 300px;
    max-height: 400px;
    object-fit: contain;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    border: 12px solid #1a1a1a;
    background: white;
}

#preview-label {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.95);
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 10;
    color: #333;
}

#preview-disclaimer {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 15px;
    border-radius: 15px;
    font-size: 11px;
    font-style: italic;
    opacity: 0.8;
    z-index: 9;
    max-width: 95%;
    text-align: center;
    line-height: 1.4;
}

/* Preview Orientation Lock (Item #42) */
/* Maintain consistent aspect ratio regardless of device orientation */
#preview-modal.preview-vertical #preview-photo-wrapper {
    /* Lock aspect ratio for vertical/portrait photos */
    aspect-ratio: 2/3;
}

#preview-modal.preview-horizontal #preview-photo-wrapper {
    /* Lock aspect ratio for horizontal/landscape photos */
    aspect-ratio: 3/2;
}

#preview-modal.preview-vertical #preview-photo {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

#preview-modal.preview-horizontal #preview-photo {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

#preview-controls {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

#preview-controls h3 {
    width: 100%;
    text-align: center;
    color: #333;
    margin-bottom: 10px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: bold;
}

.control-group select {
    padding: 10px 15px;
    border-radius: 6px;
    border: 2px solid #ddd;
    background: white;
    cursor: pointer;
    font-size: 14px;
}

.control-group select:hover {
    border-color: #7bab98;  /* Natural sage green */
}

.upload-button {
    display: inline-block;
    padding: 10px 15px;
    background: #7bab98;  /* Sage green to match theme */
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
    margin-top: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(123, 171, 152, 0.3);
    text-transform: none;
}

.upload-button:hover {
    background: #6a9a87;  /* Slightly darker sage on hover */
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(123, 171, 152, 0.4);
}

#remove-custom-env {
    margin-top: 8px;
    padding: 8px 12px;
    background: #e94560;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.3s ease;
}

#remove-custom-env:hover {
    background: #c93850;
    transform: translateY(-2px);
}

.preview-add-cart-btn {
    margin-top: 20px;
    width: 100%;
    padding: 15px;
    background: #7bab98;  /* Natural sage green */
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preview-add-cart-btn:hover {
    background: #618c7e;  /* Darker sage on hover */
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(123, 171, 152, 0.3);
}

/* Checkout Modal */
.checkout-form {
    display: grid;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    color: #333;
    font-weight: bold;
    font-size: 14px;
}

.form-group input {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #7bab98;  /* Natural sage green */
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.order-summary {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.order-summary h3 {
    color: #333;
    margin-bottom: 15px;
}

.order-item {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    color: #666;
}

.order-total {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #ddd;
    font-weight: bold;
    font-size: 18px;
    color: #333;
}

/* ===== MOBILE TOUCH CONTROLS ===== */
#mobile-controls {
    display: none; /* Hidden on desktop, shown on mobile via media query */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    z-index: 50;
    pointer-events: none;
}

#mobile-joystick {
    position: absolute;
    bottom: 40px;
    left: 40px;
    width: 130px;
    height: 130px;
    pointer-events: all;
    z-index: 100;
}

#joystick-base {
    width: 130px;
    height: 130px;
    border-radius: 65px;
    background: rgba(123, 171, 152, 0.25);
    border: 3px solid rgba(123, 171, 152, 0.5);
    position: absolute;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#joystick-stick {
    width: 55px;
    height: 55px;
    border-radius: 28px;
    background: linear-gradient(145deg, rgba(123, 171, 152, 0.9), rgba(123, 171, 152, 0.7));
    border: 3px solid rgba(123, 171, 152, 1);
    position: absolute;
    top: 37.5px;
    left: 37.5px;
    transition: none;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.4);
    touch-action: none;
}

#mobile-instructions {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 13px;
    text-align: center;
    pointer-events: none;
    max-width: 90%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    line-height: 1.4;
}

/* Mobile-specific adjustments */
@media (max-width: 768px), (hover: none) {
    /* HIDE desktop keyboard controls completely on mobile */
    #controls {
        display: none !important;
    }

    /* Show mobile controls */
    #mobile-controls {
        display: block;
    }

    /* Show Hide UI button on mobile */
    #hide-ui-btn {
        display: block !important;
    }

    /* Position photo-info at bottom on mobile (above joystick) */
    #photo-info {
        position: fixed;
        top: auto;
        bottom: 140px;
        left: 50%;
        transform: translateX(-50%);
        max-width: 90%;
    }

    /* Compact ALL right-side UI for mobile screens */
    #cart-button {
        top: 8px;
        right: 8px;
        padding: 8px 14px;
        font-size: 13px;
    }

    /* Ensure cart count badge is visible on mobile */
    #cart-count {
        width: 20px;
        height: 20px;
        font-size: 11px;
        font-weight: bold;
        margin-left: 4px;
    }

    #night-mode-toggle {
        top: 52px;
        right: 8px;
        padding: 8px 14px;
        font-size: 13px;
    }

    #brightness-control {
        top: 96px;
        right: 8px;
        padding: 10px 12px;
        min-width: 140px;
    }

    #brightness-control label {
        font-size: 11px;
    }

    #brightness-slider {
        height: 4px;
    }

    #brightness-value {
        font-size: 11px;
    }

    /* GLOW CONTROL - Compact for mobile */
    #glow-control {
        top: 180px !important;
        right: 8px !important;
        padding: 10px 12px !important;
        min-width: 140px !important;
        gap: 6px !important;
    }

    #glow-control label {
        font-size: 11px !important;
    }

    .glow-toggle {
        gap: 4px !important;
    }

    .glow-toggle button {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }

    #glow-slider {
        height: 4px !important;
    }

    #glow-value {
        font-size: 11px !important;
    }

    /* Info box - compact */
    #info {
        top: 8px;
        left: 8px;
        padding: 10px 14px;
        max-width: 180px;
        font-size: 11px;
    }

    #info h2 {
        font-size: 15px;
        margin-bottom: 6px;
    }

    #info p {
        font-size: 11px;
        line-height: 1.4;
        margin: 3px 0;
    }

    #gallery-logo {
        width: 90px;
        margin-bottom: 6px;
    }

    /* Gallery switcher - below all controls */
    #gallery-switcher {
        top: 270px !important;
        left: 8px;
        padding: 8px 12px;
    }

    #gallery-switcher select {
        font-size: 12px;
        padding: 6px 10px;
        min-width: 140px;
    }

    /* ENSURE JOYSTICK IS VISIBLE */
    #mobile-joystick {
        bottom: 20px !important;
        left: 20px !important;
        z-index: 1000 !important;
        display: block !important;
    }

    #joystick-base {
        width: 100px !important;
        height: 100px !important;
    }

    #joystick-stick {
        width: 40px !important;
        height: 40px !important;
    }

    /* Mobile instructions - auto-hide after 8 seconds */
    #mobile-instructions {
        animation: fadeInOut 8s ease-in-out forwards;
        font-size: 11px;
        padding: 8px 12px;
    }

    @keyframes fadeInOut {
        0% { opacity: 1; }
        70% { opacity: 1; }
        100% { opacity: 0; pointer-events: none; }
    }

    /* Photo info adjustments */
    .price-display {
        font-size: 18px;
    }

    /* Mobile modal fixes - CRITICAL */
    .modal {
        z-index: 10000 !important;
        -webkit-overflow-scrolling: touch;
    }

    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
        padding: 20px;
        width: 95%;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .close-btn {
        font-size: 32px;
        width: 44px;
        height: 44px;
    }

    /* Ensure cart button is touchable */
    #cart-button {
        z-index: 101;
        pointer-events: all;
        -webkit-tap-highlight-color: transparent;
    }

    /* Preview modal mobile optimizations */
    /* FIX: Added !important to ensure width rules override any conflicting rules */
    #preview-modal .modal-content {
        width: 98% !important;
        max-width: 98% !important;
        max-height: 95vh;
        padding: 15px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    #preview-container {
        width: 100%;
        height: 50vh;
        max-height: 400px;
    }

    #preview-controls {
        padding: 15px 10px;
    }

    #preview-controls h3 {
        font-size: 16px;
    }

    #preview-controls select,
    #preview-controls button {
        font-size: 14px;
        padding: 10px;
        min-height: 44px; /* iOS touch target minimum */
    }

    .room-selector button {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    #mobile-joystick {
        width: 110px;
        height: 110px;
        bottom: 20px;
        left: 20px;
    }

    #joystick-base {
        width: 110px;
        height: 110px;
    }

    #joystick-stick {
        width: 46px;
        height: 46px;
        top: 32px;
        left: 32px;
    }

    #mobile-instructions {
        font-size: 11px;
        padding: 8px 14px;
        top: 10px;
        max-width: 85%;
    }

    /* Make right-side buttons smaller on small screens */
    #cart-button,
    #night-mode-toggle {
        padding: 8px 12px;
        font-size: 13px;
    }

    #brightness-control {
        min-width: 140px;
        padding: 10px 12px;
    }

    #brightness-control label {
        font-size: 11px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #mobile-instructions {
        top: 5px;
        font-size: 9px;
        padding: 5px 10px;
        max-width: 50%;
    }

    #mobile-joystick {
        bottom: 8px;
        left: 8px;
        width: 80px;
        height: 80px;
        z-index: 100;
    }

    #joystick-base {
        width: 80px;
        height: 80px;
    }

    #joystick-stick {
        width: 34px;
        height: 34px;
        top: 23px;
        left: 23px;
    }

    /* Stack right-side buttons horizontally in landscape */
    #cart-button {
        top: 5px;
        right: 180px;
        padding: 8px 16px;
        font-size: 13px;
    }

    #night-mode-toggle {
        top: 5px;
        right: 90px;
        padding: 8px 16px;
        font-size: 13px;
    }

    #brightness-control {
        display: none; /* Hide brightness in landscape to save space */
    }

    #glow-control {
        display: none; /* Hide glow control in landscape */
    }

    /* PREVIEW MODAL LANDSCAPE FIXES */
    /* FIX: Added explicit width to override base rule for orientation changes */
    #preview-modal .modal-content {
        width: 95vw;
        max-width: 95vw;
        max-height: 95vh;
        padding: 15px;
    }

    #preview-container {
        width: 100%;
        height: 50vh;
        max-width: none;
        max-height: 50vh;
    }

    #preview-photo {
        max-width: 500px;  /* Larger in landscape */
        max-height: 300px;
    }

    #preview-label {
        bottom: 10px;
        font-size: 14px;
        padding: 6px 15px;
        /* Ensure it doesn't overlap image */
        background: rgba(0, 0, 0, 0.8);
        color: white;
    }

    #preview-controls {
        margin-top: 10px;
    }

    .control-group {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }
}

/* LANDSCAPE ORIENTATION - ALL MOBILE DEVICES */
@media (max-width: 768px) and (orientation: landscape) {
    /* Preview modal optimizations for landscape */
    /* FIX: Added explicit width to override base rule for orientation changes */
    #preview-modal .modal-content {
        width: 95vw;
        max-width: 95vw;
        max-height: 92vh;
        padding: 15px;
        overflow-y: auto;
    }

    #preview-container {
        width: 100%;
        height: auto;
        min-height: 40vh;
        max-height: 45vh;
    }

    #preview-photo {
        max-width: 600px;  /* Much larger in landscape */
        max-height: 35vh;
    }

    #preview-label {
        position: static;  /* Remove absolute positioning */
        transform: none;
        margin-top: 10px;
        display: inline-block;
        background: rgba(0, 0, 0, 0.85);
        color: white;
        font-size: 16px;
    }

    #preview-controls {
        margin-top: 15px;
        gap: 10px;
    }

    .control-group {
        flex: 1;
        min-width: 150px;
    }

    /* Make preview container parent flex */
    #preview-modal .modal-content > div:first-of-type {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;  /* FIX: Added to prevent left-alignment on rotation */
    }
}

/* PORTRAIT ORIENTATION - Explicit override to fix Android rotation bug */
@media (max-width: 768px) and (orientation: portrait) {
    /* CRITICAL FIX: Force flexbox display on modal to prevent collapse */
    #preview-modal {
        display: flex !important;
    }

    #preview-modal .modal-content {
        width: 98% !important;
        max-width: 98% !important;
        max-height: 95vh !important;
        height: auto !important;
        overflow-y: auto !important;
    }

    /* CRITICAL FIX: Force flexbox on .visible state to override 767px media query */
    #preview-modal.visible {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* FIX: Reset inner div from flex (set in landscape) back to block for portrait */
    #preview-modal .modal-content > div:first-of-type {
        display: block !important;
        flex-direction: unset !important;
        align-items: unset !important;
        justify-content: unset !important;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    #mobile-instructions {
        font-size: 9px;
        padding: 6px 10px;
    }

    #cart-button span:first-child {
        display: none; /* Hide cart icon on tiny screens */
    }
}

    #joystick-base {
        width: 90px;
        height: 90px;
    }

    #joystick-stick {
        width: 38px;
        height: 38px;
        top: 26px;
        left: 26px;
    }

/* ================================================== */
/* AR OVERLAY STYLES - MATCHING GALLERY THEME */
/* ================================================== */

#ar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    z-index: 9999;
    display: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#ar-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

#ar-title {
    color: #7bab98;
    font-size: 20px;
    font-weight: bold;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#ar-exit-btn {
    background: #7bab98;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(123, 171, 152, 0.3);
}

#ar-exit-btn:active {
    transform: scale(0.95);
    background: #699987;
}

#ar-ui {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    padding-bottom: max(15px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.8) 70%, transparent 100%);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10001;
    max-height: 65vh;
    overflow-y: auto;
}

#ar-instructions {
    text-align: center;
    color: white;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    padding: 12px 20px;
    background: rgba(123, 171, 152, 0.2);
    border: 2px solid rgba(123, 171, 152, 0.4);
    border-radius: 12px;
    backdrop-filter: blur(5px);
}

#ar-place-btn {
    background: #7bab98;
    color: white;
    border: none;
    padding: 16px 30px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(123, 171, 152, 0.4);
    transition: all 0.3s ease;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#ar-place-btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(123, 171, 152, 0.3);
    background: #699987;
}

#ar-controls {
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

#ar-controls button {
    background: rgba(255,255,255,0.95);
    color: #333;
    border: 2px solid rgba(123, 171, 152, 0.3);
    padding: 12px 8px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    backdrop-filter: blur(5px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive AR controls for landscape */
@media (orientation: landscape) and (max-height: 500px) {
    #ar-controls {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    #ar-controls button {
        padding: 10px 6px;
        font-size: 12px;
    }
}

#ar-controls button:active {
    transform: scale(0.96);
    background: rgba(255,255,255,0.85);
    border-color: rgba(123, 171, 152, 0.5);
}

#ar-info {
    text-align: center;
    color: white;
    font-size: 14px;
    background: rgba(0,0,0,0.7);
    padding: 10px 15px;
    border-radius: 8px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(123, 171, 152, 0.3);
}

#ar-size-display {
    font-weight: 600;
    margin-bottom: 4px;
    color: #7bab98;
}

#ar-scale-display {
    opacity: 0.9;
    font-size: 13px;
}

.btn-ar {
    background: linear-gradient(135deg, #7b68ee 0%, #9370db 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(123, 104, 238, 0.3);
}

.btn-ar:hover {
    background: linear-gradient(135deg, #6a5acd 0%, #8a2be2 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(123, 104, 238, 0.4);
}

.btn-ar:active {
    transform: translateY(0);
}

/* AR not supported message */
.ar-not-supported {
    background: rgba(255, 200, 0, 0.9);
    color: #333;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    border-radius: 6px;
    margin: 10px 0;
}

/* ========================================================================
   NEW E-COMMERCE ENHANCEMENTS - Features #5, #6, #7
   ======================================================================== */


/* ========================================================================
   RESPONSIVE ADJUSTMENTS FOR NEW FEATURES
   ======================================================================== */

@media (max-width: 768px) {
    #size-comparison-canvas {
        height: 400px;
    }

    #material-swatches {
        flex-direction: column;
    }
}

/* ========================================================================
   FLOATING ACTION BUTTON (FAB) - Mobile Cart
   ======================================================================== */

.cart-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #7bab98 0%, #618c7e 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(123, 171, 152, 0.4);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.cart-fab:active {
    transform: scale(0.9);
}

.cart-fab .fab-icon {
    font-size: 28px;
    line-height: 1;
}

.cart-fab .fab-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e94560;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.4);
}

/* FAB Animation on scroll */
@keyframes fabBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.cart-fab.bounce {
    animation: fabBounce 0.5s ease;
}

/* ========================================================================
   MOBILE MODAL IMPROVEMENTS
   ======================================================================== */

@media (max-width: 767px) {
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        -webkit-overflow-scrolling: touch;
    }

    .modal.visible {
        align-items: flex-end;
    }

    /* OVERRIDE: Keep preview modal centered (not bottom-aligned) to fix orientation bug */
    #preview-modal.visible {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Make modals slide up from bottom */
    .modal.visible .modal-content {
        animation: slideUpModal 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    }

    /* OVERRIDE: No slide animation for preview modal */
    #preview-modal.visible .modal-content {
        animation: none;
    }

    @keyframes slideUpModal {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

/* ========================================================================
   MOBILE TOUCH IMPROVEMENTS
   ======================================================================== */

/* Larger touch targets */
@media (max-width: 767px) {
    button,
    .btn,
    .btn-preview,
    .btn-ar {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }

    /* Prevent text selection on buttons */
    button,
    .btn,
    [onclick] {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    /* Smooth scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================================================
   MOBILE SPECIFIC ANIMATIONS
   ======================================================================== */

/* Button press animation */
@media (max-width: 767px) {
    button:active,
    .btn:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}

/* Fade in animation for mobile elements */
@keyframes mobileFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mobile-optimized .action-buttons {
    animation: mobileF fadeIn 0.3s ease-out;
}

/* ========================================================================
   SAFE AREA INSETS (iPhone X+, Android with notch)
   ======================================================================== */

@supports (padding: max(0px)) {
    @media (max-width: 767px) {
        .cart-fab {
            bottom: max(20px, env(safe-area-inset-bottom));
            right: max(20px, env(safe-area-inset-right));
        }

        #photo-info.mobile-bottom-sheet {
            padding-bottom: max(20px, env(safe-area-inset-bottom));
        }

        .modal-content {
            padding-bottom: max(20px, env(safe-area-inset-bottom));
        }

        #mobile-joystick {
            bottom: max(20px, env(safe-area-inset-bottom));
            left: max(20px, env(safe-area-inset-left));
        }
    }
}

/* ========================================================================
   DARK MODE OPTIMIZATIONS (Mobile)
   ======================================================================== */

@media (max-width: 767px) and (prefers-color-scheme: dark) {
    .cart-fab {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    }

    .bottom-sheet-handle .handle-bar {
        background: rgba(255, 255, 255, 0.5);
    }
}

/* ========================================================================
   LANDSCAPE MODE ADJUSTMENTS (Mobile)
   ======================================================================== */

@media (max-width: 896px) and (orientation: landscape) {
    #photo-info.mobile-bottom-sheet {
        max-height: 75vh;
    }

    .cart-fab {
        width: 50px;
        height: 50px;
    }

    .cart-fab .fab-icon {
        font-size: 24px;
    }
}

/* ========================================================================
   ACCESSIBILITY - REDUCE MOTION
   ======================================================================== */

@media (prefers-reduced-motion: reduce) {
    .cart-fab {
        animation: none !important;
        transition: none !important;
    }

    #photo-info.mobile-bottom-sheet {
        transition: none !important;
    }
}

/* ========================================================================
   HIGH CONTRAST MODE
   ======================================================================== */

@media (prefers-contrast: high) {
    .cart-fab {
        border: 2px solid white;
    }

    .bottom-sheet-handle .handle-bar {
        background: white;
    }
}

