* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Comic Sans MS', cursive, sans-serif;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    background: linear-gradient(135deg, #0a0a23 0%, #1a1a4a 25%, #2d4a7f 50%, #ff6b6b 75%, #ffd93d 100%);
    min-height: 100vh;
    padding: 20px;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    transition: background 0.5s ease;
    /* Prevent accidental zooming on mobile */
    touch-action: pan-x pan-y;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body.dark-mode {
    background: linear-gradient(135deg, #000000 0%, #0d0d1f 25%, #1a1a3a 50%, #2d1f3f 75%, #3a2a1f 100%);
}

/* Dark Mode Component Styles */
body.dark-mode h1 {
    color: #ffd93d;
    text-shadow: 0 0 20px rgba(255, 217, 61, 0.5);
}

body.dark-mode .controls,
body.dark-mode .image-generator,
body.dark-mode .templates,
body.dark-mode .app-footer,
body.dark-mode .zoom-controls {
    background-color: rgba(26, 26, 58, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Dark mode scrollbar for controls */
body.dark-mode .controls::-webkit-scrollbar {
    width: 8px;
}

body.dark-mode .controls::-webkit-scrollbar-track {
    background: rgba(26, 32, 44, 0.4);
    border-radius: 4px;
}

body.dark-mode .controls::-webkit-scrollbar-thumb {
    background: rgba(99, 179, 237, 0.5);
    border-radius: 4px;
}

body.dark-mode .controls::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 179, 237, 0.7);
}

body.dark-mode .image-generator h3 {
    color: #b794f6;
}

body.dark-mode .templates h3 {
    color: #63b3ed;
}

body.dark-mode .orientation-selector {
    background-color: rgba(45, 55, 72, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .orientation-selector label {
    color: #e2e8f0;
}

body.dark-mode #orientationSelect,
body.dark-mode #promptInput {
    background-color: rgba(26, 32, 44, 0.8);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode #orientationSelect:hover,
body.dark-mode #promptInput:hover {
    background-color: rgba(45, 55, 72, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

body.dark-mode #orientationSelect:focus,
body.dark-mode #promptInput:focus {
    background-color: rgba(45, 55, 72, 0.9);
    border-color: #b794f6;
    box-shadow: 0 0 10px rgba(183, 148, 246, 0.3);
}

body.dark-mode .loading {
    color: #b794f6;
}

body.dark-mode .brush-size label,
body.dark-mode .zoom-controls label {
    color: #e2e8f0;
}

body.dark-mode #brushSizeValue,
body.dark-mode #zoomValue {
    color: #63b3ed;
}

body.dark-mode .drawing-area {
    background-color: rgba(26, 32, 44, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode canvas {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

body.dark-mode .footer-text {
    color: #cbd5e0;
}

body.dark-mode .footer-link {
    background-color: rgba(45, 55, 72, 0.6);
    color: #63b3ed;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .footer-link:hover {
    background-color: #63b3ed;
    color: #1a202c;
}

body.dark-mode .footer-note {
    color: #68d391;
}

/* Dark Mode Button Styles */
body.dark-mode button {
    background-color: rgba(72, 187, 120, 0.9);
    color: #1a202c;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode button:hover {
    background-color: rgba(72, 187, 120, 1);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

body.dark-mode #fillTool {
    background-color: rgba(0, 188, 212, 0.9);
}

body.dark-mode #fillTool:hover {
    background-color: rgba(0, 188, 212, 1);
}

body.dark-mode #eraser {
    background-color: rgba(255, 152, 0, 0.9);
}

body.dark-mode #eraser:hover {
    background-color: rgba(255, 152, 0, 1);
}

body.dark-mode #undo {
    background-color: rgba(156, 39, 176, 0.9);
}

body.dark-mode #undo:hover {
    background-color: rgba(156, 39, 176, 1);
}

body.dark-mode #redo {
    background-color: rgba(103, 58, 183, 0.9);
}

body.dark-mode #redo:hover {
    background-color: rgba(103, 58, 183, 1);
}

body.dark-mode #download {
    background-color: rgba(72, 187, 120, 0.9);
}

body.dark-mode #download:hover {
    background-color: rgba(72, 187, 120, 1);
}

