/* Base Styles */
:root {
    /* Color Variables */
    --bg-color: #f9f9f9;
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --text-color: #333;
    --border-color: #ddd;
    --tile-color: #fff;
    --tile-shadow: rgba(0, 0, 0, 0.1);
    --letterbox-color: #222; /* Dark background for letterboxing and smooth transitions */
    
    /* Spacing */
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    
    /* Typography */
    --font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.5rem;
    --font-size-xxl: 2rem;
    --header-height: 70px; /* Consistent header height */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    /* Prevent text selection on long press and drag */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Prevent long-press context menus and callouts */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Allow text selection only for specific elements that need it */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
textarea,
[contenteditable="true"],
.selectable-text,
.modal-content p,
.modal-content li,
.error-message,
.notification-text {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--letterbox-color); /* DRY: Use consistent letterbox color */
    min-height: 100vh;
    min-height: var(--actual-vh, 100vh); /* Use actual viewport height */
    padding-top: 70px; /* Only account for the fixed header */
    margin: 0;
    transition: padding-top 0.3s ease; /* Smooth padding transition */
    /* Improve touch interactions on mobile */
    touch-action: manipulation;
    /* Prevent pull-to-refresh and overscroll behavior */
    overscroll-behavior: none;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: var(--spacing-sm);
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000; /* Increased z-index to ensure it stays on top */
    height: 70px; /* Fixed height for consistency */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: height 0.3s ease; /* Smooth height transitions */
}

/* Header Title Section */
.header-title {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    pointer-events: auto;
    position: relative;
}

.museum-name-container {
    display: flex;
    align-items: baseline;
    justify-content: center;
    font-size: var(--font-size-xxl);
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.museum-name-display {
    display: flex;
    align-items: baseline;
    gap: 0;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    overflow: visible;
}

.museum-name-text {
    color: white;
    font-size: var(--font-size-xxl);
    font-weight: 700;
    letter-spacing: -0.02em;
    min-width: 0;
    white-space: pre;
    outline: none;
    border: none;
    background: transparent;
    caret-color: white;
    border-radius: 8px;
    padding: 4px 12px;
    margin: -4px -12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    /* Allow text selection for editing */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.museum-name-text:empty::before {
    content: attr(data-placeholder);
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    font-style: italic;
}

/* Subtle attention indicator when empty and NOT focused */
.museum-name-text:empty:not(:focus) {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    box-shadow: 
        0 0 0 2px rgba(255, 255, 255, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: gentle-pulse 4s ease-in-out infinite;
}

.museum-name-text:empty:not(:focus)::before {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    font-weight: 600;
    font-style: italic;
}

@keyframes gentle-pulse {
    0%, 100% { 
        box-shadow: 
            0 0 0 2px rgba(255, 255, 255, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
        transform: scale(1);
    }
    50% { 
        box-shadow: 
            0 0 0 2px rgba(255, 255, 255, 0.6),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
        transform: scale(1);
    }
}

.museum-name-text:focus:empty::before {
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    font-weight: 600;
    font-style: italic;
}

.museum-name-text:focus:empty {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    animation: none;
    box-shadow: 
        0 0 0 2px rgba(255, 255, 255, 0.4),
        0 4px 16px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.museum-name-text:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.museum-name-text:focus {
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 
        0 0 0 2px rgba(255, 255, 255, 0.4),
        0 4px 16px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: none;
}

.museum-name-text:focus:empty::before {
    animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { 
        opacity: 0.5; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.8; 
        transform: scale(1.02);
    }
}

.museum-title-suffix {
    color: white;
    font-size: var(--font-size-xxl);
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

h1 {
    font-size: var(--font-size-xxl);
}

h2 {
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-md);
}

h3 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-sm);
}

/* Button Styles */
.btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--font-size-md);
    transition: background-color 0.2s;
    /* Optimize for touch interactions */
    touch-action: manipulation;
    /* Ensure buttons are properly sized for touch */
    min-height: 44px; /* iOS recommendation for touch targets */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    background-color: #2980b9;
}

.btn-accent {
    background-color: var(--accent-color);
}

.btn-accent:hover {
    background-color: #c0392b;
}

/* Container */
main#app-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Loading State */
#loading {
    text-align: center;
    padding: var(--spacing-lg);
    font-size: var(--font-size-lg);
    color: var(--primary-color);
}

