/* iOS-specific styles and optimizations */

/* Force light mode - disable dark mode support */
:root {
    color-scheme: light !important;
}

* {
    color-scheme: light !important;
}

/* Force light backgrounds and text colors */
html, body {
    background-color: #ffffff !important;
    color: #000000 !important;
}

/* Prevent iOS Safari from zooming on input focus */
input, select, textarea {
    font-size: 16px !important;
    background-color: #ffffff !important;
    color: #000000 !important;
}

/* Prevent iOS bounce scroll */
html, body {
    position: fixed;
    overflow: hidden;
    width: 100%;
    height: 100%;
    -webkit-overflow-scrolling: touch;
}

/* iOS safe area support */
@supports(padding: max(0px)) {
    body {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* Touch optimization for iOS */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Allow text selection for specific elements */
.modal-text,
.game-over-story,
.typewriter-text {
    -webkit-user-select: text;
    user-select: text;
}

/* iOS button styling */
button {
    -webkit-appearance: none;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(145deg, #2c3e50, #34495e);
    border: 2px solid #3498db;
    color: white;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    padding: 12px 20px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    min-height: 44px; /* iOS minimum touch target */
    min-width: 44px;
}

button:active {
    transform: scale(0.95);
    background: linear-gradient(145deg, #34495e, #2c3e50);
    border-color: #2980b9;
}

/* Game canvas iOS optimization */
#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    touch-action: none;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Modal optimizations for iOS - Force light theme */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.modal-content {
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: 5vh auto;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    background-color: #ffffff !important;
    color: #000000 !important;
}

/* Force light theme on all game over dialogs and modals */
#game-over, #game-over .modal-content,
#photo-dialog, #photo-dialog .photo-content,
#tos-modal, #tos-modal .modal-content,
#about-modal, #about-modal .modal-content,
#donate-modal, #donate-modal .modal-content,
#follow-modal, #follow-modal .modal-content {
    background-color: #ffffff !important;
    color: #000000 !important;
}

/* Force light theme on all text elements in modals */
.modal-content h2,
.modal-content h3,
.modal-content p,
.modal-content div,
.modal-content span,
.photo-content h3,
.photo-content p,
.game-over-story,
.game-over-trump-quote,
#final-surplus,
#game-over-reason {
    color: #000000 !important;
    background-color: transparent !important;
}

/* Photo dialog iOS optimization */
.photo-content {
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.game-over-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* HUD iOS optimization */
#hud {
    position: fixed;
    top: max(20px, env(safe-area-inset-top, 20px));
    left: max(20px, env(safe-area-inset-left, 20px));
    z-index: 100;
    pointer-events: none;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Conversation bubble iOS optimization */
#conversation-bubble {
    position: fixed;
    bottom: max(120px, env(safe-area-inset-bottom, 120px));
    left: 50%;
    transform: translateX(-50%);
    max-width: 90vw;
    z-index: 200;
    -webkit-transform: translateX(-50%) translateZ(0);
    transform: translateX(-50%) translateZ(0);
}

/* Header links iOS optimization - More compact design */
#header-links {
    position: fixed;
    top: max(15px, env(safe-area-inset-top, 15px));
    right: max(15px, env(safe-area-inset-right, 15px));
    z-index: 100;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 70vw;
}

#header-links a {
    min-height: 36px;
    min-width: 60px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 6px 10px;
    font-size: 10px !important;
    font-family: 'Press Start 2P', monospace;
    background: rgba(44, 62, 80, 0.9) !important;
    color: #ffffff !important;
    text-decoration: none;
    border: 1px solid rgba(52, 152, 219, 0.7) !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 80px;
}

#header-links a:hover, #header-links a:active {
    background: rgba(52, 73, 94, 0.95) !important;
    border-color: rgba(41, 128, 185, 0.9) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
}

/* Language switcher special styling */
#language-switcher {
    font-size: 9px !important;
    max-width: 90px !important;
}

