/* ======= BASE STYLES ======= */
:root {
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --primary-color: #4a6fa5;
    --secondary-color: #4fc3dc;
    --accent-color: #4a6fa5;
    --accent-color-hover: #355a8e;
    --border-color: #e1e1e1;
    --card-bg: #ffffff;
    --secondary-bg: #ffffff;
    --panel-bg: #ffffff;
    --header-height: 60px;
    --controls-width: 320px;
    --transition-fast: 0.15s;
    --transition-normal: 0.25s;
    --transition-slow: 0.4s;
    --primary-bg: #f5f5f5;
    --primary-text: #121224;
    --secondary-accent: #4fc3dc;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --panel-width: 320px;
    --status-bar-height: 24px;
    --mobile-controls-height: 70px;
    --color-info: #3498db;
    --color-success: #2ecc71;
    --color-warning: #f39c12;
    --color-error: #e74c3c;
    --button-bg: #ffffff;
    --button-text: #212529;
    --button-border: #e1e1e1;
    --button-hover: #f5f5f5;
    
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-heading: 'Montserrat', var(--font-primary);
}

/* Dark theme variables */
.dark-theme {
    --bg-color: #121224;
    --text-color: #f8f9fa;
    --secondary-bg: #202040;
    --panel-bg: #202040;
    --card-bg: #282850;
    --border-color: #303050;
    --primary-bg: #151530;
    --button-bg: #2a2a50;
    --button-text: #f8f9fa;
    --button-border: #303050;
    --button-hover: #353570;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --primary-text: #f8f9fa;
}

/* Dark theme specific overrides - force white text and icons */
.dark-theme button, 
.dark-theme .tool-button, 
.dark-theme #toggle-controls,
.dark-theme .info-button,
.dark-theme .zoom-btn,
.dark-theme .theme-toggle,
.dark-theme label,
.dark-theme h3,
.dark-theme .slider-value,
.dark-theme .fractal-select,
.dark-theme .fractal-selector,
.dark-theme .performance-info,
.dark-theme .status-text,
.dark-theme .status-bar,
.dark-theme .zoom-level,
.dark-theme .webgl-info p {
    color: #f8f9fa !important;
}

.dark-theme .tool-button i,
.dark-theme #toggle-controls i,
.dark-theme .info-button i,
.dark-theme .zoom-btn i,
.dark-theme .theme-toggle i,
.dark-theme .fractal-selector i,
.dark-theme .control-group h3 i,
.dark-theme .status-bar i {
    color: #f8f9fa !important;
}

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

html, body {
    font-family: var(--font-primary);
    font-size: 16px;
    color: var(--primary-text);
    background-color: var(--primary-bg);
    overscroll-behavior: none;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

button, select, input {
    font-family: var(--font-primary);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
}

/* ======= HEADER ======= */
.app-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background-color: var(--secondary-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    box-shadow: 0 2px 4px var(--shadow-color);
    position: relative;
    touch-action: auto;
    pointer-events: auto;
}

.app-header h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Styling for the site title link */
.site-title {
    color: inherit;
    text-decoration: none;
    transition: opacity var(--transition-fast) ease;
}

.site-title:hover {
    opacity: 0.9;
}

.webgl-badge {
    background: linear-gradient(45deg, var(--accent-color), var(--secondary-accent));
    color: white;
    font-size: 0.65rem;
    padding: 3px 6px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mobile WebGL badge */
.mobile-only.webgl-badge {
    display: inline-block;
    margin: 0 auto 16px auto;
    font-size: 0.75rem;
    padding: 4px 8px;
    text-align: center;
}

.app-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    flex-direction: row;
    z-index: 101;
    position: relative;
}

/* Ensure all buttons in the header are clickable */
.fractal-selector, .tool-button, #toggle-controls, .theme-toggle, .info-button-header {
    position: relative;
    z-index: 102;
    touch-action: auto;
    pointer-events: auto;
}

/* ======= MAIN CONTENT ======= */
.app-main {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal) ease;
}