/* Views */
.view {
    animation: fadeIn 0.3s ease-in-out;
    margin: 0;
    padding: 0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

section {
    margin: 0;
    padding: 0;
}

main {
    margin: 0;
    padding: 0;
}

#home-view {
    margin: 0;
    padding: 0;
}

/* Header Controls (Moved from inline styles in index.html) */
.header-controls {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1001; /* Ensure it's above other header content if any overlap */
    transition: transform 0.3s ease; /* Smooth scaling transitions */
}

.header-right {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1001;
    transition: transform 0.3s ease; /* Smooth scaling transitions */
}
.header-controls .btn, 
.header-controls label,
.header-right .btn,
.header-right label, 
.header-right .share-btn { /* Apply button-like styling to the label */
    background: var(--secondary-color); /* Use theme color */
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.5em 1em;
    font-size: var(--font-size-md); /* Use theme font size */
    cursor: pointer;
    transition: background-color 0.2s;
}
.header-controls .btn:hover,
.header-controls label:hover,
.header-right .btn:hover,
.header-right label:hover,
.header-right .share-btn:hover:not(:disabled) {
    background: #2980b9; /* Darker shade of secondary color */
}
.header-controls input[type="checkbox"],
.header-right input[type="checkbox"] {
    margin-right: 0.5em;
    vertical-align: middle; /* Align checkbox better with text */
}

/* Specific button styling within header-controls if needed */
.header-controls .logout-btn,
.header-right .logout-btn {
    background: var(--accent-color); /* Use accent color for logout */
}
.header-controls .logout-btn:hover,
.header-right .logout-btn:hover {
    background: #c0392b; /* Darker shade of accent */
}

/* File Management Buttons */
.file-management {
    display: inline-flex;
    gap: 0.5rem;
}

.header-controls .file-btn {
    background: transparent;
    color: white;
    border: none;
    font-size: 1.2rem;
    padding: 0.25rem;
    width: 63px;
    height: 63px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-controls .file-btn .icon {
    width: 2.5rem;
    height: 2.5rem;
}

.header-controls .file-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header-controls .file-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

.header-controls .file-btn:disabled .icon {
    opacity: 0.5;
}

.header-controls .settings-btn,
.header-right .settings-btn,
.header-right .share-btn {
    background: transparent;
    color: white;
    border: none;
    font-size: 1.2rem;
    padding: 0.25rem;
    width: 63px;
    height: 63px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.header-controls .settings-btn .icon,
.header-right .settings-btn .icon,
.header-right .share-btn .icon {
    width: 2.5rem;
    height: 2.5rem;
}

.header-controls .settings-btn:hover,
.header-right .settings-btn:hover,
.header-right .share-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.header-right .share-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.header-right .share-btn:disabled .icon {
    filter: grayscale(100%);
}

/* Tile selection states for swap mode */
.concept-tile.swap-selected {
    border: 3px solid #f39c12;
    box-shadow: 0 0 15px rgba(243, 156, 18, 0.6);
    transform: scale(1.02);
}

.concept-tile.swap-target {
    border: 3px dashed #e74c3c;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.6);
}

/* Swap mode overlay instruction */
.swap-instruction {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(52, 152, 219, 0.95);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    animation: slideInDown 0.3s ease-out;
    max-width: 90%;
    text-align: center;
    font-size: 0.9em;
}

@keyframes slideInDown {
    from {
        transform: translate(-50%, -20px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Modal Styles (Moved from inline styles in index.html) */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000; /* High z-index to appear on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if content is too long */
    background-color: rgba(0,0,0,0.6); /* Darker overlay for better focus */
}
.modal-content {
    background-color: #fff; /* White background for modal content */
    margin: 10vh auto; /* Centered, with 10% margin from top */
    padding: 25px;
    border: 1px solid #ccc; /* Softer border */
    width: 90%;
    max-width: 700px; /* Slightly reduced max-width for better readability */
    border-radius: 8px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); /* Softer shadow */
    animation: slideInModal 0.3s ease-out;
}

@keyframes slideInModal {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-btn {
    color: #888; /* Softer color for close button */
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 32px;
    font-weight: bold;
    transition: color 0.2s;
}
.close-btn:hover,
.close-btn:focus {
    color: #333; /* Darker on hover/focus */
    text-decoration: none;
    cursor: pointer;
}

#classmates-tiles-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem; /* Increased gap */
    justify-content: center;
    margin-top: 1.5rem; /* Increased margin */
    padding: 10px 0; /* Add some padding */
}
.classmate-tile {
    border: 1px solid var(--border-color);
    padding: 15px;
    width: calc(50% - 2rem); /* Responsive width, 2 tiles per row with gap */
    min-height: 180px; 
    border-radius: 6px;
    background-color: var(--bg-color); /* Use theme background color */
    box-shadow: 0 2px 4px var(--tile-shadow);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.classmate-tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.classmate-tile h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}
.classmate-tile img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border: 1px solid #eee;
}
.classmate-tile p {
    font-size: var(--font-size-sm);
    color: var(--text-color);
    word-wrap: break-word; /* Ensure long words don't overflow */
}

/* Responsive adjustments for classmate tiles */
@media (max-width: 600px) {
    .classmate-tile {
        width: calc(100% - 1rem); /* Full width on smaller screens */
    }
    .modal-content {
        margin: 5vh auto; /* Smaller margin on small screens */
        width: 95%;
    }
}

/* Sync Notification - Smart Dynamic Positioning with Toaster Animation */
#sync-notification {
    position: fixed;
    width: max-content;
    min-width: 20vw;
    max-width: 80vw;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: #374151;
    display: flex;
    align-items: center;
    gap: 0.5vmin;
    font-size: 2.4vmin;
    z-index: 10001;
    border-radius: 1vmin;
    padding: 0.8vmin 1.2vmin;
    font-weight: 500;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sync-notification::before {
    content: '';
    width: 1vmin;
    height: 1vmin;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
}

/* Corner positioning classes with off-screen starting positions for toaster animation */
#sync-notification.position-top-left {
    top: calc(var(--header-height, 70px) + 10px); /* Dynamic header height + smaller margin */
    left: -350px; /* Start off-screen left */
}

#sync-notification.position-top-left.show {
    left: 10px; /* Slide in from left with smaller margin */
    opacity: 1;
}

