/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #000;
    color: #fff;
    overflow: hidden;
}

/* Allow scrolling on settings screen */
body.settings-active {
    overflow: auto;
}

/* Ensure all screens can scroll on mobile if content overflows */
@media (max-width: 480px) {
    body.settings-active {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

#app {
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.screen.active {
    display: flex;
}

/* Time Selection Screen */
#time-selection-screen {
    background-color: #000;
}

#time-selection-screen h1 {
    font-size: 24px;
    font-weight: 300;
    margin-bottom: 40px;
    text-align: center;
}

.time-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    width: 100%;
    max-width: 300px;
}

.time-button {
    background-color: #333;
    color: #fff;
    border: 2px solid #555;
    border-radius: 12px;
    padding: 20px;
    font-size: 24px;
    font-weight: bold;
    min-height: 80px;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.time-button:hover,
.time-button:focus {
    background-color: #444;
    border-color: #666;
    outline: none;
}

.time-button:active {
    background-color: #555;
    transform: scale(0.98);
}

.settings-button {
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Preparation Screen */
#preparation-screen {
    background-color: #000;
}

.back-button-container {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
}

.back-button {
    background-color: #333;
    color: #fff;
    border: 2px solid #555;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.back-button:hover,
.back-button:focus {
    background-color: #444;
    border-color: #666;
    outline: none;
}

.back-button:active {
    background-color: #555;
    transform: scale(0.98);
}

.settings-button {
    font-size: 28px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.button-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 400px;
}

.back-button {
    background-color: #333;
    color: #fff;
    border: 2px solid #555;
    border-radius: 12px;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    flex: 0.6;
    min-height: 60px;
}

.back-button:hover,
.back-button:focus {
    background-color: #444;
    border-color: #666;
    outline: none;
}

.back-button:active {
    background-color: #555;
    transform: scale(0.98);
}

.preparation-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 60px;
}

#selected-time-display {
    font-size: 72px;
    font-weight: 300;
    font-family: 'Courier New', monospace;
    text-align: center;
    letter-spacing: 2px;
}

.start-button {
    background-color: #2d5a2d;
    color: #fff;
    border: 3px solid #4a8f4a;
    border-radius: 12px;
    padding: 20px 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    flex: 1.4;
    min-height: 60px;
}

.start-button:hover,
.start-button:focus {
    background-color: #3d6a3d;
    border-color: #5a9f5a;
    outline: none;
}

.start-button:active {
    background-color: #4d7a4d;
    transform: scale(0.98);
}

/* Timer Screen */
#timer-screen {
    transition: background-color 0.3s ease;
}

#timer-screen.loading {
    background-color: #000;
}

#timer-screen.preparation,
#timer-screen.complete {
    background-color: #8b0000;
}

#timer-screen.shooting {
    background-color: #006400;
}

/* Timer State Background Colors */
body.timer-loading {
    background-color: #000;
}

body.timer-preparation,
body.timer-complete {
    background-color: #8b0000;
}

body.timer-shooting {
    background-color: #006400;
}

.cancel-button {
    background-color: #cc0000;
    color: #fff;
    border: 2px solid #ff0000;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    margin-top: 40px;
}

.cancel-button:hover,
.cancel-button:focus {
    background-color: #dd0000;
    outline: none;
}

.cancel-button:active {
    background-color: #aa0000;
    transform: scale(0.98);
}

.cancel-button.hidden {
    display: none;
}

.timer-display {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#timer-text,
.timer-text-style {
    font-size: 72px;
    font-weight: 300;
    font-family: 'Courier New', monospace;
    text-align: center;
    letter-spacing: 2px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 480px) {
    .screen {
        padding: 15px;
    }
    
    #time-selection-screen h1 {
        font-size: 20px;
        margin-bottom: 30px;
    }
    
    .time-grid {
        gap: 15px;
        max-width: 280px;
    }
    
    .time-button {
        padding: 15px;
        font-size: 20px;
        min-height: 70px;
    }
    
    #selected-time-display {
        font-size: 60px;
    }
    
    .start-button {
        padding: 25px 50px;
        font-size: 24px;
        min-width: 180px;
    }
    
    #timer-text,
    .timer-text-style {
        font-size: 60px;
    }

    /* Settings screen mobile styles */
    #settings-screen {
        padding-top: 15px;
        padding-bottom: 30px; /* Extra bottom padding for mobile scrolling */
    }
    
    .settings-content {
        gap: 20px;
        min-height: auto; /* Allow content to determine height */
    }
    
    .settings-header h2 {
        font-size: 20px;
        margin-right: 50px;
    }
    
    .settings-section {
        padding: 15px;
    }
    
    .about-content p {
        font-size: 13px;
    }

    /* Mobile responsive adjustments for new elements */
    .toggle-group {
        gap: 10px;
    }
    
    .toggle-label {
        font-size: 13px;
    }
    
    .external-link {
        font-size: 13px;
        padding: 10px;
    }
    
    .links-grid {
        gap: 10px;
    }
}

