/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables for consistent theming */
:root {
    --primary-color: #667eea;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-color: #f093fb;
    --accent-color: #4facfe;
    --text-dark: #2d3748;
    --text-light: #718096;
    --text-muted: #a0aec0;
    --bg-light: #f7fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 25px 50px rgba(0, 0, 0, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--bg-light);
    min-height: 100vh;
    padding: 1rem;
    transition: var(--transition);
    position: relative;
    overflow-x: hidden;
}

/* Animated background gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-gradient);
    opacity: 0.03;
    z-index: -1;
    animation: gradientShift 10s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { opacity: 0.03; }
    50% { opacity: 0.08; }
}

/* Main container */
.container {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 2.5rem;
    max-width: 600px;
    margin: 2rem auto;
    position: relative;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.8s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Container glow effect */
.container::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--primary-gradient);
    border-radius: var(--radius-xl);
    z-index: -1;
    opacity: 0;
    transition: var(--transition);
}

.container:hover::before {
    opacity: 0.1;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

p {
    color: var(--text-light);
    margin-bottom: 1rem;
    font-size: 1rem;
    line-height: 1.6;
}

/* Form elements */
label {
    display: block;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

#food-select {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-dark);
    background: var(--bg-white);
    transition: var(--transition);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    cursor: pointer;
    margin-bottom: 1.5rem;
}

#food-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

#food-select:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

#food-select option {
    padding: 0.75rem;
    color: var(--text-dark);
    background: var(--bg-white);
    font-weight: 500;
}

/* Food Cards Selection */
.food-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.food-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.food-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.food-card.active {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.food-card.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-gradient);
    opacity: 0.05;
    pointer-events: none;
}

.food-emoji {
    width: 2rem;
    height: 2rem;
    margin-bottom: 0.2rem;
    animation: bounce 2s infinite;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 auto 0.2rem;
}

.food-card.active .food-emoji {
    animation: pulse 1.5s infinite;
}

