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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-wrapper {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.main-content {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.controls-panel {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    flex: 0 0 300px;
    height: fit-content;
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: relative;
}

.controls-panel.hidden {
    transform: translateX(-100%);
    opacity: 0;
    position: absolute;
    pointer-events: none;
}

/* Google Ads Sidebar */
.ad-sidebar {
    flex: 0 0 300px;
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    height: fit-content;
    position: sticky;
    top: 20px;
}

.ad-sidebar h3 {
    font-size: 0.9em;
    color: #999;
    text-align: center;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ad-placeholder {
    background: #f5f5f5;
    border: 2px dashed #ddd;
    border-radius: 8px;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.9em;
    text-align: center;
    padding: 20px;
}

.menu-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: white;
    border: 2px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.menu-toggle:hover {
    background: #667eea;
    transform: scale(1.1);
}

.menu-toggle:hover .hamburger span {
    background: white;
}

.hamburger {
    width: 24px;
    height: 18px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger span {
    display: block;
    height: 3px;
    background: #667eea;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-toggle.active .hamburger span:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}

.menu-toggle.active .hamburger span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .hamburger span:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

.canvas-area {
    flex: 1;
    min-width: 300px;
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 500px;
    overflow: auto;
    transition: all 0.3s ease;
}

.canvas-area.expanded {
    flex: 1 1 100%;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
    color: white;
}

.spinner {
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid #667eea;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.2em;
    font-weight: 600;
}

/* Limit Modal */
.limit-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.limit-modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 50px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.8em;
    color: #667eea;
    margin-bottom: 15px;
    font-weight: 700;
}

.modal-message {
    font-size: 1.1em;
    color: #555;
    margin-bottom: 25px;
    line-height: 1.6;
}

.modal-highlight {
    background: #f0f0ff;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid #667eea;
}

.modal-highlight strong {
    color: #667eea;
}

.modal-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
    margin: 5px;
}

.modal-btn:hover {
    transform: translateY(-2px);
}

.modal-btn-secondary {
    background: #f0f0f0;
    color: #667eea;
}

.control-group {
    margin-bottom: 25px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.upload-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

input[type="file"] {
    display: none;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

input[type="color"] {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.range-value {
    text-align: center;
    font-weight: 600;
    color: #667eea;
    margin-top: 5px;
    font-size: 1.1em;
}

.toggle-btn {
    width: 100%;
    padding: 12px;
    background: #f0f0f0;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    color: #667eea;
}

.toggle-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#imageContainer {
    position: relative;
    display: inline-block;
}

.canvas-area:fullscreen {
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-area:-webkit-full-screen {
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-area:-moz-full-screen {
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}

#uploadedImage {
    max-width: 100%;
    max-height: 70vh;
    display: block;
    border-radius: 8px;
    transition: filter 0.3s ease;
}

#uploadedImage.grayscale {
    filter: grayscale(100%);
}

#gridCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.placeholder {
    text-align: center;
    color: #999;
    padding: 60px 20px;
}

.placeholder svg {
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.section-divider {
    border-top: 2px solid #e0e0e0;
    margin: 20px 0;
}

/* Bottom Ad Section */
.bottom-ad-section {
    margin-top: 40px;
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.bottom-ad-section h3 {
    font-size: 0.9em;
    color: #999;
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bottom-ad-placeholder {
    background: #f5f5f5;
    border: 2px dashed #ddd;
    border-radius: 8px;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.9em;
}

/* SEO Content Section */
.seo-content {
    background: white;
    border-radius: 16px;
    padding: 30px;
    margin-top: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    color: #555;
    line-height: 1.8;
}

.seo-content h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.seo-content h3 {
    color: #764ba2;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.seo-content p {
    margin-bottom: 15px;
}

.seo-content ul {
    margin-left: 30px;
    margin-bottom: 15px;
}

.seo-content li {
    margin-bottom: 8px;
}

@media (max-width: 1200px) {
    .ad-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .controls-panel {
        flex: 1;
    }

    h1 {
        font-size: 1.8em;
    }
}