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

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --accent: #764ba2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.floating {
    animation: float 3s ease-in-out infinite;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
    position: relative;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header p {
    opacity: 0.9;
    font-size: 1.1em;
    font-weight: 400;
}

.download-btn {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    color: #667eea;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.download-btn:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 30px;
    padding: 30px;
}

.canvas-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 10px;
    flex-wrap: wrap;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.tool-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    color: #666;
}

.tool-btn:hover {
    background: #e8ebff;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.tool-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.tool-btn svg {
    fill: currentColor;
}

.tool-separator {
    width: 1px;
    height: 30px;
    background: #ddd;
    margin: 0 5px;
}

.brush-settings {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brush-size-label {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
}

.brush-slider {
    width: 100px;
    height: 6px;
    background: #ddd;
    outline: none;
    border-radius: 3px;
    cursor: pointer;
}

.brush-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
}

#brushSizeValue {
    font-size: 14px;
    color: #333;
    font-weight: bold;
    min-width: 35px;
}

.tool-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
}

.tool-checkbox input[type="checkbox"] {
    cursor: pointer;
}

.canvas-info {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-item .label {
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.info-item .value {
    font-weight: 700;
    color: #333;
    font-size: 18px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
}

.grid-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.grid-toggle label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.grid-toggle input[type="checkbox"] {
    width: 40px;
    height: 20px;
    appearance: none;
    background: #ddd;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.grid-toggle input[type="checkbox"]:checked {
    background: #667eea;
}

.grid-toggle input[type="checkbox"]::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.grid-toggle input[type="checkbox"]:checked::after {
    transform: translateX(20px);
}

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

.color-display .label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.color-box {
    width: 30px;
    height: 30px;
    border: 2px solid #ddd;
    border-radius: 5px;
    background: #000;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.color-code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 14px;
    color: #333;
    font-weight: 600;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 10px;
}

.zoom-btn {
    width: 35px;
    height: 35px;
    border: none;
    background: #667eea;
    color: white;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.zoom-btn:hover {
    background: #5a67d8;
    transform: scale(1.1);
}

#zoomSlider {
    flex: 1;
    height: 6px;
    background: #ddd;
    outline: none;
    border-radius: 3px;
    cursor: pointer;
}

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

.zoom-value {
    min-width: 50px;
    text-align: center;
    font-weight: bold;
}

.canvas-wrapper {
    position: relative;
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    overflow: hidden;
    cursor: grab;
}

.canvas-wrapper:active {
    cursor: grabbing;
}

#pixelCanvas {
    max-width: 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    cursor: crosshair;
    transition: transform 0.1s ease-out;
}

.hover-info {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 12px;
    pointer-events: none;
}

.reset-view-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    color: #667eea;
}

.reset-view-btn:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.upload-section {
    margin-top: 20px;
}

.upload-icon {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #f8f9ff;
}

.upload-icon:hover {
    background: #eef1ff;
    border-color: #5a67d8;
}

.upload-icon svg {
    margin-bottom: 15px;
}

.upload-icon p {
    color: #666;
    margin: 10px 0;
}

.format-info {
    font-size: 12px;
    color: #999;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.image-size-control {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.image-size-control h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.slider-premium {
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, #ddd 0%, #667eea 0%);
    outline: none;
    border-radius: 3px;
    cursor: pointer;
    margin: 10px 0;
    appearance: none;
    -webkit-appearance: none;
}

.slider-premium::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.slider-premium::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    border: none;
}

.badge-premium {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    margin-left: 4px;
}

#pixelSize {
    width: 100%;
    height: 6px;
    background: #ddd;
    outline: none;
    border-radius: 3px;
    cursor: pointer;
    margin: 10px 0;
}

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

.hint {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
}

.advanced-settings {
    background: #f5f5f5;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.accordion {
    width: 100%;
    padding: 16px 20px;
    background: white;
    color: #333;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-align: left;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.accordion:hover {
    background: #f9fafb;
    border-color: #667eea;
}

.accordion::before {
    content: '⚙️';
    margin-right: 8px;
}

.accordion.active {
    background: #f3f4f6;
    border-color: #667eea;
    color: #667eea;
}

.panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.panel.show {
    max-height: 500px;
    padding: 20px;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item input[type="checkbox"] {
    margin-right: 10px;
}

.setting-item label {
    font-weight: 500;
    cursor: pointer;
}

.description {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    margin-left: 25px;
}

.algorithm-group {
    margin-top: 20px;
}

.algorithm-group h4 {
    margin-bottom: 10px;
    color: #333;
}

.algorithm-group label {
    display: block;
    margin: 8px 0;
    cursor: pointer;
}

.algorithm-group input[type="radio"] {
    margin-right: 10px;
}

.color-palette {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.color-palette h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.palette-options {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.palette-options label {
    cursor: pointer;
}

.palette-options input[type="radio"] {
    margin-right: 5px;
}

.colors-grid {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 2px;
    margin: 15px 0;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

.color-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}

.color-cell:hover {
    transform: scale(1.2);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.color-cell.selected {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.palette-info {
    font-size: 12px;
    color: #666;
    text-align: center;
    margin-top: 10px;
}

.color-stats {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.color-stats h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-stats h3::before {
    content: '🎨';
}

.stats-info {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    padding: 12px 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stats-info span {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.stats-info strong {
    color: #333;
    font-size: 16px;
    font-weight: 700;
    margin-left: 4px;
}

.used-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    max-height: 150px;
    overflow-y: auto;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.used-color {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.used-color:hover {
    transform: scale(1.3);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.used-color.locked::after {
    content: '🔒';
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 10px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

.note {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
    line-height: 1.5;
    font-style: italic;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .settings-section {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
    }
    
    .download-btn {
        position: static;
        transform: none;
        margin-top: 20px;
    }
    
    .settings-section {
        grid-template-columns: 1fr;
    }
    
    .colors-grid {
        grid-template-columns: repeat(8, 1fr);
    }
}