body.dark-mode #clear {
    background-color: rgba(244, 67, 54, 0.9);
}

body.dark-mode #clear:hover {
    background-color: rgba(244, 67, 54, 1);
}

body.dark-mode #generateBtn {
    background-color: rgba(156, 39, 176, 0.9);
}

body.dark-mode #generateBtn:hover {
    background-color: rgba(156, 39, 176, 1);
}

body.dark-mode #uploadBtn {
    background-color: rgba(255, 152, 0, 0.9);
}

body.dark-mode #uploadBtn:hover {
    background-color: rgba(255, 152, 0, 1);
}

body.dark-mode #resetZoom,
body.dark-mode #fitCanvas {
    background-color: rgba(33, 150, 243, 0.9);
}

body.dark-mode #resetZoom:hover,
body.dark-mode #fitCanvas:hover {
    background-color: rgba(33, 150, 243, 1);
}

body.dark-mode .template-btn {
    background-color: rgba(33, 150, 243, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.dark-mode .template-btn:hover {
    background-color: rgba(33, 150, 243, 1);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

/* Dark Mode Input Styles */
body.dark-mode input[type="color"] {
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode input[type="range"] {
    background: rgba(45, 55, 72, 0.6);
}

body.dark-mode input[type="range"]::-webkit-slider-thumb {
    background: #63b3ed;
    box-shadow: 0 0 10px rgba(99, 179, 237, 0.5);
}

body.dark-mode input[type="range"]::-moz-range-thumb {
    background: #63b3ed;
    box-shadow: 0 0 10px rgba(99, 179, 237, 0.5);
}

/* Dark Mode Scrollbar */
body.dark-mode .drawing-area::-webkit-scrollbar-track {
    background: rgba(26, 32, 44, 0.8);
}

body.dark-mode .drawing-area::-webkit-scrollbar-thumb {
    background: rgba(99, 179, 237, 0.6);
}

body.dark-mode .drawing-area::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 179, 237, 0.8);
}

/* Dark Mode Tool Sections */
body.dark-mode .tool-section {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(45, 55, 72, 0.4);
}

body.dark-mode .tool-section h4 {
    color: #63b3ed;
}

body.dark-mode .tool-btn,
body.dark-mode .palette-btn {
    background-color: rgba(26, 32, 44, 0.8);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .tool-btn:hover,
body.dark-mode .palette-btn:hover {
    background-color: rgba(45, 55, 72, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(99, 179, 237, 0.2);
}

body.dark-mode .tool-btn.active {
    background-color: #48bb78;
    border-color: #48bb78;
    box-shadow: 0 0 15px rgba(72, 187, 120, 0.4);
}

body.dark-mode .brush-size {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(45, 55, 72, 0.4);
}

body.dark-mode .action-buttons button {
    background-color: rgba(26, 32, 44, 0.8);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .action-buttons button:hover {
    background-color: rgba(45, 55, 72, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(99, 179, 237, 0.2);
}

body.dark-mode #autoColor {
    background: linear-gradient(135deg, rgba(183, 148, 246, 0.3), rgba(99, 179, 237, 0.3));
    border-color: #b794f6;
}

body.dark-mode #autoColor:hover {
    background: linear-gradient(135deg, rgba(183, 148, 246, 0.5), rgba(99, 179, 237, 0.5));
    box-shadow: 0 4px 15px rgba(183, 148, 246, 0.4);
}

body.dark-mode #download {
    background-color: rgba(72, 187, 120, 0.2);
    border-color: #48bb78;
}

body.dark-mode #download:hover {
    background-color: rgba(72, 187, 120, 0.4);
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
}

body.dark-mode .palette-btn.active {
    background-color: #63b3ed;
    border-color: #63b3ed;
    color: #1a202c;
}

body.dark-mode .recent-color,
body.dark-mode .palette-color {
    border-color: rgba(255, 255, 255, 0.3);
}

.dark-mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    /* Prevent accidental activation */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dark-mode-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.app {
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

/* Header Logo Styles */
.header-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    animation: fadeInDown 1s ease-out;
}

.logo-image {
    width: 80px;
    height: auto;
    filter: drop-shadow(0 4px 15px rgba(255, 152, 0, 0.3));
    animation: float 3s ease-in-out infinite;
    transition: transform 0.3s ease;
}

.logo-image:hover {
    transform: scale(1.1) rotate(5deg);
    filter: drop-shadow(0 6px 20px rgba(255, 152, 0, 0.5));
}

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

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

/* Dark Mode Logo */
body.dark-mode .logo-image {
    filter: drop-shadow(0 4px 15px rgba(255, 217, 61, 0.4));
}

body.dark-mode .logo-image:hover {
    filter: drop-shadow(0 6px 20px rgba(255, 217, 61, 0.6));
}

h1 {
    color: #ff6b6b;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

/* Affiliate Banner Styles */
.affiliate-banner {
    background: linear-gradient(135deg, #ff9a56 0%, #ff6b6b 50%, #ffd93d 100%);
    border-radius: 15px;
    padding: 25px;
    margin: 30px auto;
    max-width: 600px;
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
    animation: pulseGlow 3s ease-in-out infinite;
}

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

.affiliate-emoji {
    font-size: 48px;
    animation: bounce 2s ease-in-out infinite;
}

.affiliate-text {
    color: white;
    font-size: 18px;
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin: 0;
    line-height: 1.5;
}

.affiliate-text strong {
    color: #ffd93d;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.affiliate-button {
    background: white;
    color: #ff6b6b;
    padding: 12px 30px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    font-size: 18px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: inline-block;
}

.affiliate-button:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    background: #ffd93d;
    color: #ff6b6b;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
    }
    50% {
        box-shadow: 0 8px 35px rgba(255, 107, 107, 0.5);
    }
}

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

/* Dark Mode Affiliate Banner */
body.dark-mode .affiliate-banner {
    background: linear-gradient(135deg, #b794f6 0%, #9f7aea 50%, #805ad5 100%);
    box-shadow: 0 8px 25px rgba(183, 148, 246, 0.4);
}

body.dark-mode .affiliate-text {
    color: #e2e8f0;
}

body.dark-mode .affiliate-text strong {
    color: #ffd93d;
}

body.dark-mode .affiliate-button {
    background: #ffd93d;
    color: #2d3748;
}

body.dark-mode .affiliate-button:hover {
    background: white;
    color: #805ad5;
}

body.dark-mode .affiliate-banner {
    animation: pulseGlowDark 3s ease-in-out infinite;
}

@keyframes pulseGlowDark {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(183, 148, 246, 0.4);
    }
    50% {
        box-shadow: 0 8px 35px rgba(183, 148, 246, 0.6);
    }
}

.controls {
    background-color: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.tool-section {
    border: 2px solid #f0f0f0;
    padding: 12px;
    border-radius: 8px;
    background: #fafafa;
}

.tool-section h4 {
    color: #2d4a7f !important;
    font-size: 14px;
    margin: 0 0 8px 0;
    text-align: center;
    font-weight: 600;
}

.tool-buttons, .action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.tool-btn, .action-buttons button {
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
    font-weight: 500;
    min-height: 40px;
    touch-action: manipulation;
    white-space: nowrap;
}

.tool-btn:hover, .action-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.tool-btn.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.color-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.recent-colors {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.recent-color {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recent-color:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.palette-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.palette-btn {
    padding: 8px 15px;
    border: 2px solid #ddd;
    border-radius: 20px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.palette-btn:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.palette-btn.active {
    background: #2d4a7f;
    color: white;
    border-color: #2d4a7f;
}

.palette-colors {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 40px;
}

.palette-color {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: all 0.2s ease;
}

.palette-color:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.color-picker, .brush-size {
    margin: 0;
}

.brush-size {
    border: 2px solid #f0f0f0;
    padding: 12px;
    border-radius: 8px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.brush-size label {
    color: #2d4a7f;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    margin: 0;
}

/* Stamp Selector */
.stamp-selector {
    margin-top: 15px;
}

.stamp-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.stamp-btn {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 24px;
    transition: all 0.3s ease;
    min-height: 50px;
    min-width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stamp-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.stamp-btn.active {
    background: #2196f3;
    border-color: #2196f3;
    transform: scale(1.05);
}

body.dark-mode .stamp-btn {
    background-color: rgba(45, 55, 72, 0.6);
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .stamp-btn:hover {
    background-color: rgba(45, 55, 72, 0.8);
}

body.dark-mode .stamp-btn.active {
    background-color: #2196f3;
    border-color: #2196f3;
}

button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 8px 15px;
    margin: 0 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    /* Larger touch targets for mobile */
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

button:hover {
    transform: scale(1.05);
}

#fillTool {
    background-color: #00bcd4;
}

#eraser {
    background-color: #ff9800;
}

#undo {
    background-color: #9c27b0;
}

#redo {
    background-color: #673ab7;
}

#download {
    background-color: #4CAF50;
}

#clear {
    background-color: #f44336;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

input[type="color"] {
    width: 50px;
    height: 40px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-right: 10px;
    vertical-align: middle;
}

input[type="range"] {
    width: 150px;
    vertical-align: middle;
    margin: 0 10px;
}

.zoom-controls {
    background-color: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.zoom-controls label {
    font-weight: 600;
    color: #555;
}

#zoomSlider {
    width: 200px;
}

#zoomValue {
    font-weight: bold;
    color: #2196f3;
    min-width: 50px;
}

#resetZoom, #fitCanvas {
    background-color: #2196f3;
    padding: 8px 15px;
}

#resetZoom:hover, #fitCanvas:hover {
    background-color: #1976d2;
}

.drawing-area {
    background-color: #f5f5f5;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: auto;
    margin-bottom: 20px;
    position: relative;
    will-change: transform;
    max-height: 800px;
    min-height: 500px;
    cursor: grab;
    text-align: center;
    padding: 20px;
    /* Better touch scrolling */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.drawing-area:active {
    cursor: grabbing;
}

.canvas-container {
    display: inline-block;
    transition: transform 0.2s ease;
    transform-origin: center center;
    position: relative;
    padding: 20px;
}

canvas {
    background-color: white;
    cursor: crosshair;
    display: block;
    margin: 0 auto;
    border: 2px solid #ddd;
    touch-action: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    /* Prevent pull-to-refresh on canvas */
    overscroll-behavior: contain;
}

/* Custom scrollbar for drawing area */
.drawing-area::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.drawing-area::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.drawing-area::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.drawing-area::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.image-generator {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.image-generator h3 {
    color: #9c27b0;
    margin-bottom: 15px;
}

.generator-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.orientation-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #f0f8ff;
    padding: 8px 12px;
    border-radius: 5px;
}

.orientation-selector label {
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

#orientationSelect {
    padding: 6px 10px;
    border: 2px solid #2196f3;
    border-radius: 5px;
    background-color: white;
    color: #333;
    font-size: 14px;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    cursor: pointer;
    transition: all 0.3s;
}

#orientationSelect:hover {
    border-color: #1976d2;
    background-color: #f0f8ff;
}

#orientationSelect:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow: 0 0 5px rgba(33, 150, 243, 0.3);
}