.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    background-color: var(--bg-color);
}

#fractal-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.info-button {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    background-color: rgba(0, 0, 0, 0.3);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    cursor: pointer;
    font-size: 1.25rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: background-color var(--transition-fast) ease, transform var(--transition-fast) ease;
    user-select: none;
    text-decoration: none; /* Remove underline from links */
}

.info-button:hover {
    background-color: rgba(0, 0, 0, 0.5);
    transform: scale(1.05);
}

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

/* Specific style for the info button in the header */
.info-button-header {
    position: relative !important;  
    top: auto !important;
    bottom: auto !important;
    right: auto !important;
    margin: 0 !important;
    margin-right: 8px !important;
    background-color: var(--secondary-bg) !important;
    color: var(--primary-text) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: none !important;
    order: -1 !important; /* Make it appear before other elements */
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.info-button-header i {
    font-size: 1.6rem !important;
    line-height: 0 !important; /* This fixes the vertical alignment */
}

.info-button-header:hover {
    background-color: var(--secondary-bg) !important;
    border-color: var(--accent-color) !important;
    transform: scale(1.05);
}

.fractal-selector {
    position: relative;
    display: flex;
    align-items: center;
}

.fractal-selector .info-button-header {
    margin-right: 8px !important;
}

.fractal-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 32px 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--primary-text);
    transition: all var(--transition-fast) ease;
    touch-action: manipulation;
    pointer-events: auto;
}

.fractal-select:hover {
    border-color: var(--accent-color);
}

.fractal-selector i {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--primary-text);
    opacity: 0.7;
}

.tool-button, #toggle-controls {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    color: var(--primary-text);
    touch-action: manipulation;
    pointer-events: auto;
}

.tool-button:hover, #toggle-controls:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.tool-button:active, #toggle-controls:active {
    transform: scale(0.95);
}

.dark-mode-toggle {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    cursor: pointer;
    overflow: hidden;
}

.dark-mode-toggle::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 8px;
    width: 18px;
    height: 18px;
    background-color: var(--primary-text);
    border-radius: 50%;
    transition: all var(--transition-normal) ease;
}

.dark-theme .dark-mode-toggle::before {
    transform: translateX(16px);
    box-shadow: -10px 0 0 -4px var(--primary-text);
}

/* ======= CONTROLS PANEL ======= */
.controls-panel {
    position: fixed;
    right: 0;
    top: var(--header-height);
    width: var(--controls-width);
    height: calc(100vh - var(--header-height));
    background-color: var(--panel-bg);
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 20;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

.controls-panel.collapsed {
    transform: translateX(100%);
}

.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    background-color: var(--bg-color);
}

#fractal-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.scroll-tip {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    text-align: center;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 100;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity var(--transition-normal) ease, transform var(--transition-normal) ease;
    pointer-events: none;
    display: none; /* Hide by default on all screen sizes */
}

.scroll-tip.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Show scroll tip only on mobile */
@media (max-width: 768px) {
    .scroll-tip {
        display: block; /* Show only on mobile */
    }
}

.controls-content {
    padding: 16px;
    padding-bottom: 60px; /* Extra padding at bottom for scrolling space */
    overscroll-behavior: contain; /* Prevent body scroll when reaching the edges */
    touch-action: pan-y; /* Allow vertical touch panning */
    -webkit-overflow-scrolling: touch; /* For iOS momentum scrolling */
}

.control-group {
    margin-bottom: 24px;
}

.control-group h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group h3 i {
    color: var(--accent-color);
}

.slider-control {
    margin-bottom: 24px;
}

.slider-control label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.slider-value {
    font-family: monospace;
    opacity: 0.9;
}

.slider-input {
    width: 100%;
    -webkit-appearance: none;
    height: 8px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    transition: all var(--transition-fast) ease;
}

.slider-input::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    border: none;
}

.slider-input::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--accent-color-hover);
}

.slider-input::-moz-range-thumb:hover {
    transform: scale(1.1);
    background: var(--accent-color-hover);
}