@media (max-width: 360px) {
    .time-grid {
        max-width: 260px;
    }
    
    .time-button {
        padding: 12px;
        font-size: 18px;
        min-height: 60px;
    }
    
    #timer-text,
    .timer-text-style {
        font-size: 48px;
    }
}

/* Landscape Orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .screen {
        padding: 10px;
    }
    
    #time-selection-screen h1 {
        margin-bottom: 20px;
    }
    
    .preparation-content {
        gap: 40px;
    }
    
    #timer-text,
    .timer-text-style {
        font-size: 56px;
    }
}

/* Settings Screen */
#settings-screen {
    background-color: #000;
    justify-content: flex-start;
    padding-top: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 100vh;
}

.settings-content {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.settings-header h2 {
    font-size: 24px;
    font-weight: 300;
    flex: 1;
    text-align: center;
    margin-right: 60px; /* Compensate for back button width */
}

.settings-section {
    background-color: #111;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 20px;
}

.settings-section h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 15px;
    color: #fff;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-group label {
    font-size: 14px;
    color: #ccc;
}

#loading-time-input {
    background-color: #222;
    color: #fff;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 12px;
    font-size: 16px;
    width: 100%;
}

#loading-time-input:focus {
    outline: none;
    border-color: #666;
}

.save-button {
    background-color: #2d5a2d;
    color: #fff;
    border: 2px solid #4a8f4a;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    align-self: flex-start;
}

.save-button:hover,
.save-button:focus {
    background-color: #3d6a3d;
    border-color: #5a9f5a;
    outline: none;
}

.save-button:active {
    background-color: #4d7a4d;
    transform: scale(0.98);
}

.save-button:disabled {
    background-color: #333;
    border-color: #555;
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.save-button:disabled:hover {
    background-color: #333;
    border-color: #555;
    transform: none;
}

/* Autosave Indicator */
.autosave-indicator {
    display: none;
    font-size: 12px;
    margin-top: 5px;
    padding: 4px 8px;
    border-radius: 4px;
    text-align: center;
    font-weight: 500;
    transition: all 0.3s ease;
}

.autosave-indicator.saved {
    background-color: rgba(45, 90, 45, 0.2);
    color: #4a8f4a;
    border: 1px solid rgba(74, 143, 74, 0.3);
}

.autosave-indicator.error {
    background-color: rgba(204, 0, 0, 0.2);
    color: #ff6666;
    border: 1px solid rgba(255, 102, 102, 0.3);
}

.autosave-indicator.invalid {
    background-color: rgba(255, 165, 0, 0.2);
    color: #ffaa44;
    border: 1px solid rgba(255, 170, 68, 0.3);
}

/* Autosave Note */
.autosave-note {
    font-size: 12px;
    color: #888;
    margin-top: 8px;
    text-align: center;
    font-style: italic;
}

/* Slider Control */
.slider-container {
    margin: 10px 0;
}

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #333;
    outline: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.slider:hover {
    opacity: 1;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4a8f4a;
    cursor: pointer;
    border: 2px solid #2d5a2d;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4a8f4a;
    cursor: pointer;
    border: 2px solid #2d5a2d;
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.toggle-label {
    font-size: 14px;
    color: #ccc;
    flex: 1;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    cursor: pointer;
    z-index: 1;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: 0.3s;
    border-radius: 24px;
    border: 2px solid #555;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: #666;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #2d5a2d;
    border-color: #4a8f4a;
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
    background-color: #4a8f4a;
}

/* External Links Section */
.external-links-section {
    background-color: #0f0f0f;
}

.links-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.external-link {
    display: block;
    color: #4a8f4a;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 12px;
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    transition: all 0.2s ease;
    text-align: center;
}

.external-link:hover,
.external-link:focus {
    background-color: #2a2a2a;
    border-color: #4a8f4a;
    color: #5a9f5a;
    outline: none;
}

.external-link:active {
    background-color: #333;
    transform: scale(0.98);
}

.about-section {
    background-color: #0a0a0a;
}

.about-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.about-content h4 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.about-content p {
    font-size: 14px;
    line-height: 1.5;
    color: #ccc;
}

.copyright {
    font-weight: 500;
    color: #aaa;
    font-style: italic;
    margin-top: 10px;
}

/* Install Button */
.install-container {
    margin-top: 30px;
    width: 100%;
    max-width: 300px;
    display: flex;
    justify-content: center;
}

.install-button {
    background-color: #333;
    color: #fff;
    border: 2px solid #555;
    border-radius: 12px;
    padding: 15px 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
}

.install-button:hover,
.install-button:focus {
    background-color: #444;
    border-color: #666;
    outline: none;
}

.install-button:active {
    background-color: #555;
    transform: scale(0.98);
}

.install-button:disabled {
    background-color: #333;
    border-color: #555;
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.install-button.installing {
    background-color: #2d5a2d;
    border-color: #4a8f4a;
}

.install-button.installed {
    background-color: #555;
    border-color: #777;
    color: #aaa;
    cursor: default;
}

/* Battery Optimization Mode */
body.battery-optimization {
    /* Reduce animations and transitions for battery saving */
}

body.battery-optimization .time-button,
body.battery-optimization .start-button,
body.battery-optimization .cancel-button,
body.battery-optimization .back-button {
    transition: none;
}

body.battery-optimization .screen {
    transition: none;
}

body.battery-optimization #timer-screen {
    transition: none;
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .time-button,
    .start-button,
    .cancel-button,
    .install-button {
        border-width: 1px;
    }
}
/* Offli
ne Status Indicator */
.offline-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.8);
    border: 1px solid #666;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    color: #fff;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: opacity 0.3s ease;
}

