* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    --secondary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --text-dark: #1a1a2e;
    --text-light: #5a5a7a;
    --text-muted: #8a8a9a;
    --bg-light: #f5f6fa;
    --bg-white: #ffffff;
    --border-color: #e0e0e8;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-light);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.6;
}

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon {
    width: 36px;
    height: 36px;
}

.brand-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease;
}

.brand-link:hover {
    transform: scale(1.02);
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--bg-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    display: flex;
    gap: 8px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    background: var(--bg-gradient);
    color: #f5f5f5;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background: var(--text-dark);
    border-radius: 3px;
    transition: all 0.3s ease;
}

.main-content {
    padding: 80px 20px 60px;
}

.content-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

.generator-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 30px;
    align-items: start;
}

.generator-left {
    position: sticky;
    top: 80px;
}

.upload-section {
    margin-bottom: 20px;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.upload-area.dragover {
    border-color: var(--secondary-color);
    background: rgba(118, 75, 162, 0.08);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.upload-label p {
    color: var(--text-dark);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.upload-label .hint {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.crop-section {
    margin-top: 15px;
    background: white;
    border-radius: 16px;
    padding: 15px;
    box-shadow: var(--shadow-sm);
}

.crop-section h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #1a1a2e;
    font-size: 1rem;
    font-weight: 700;
}

.crop-container {
    max-width: 100%;
    overflow: hidden;
    border-radius: 12px;
    background: var(--bg-light);
    margin-bottom: 15px;
}

#cropCanvas {
    width: 100%;
    max-height: 280px;
    display: block;
}

.crop-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 12px;
}

.crop-ratio {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.crop-ratio span {
    color: #4a4a6a;
    font-weight: 600;
    font-size: 0.95rem;
}

.ratio-btn {
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    min-width: 50px;
    text-align: center;
}

.ratio-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.ratio-btn.active {
    background: var(--bg-gradient);
    border-color: var(--primary-color);
    color: #f5f5f5;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.controls-section {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: space-between;
    align-items: center;
}

.control-row:not(:last-child) {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9rem;
    min-width: 50px;
}

.control-group input[type="range"] {
    width: 100px;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    transition: all 0.2s ease;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.5);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.control-group input[type="number"] {
    width: 55px;
    padding: 6px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
}

.control-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.control-group select {
    padding: 6px 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    background: white;
}

.control-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.control-group span {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
    min-width: 35px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.preview-section {
    margin-bottom: 20px;
}

.preview-container {
    display: grid;
    grid-template-columns: 1fr minmax(200px, 450px);
    gap: 20px;
    align-items: start;
}

.preview-box {
    background: white;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.preview-box:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.preview-box h3 {
    color: #1a1a2e;
    margin-bottom: 15px;
    font-size: 1rem;
    font-weight: 700;
}

.image-container {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: all 0.3s ease;
}

.pixel-box {
    flex-shrink: 0;
}

.pixel-art-container {
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    transition: all 0.3s ease;
}

.pixel-art-container canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-container:hover {
    border-color: var(--primary-color);
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-container .placeholder {
    text-align: center;
    color: var(--text-muted);
}

.image-container .placeholder span {
    font-size: 3rem;
    display: block;
    margin-bottom: 8px;
}

#pixelatedCanvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.primary-actions {
    margin-bottom: 20px;
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.stats-section#statsSection {
    display: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.3);
}

.stats-section#statsSection.show {
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.stat-item {
    text-align: center;
    padding: 20px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    border: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.stat-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 5px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 5px;
    font-weight: 600;
}

.stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    color: #ffffff;
}

.color-palette-section {
    margin-bottom: 20px;
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.color-palette-section h3 {
    color: #1a1a2e;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.color-palette .placeholder {
    color: #999;
    width: 100%;
    text-align: center;
    font-size: 0.95rem;
    padding: 20px 0;
}

.color-swatch {
    width: 42px;
    height: 52px;
    border-radius: 8px;
    border: 3px solid white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.color-swatch:hover {
    transform: scale(1.2) translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    z-index: 10;
    border-color: #667eea;
}

.color-swatch-inner {
    flex: 1;
}

.color-swatch-info {
    text-align: center;
    padding: 3px 0;
    background: white;
}

.color-swatch .hex-code {
    display: block;
    font-size: 7px;
    color: var(--text-dark);
    font-weight: 600;
    text-transform: uppercase;
}

.color-swatch .bead-count {
    display: block;
    font-size: 6px;
    color: var(--text-light);
}

.actions-section {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-primary {
    background: var(--bg-gradient);
    color: #f5f5f5;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-dark);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-danger {
    background: #e74c5e;
    color: #f5f5f5;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(231, 76, 94, 0.25);
}

.btn-danger:hover {
    background: #d63e52;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 94, 0.35);
}

.about-section {
    padding: 60px 20px;
    background: var(--bg-gradient);
    color: #f5f5f5;
}

.about-container {
    max-width: 1200px;
    margin: 0 auto;
}

.about-container h2 {
    text-align: center;
    font-size: 2.2rem;
    margin-bottom: 15px;
    color: #ffffff;
    font-weight: 800;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.about-container > p {
    text-align: center;
    font-size: 1rem;
    opacity: 0.95;
    max-width: 600px;
    margin: 0 auto 30px;
    color: rgba(255, 255, 255, 0.95);
}

.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.about-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 25px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.about-card h3 {
    margin-bottom: 12px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1a2e;
}

.about-card ol,
.about-card ul {
    padding-left: 20px;
    margin-bottom: 12px;
}

.about-card li {
    margin-bottom: 6px;
    opacity: 0.9;
    font-size: 0.95rem;
    color: #3a3a5a;
}

.about-card .color-link {
    display: inline-block;
    padding: 8px 18px;
    background: white;
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.about-card .color-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.footer {
    padding: 25px 20px;
    background: var(--text-dark);
    color: #f5f5f5;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
}

.footer p {
    opacity: 0.7;
    font-size: 0.85rem;
}

#toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: #f5f5f5;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: var(--shadow-lg);
}

#toast.show {
    opacity: 1;
}

@media (max-width: 1024px) {
    .generator-grid {
        grid-template-columns: 1fr;
    }

    .generator-left {
        position: static;
    }

    .preview-container {
        grid-template-columns: 1fr minmax(200px, 400px);
    }
}

@media (max-width: 768px) {
    .pixel-art-container {
        max-width: 100%;
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 15px 20px;
        box-shadow: var(--shadow-md);
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-link {
        padding: 12px 16px;
        border-radius: 10px;
    }

    .upload-area {
        padding: 30px 15px;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .control-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .control-group {
        justify-content: space-between;
    }

    .control-group input[type="range"] {
        flex: 1;
    }

    .preview-container {
        grid-template-columns: 1fr;
    }

    .image-container {
        aspect-ratio: 1;
    }

    .actions-section {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .btn-lg {
        padding: 14px 20px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .color-swatch {
        width: 50px;
        height: 58px;
    }

    .about-container h2 {
        font-size: 1.6rem;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .nav-container {
        padding: 0 15px;
    }

    .brand-text {
        font-size: 1rem;
    }

    .upload-label p {
        font-size: 1rem;
    }

    .preview-box {
        padding: 15px;
    }

    .preview-box h3 {
        font-size: 0.95rem;
    }

    .color-palette {
        padding: 15px;
        gap: 8px;
    }

    .color-swatch {
        width: 45px;
        height: 52px;
    }
}


