/* Responsive Styles - Color Splash Game */
/* Mobile, tablet, and accessibility optimizations */

/* Base responsive utilities */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Mobile-first responsive breakpoints */
@media (max-width: 480px) {
    /* Extra small mobile devices */
    .header {
        padding: 10px 0;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-logo h1 {
        font-size: 1.8em;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .nav-btn {
        padding: 6px 10px; /* Reduced from 8px 12px */
        font-size: 0.85em; /* Reduced from 0.9em */
    }
    
    /* Game layout adjustments - vertical stack for very small screens */
    .game-layout {
        flex-direction: column;
        gap: 15px;
        padding: 10px;
    }
      .tools-panel {
        order: 2;
        width: 100%;
        padding: 12px; /* Reduced from 15px */
        border-radius: 12px; /* Reduced from 15px */
        max-height: 400px;
    }

    .canvas-container {
        order: 1;
        margin: 0;
        padding: 12px; /* Reduced from 15px */
        min-height: 300px;
    }

    .education-panel {
        order: 3;
        width: 100%;
        padding: 12px; /* Reduced from 15px */
    }
      /* Simplify tool layout for small screens */
    .brush-tools {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px; /* Reduced from 8px */
    }

    .tool-btn {
        padding: 8px 4px; /* Further reduced from 10px 5px */
        min-height: 55px; /* Further reduced from 65px */
        font-size: 0.68em; /* Further reduced from 0.75em */
    }

    .tool-icon {
        font-size: 1.2em; /* Further reduced from 1.4em */
    }
    
    /* Larger touch targets */
    .color-btn {
        width: 36px; /* Further reduced from 40px */
        height: 36px; /* Further reduced from 40px */
        margin: 2px;
    }
    
    .primary-colors {
        justify-content: space-around;
    }
    
    /* Simplified mixing interface */
    .mix-area {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .mix-slot,
    .mix-result {
        width: 50px;
        height: 50px;
    }
    
    /* Age selector optimization */
    .age-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .age-btn {
        width: 100%;
        padding: 15px;
        font-size: 1.1em;
    }
    
    /* Mode cards stack vertically */
    .mode-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .mode-card {
        padding: 20px;
    }
    
    /* Canvas tools */
    .canvas-tools {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        margin-top: 10px;
    }
    
    .selected-color {
        width: 35px;
        height: 35px;
    }
    
    .selected-tool {
        font-size: 1em;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    /* Small tablets and large mobile devices */
    .nav-container {
        flex-wrap: wrap;
        justify-content: space-between;
        padding: 0 15px;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .nav-btn {
        padding: 12px 16px;
        font-size: 0.95em;
        min-height: 44px; /* iOS recommended touch target */
    }
    
    .game-layout {
        flex-direction: row;
        gap: 20px;
        padding: 20px;
    }
    
    .tools-panel {
        width: 280px;
        max-height: 75vh;
        overflow-y: auto;
        order: 1;
        flex-shrink: 0;
        scroll-padding: 20px;
    }
    
    .canvas-container {
        order: 2;
        flex: 1;
        margin: 0;
        min-height: 450px;
        display: flex;
        flex-direction: column;
    }
    
    .education-panel {
        order: 3;
        width: 280px;
        flex-shrink: 0;
        max-height: 75vh;
        overflow-y: auto;
    }
    
    /* Enhanced tool grid for tablets */
    .brush-tools {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .tool-btn {
        padding: 18px 10px;
        min-height: 88px;
        font-size: 0.9em;
        transition: all 0.2s ease;
    }
    
    .tool-icon {
        font-size: 2em;
        margin-bottom: 6px;
    }
    
    /* Color grid optimization */
    .primary-colors,
    .mixed-colors {
        gap: 10px;
        justify-content: center;
    }
    
    .color-btn {
        width: 50px;
        height: 50px;
    }
    
    /* Mode grid for tablets */
    .mode-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .age-buttons {
        flex-direction: row;
        justify-content: center;
        gap: 15px;
    }
    
    .age-btn {
        flex: 1;
        max-width: 200px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    /* iPad and large tablets (Portrait: 768x1024, Landscape: 1024x768) */
    body {
        font-size: 16px;
    }
    
    .header {
        padding: 12px 0;
    }
    
    .nav-container {
        padding: 0 20px;
    }
    
    .nav-btn {
        padding: 12px 18px; /* Reduced from 14px 20px */
        font-size: 0.95em; /* Reduced from 1em */
        min-height: 40px; /* Reduced from 44px */
    }
    
    .game-layout {
        gap: 18px; /* Reduced from 20px */
        padding: 18px; /* Reduced from 20px */
    }
    
    .tools-panel {
        width: 180px; /* Updated to match new size */
        padding: 12px; /* Reduced from 15px */
        border-radius: 10px; /* Reduced from 12px */
    }
    
    .education-panel {
        width: 180px; /* Updated to match new size */
        padding: 12px; /* Reduced from 15px */
        border-radius: 10px; /* Reduced from 12px */
    }
    
    .canvas-container {
        flex: 1;
        margin: 0 8px; /* Reduced from 10px */
        min-height: 500px;
        padding: 18px; /* Reduced from 20px */
        border-radius: 12px; /* Reduced from 15px */
    }
    
    /* Optimal tool layout for iPad with smaller sizes */
    .brush-tools {
        grid-template-columns: 1fr 1fr;
        gap: 10px; /* Reduced from 12px */
    }
    
    .tool-btn {
        padding: 12px 8px; /* Further reduced from 14px 10px */
        min-height: 60px; /* Further reduced from 70px */
        font-size: 0.75em; /* Further reduced from 0.85em */
        border-radius: 8px; /* Further reduced from 10px */
        transition: all 0.3s ease;
    }
    
    .tool-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    .tool-icon {
        font-size: 1.5em; /* Further reduced from 1.8em */
        margin-bottom: 4px; /* Further reduced from 6px */
    }
    
    /* Enhanced color buttons for touch but smaller */
    .color-btn {
        width: 38px; /* Further reduced from 45px */
        height: 38px; /* Further reduced from 45px */
        margin: 2px; /* Further reduced from 3px */
        border-radius: 8px; /* Further reduced from 10px */
        transition: all 0.2s ease;
    }
    
    .color-btn:active {
        transform: scale(0.9);
    }
    
    /* Canvas controls optimization */
    .canvas-tools {
        gap: 12px; /* Reduced from 15px */
        padding: 12px; /* Reduced from 15px */
        background: rgba(255, 255, 255, 0.1);
        border-radius: 12px; /* Reduced from 15px */
        margin-bottom: 12px; /* Reduced from 15px */
    }
    
    .selected-color {
        width: 42px; /* Reduced from 50px */
        height: 42px; /* Reduced from 50px */
        border-radius: 10px; /* Reduced from 12px */
    }
    
    .brush-size-slider {
        width: 120px; /* Reduced from 150px */
        height: 6px; /* Reduced from 8px */
    }
    
    /* Mode selection for iPad */
    .mode-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px; /* Reduced from 30px */
    }
    
    .mode-card {
        padding: 25px; /* Reduced from 30px */
        border-radius: 15px; /* Reduced from 20px */
        min-height: 160px; /* Reduced from 180px */
        transition: all 0.3s ease;
    }
    
    .mode-card:active {
        transform: scale(0.98);
    }
    
    .mode-icon {
        font-size: 2.5em; /* Reduced from 3em */
        margin-bottom: 12px; /* Reduced from 15px */
    }
    
    /* Age selector optimization */
    .age-buttons {
        gap: 15px; /* Reduced from 20px */
    }
    
    .age-btn {
        padding: 15px 25px; /* Reduced from 20px 30px */
        font-size: 1em; /* Reduced from 1.1em */
        min-height: 50px; /* Reduced from 60px */
        border-radius: 12px; /* Reduced from 15px */
    }
    
    /* Enhanced scrolling for touch */
    .tools-panel,
    .education-panel {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        scrollbar-width: thin;
    }
    
    /* Tool sections spacing */
    .tool-section {
        margin-bottom: 18px; /* Reduced from 25px */
        padding: 12px; /* Reduced from 15px */
        border-radius: 10px; /* Reduced from 15px */
    }
    
    .tool-section h3 {
        font-size: 1em; /* Reduced from 1.1em */
        margin-bottom: 12px; /* Reduced from 15px */
    }
}

@media (min-width: 1025px) {
    /* Large screens and desktops */
    .game-layout {
        gap: 25px;
    }
    
    .tools-panel,
    .education-panel {
        width: 300px;
    }
    
    .canvas-container {
        margin: 0 15px;
    }
    
    /* Enhanced desktop experience */
    .brush-tools {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .tool-btn {
        padding: 16px 12px;
        min-height: 90px;
    }
    
    .color-btn {
        width: 50px;
        height: 50px;
    }
    
    .mode-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
}

/* Collapsible Education Panel */
.panel-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 15px;
    padding: 5px 0;
}

.collapse-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 5px; /* Reduced from 6px */
    padding: 5px 8px; /* Reduced from 6px 10px */
    cursor: pointer;
    color: white;
    font-size: 11px; /* Reduced from 12px */
    transition: all 0.3s ease;
    min-height: 28px; /* Reduced from 32px */
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.collapse-btn:active {
    transform: scale(0.95);
}

.collapse-icon {
    transition: transform 0.3s ease;
    font-weight: bold;
}

/* Education Panel Collapsed State */
.education-panel.collapsed {
    width: 35px !important; /* Reduced from 40px */
    min-width: 35px; /* Reduced from 40px */
    padding: 8px 4px; /* Reduced padding */
    overflow: hidden;
    transition: all 0.3s ease;
}

.education-panel.collapsed .education-section {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.education-panel.collapsed .panel-header {
    margin-bottom: 0;
    justify-content: center;
}

.education-panel.collapsed .collapse-btn {
    padding: 5px; /* Reduced from 6px */
    min-width: 26px; /* Reduced from 30px */
}

/* Canvas Container Expanded State */
.canvas-container.expanded {
    margin-right: 45px !important; /* Reduced to match new collapsed width */
    transition: margin 0.3s ease;
}

/* Smaller Panel Sizes and Icons */
.tools-panel,
.education-panel {
    width: 180px; /* Significantly reduced from 220px */
    padding: 8px; /* Reduced from 10px */
}

.tool-section {
    margin-bottom: 10px; /* Reduced from 12px */
    padding: 6px; /* Reduced from 8px */
    border-radius: 5px; /* Reduced from 6px */
}

.tool-section h3 {
    font-size: 0.8em; /* Reduced from 0.85em */
    margin-bottom: 6px; /* Reduced from 8px */
}

/* Smaller Tool Buttons */
.tool-btn {
    padding: 6px 4px; /* Further reduced from 8px 5px */
    min-height: 45px; /* Further reduced from 55px */
    font-size: 0.65em; /* Further reduced from 0.7em */
    border-radius: 5px; /* Further reduced from 6px */
}

.tool-icon {
    font-size: 1.1em; /* Further reduced from 1.3em */
    margin-bottom: 1px; /* Further reduced from 2px */
}

.tool-name {
    font-size: 0.6em; /* Further reduced from 0.65em */
}

/* Smaller Color Buttons */
.color-btn {
    width: 26px; /* Further reduced from 30px */
    height: 26px; /* Further reduced from 30px */
    margin: 1px; /* Reduced from 2px */
    border-radius: 4px; /* Further reduced from 5px */
}

/* Smaller Brush Tools Grid */
.brush-tools {
    gap: 3px; /* Further reduced from 5px */
}

/* Smaller Primary Colors Layout */
.primary-colors,
.mixed-colors {
    gap: 2px; /* Further reduced from 3px */
    padding: 3px; /* Further reduced from 4px */
}

/* Smaller Mix Area */
.mix-area {
    gap: 6px; /* Reduced from 8px */
    padding: 6px; /* Reduced from 8px */
}

.mix-slot,
.mix-result {
    width: 28px; /* Further reduced from 32px */
    height: 28px; /* Further reduced from 32px */
    border-radius: 4px; /* Further reduced from 5px */
}

.mix-operator,
.mix-equals {
    font-size: 0.9em; /* Reduced from 1em */
}

/* Smaller Achievement Icons */
.achievement-icon {
    font-size: 1.4em; /* Reduced from 1.6em */
    width: 28px; /* Reduced from 32px */
    height: 28px; /* Reduced from 32px */
}

.achievement {
    padding: 6px; /* Reduced from 8px */
    margin-bottom: 5px; /* Reduced from 6px */
    border-radius: 5px; /* Reduced from 6px */
}

.achievement-name {
    font-size: 0.75em; /* Reduced from 0.8em */
}

.achievement-desc {
    font-size: 0.65em; /* Reduced from 0.7em */
}

/* Smaller Canvas Tools */
.canvas-tools {
    gap: 10px; /* Reduced from 12px */
    padding: 10px; /* Reduced from 12px */
    border-radius: 10px; /* Reduced from 12px */
}

.selected-color {
    width: 36px; /* Reduced from 40px */
    height: 36px; /* Reduced from 40px */
    border-radius: 8px; /* Reduced from 10px */
}

.selected-tool {
    font-size: 0.85em; /* Reduced from 0.9em */
}

/* Brush Size Controls */
.size-controls {
    padding: 6px; /* Reduced from 8px */
}

.size-display {
    font-size: 0.8em; /* Reduced from 0.85em */
    gap: 6px; /* Reduced from 8px */
}

.size-preview {
    min-width: 18px; /* Reduced from 20px */
    min-height: 18px; /* Reduced from 20px */
}

/* Compact Education Content */
.education-content {
    padding: 10px; /* Reduced from 12px */
    line-height: 1.3; /* Reduced from 1.4 */
}

.education-content h3 {
    font-size: 1em; /* Reduced from 1.1em */
    margin-bottom: 8px; /* Reduced from 10px */
}

.education-content p {
    font-size: 0.9em; /* Reduced from 0.95em */
    margin-bottom: 6px; /* Reduced from 8px */
}

/* Challenges Section Smaller */
.challenges-list {
    gap: 6px; /* Reduced from 8px */
}

.challenge-btn {
    padding: 6px 10px; /* Reduced from 8px 12px */
    font-size: 0.8em; /* Reduced from 0.85em */
    min-height: 32px; /* Reduced from 36px */
}

/* Light Explorer Smaller */
.prism-container {
    height: 70px; /* Reduced from 80px */
}

.prism {
    font-size: 1.3em; /* Reduced from 1.5em */
}

.rainbow-band {
    height: 6px; /* Reduced from 8px */
}

/* Responsive adjustments for smaller panels */
@media (min-width: 769px) and (max-width: 1024px) {
    .tools-panel,
    .education-panel {
        width: 170px; /* Even smaller for tablets */
        padding: 8px;
    }
    
    .tool-btn {
        min-height: 55px;
        padding: 8px 4px;
    }
    
    .tool-icon {
        font-size: 1.3em;
    }
    
    .color-btn {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 768px) {
    .education-panel.collapsed {
        display: none; /* Hide completely on mobile */
    }
    
    .canvas-container.expanded {
        margin-right: 0 !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Enhanced touch targets for better iPad experience */
    .nav-btn,
    .btn {
        padding: 15px 24px;
        font-size: 1em;
        min-height: 44px; /* iOS recommended minimum */
        border-radius: 12px;
        transition: all 0.2s ease;
    }
    
    .tool-btn {
        padding: 20px 15px;
        min-height: 100px;
        border-radius: 15px;
        transition: all 0.2s ease;
        touch-action: manipulation; /* Prevents double-tap zoom */
    }
    
    .color-btn {
        width: 60px;
        height: 60px;
        margin: 5px;
        border-radius: 12px;
        transition: all 0.2s ease;
        touch-action: manipulation;
    }
    
    .age-btn {
        padding: 20px 30px;
        font-size: 1.2em;
        min-height: 60px;
        border-radius: 15px;
        touch-action: manipulation;
    }
    
    .mode-card {
        padding: 30px;
        border-radius: 20px;
        min-height: 200px;
        transition: all 0.3s ease;
        touch-action: manipulation;
    }
    
    /* Remove hover effects that don't work on touch */
    .tool-btn:hover,
    .color-btn:hover,
    .nav-btn:hover,
    .mode-card:hover {
        transform: none;
        box-shadow: inherit;
    }
    
    /* Enhanced touch feedback with better timing */
    .tool-btn:active,
    .color-btn:active,
    .btn:active,
    .age-btn:active,
    .mode-card:active {
        transform: scale(0.95);
        opacity: 0.8;
        transition: all 0.1s ease;
    }
    
    /* Canvas-specific touch optimizations */
    #painting-canvas {
        touch-action: none; /* Prevents scrolling when drawing */
        -webkit-touch-callout: none; /* Prevents touch callout */
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Brush size slider for touch */
    .brush-size-slider {
        height: 12px;
        border-radius: 6px;
        touch-action: manipulation;
    }
    
    .brush-size-slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
        border-radius: 12px;
        cursor: pointer;
    }
    
    /* Better spacing for touch elements */
    .primary-colors,
    .mixed-colors {
        gap: 8px;
        padding: 10px;
    }
    
    .mix-area {
        gap: 15px;
        padding: 15px;
    }
    
    .mix-slot,
    .mix-result {
        width: 60px;
        height: 60px;
        border-radius: 12px;
        touch-action: manipulation;
    }
    
    /* Improved scrolling */
    .tools-panel,
    .education-panel {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overscroll-behavior: contain;
    }
    
    /* Enhanced notification positioning for tablets */
    .achievement-notification,
    .challenge-hint,
    .save-message {
        max-width: 80vw;
        padding: 20px;
        border-radius: 15px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    }
    
    /* Better canvas tools layout for touch */
    .canvas-tools {
        padding: 15px;
        border-radius: 15px;
        gap: 20px;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
    }
    
    .selected-color {
        width: 50px;
        height: 50px;
        border-radius: 12px;
        touch-action: manipulation;
    }
    
    /* Undo/Redo buttons optimization */
    .canvas-controls button {
        min-height: 44px;
        padding: 12px 16px;
        margin: 5px;
        border-radius: 10px;
        font-size: 1em;
        touch-action: manipulation;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure crisp rendering on retina displays */
    #painting-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    .color-btn,
    .tool-btn {
        border-width: 1px; /* Thinner borders look better on high DPI */
    }
}

/* Accessibility features */
@media (prefers-reduced-motion: reduce) {
    /* Disable animations for users who prefer reduced motion */
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .floating-color {
        animation: none !important;
    }
    
    .turn-indicator {
        animation: none !important;
    }
}

@media (prefers-high-contrast: high) {
    /* Enhanced contrast for accessibility */
    .color-btn {
        border-width: 3px;
        border-color: #000 !important;
    }
    
    .tool-btn {
        border: 2px solid #000 !important;
        background: #fff !important;
        color: #000 !important;
    }
    
    .tool-btn.active {
        background: #000 !important;
        color: #fff !important;
    }
}

/* Print styles */
@media print {
    .header,
    .nav-container,
    .tools-panel,
    .education-panel,
    .game-controls {
        display: none !important;
    }
    
    .game-layout {
        flex-direction: column;
    }
    
    .canvas-container {
        width: 100%;
        margin: 0;
        box-shadow: none;
        border: 2px solid #000;
    }
    
    #painting-canvas {
        max-width: 100%;
        border: 1px solid #000;
    }
    
    .canvas-tools {
        display: none;
    }
}

/* Custom scroll bars for webkit browsers */
.tools-panel::-webkit-scrollbar,
.education-panel::-webkit-scrollbar {
    width: 8px;
}

.tools-panel::-webkit-scrollbar-track,
.education-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.tools-panel::-webkit-scrollbar-thumb,
.education-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.tools-panel::-webkit-scrollbar-thumb:hover,
.education-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Focus management for keyboard navigation */
.tool-btn:focus,
.color-btn:focus,
.nav-btn:focus,
.btn:focus {
    outline: 3px solid #4ecdc4;
    outline-offset: 2px;
    z-index: 10;
    position: relative;
}

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: #000;
    color: #fff;
    padding: 10px;
    text-decoration: none;
    z-index: 9999;
}

.skip-link:focus {
    left: 0;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Notification styles for all screen sizes */
.achievement-notification,
.challenge-hint,
.save-message {
    position: fixed;
    z-index: 1000;
    transform: translate(-50%, -50%);
    left: 50%;
    top: 50%;
    max-width: 90vw;
    text-align: center;
}

@media (max-width: 480px) {
    .achievement-notification,
    .challenge-hint,
    .save-message {
        max-width: 95vw;
        top: 20%;
    }
    
    .notification-content,
    .save-content {
        padding: 20px;
        font-size: 0.9em;
    }
    
    .notification-icon,
    .save-icon {
        font-size: 1.5em;
    }
}

/* Utility classes for responsive design */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

/* Loading states */
.loading {
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid #4ecdc4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* iPad-specific optimizations */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    body {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Prevent zoom on form elements */
    input, select, textarea {
        font-size: 16px !important;
    }
    
    /* Better canvas handling on iOS */
    #painting-canvas {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        touch-action: none;
    }
}

/* iPad Air and iPad Pro optimizations */
@media screen and (min-width: 820px) and (max-width: 1180px) {
    .game-layout {
        max-width: 1100px;
        margin: 0 auto;
        padding: 30px;
    }
    
    .tools-panel,
    .education-panel {
        width: 280px;
        padding: 25px;
    }
    
    .canvas-container {
        min-height: 600px;
        padding: 30px;
    }
    
    .tool-btn {
        min-height: 95px;
        font-size: 1em;
    }
    
    .mode-card {
        min-height: 220px;
        padding: 35px;
    }
}

/* Additional touch optimizations for all tablet sizes */
@media (pointer: coarse) {
    /* Ensure all interactive elements are large enough */
    .challenge-btn,
    .spectrum-btn,
    .coop-btn {
        min-height: 50px;
        padding: 15px 25px;
        font-size: 1.1em;
        border-radius: 12px;
        touch-action: manipulation;
    }
    
    /* Optimize color mixing interface */
    .mix-btn {
        min-height: 50px;
        padding: 12px 20px;
        font-size: 1em;
        border-radius: 10px;
        touch-action: manipulation;
    }
    
    /* Better navigation for tablets */
    .nav-logo h1 {
        font-size: 2.2em;
        touch-action: manipulation;
    }
    
    /* Enhanced education panel for touch */
    .education-content {
        padding: 20px;
        line-height: 1.6;
    }
    
    .education-content h3 {
        font-size: 1.3em;
        margin-bottom: 15px;
    }
    
    .education-content p {
        font-size: 1.1em;
        margin-bottom: 12px;
    }
}

/* Prevent overscroll bounce on iOS */
@supports (-webkit-overflow-scrolling: touch) {
    body {
        position: fixed;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    
    .app-container {
        height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tools-panel,
    .education-panel {
        overscroll-behavior: contain;
    }
}

/* Orientation change handling */
@media screen and (orientation: portrait) {
    .game-layout {
        min-height: calc(100vh - 120px);
    }
}

@media screen and (orientation: landscape) {
    .game-layout {
        min-height: calc(100vh - 80px);
    }
    
    .header {
        padding: 8px 0;
    }
}

/* Tablet-specific class optimizations */
.tablet-device .game-layout {
    padding: 20px; /* Reduced from 25px */
    gap: 20px; /* Reduced from 25px */
}

.tablet-device .tool-btn {
    min-height: 75px; /* Reduced from 90px */
    padding: 14px 12px; /* Reduced from 18px 15px */
    font-size: 0.9em; /* Reduced from 1em */
    transition: all 0.2s ease;
}

.tablet-device .tool-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

.tablet-device .color-btn {
    width: 45px; /* Reduced from 55px */
    height: 45px; /* Reduced from 55px */
    margin: 3px; /* Reduced from 4px */
    transition: all 0.2s ease;
}

.tablet-device .color-btn:active {
    transform: scale(0.9);
    transition: transform 0.1s ease;
}

.tablet-device .canvas-container {
    padding: 25px; /* Reduced from 30px */
    border-radius: 15px; /* Reduced from 20px */
}

.tablet-device #painting-canvas {
    border-radius: 12px; /* Reduced from 15px */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1); /* Reduced shadow */
}

.tablet-device .mode-card {
    padding: 25px; /* Reduced from 30px */
    border-radius: 15px; /* Reduced from 20px */
    transition: all 0.3s ease;
}

.tablet-device .mode-card:active {
    transform: scale(0.98);
}

.tablet-device .nav-btn {
    padding: 12px 16px; /* Reduced from 15px 20px */
    border-radius: 10px; /* Reduced from 12px */
    font-size: 0.95em; /* Reduced from 1em */
}

.tablet-device .age-btn {
    padding: 15px 20px; /* Reduced from 18px 25px */
    border-radius: 12px; /* Reduced from 15px */
    font-size: 1em; /* Reduced from 1.1em */
}

/* Tablet layout optimizations */
.tablet-optimized {
    min-height: calc(var(--vh, 1vh) * 100 - 120px);
}

.tablet-optimized .tools-panel,
.tablet-optimized .education-panel {
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.tablet-optimized .tool-section {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

/* Enhanced scrollbar for tablets */
.tablet-device .tools-panel::-webkit-scrollbar,
.tablet-device .education-panel::-webkit-scrollbar {
    width: 12px;
}

.tablet-device .tools-panel::-webkit-scrollbar-thumb,
.tablet-device .education-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 6px;
}

.tablet-device .tools-panel::-webkit-scrollbar-thumb:hover,
.tablet-device .education-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.6);
}