.color-control {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.color-control label {
    font-size: 0.9rem;
}

.color-input {
    -webkit-appearance: none;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    min-width: 44px;
    min-height: 44px;
}

.color-input::-webkit-color-swatch {
    border: 2px solid var(--border-color);
    border-radius: 4px;
}

.color-input::-moz-color-swatch {
    border: 2px solid var(--border-color);
    border-radius: 4px;
}

.check-control {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    cursor: pointer;
    min-height: 44px;
}

.check-control input {
    cursor: pointer;
    margin-right: 12px;
    width: 24px;
    height: 24px;
}

.check-control label {
    font-size: 0.9rem;
    user-select: none;
}

.button-control {
    margin-bottom: 16px;
}

.full-width-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color var(--transition-fast) ease;
}

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

.full-width-btn:active {
    transform: scale(0.98);
}

/* ======= BOTTOM STATUS BAR ======= */
.status-bar {
    height: var(--status-bar-height);
    background-color: var(--secondary-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--primary-text);
    opacity: 0.8;
}

/* ======= PERFORMANCE INFO ======= */
.performance-info {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: monospace;
    z-index: 10;
    display: flex;
    gap: 10px;
}

/* ======= ZOOM CONTROLS ======= */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 2px 10px var(--shadow-color);
    overflow: hidden;
    z-index: 50;
}

.zoom-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 38px;
    height: 38px;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: 1px solid var(--button-border);
    font-size: 1.25rem;
    cursor: pointer;
    transition: background-color var(--transition-fast) ease;
    padding: 0;
    position: relative;
    user-select: none;
}

.zoom-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: transparent;
    transition: background-color var(--transition-fast) ease;
}

.zoom-btn:hover {
    background-color: var(--button-hover);
}

.zoom-btn:active, .zoom-btn.touch-active {
    background-color: var(--button-hover);
}

.zoom-level {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    user-select: none;
    background-color: var(--button-bg);
    height: 38px;
    border-left: 1px solid var(--button-border);
    border-right: 1px solid var(--button-border);
}

/* ======= NOTIFICATIONS ======= */
.notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transition: transform var(--transition-normal) ease, opacity var(--transition-normal) ease;
}

.notification.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.notification i {
    font-size: 1.2rem;
}

.success {
    background-color: rgba(46, 204, 113, 0.9);
}

.error {
    background-color: rgba(231, 76, 60, 0.9);
}

.info {
    background-color: rgba(52, 152, 219, 0.9);
}

/* ======= LOADING INDICATOR ======= */
.loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    color: white;
    gap: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal) ease;
}

.loading-indicator.active {
    opacity: 1;
    pointer-events: all;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--secondary-accent);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ======= WEBGL INFO ======= */
.webgl-info {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    padding: 12px;
    margin-top: 16px;
    margin-bottom: 16px;
}

.dark-theme .webgl-info {
    background-color: rgba(255, 255, 255, 0.05);
}

.webgl-info p {
    font-size: 0.8rem;
    margin-bottom: 8px;
    opacity: 0.8;
}

.webgl-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--color-error);
}

.status-indicator.active {
    background-color: var(--color-success);
}

.status-text {
    font-size: 0.8rem;
    font-weight: 500;
}

/* ====== RESPONSIVE DESIGN ====== */
@media (max-width: 1024px) {
    :root {
        --panel-width: 280px;
    }
}