/* Honeybun Icon */
.honeybun-icon {
    background: linear-gradient(135deg, #ffcc99 0%, #ff9966 100%);
    border: 2px solid #ff9966;
    box-shadow: inset 0 0 0 3px rgba(139, 69, 19, 0.2);
}

/* Apple Icon */
.apple-icon {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    border: 2px solid #ee5a52;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* Banana Icon */
.banana-icon {
    background: linear-gradient(135deg, #fff275 0%, #ffd700 100%);
    border: 2px solid #ffd700;
    border-radius: 40% 60% 40% 60%;
    box-shadow: inset 0 0 0 3px rgba(243, 156, 18, 0.2);
}

/* Cookie Icon */
.cookie-icon {
    background: linear-gradient(135deg, #deb887 0%, #d2691e 100%);
    border: 2px solid #d2691e;
    box-shadow: inset 2px 2px 0 rgba(101, 67, 33, 0.4), inset -2px -2px 0 rgba(101, 67, 33, 0.2);
}

/* Pizza Icon */
.pizza-icon {
    background: linear-gradient(135deg, #ffcccb 0%, #ff6b6b 100%);
    border: 2px solid #ff6b6b;
    border-radius: 50% 50% 50% 10%;
    box-shadow: inset 0 0 0 3px rgba(225, 112, 85, 0.3);
}

/* Bagel Icon */
.bagel-icon {
    background: linear-gradient(135deg, #f4e4bc 0%, #e6b800 100%);
    border: 2px solid #e6b800;
    box-shadow: inset 0 0 0 4px rgba(184, 134, 11, 0.2), inset 0 0 0 8px rgba(244, 228, 188, 0.8);
}

/* Donut Icon */
.donut-icon {
    background: linear-gradient(135deg, #ffb3d9 0%, #ff69b4 100%);
    border: 2px solid #ff69b4;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.4), inset 0 0 0 6px rgba(255, 105, 180, 0.2);
}

/* Sandwich Icon */
.sandwich-icon {
    background: linear-gradient(135deg, #e6f3ff 0%, #b3d9ff 100%);
    border: 2px solid #b3d9ff;
    box-shadow: inset 0 2px 0 rgba(139, 195, 74, 0.3), inset 0 4px 0 rgba(255, 235, 59, 0.2), inset 0 6px 0 rgba(255, 87, 34, 0.2);
    border-radius: 25%;
}

.food-name {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.75rem;
    margin-bottom: 0.1rem;
    text-transform: capitalize;
    line-height: 1.1;
}

.food-calories {
    font-size: 0.65rem;
    color: var(--text-light);
    font-weight: 500;
    line-height: 1;
}

.food-card.active .food-name {
    color: var(--primary-color);
}

.food-card.active .food-calories {
    color: var(--primary-color);
}

/* Food card animations */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
    60% { transform: translateY(-4px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Mobile optimizations for food cards */
@media (max-width: 768px) {
    .food-cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.75rem;
    }
    
    .food-card {
        padding: 0.75rem;
        min-height: 100px;
        min-width: 44px; /* Touch target */
    }
    
    .food-emoji {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.8rem;
    }
    
    /* Enhanced mobile food icons */
    .honeybun-icon {
        background: linear-gradient(135deg, #ffcc99 0%, #ff9966 100%) !important;
        border: 3px solid #ff9966 !important;
        box-shadow: inset 0 0 0 4px rgba(139, 69, 19, 0.3) !important;
    }
    
    .apple-icon {
        background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%) !important;
        border: 3px solid #ee5a52 !important;
        box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.4) !important;
    }
    
    .banana-icon {
        background: linear-gradient(135deg, #fff275 0%, #ffd700 100%) !important;
        border: 3px solid #ffd700 !important;
        border-radius: 40% 60% 40% 60% !important;
        box-shadow: inset 0 0 0 4px rgba(243, 156, 18, 0.3) !important;
    }
    
    .cookie-icon {
        background: linear-gradient(135deg, #deb887 0%, #d2691e 100%) !important;
        border: 3px solid #d2691e !important;
        box-shadow: inset 3px 3px 0 rgba(101, 67, 33, 0.5), inset -3px -3px 0 rgba(101, 67, 33, 0.3) !important;
    }
    
    .pizza-icon {
        background: linear-gradient(135deg, #ffcccb 0%, #ff6b6b 100%) !important;
        border: 3px solid #ff6b6b !important;
        border-radius: 50% 50% 50% 15% !important;
        box-shadow: inset 0 0 0 4px rgba(225, 112, 85, 0.4) !important;
    }
    
    .bagel-icon {
        background: linear-gradient(135deg, #f4e4bc 0%, #e6b800 100%) !important;
        border: 3px solid #e6b800 !important;
        box-shadow: inset 0 0 0 5px rgba(184, 134, 11, 0.3), inset 0 0 0 9px rgba(244, 228, 188, 0.9) !important;
    }
    
    .donut-icon {
        background: linear-gradient(135deg, #ffb3d9 0%, #ff69b4 100%) !important;
        border: 3px solid #ff69b4 !important;
        box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.5), inset 0 0 0 7px rgba(255, 105, 180, 0.3) !important;
    }
    
    .sandwich-icon {
        background: linear-gradient(135deg, #e6f3ff 0%, #b3d9ff 100%) !important;
        border: 3px solid #b3d9ff !important;
        box-shadow: inset 0 3px 0 rgba(139, 195, 74, 0.4), inset 0 6px 0 rgba(255, 235, 59, 0.3), inset 0 9px 0 rgba(255, 87, 34, 0.3) !important;
        border-radius: 30% !important;
    }
    
    .food-name {
        font-size: 0.85rem;
    }
    
    .food-calories {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .food-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .food-card {
        padding: 0.5rem;
        min-height: 90px;
    }
    
    .food-emoji {
        width: 2rem;
        height: 2rem;
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    /* Force mobile icon visibility with simple backgrounds */
    .honeybun-icon {
        background: #ffcc99 !important;
        border: 2px solid #ff9966 !important;
        box-shadow: inset 0 0 0 2px rgba(139, 69, 19, 0.4) !important;
    }
    
    .apple-icon {
        background: #ff6b6b !important;
        border: 2px solid #ee5a52 !important;
        box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5) !important;
    }
    
    .banana-icon {
        background: #fff275 !important;
        border: 2px solid #ffd700 !important;
        border-radius: 35% 65% 35% 65% !important;
        box-shadow: inset 0 0 0 2px rgba(243, 156, 18, 0.4) !important;
    }
    
    .cookie-icon {
        background: #deb887 !important;
        border: 2px solid #d2691e !important;
        box-shadow: inset 2px 2px 0 rgba(101, 67, 33, 0.6), inset -2px -2px 0 rgba(101, 67, 33, 0.4) !important;
    }
    
    .pizza-icon {
        background: #ffcccb !important;
        border: 2px solid #ff6b6b !important;
        border-radius: 50% 50% 50% 20% !important;
        box-shadow: inset 0 0 0 2px rgba(225, 112, 85, 0.5) !important;
    }
    
    .bagel-icon {
        background: #f4e4bc !important;
        border: 2px solid #e6b800 !important;
        box-shadow: inset 0 0 0 3px rgba(184, 134, 11, 0.4), inset 0 0 0 6px rgba(244, 228, 188, 0.8) !important;
    }
    
    .donut-icon {
        background: #ffb3d9 !important;
        border: 2px solid #ff69b4 !important;
        box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6), inset 0 0 0 4px rgba(255, 105, 180, 0.4) !important;
    }
    
    .sandwich-icon {
        background: #e6f3ff !important;
        border: 2px solid #b3d9ff !important;
        box-shadow: inset 0 2px 0 rgba(139, 195, 74, 0.5), inset 0 4px 0 rgba(255, 235, 59, 0.4), inset 0 6px 0 rgba(255, 87, 34, 0.4) !important;
        border-radius: 25% !important;
    }
    
    .food-name {
        font-size: 0.8rem;
        margin-bottom: 0.1rem;
    }
    
    .food-calories {
        font-size: 0.7rem;
    }
}

/* Status messages */
#status-message {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-light);
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Results section */
.result {
    font-size: 1.25rem;
    line-height: 1.8;
    margin: 2rem 0;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(240, 147, 251, 0.05) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(102, 126, 234, 0.1);
    font-weight: 500;
    color: var(--text-dark);
    animation: resultSlide 0.6s ease-out;
}

@keyframes resultSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
        scale: 0.95;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        scale: 1;
    }
}

/* Refresh note */
.refresh-note {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 1.5rem;
    padding: 0.75rem;
    background: rgba(113, 128, 150, 0.05);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(113, 128, 150, 0.1);
}

/* Calorie note */
#calorie-note {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(79, 172, 254, 0.05);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(79, 172, 254, 0.1);
    font-weight: 500;
}

/* Footer */
.footer {
    margin-top: 3rem;
    padding: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(113, 128, 150, 0.03);
    border-radius: var(--radius-md);
    border: 1px solid rgba(113, 128, 150, 0.05);
    text-align: center;
    line-height: 1.6;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Modal styling */
#consentModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

.modal-content {
    background: var(--bg-white);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    text-align: center;
    max-width: 450px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: modalSlideIn 0.4s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content h2 {
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.modal-content p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.modal-content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.modal-content a:hover {
    text-decoration: underline;
}

/* Button styles */
.modal-content button {
    padding: 0.75rem 1.5rem;
    margin: 0 0.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    outline: none;
}

.modal-content button:first-of-type {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.modal-content button:first-of-type:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.modal-content button:last-of-type {
    background: var(--bg-light);
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.modal-content button:last-of-type:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

/* Dynamic background themes with enhanced colors */
.honeybun { 
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
}

.apple { 
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
}

.banana { 
    background: linear-gradient(135deg, #fffde7 0%, #f0f4c3 100%);
}

.donut { 
    background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%);
}

.pizza {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
}

/* Enhanced responsive design for mobile */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
        font-size: 16px; /* Prevents zoom on iOS */
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    .container {
        padding: 1.5rem;
        margin: 0.5rem auto;
        max-width: 100%;
        min-height: auto;
    }
    
    h1 {
        font-size: 2rem;
        line-height: 1.3;
        margin-bottom: 1rem;
    }
    
    /* Better touch targets */
    #food-select {
        padding: 1rem;
        font-size: 1.1rem;
        min-height: 44px; /* iOS recommended touch target */
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
    
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
        border-radius: var(--radius-lg);
        max-width: calc(100vw - 2rem);
    }
    
    .modal-content button {
        display: block;
        width: 100%;
        margin: 0.5rem 0;
        padding: 1rem;
        font-size: 1.1rem;
        min-height: 44px; /* iOS recommended touch target */
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Feature grid improvements */
    .feature-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin: 1.5rem 0;
    }
    
    .feature-card {
        padding: 1rem;
        text-align: center;
    }
    
    .feature-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }
    
    /* Status and result improvements */
    .status-indicator {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        margin: 1rem 0;
        border-radius: var(--radius-md);
    }
    
    .result-highlight {
        padding: 1rem;
        margin: 1rem 0;
        border-radius: var(--radius-md);
    }
    
    .result {
        font-size: 1.1rem;
        line-height: 1.6;
        padding: 1rem;
    }
    
    /* Footer improvements */
    .footer {
        margin-top: 2rem;
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .footer-links a {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.25rem;
    }
    
    .container {
        padding: 1rem;
        margin: 0.25rem auto;
        border-radius: var(--radius-lg);
    }
    
    h1 {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    .container header p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    
    /* Improved form elements */
    #food-select {
        padding: 0.875rem;
        font-size: 1rem;
        width: 100%;
        border-radius: var(--radius-sm);
    }
    
    label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    /* Compact feature cards */
    .feature-card {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .feature-card h3 {
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }
    
    .feature-card p {
        font-size: 0.85rem;
        margin: 0;
    }
    
    /* Improved modal for small screens */
    .modal-content {
        padding: 1rem;
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }
    
    .modal-content h2 {
        font-size: 1.3rem;
        margin-bottom: 0.75rem;
    }
    
    .modal-content p {
        font-size: 0.9rem;
        line-height: 1.5;
        margin-bottom: 1rem;
    }
    
    .modal-content button {
        padding: 0.875rem;
        font-size: 1rem;
        margin: 0.25rem 0;
        border-radius: var(--radius-sm);
    }
    
    /* Compact status and results */
    .status-indicator {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        margin: 0.75rem 0;
    }
    
    .result-highlight {
        padding: 0.75rem;
        margin: 0.75rem 0;
    }
    
    .result {
        font-size: 1rem;
        line-height: 1.5;
        padding: 0.75rem;
    }
    
    /* Compact info sections */
    .refresh-note, #calorie-note {
        font-size: 0.8rem;
        padding: 0.5rem;
        margin: 0.5rem 0;
    }
    
    /* Footer adjustments */
    .footer {
        margin-top: 1.5rem;
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    
    .footer-links a {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        min-height: 40px;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 360px) {
    .container {
        padding: 0.75rem;
        margin: 0.125rem auto;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .feature-grid {
        margin: 1rem 0;
    }
    
    .feature-card {
        padding: 0.5rem;
    }
    
    .feature-icon {
        font-size: 2rem;
    }
    
    .modal-content {
        padding: 0.75rem;
        margin: 0.25rem;
    }
    
    .modal-content h2 {
        font-size: 1.2rem;
    }
    
    .modal-content p {
        font-size: 0.85rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .container:hover {
        transform: none;
        box-shadow: var(--shadow-xl);
    }
    
    .container:hover::before {
        opacity: 0;
    }
    
    .feature-card:hover {
        transform: none;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    
    .footer-links a:hover {
        transform: none;
    }
    
    #food-select:hover {
        transform: none;
    }
    
    /* Add active states for better touch feedback */
    .modal-content button:active {
        transform: scale(0.98);
    }
    
    .footer-links a:active {
        transform: scale(0.98);
        background: rgba(102, 126, 234, 0.3);
    }
    
    #food-select:active {
        transform: scale(0.99);
    }
}

/* Landscape phone optimizations */
@media (max-width: 896px) and (orientation: landscape) {
    body {
        padding: 0.5rem;
    }
    
    .container {
        padding: 1rem;
        margin: 0.5rem auto;
        max-width: 90%;
    }
    
    h1 {
        font-size: 1.75rem;
        margin-bottom: 0.75rem;
    }
    
    .feature-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
        margin: 1rem 0;
    }
    
    .feature-card {
        padding: 0.75rem;
    }
    
    .feature-icon {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .modal-content {
        max-width: 500px;
        padding: 1.5rem;
    }
    
    .footer-links {
        flex-direction: row;
        gap: 1rem;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-text-size-adjust: 100%;
        -webkit-font-smoothing: antialiased;
    }
    
    #food-select {
        -webkit-appearance: none;
        border-radius: var(--radius-md);
    }
    
    .modal-content button {
        -webkit-appearance: none;
        border-radius: var(--radius-md);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for accessibility */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0066cc;
        --text-dark: #000000;
        --text-light: #333333;
        --border-color: #666666;
    }
}

/* Loading animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Hover effects for better interactivity */
.container:hover {
    transform: translateY(-2px);
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.12);
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection styling */
::selection {
    background: rgba(102, 126, 234, 0.2);
    color: var(--text-dark);
}

::-moz-selection {
    background: rgba(102, 126, 234, 0.2);
    color: var(--text-dark);
}