#sync-notification.position-top-right {
    top: calc(var(--header-height, 70px) + 10px); /* Dynamic header height + smaller margin */
    right: -350px; /* Start off-screen right */
}

#sync-notification.position-top-right.show {
    right: 10px; /* Slide in from right with smaller margin */
    opacity: 1;
}

#sync-notification.position-bottom-left {
    bottom: 10px; /* Smaller margin from bottom */
    left: -350px; /* Start off-screen left */
}

#sync-notification.position-bottom-left.show {
    left: 10px; /* Slide in from left with smaller margin */
    opacity: 1;
}

#sync-notification.position-bottom-right {
    bottom: 10px; /* Smaller margin from bottom */
    right: -350px; /* Start off-screen right */
}

#sync-notification.position-bottom-right.show {
    right: 10px; /* Slide in from right with smaller margin */
    opacity: 1;
}

#sync-notification.show {
    opacity: 1;
    transform: scale(1);
}

#sync-notification.saving {
    background: rgba(255, 248, 235, 0.95);
    color: #92400e;
    border-color: rgba(251, 191, 36, 0.2);
}

#sync-notification.saving::before {
    background-color: #f59e0b;
    animation: pulse-saving 1.5s infinite;
}

#sync-notification.saved {
    background: rgba(240, 253, 244, 0.95);
    color: #065f46;
    border-color: rgba(34, 197, 94, 0.2);
}

#sync-notification.saved::before {
    background-color: #10b981;
}

#sync-notification.unsaved {
    background: rgba(254, 242, 242, 0.95);
    color: #991b1b;
    border-color: rgba(239, 68, 68, 0.2);
}

#sync-notification.unsaved::before {
    background-color: #ef4444;
    animation: pulse-warning 2s infinite;
}

@keyframes pulse-saving {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.6; 
        transform: scale(0.9);
    }
}

@keyframes pulse-warning {
    0%, 100% { 
        opacity: 1; 
    }
    50% { 
        opacity: 0.7; 
    }
}

/* Collapsed Title Styles */
.collapsed-title-overlay {
    position: fixed;
    top: var(--header-height, 70px);
    left: 0;
    right: 0;
    background: var(--primary-color);
    color: white;
    z-index: 999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-100%);
    transition: transform 0.3s ease-out;
    pointer-events: none;
}