#promptInput {
    padding: 12px 16px;
    font-size: 16px;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    border: 2px solid #9c27b0;
    border-radius: 8px;
    background-color: white;
    color: #333;
    width: 100%;
    min-height: 60px;
    resize: vertical;
    transition: all 0.3s;
}

#promptInput:focus {
    outline: none;
    border-color: #7b1fa2;
    box-shadow: 0 0 8px rgba(156, 39, 176, 0.3);
}

#generateBtn {
    background-color: #9c27b0;
    padding: 10px 20px;
}

#generateBtn:hover {
    background-color: #7b1fa2;
}

#uploadBtn {
    background-color: #ff9800;
    padding: 10px 20px;
}

#uploadBtn:hover {
    background-color: #f57c00;
}

.loading {
    margin-top: 15px;
    color: #9c27b0;
    font-weight: bold;
    font-size: 18px;
}

.loading.hidden {
    display: none;
}

.music-controls {
    background-color: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.music-controls h3 {
    color: #ff9800;
    margin-bottom: 10px;
    text-align: center;
}

.music-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.music-buttons button {
    background-color: #ff9800;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.music-buttons button:hover {
    background-color: #f57c00;
    transform: scale(1.05);
}

#musicVolume {
    width: 100px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#musicVolume:hover {
    opacity: 1;
}

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