@media (max-width: 768px) {
    .app-header h1 {
        font-size: 1.2rem;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .app-main {
        position: relative;
        width: 100%;
        height: calc(100vh - var(--header-height) - var(--status-bar-height));
        overflow: hidden;
    }
    
    .canvas-container {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 1; /* Behind the controls panel */
    }
    
    /* Ensure header controls have higher z-index on mobile */
    .app-header {
        z-index: 50; /* Higher z-index for mobile */
    }
    
    .app-controls {
        z-index: 51; /* Higher z-index for mobile */
        position: relative;
    }
    
    /* Increase touch target size for better mobile interaction */
    .tool-button, #toggle-controls, .theme-toggle, .fractal-select {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }
    
    .controls-panel {
        width: 100% !important;
        height: auto !important;
        max-height: 45vh !important; /* Maximum 45% of viewport height */
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: translateY(0) !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
        transition: transform 0.3s ease;
        z-index: 20;
        border-top: 1px solid var(--border-color);
        border-left: none;
        border-right: none;
    }
    
    .controls-panel.collapsed {
        transform: translateY(100%) !important; /* FORCE hide DOWNWARD on mobile */
    }
    
    .canvas-container {
        width: 100%;
    }
    
    .zoom-controls {
        bottom: 10px;
        left: 10px;
    }
    
    .mobile-only.webgl-badge {
        display: block;
        margin: 0 auto 15px auto;
        text-align: center;
        width: fit-content;
    }
    
    /* Fix dark mode toggle position for mobile */
    .mobile-only .dark-mode-toggle {
        display: inline-block;
        margin: 5px auto;
    }
    
    /* Enhanced touch targets for inputs */
    .color-control {
        margin-bottom: 20px; /* More space between controls */
    }
    
    .color-input {
        width: 44px; /* Larger touch target */
        height: 44px; /* Larger touch target */
        min-width: 44px; /* Ensure minimum size */
        min-height: 44px; /* Ensure minimum size */
    }
    
    .check-control {
        margin-bottom: 20px; /* More space between controls */
        min-height: 44px; /* Larger touch target */
    }
    
    .check-control input[type="checkbox"] {
        width: 24px; /* Larger checkbox */
        height: 24px; /* Larger checkbox */
        margin-right: 12px; /* More spacing */
    }
    
    .slider-control {
        margin-bottom: 24px; /* More space between controls */
    }
    
    .slider-input {
        height: 8px; /* Thicker slider track */
    }
    
    .slider-input::-webkit-slider-thumb {
        width: 24px; /* Larger thumb */
        height: 24px; /* Larger thumb */
    }
    
    .slider-input::-moz-range-thumb {
        width: 24px; /* Larger thumb */
        height: 24px; /* Larger thumb */
    }
    
    /* Fix mobile info button positioning */
    .info-button.mobile-only {
        display: flex !important;
        position: absolute !important;
        bottom: calc(var(--status-bar-height, 30px) + 45px) !important; /* Increased to 45px for more space above the footer */
        right: 16px !important;
        z-index: 10 !important;
        width: var(--mobile-info-button-size);
        height: var(--mobile-info-button-size);
    }
    
    /* Ensure icon is centered */
    .info-button.mobile-only i {
        font-size: 1.6rem !important;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
    }
    
    .zoom-level {
        font-size: 0.9rem;
        padding: 5px 10px;
        min-width: 60px;
        background-color: rgba(0, 0, 0, 0.5);
    }
}

@media (min-width: 769px) {
    /* Desktop */
    .mobile-only {
        display: none !important;
    }
    
    .mobile-tablet-only {
        display: none !important;
    }
}

/* Larger tablet-specific (769px-1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Hide the bottom-right info button on larger tablets */
    #info-button-mobile {
        display: none !important;
    }
}

/* Tablet-specific */
@media (min-width: 481px) and (max-width: 768px) {
    /* Tablet - show desktop-tablet items, hide mobile-only items */
    .desktop-tablet-only {
        display: flex !important;
    }
    
    .mobile-only {
        display: none !important; /* Ensure mobile-only items are hidden on tablet */
    }
    
    /* Hide the bottom-right info button on tablet */
    #info-button-mobile {
        display: none !important;
    }
}