/* Game over modal iOS optimization */
#game-over {
    align-items: center;
    justify-content: center;
    padding: max(20px, env(safe-area-inset-top, 20px)) max(20px, env(safe-area-inset-right, 20px)) max(20px, env(safe-area-inset-bottom, 20px)) max(20px, env(safe-area-inset-left, 20px));
}

#game-over .modal-content {
    width: 90vw;
    max-width: 500px;
    margin: 0;
}

/* Photo button animation for iOS */
.photo-button.shake-animation {
    animation: shake-ios 0.5s ease-in-out infinite alternate;
}

@keyframes shake-ios {
    0% { transform: translateX(0px) scale(1); }
    25% { transform: translateX(-2px) scale(1.02); }
    50% { transform: translateX(2px) scale(1); }
    75% { transform: translateX(-2px) scale(1.02); }
    100% { transform: translateX(0px) scale(1); }
}

/* Star rating iOS optimization */
.star-rating {
    font-size: 24px;
    margin: 15px 0;
    text-align: center;
}

.star {
    display: inline-block;
    margin: 0 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
    min-width: 44px;
    line-height: 44px;
    text-align: center;
}

.star.fill {
    color: #f39c12;
    transform: scale(1.2);
    text-shadow: 0 0 10px #f39c12;
}

/* Loading screen for iOS */
.ios-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.ios-loading-text {
    color: white;
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    margin-top: 20px;
    text-align: center;
}

.ios-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Optimize font rendering on iOS */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Prevent text size adjustment on iOS */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* iOS viewport height fix */
.ios-vh-fix {
    height: 100vh;
    height: -webkit-fill-available;
}

/* Homepage optimization for cleaner, modern look */
#home-screen {
    padding: max(40px, env(safe-area-inset-top, 40px)) max(20px, env(safe-area-inset-right, 20px)) max(40px, env(safe-area-inset-bottom, 40px)) max(20px, env(safe-area-inset-left, 20px)) !important;
    max-width: 90vw !important;
    margin: 0 auto !important;
}

#home-screen h1 {
    font-size: 24px !important;
    margin-bottom: 30px !important;
    text-align: center !important;
    line-height: 1.3 !important;
}

#play-button {
    display: block !important;
    margin: 30px auto !important;
    padding: 16px 32px !important;
    font-size: 14px !important;
    min-width: 160px !important;
    background: linear-gradient(145deg, #e74c3c, #c0392b) !important;
    border: 2px solid #e74c3c !important;
    color: #ffffff !important;
    box-shadow: 0 4px 16px rgba(231, 76, 60, 0.3) !important;
}

#play-button:active, #play-button:hover {
    background: linear-gradient(145deg, #c0392b, #a93226) !important;
    border-color: #c0392b !important;
    transform: translateY(2px) scale(0.98) !important;
}

#instructions {
    margin-top: 40px !important;
    text-align: center !important;
    max-width: 80vw !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

#instruction-text {
    font-size: 11px !important;
    line-height: 1.6 !important;
    color: #666666 !important;
    text-align: center !important;
    padding: 0 10px !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Simplify flying characters animation for mobile */
#flying-characters {
    opacity: 0.7 !important;
}

#flying-trump, #flying-penguin {
    width: 60px !important;
    height: 60px !important;
    animation-duration: 8s !important;
}

/* Clean up background overlay for better readability */
#color-overlay {
    background: rgba(0, 0, 0, 0.3) !important;
}

/* Energy efficient animations for iOS */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    #flying-characters {
        display: none !important;
    }
}

/* Dark mode support for iOS */
@media (prefers-color-scheme: dark) {
    /* Game already has dark theme, so minimal changes needed */
    .modal-content {
        background: rgba(30, 30, 30, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* High contrast mode support for iOS */
@media (prefers-contrast: high) {
    button {
        border-width: 3px;
        font-weight: bold;
    }
    
    .star {
        text-shadow: 2px 2px 0 #000;
    }
}