#musicVolume::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff9800;
    cursor: pointer;
    border: none;
}

#volumeValue {
    font-weight: bold;
    color: #ff9800;
    min-width: 40px;
    text-align: center;
    font-size: 14px;
}

#preview {
    width: 100px;
    height: 100px;
    border: 2px solid #ddd;
    margin: 10px auto;
    border-radius: 5px;
}

.templates {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.templates h3 {
    color: #2196f3;
    margin-bottom: 15px;
}

.template-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.template-btn {
    background-color: #2196f3;
    padding: 10px 15px;
    font-size: 14px;
}

.template-btn:hover {
    background-color: #1976d2;
}

/* Footer Styles */
.app-footer {
    background-color: white;
    padding: 25px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
    text-align: center;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
}

.footer-text {
    color: #555;
    font-size: 16px;
    margin-bottom: 15px;
    font-weight: 500;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.footer-link {
    color: #2196f3;
    text-decoration: none;
    font-size: 15px;
    padding: 8px 15px;
    border-radius: 5px;
    background-color: #f0f8ff;
    transition: all 0.3s;
    font-weight: 500;
}

.footer-link:hover {
    background-color: #2196f3;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.footer-note {
    color: #4CAF50;
    font-size: 13px;
    font-weight: 600;
    margin-top: 10px;
}

/* Keyboard Shortcuts Section */
.keyboard-shortcuts {
    margin: 20px auto;
    max-width: 600px;
    background: #f0f8ff;
    border-radius: 10px;
    padding: 15px;
}

.keyboard-shortcuts summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    color: #2d4a7f;
    padding: 10px;
    list-style: none;
    user-select: none;
}

.keyboard-shortcuts summary::-webkit-details-marker {
    display: none;
}

.keyboard-shortcuts summary::before {
    content: '▶ ';
    display: inline-block;
    transition: transform 0.2s;
}

.keyboard-shortcuts[open] summary::before {
    transform: rotate(90deg);
}

.keyboard-shortcuts summary:hover {
    background: rgba(33, 150, 243, 0.1);
    border-radius: 5px;
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 15px;
    padding: 10px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #555;
}

kbd {
    background: white;
    border: 2px solid #2196f3;
    border-radius: 5px;
    padding: 4px 8px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: bold;
    color: #2196f3;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 30px;
    text-align: center;
}

body.dark-mode .keyboard-shortcuts {
    background: rgba(45, 55, 72, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .keyboard-shortcuts summary {
    color: #63b3ed;
}

body.dark-mode .keyboard-shortcuts summary:hover {
    background: rgba(99, 179, 237, 0.1);
}

body.dark-mode .shortcut-item {
    color: #e2e8f0;
}

body.dark-mode kbd {
    background: rgba(26, 32, 44, 0.8);
    border-color: #63b3ed;
    color: #63b3ed;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .logo-image {
        width: 65px;
    }
    
    .affiliate-banner {
        padding: 20px;
        margin: 20px auto;
    }
    
    .affiliate-emoji {
        font-size: 36px;
    }
    
    .affiliate-text {
        font-size: 16px;
    }
    
    .affiliate-button {
        padding: 10px 25px;
        font-size: 16px;
    }
    
    .tool-section h4 {
        font-size: 14px;
    }
    
    .tool-btn, .palette-btn, .action-buttons button {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .recent-color, .palette-color {
        width: 30px;
        height: 30px;
    }
    
    h1 {
        font-size: 24px;
        margin-bottom: 15px;
    }

    .zoom-controls {
        padding: 12px;
        gap: 10px;
    }

    #zoomSlider {
        width: 150px;
    }

    #zoomValue {
        font-size: 14px;
    }

    #resetZoom, #fitCanvas {
        padding: 6px 12px;
        font-size: 14px;
    }

    .drawing-area {
        max-height: 600px;
    }
    
    .image-generator h3,
    .preview h3,
    .templates h3 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    .music-controls {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .music-controls h3 {
        font-size: 18px;
        margin-bottom: 8px;
    }
    
    .music-buttons {
        gap: 8px;
    }
    
    .music-buttons button {
        padding: 8px 10px;
        font-size: 13px;
        min-width: 70px;
        flex: 1;
    }
    
    #musicVolume {
        width: 80px;
        height: 5px;
    }
    
    #musicVolume::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
    }
    
    #musicVolume::-moz-range-thumb {
        width: 18px;
        height: 18px;
    }
    
    #volumeValue {
        font-size: 13px;
        min-width: 35px;
    }
    
    .generator-controls {
        flex-direction: column;
        width: 100%;
    }
    
    #promptInput {
        width: 100%;
        min-width: auto;
        font-size: 18px;
        padding: 15px 18px;
        min-height: 70px;
        resize: vertical;
        border: 3px solid #9c27b0;
        border-radius: 10px;
        background-color: white;
        font-family: 'Comic Sans MS', cursive, sans-serif;
    }

    .orientation-selector {
        width: 100%;
        justify-content: center;
        padding: 6px 10px;
    }

    .orientation-selector label {
        font-size: 13px;
    }

    #orientationSelect {
        font-size: 13px;
        padding: 5px 8px;
        flex: 1;
        max-width: 200px;
    }
    
    #generateBtn,
    #uploadBtn {
        width: 100%;
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .color-picker {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    button {
        padding: 10px 12px;
        font-size: 14px;
        margin: 0;
        min-width: 80px;
        flex: 1 1 auto;
    }
    
    input[type="color"] {
        width: 45px;
        height: 45px;
        flex: 0 0 auto;
    }
    
    .brush-size {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 10px;
        width: 100%;
    }
    
    .brush-size label {
        margin-bottom: 5px;
        font-size: 14px;
    }
    
    input[type="range"] {
        width: 100%;
        max-width: 250px;
    }
    
    canvas {
        touch-action: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    .template-buttons {
        gap: 8px;
    }
    
    .template-btn {
        padding: 10px 12px;
        font-size: 13px;
        flex: 1 1 calc(50% - 8px);
        min-width: 120px;
    }
    
    #preview {
        width: 80px;
        height: 80px;
    }
    
    .app-footer {
        padding: 20px 15px;
    }
    
    .footer-text {
        font-size: 14px;
    }
    
    .footer-links {
        gap: 10px;
    }
    
    .footer-link {
        font-size: 13px;
        padding: 8px 12px;
        flex: 1 1 calc(50% - 10px);
        min-width: 120px;
    }
    
    .footer-note {
        font-size: 12px;
    }
    
    .dark-mode-toggle {
        width: 50px;
        height: 50px;
        font-size: 24px;
        top: 15px;
        right: 15px;
    }
    
    /* Larger touch targets for mobile buttons */
    button {
        min-height: 48px;
        padding: 12px 15px;
    }
    
    .tool-btn, .palette-btn, .action-buttons button {
        min-height: 48px;
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    .logo-image {
        width: 50px;
    }
    
    .affiliate-banner {
        padding: 15px;
        margin: 15px auto;
    }
    
    .affiliate-emoji {
        font-size: 32px;
    }
    
    .affiliate-text {
        font-size: 14px;
    }
    
    .affiliate-button {
        padding: 8px 20px;
        font-size: 14px;
    }
    
    .tool-section h4 {
        font-size: 13px;
    }
    
    .tool-btn, .palette-btn, .action-buttons button {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .recent-color, .palette-color {
        width: 28px;
        height: 28px;
    }
    
    .controls {
        padding: 12px;
        gap: 10px;
        grid-template-columns: 1fr;
        max-height: 300px;
    }
    
    .tool-buttons, .action-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    .image-generator h3,
    .preview h3,
    .templates h3 {
        font-size: 16px;
    }
    
    button {
        padding: 8px 10px;
        font-size: 13px;
        min-width: 70px;
    }
    
    .template-btn {
        flex: 1 1 100%;
        min-width: auto;
    }
    
    input[type="color"] {
        width: 40px;
        height: 40px;
    }
    
    #brushSizeValue {
        font-size: 14px;
        font-weight: bold;
    }
    
    .footer-text {
        font-size: 13px;
    }
    
    .footer-link {
        font-size: 12px;
        padding: 6px 10px;
        flex: 1 1 100%;
        min-width: auto;
    }
    
    .footer-note {
        font-size: 11px;
    }
    
    .dark-mode-toggle {
        width: 45px;
        height: 45px;
        font-size: 20px;
        top: 10px;
        right: 10px;
    }
    
    /* Extra large touch targets for small screens */
    button {
        min-height: 50px;
        padding: 14px 16px;
    }
    
    .tool-btn, .palette-btn, .action-buttons button {
        min-height: 50px;
        padding: 12px 16px;
    }
}

/* Orientation Lock Styles */
.orientation-lock-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(135deg, #ff6b6b, #ffd93d);
    color: white;
    padding: 12px 20px;
    text-align: center;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    display: none;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 14px;
    font-weight: 600;
}

.orientation-lock-banner.show {
    display: flex;
}

.orientation-lock-banner button {
    background: white;
    color: #ff6b6b;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    min-height: 36px;
    min-width: auto;
}

.orientation-lock-banner button:hover {
    background: #ffd93d;
    color: #333;
}

/* Prevent text selection during drawing on mobile */
.drawing-area *,
.canvas-container * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Better tap highlighting */
button,
.tool-btn,
.palette-btn,
.template-btn,
.recent-color,
.palette-color {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Prevent double-tap zoom on specific elements */
input[type="color"],
input[type="range"],
select {
    touch-action: manipulation;
}

/* Enhanced Focus Indicators for Accessibility */
button:focus,
.tool-btn:focus,
.palette-btn:focus,
.template-btn:focus,
input:focus,
select:focus,
canvas:focus {
    outline: 3px solid #2196f3;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.2);
}

body.dark-mode button:focus,
body.dark-mode .tool-btn:focus,
body.dark-mode .palette-btn:focus,
body.dark-mode .template-btn:focus,
body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode canvas:focus {
    outline: 3px solid #63b3ed;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(99, 179, 237, 0.3);
}

/* Focus visible only for keyboard navigation */
button:focus:not(:focus-visible),
.tool-btn:focus:not(:focus-visible),
.palette-btn:focus:not(:focus-visible),
.template-btn:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

button:focus-visible,
.tool-btn:focus-visible,
.palette-btn:focus-visible,
.template-btn:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible {
    outline: 3px solid #2196f3;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.2);
}

/* Skip to main content link for keyboard users */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #2196f3;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 10000;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    button,
    .tool-btn,
    .palette-btn,
    .template-btn {
        border: 2px solid currentColor;
    }
    
    canvas {
        border: 3px solid currentColor;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: white;
    color: #333;
    padding: 16px 24px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 400px;
    pointer-events: auto;
    animation: slideInRight 0.3s ease-out;
    border-left: 4px solid #4CAF50;
}

.toast.success {
    border-left-color: #4CAF50;
}

.toast.error {
    border-left-color: #f44336;
}

.toast.info {
    border-left-color: #2196f3;
}

.toast.warning {
    border-left-color: #ff9800;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    padding: 0;
    min-width: auto;
    min-height: auto;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #333;
    transform: none;
}

.toast.hiding {
    animation: slideOutRight 0.3s ease-out forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

body.dark-mode .toast {
    background: rgba(45, 55, 72, 0.95);
    color: #e2e8f0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

body.dark-mode .toast-close {
    color: #a0aec0;
}

body.dark-mode .toast-close:hover {
    color: #e2e8f0;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* Button Loading State */
button.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

button.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

/* Tooltip System */
.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
}

.tooltip:hover::before {
    transform: translateX(-50%) translateY(-4px);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* Pulse Animation for Active Tool */
.tool-btn.active {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(76, 175, 80, 0);
    }
}

/* Smooth Hover Effects */
.template-btn,
.palette-btn,
.tool-btn {
    position: relative;
    overflow: hidden;
}

.template-btn::before,
.palette-btn::before,
.tool-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.template-btn:active::before,
.palette-btn:active::before,
.tool-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Canvas Drawing Indicator */
.drawing-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(76, 175, 80, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 6px;
    z-index: 10;
}

.drawing-indicator.active {
    display: flex;
}

.drawing-indicator::before {
    content: '●';
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