/* Mobile-specific */
@media (max-width: 480px) {
    :root {
        --controls-width: 100%;
        --mobile-info-button-size: 48px;
    }
    
    .mobile-only {
        display: flex !important;
    }
    
    .mobile-only.flex-container {
        display: flex !important;
    }
    
    .desktop-tablet-only {
        display: none !important;
    }
    
    .app-header {
        padding: 0 12px;
    }
    
    .app-controls {
        gap: 8px;
    }
    
    .app-header h1 {
        font-size: 1rem;
    }
    
    .controls-panel {
        width: 100%;
    }
    
    .fractal-select {
        max-width: 120px;
        padding: 6px 28px 6px 8px;
        font-size: 0.8rem;
    }
    
    .tool-button, #toggle-controls, .dark-mode-toggle {
        width: 32px;
        height: 32px;
    }
    
    .performance-info {
        font-size: 0.65rem;
        padding: 3px 6px;
    }
    
    .zoom-controls {
        bottom: 10px;
        left: 10px;
    }
    
    .zoom-btn {
        width: 30px;
        height: 30px;
        /* Increase tap target size for better mobile usability */
        padding: 0;
        margin: 0 5px;
    }
    
    .status-bar {
        font-size: 0.7rem;
    }
    
    /* Fix mobile info button positioning */
    #info-button-mobile {
        display: flex !important;
        position: absolute !important;
        bottom: 8px !important; /* Much closer to the bottom/footer */
        right: 16px !important;
        z-index: 10 !important;
        width: var(--mobile-info-button-size);
        height: var(--mobile-info-button-size);
    }
}

/* ====== ANIMATION KEYFRAMES ====== */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

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

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

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Info button animation when clicked */
.info-button.clicked {
    animation: pulse 0.4s ease-in-out;
}

.theme-toggle {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    touch-action: manipulation;
    pointer-events: auto;
    z-index: 102;
}

/* Add touch feedback for interactive elements */
.touch-active {
    opacity: 0.7;
    transform: scale(0.97);
}

/* iOS-style toggle for mobile theme switching */
.ios-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    margin-left: auto;
    z-index: 100; /* Much higher z-index to ensure it's above other elements */
    cursor: pointer;
    touch-action: manipulation; /* Better touch behavior */
}

.ios-toggle input {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    z-index: 101; /* Even higher z-index for the actual input */
    cursor: pointer;
}

.ios-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
    z-index: 99; /* Keep slider under the input */
}

.ios-toggle-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ios-toggle input:checked + .ios-toggle-slider {
    background-color: var(--accent-color);
}

.ios-toggle input:checked + .ios-toggle-slider:before {
    transform: translateX(22px);
}

.mobile-theme-toggle {
    display: none;
    align-items: center;
    margin-left: 10px;
    z-index: 100; /* Increase z-index */
    position: relative; /* Needed for z-index to work */
}

.theme-label {
    font-size: 0.85rem;
    margin-right: 8px;
    color: var(--primary-text);
    opacity: 0.8;
    user-select: none;
    cursor: pointer;
    z-index: 100; /* Increase z-index */
}

/* Mobile/tablet specific styles */
@media (max-width: 480px) {
    /* Hide header theme toggle on mobile */
    .theme-toggle {
        display: none !important;
    }
    
    /* Show mobile theme toggle */
    .mobile-theme-toggle {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        flex: 1;
        min-width: 140px;
        padding: 5px; /* Add padding for larger touch area */
    }
    
    /* Make anti-aliasing container more accessible */
    .anti-aliasing-container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 24px;
        padding: 8px 0;
        width: 100%;
        border-radius: 4px;
        overflow: visible; /* Change to visible to ensure toggle is not cut off */
        position: relative; /* Needed for z-index to work properly */
        z-index: 10; /* Higher z-index */
    }
    
    .anti-aliasing-container .check-control {
        margin-bottom: 0;
        min-height: 36px;
        display: flex;
        align-items: center;
        flex: 1;
    }
    
    /* Make sure checkbox is visible and easier to tap */
    .anti-aliasing-container .check-control input[type="checkbox"] {
        width: 24px;
        height: 24px;
        margin-right: 8px;
    }
    
    /* Create a completely separate tappable area for theme toggle */
    .anti-aliasing-container:after {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        width: 50%; /* Cover the right half where toggle is */
        height: 100%;
        z-index: 1; /* Low z-index */
        pointer-events: none; /* Don't block interactions */
    }
}

