/* Help Bot's Maze Adventure - Main Styles */

body {
    font-family: 'Inter', sans-serif;
    background: #f8fafc;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    touch-action: manipulation;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-theme {
    background: #0f172a;
    color: #f1f5f9;
}

body.dark-theme .game-title {
    color: #fbbf24 !important;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

body.dark-theme p {
    color: #cbd5e1 !important;
}

/* Auto theme - follows system preference */
@media (prefers-color-scheme: dark) {
    body.auto-theme {
        background: #0f172a;
        color: #f1f5f9;
    }
    
    body.auto-theme .game-title {
        color: #fbbf24 !important;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    }
    
    body.auto-theme p {
        color: #cbd5e1 !important;
    }
    
    body.auto-theme .modal-content {
        background: #1e293b;
        border-color: #475569;
        color: #f1f5f9;
    }
    
    body.auto-theme .options-panel {
        background: #1e293b;
        border-left-color: #475569;
        color: #f1f5f9;
    }
    
    body.auto-theme .preset-btn {
        background: #334155;
        color: #f1f5f9;
        border-color: #475569;
    }
    
    body.auto-theme .preset-btn:hover {
        background: #475569;
    }
    
    body.auto-theme .preset-btn.active {
        background: #fbbf24;
        color: #0f172a;
    }
}

body.day-theme {
    background: #fffbeb;
    color: #451a03;
}

body.day-theme .game-title {
    color: #ea580c !important;
    text-shadow: 2px 2px 4px rgba(255,255,255,0.8);
}

body.day-theme p {
    color: #7c2d12 !important;
}

body.night-theme .modal-content {
    background: #1e293b;
    border-color: #475569;
    color: #f1f5f9;
}

body.night-theme .options-panel {
    background: #1e293b;
    border-left-color: #475569;
    color: #f1f5f9;
}

body.night-theme .preset-btn {
    background: #334155;
    color: #f1f5f9;
    border-color: #475569;
}

body.night-theme .preset-btn:hover {
    background: #475569;
}

body.night-theme .preset-btn.active {
    background: #fbbf24;
    color: #0f172a;
}

.game-title {
    font-family: 'Press Start 2P', cursive;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

canvas {
    border: 4px solid #7c3aed;
    border-radius: 16px;
    background-color: #f1f5f9;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    max-width: 100%;
    height: auto;
    box-shadow: 0 8px 25px -8px rgba(124, 58, 237, 0.3);
}

.control-button {
    transition: all 0.2s ease-in-out;
    border: 3px solid;
    font-weight: bold;
    -webkit-user-select: none;
    user-select: none;
    min-height: 48px;
    touch-action: manipulation;
}

.control-button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: min(90vw, 400px);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 3px solid #3b82f6;
    margin: auto;
    text-align: center;
}

.options-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    transition: right 0.3s ease-in-out;
    overflow-y: auto;
    padding: 1rem;
    z-index: 500;
    border-left: 3px solid #6366f1;
}

.options-panel.open {
    right: 0;
}

.option-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.option-group:last-child {
    border-bottom: none;
}

.option-group h3 {
    font-size: 1rem;
    font-weight: bold;
    color: #374151;
    margin-bottom: 0.75rem;
}

.custom-colors-header {
    margin-top: 1rem !important;
}

.color-picker-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.color-picker-row label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.color-input {
    width: 40px;
    height: 40px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: none;
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.slider-container {
    margin: 0.5rem 0;
}

.slider-container label {
    display: block;
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
    border: none;
}

.preset-buttons {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 1fr 1fr 1fr;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.difficulty-buttons {
    grid-template-columns: 1fr 1fr;
}

.preset-btn {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: #f3f4f6;
    border-color: #6366f1;
}

.preset-btn.active {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
}

.apply-btn {
    background: #22c55e !important;
    color: white !important;
    border-color: #16a34a !important;
    font-weight: bold;
}

.apply-btn:hover {
    background: #16a34a !important;
    border-color: #15803d !important;
}

.action-btn {
    width: 100%;
}

.action-btn + .action-btn {
    margin-top: 0.5rem;
}

#speechBubble {
    transition: opacity 0.3s ease-in-out;
}

.canvas-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    body {
        padding: 1rem;
        touch-action: manipulation;
    }
    
    .control-button {
        min-height: 56px;
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    canvas {
        max-width: 100%;
        width: 100%;
    }
    
    .options-panel {
        width: 280px;
        right: -290px;
    }
    
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .grid {
        gap: 0.75rem;
    }
    
    .grid {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .control-button {
        border-width: 4px;
    }
    
    canvas {
        border-width: 6px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .control-button {
        transition: none;
    }
    
    .options-panel {
        transition: none;
    }
    
    #speechBubble {
        transition: none;
    }
}