.collapsed-title-overlay.show {
    transform: translateY(0);
    pointer-events: auto;
}

.collapsed-title-content {
    padding: 16px;
    text-align: center;
    font-size: var(--font-size-xl);
    font-weight: bold;
    letter-spacing: -0.01em;
}

/* PWA Styles */
.pwa-update-notification {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    background: var(--secondary-color) !important;
    color: white !important;
    padding: 16px !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    z-index: 10000 !important;
    max-width: 320px !important;
    animation: slideInRight 0.3s ease !important;
}

.pwa-notification-content {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

.pwa-notification-content h3 {
    margin: 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
}

.pwa-notification-content p {
    margin: 0 !important;
    font-size: 14px !important;
    opacity: 0.9 !important;
}

.pwa-notification-content .btn {
    padding: 8px 16px !important;
    font-size: 13px !important;
    border-radius: 4px !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.pwa-notification-content .btn-primary {
    background: white !important;
    color: var(--secondary-color) !important;
}

.pwa-notification-content .btn-secondary {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.pwa-welcome-notification {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: white !important;
    padding: 24px !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
    z-index: 10001 !important;
    text-align: center !important;
    max-width: 320px !important;
    animation: fadeInScale 0.3s ease !important;
}

/* iOS Install Prompt */
.ios-install-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.ios-install-content h3 {
    margin: 0 0 16px 0;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.ios-install-content p {
    margin: 0 0 20px 0;
    color: var(--text-color);
    line-height: 1.5;
    font-size: 0.95rem;
}

.ios-install-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.ios-install-actions .btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 14px;
}

/* Standalone mode adjustments */
.pwa-standalone header {
    /* Add extra padding for devices with notches/safe areas */
    padding-top: env(safe-area-inset-top, 0);
}

.pwa-standalone body {
    /* Adjust for safe areas in standalone mode */
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* iOS Safari minimal-ui behavior */
@media (max-height: 500px) and (-webkit-min-device-pixel-ratio: 2) {
    /* Detect when Safari is in minimal-ui mode (URL bar hidden) */
    body {
        /* Adjust layout when URL bar disappears */
        transition: padding-top 0.3s ease;
    }
}

/* Progressive enhancement for iOS Safari */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific optimizations */
    body {
        /* Prevent rubber band scrolling */
        overscroll-behavior: none;
        /* Improve touch responsiveness */
        -webkit-overflow-scrolling: touch;
    }
    
    /* Hide address bar more aggressively */
    html {
        height: 100%;
        overflow: hidden;
    }
    
    body {
        height: 100vh;
        height: -webkit-fill-available; /* iOS Safari viewport fix */
        height: var(--actual-vh, 100vh); /* Use actual measured viewport height */
        overflow-y: auto;
    }
}

/* Additional mobile touch optimizations */
@media (pointer: coarse) {
    /* For touch devices, ensure better touch targets */
    .btn,
    button,
    [role="button"] {
        min-height: 48px; /* Increase touch target size */
        min-width: 48px;
    }
    
    /* Prevent text selection feedback on touch */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Better visual feedback for interactive elements */
    .concept-tile:active,
    .btn:active,
    button:active {
        transform: scale(0.98);
    }
}

/* PWA Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeInScale {
    from {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Adjustments for installed PWA */
@media (display-mode: standalone) {
    body {
        /* Prevent pull-to-refresh on iOS */
        overscroll-behavior-y: contain;
    }
    
    /* Full viewport height in standalone mode */
    #app-container {
        height: 100vh !important;
        height: -webkit-fill-available !important;
    }
}

/* PWA-specific loading states */
.pwa-loading {
    position: relative;
    overflow: hidden;
}

.pwa-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--secondary-color), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Performance Optimizations */
.low-end-device .concept-tile {
    will-change: auto !important;
    transform: translateZ(0); /* Force hardware acceleration */
}

.low-end-device .concept-tile:hover {
    transition: transform 0.1s ease !important;
}

.pwa-loading::after {
    display: none; /* Remove loading animations on low bandwidth */
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .concept-tile {
        border: 2px solid var(--text-color);
    }
    
    .pwa-install-button,
    .pwa-update-notification {
        border: 2px solid white;
    }
}

/* Optimize for print */
@media print {
    .pwa-update-notification,
    .share-btn {
        display: none !important;
    }
    
    .concept-tile {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