.offline-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

.offline-content {
    display: flex;
    align-items: center;
    gap: 6px;
}

.offline-icon {
    font-size: 16px;
    opacity: 0.7;
}

.offline-text {
    font-weight: 500;
    font-size: 12px;
}

/* User-Friendly Update Notification */
.update-available-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background-color: rgba(40, 40, 40, 0.95);
    border: 1px solid #555;
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: slideUp 0.3s ease;
    max-width: 90vw;
}

.update-available-notification .update-content {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.update-refresh-btn {
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.update-refresh-btn:hover {
    background-color: #444;
    border-color: #666;
}

.update-dismiss-btn {
    background: none;
    color: #ccc;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.update-dismiss-btn:hover {
    color: #fff;
}

/* Install Modal */
.install-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.install-modal-content {
    background-color: #222;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    color: #fff;
}

.install-modal-content h3 {
    margin: 0 0 20px 0;
    color: #fff;
    font-size: 20px;
}

.install-modal-content p {
    margin: 0 0 25px 0;
    line-height: 1.5;
    color: #ccc;
}

.install-modal-close {
    background-color: #333;
    color: #fff;
    border: 2px solid #555;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.install-modal-close:hover,
.install-modal-close:focus {
    background-color: #444;
    border-color: #666;
    outline: none;
}

.update-content {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.update-button {
    background-color: #fff;
    color: #006400;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.update-button:hover {
    background-color: #f0f0f0;
    transform: scale(1.05);
}

.update-button:active {
    transform: scale(0.95);
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Mobile optimizations for offline indicators */
@media (max-width: 480px) {
    .offline-indicator {
        top: 5px;
        right: 5px;
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .offline-text {
        font-size: 11px;
    }
    
    .update-notification {
        bottom: 15px;
        left: 10px;
        right: 10px;
        transform: none;
        padding: 10px 14px;
    }
    
    .update-content {
        font-size: 13px;
        gap: 10px;
    }
    
    .update-button {
        padding: 5px 10px;
        font-size: 11px;
    }
}
/* Err
or Handling and Recovery Notifications */
.recovery-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background-color: rgba(0, 100, 200, 0.9);
    border: 1px solid #4a8fcc;
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: slideDown 0.3s ease;
}

.recovery-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.recovery-icon {
    font-size: 16px;
}

.accuracy-warning {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background-color: rgba(255, 165, 0, 0.9);
    border: 1px solid #ffaa00;
    border-radius: 8px;
    padding: 8px 12px;
    color: #000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: slideDown 0.3s ease;
}

.warning-content {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}

.warning-icon {
    font-size: 14px;
}

.visual-announcement {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid currentColor;
    border-radius: 12px;
    padding: 20px 30px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: slideDown 0.3s ease;
}

.announcement-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.announcement-icon {
    font-size: 32px;
}

.announcement-text {
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 2px;
}

.audio-diagnostics {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1002;
    background-color: rgba(0, 0, 0, 0.95);
    border: 1px solid #444;
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.diagnostics-content h3 {
    margin-bottom: 15px;
    color: #fff;
    font-size: 18px;
}

.diagnostics-content pre {
    background-color: #222;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-wrap;
    margin-bottom: 15px;
    color: #ccc;
}

.diagnostics-content button {
    background-color: #444;
    color: #fff;
    border: 1px solid #666;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.diagnostics-content button:hover {
    background-color: #555;
    border-color: #777;
}

/* Flash animation for visual announcements */
@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -100%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Mobile optimizations for error notifications */
@media (max-width: 480px) {
    .recovery-notification,
    .accuracy-warning {
        left: 10px;
        right: 10px;
        transform: none;
        max-width: calc(100vw - 20px);
    }
    
    .visual-announcement {
        left: 10px;
        right: 10px;
        transform: translateY(-50%);
        max-width: calc(100vw - 20px);
    }
    
    .audio-diagnostics {
        left: 10px;
        right: 10px;
        transform: translateY(-50%);
        max-width: calc(100vw - 20px);
        padding: 15px;
    }
    
    .diagnostics-content pre {
        font-size: 11px;
    }
}