.mobile-theme-toggle.super-tappable {
    width: 100%;
    padding: 10px;
    margin: 15px 0;
    background-color: rgba(0, 0, 0, 0.07);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dark-theme .mobile-theme-toggle.super-tappable {
    background-color: rgba(255, 255, 255, 0.07);
}

.mobile-theme-toggle.super-tappable:active {
    background-color: rgba(0, 0, 0, 0.14);
    transform: scale(0.98);
}

.dark-theme .mobile-theme-toggle.super-tappable:active {
    background-color: rgba(255, 255, 255, 0.14);
}

/* Make all elements inside the toggle tappable */
.super-tappable .ios-toggle,
.super-tappable .ios-toggle-slider,
.super-tappable .theme-label {
    pointer-events: none;
}

/* Desktop and tablet iOS-style toggle for the header */
.desktop-tablet-ios-toggle {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 6px;
    z-index: 102;
    height: 38px;
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.header-ios-toggle {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    margin: 0 4px;
    z-index: 100;
    cursor: pointer;
}

.header-ios-toggle input {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    z-index: 101;
    cursor: pointer;
}

.header-ios-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 34px;
    z-index: 99;
}

.header-ios-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.header-ios-toggle input:checked + .header-ios-toggle-slider {
    background-color: var(--accent-color);
}

.dark-theme .header-ios-toggle input:checked + .header-ios-toggle-slider {
    background-color: var(--accent-color);
}

.header-ios-toggle input:checked + .header-ios-toggle-slider:before {
    transform: translateX(22px);
}

.desktop-theme-icon {
    display: none; /* Hide the icons, use just the toggle */
}

/* Hide the old theme toggle on mobile screens */
@media (max-width: 480px) {
    .desktop-tablet-ios-toggle {
        display: none !important;
    }
}

.copyright-notice {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.7;
    padding: 16px 0;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
}

.dark-theme .copyright-notice {
    color: rgba(255, 255, 255, 0.7);
    border-top-color: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .copyright-notice {
        padding: 12px 0;
        margin-top: 15px;
        font-size: 0.7rem;
    }
}

/* Animation for the info button */
@keyframes pulsate {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.info-button.mobile-only {
    animation: pulsate 2s ease-in-out infinite;
}

.info-button:hover {
    animation: none;
}

/* Add a new media query to hide the mobile info button specifically on tablets */
@media (min-width: 481px) and (max-width: 1024px) {
    /* Hide the mobile-tablet info button on tablet screens */
    .mobile-tablet-only#info-button-mobile {
        display: none !important;
    }
}

/* Keep the mobile style for the bottom right button on mobile only */
@media (max-width: 480px) {
    .info-button.mobile-tablet-only {
        display: flex !important; 
        position: absolute;
        bottom: 16px;
        right: 16px;
        width: var(--mobile-info-button-size, 48px);
        height: var(--mobile-info-button-size, 48px);
    }
}

/* Add styling for the site title link */
.site-title {
    color: inherit;
    text-decoration: none;
    transition: opacity var(--transition-fast) ease;
}

.site-title:hover {
    opacity: 0.9;
}

/* Remove tap highlight on mobile and tablet devices */
button, 
select, 
input,
a,
.tool-button,
.info-button,
.zoom-btn,
.fractal-select,
.slider-input,
.ios-toggle,
[role="button"],
[tabindex="0"] {
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

/* Ensure focus styles are removed for touch devices but maintained for keyboard navigation */
@media (hover: none) {
    button:focus,
    select:focus,
    input:focus,
    a:focus,
    .tool-button:focus,
    .info-button:focus,
    .zoom-btn:focus,
    .fractal-select:focus,
    .slider-input:focus,
    .ios-toggle:focus,
    [role="button"]:focus,
    [tabindex="0"]:focus {
        outline: none;
        box-shadow: none;
    }
} 