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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #ff9ec4 0%, #ffb3d1 50%, #ffc8df 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

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

.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 20px;
}

.logo {
    font-size: 3rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.tagline {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
}

.main-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        max-width: 100%;
    }

    .header {
        padding: 20px 10px;
        margin-bottom: 20px;
    }

    .logo {
        font-size: 2rem;
        letter-spacing: 1px;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .controls-panel {
        position: relative;
        top: auto;
        padding: 20px;
        border-radius: 15px;
    }

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

    .slider-input-group {
        gap: 10px;
    }

    .number-input {
        width: 60px;
        padding: 6px 8px;
        font-size: 0.9rem;
    }

    .preview-panel {
        padding: 15px;
        border-radius: 15px;
        min-height: 300px;
    }

    .grid-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .grid-wrapper {
        min-width: fit-content;
    }

    .column-labels {
        margin-left: 45px;
        height: 25px;
    }

    .column-label {
        font-size: 0.65rem;
        min-width: 25px;
        padding: 1px 4px;
    }

    .row-labels {
        width: 45px;
        margin-right: 5px;
    }

    .row-label {
        font-size: 0.65rem;
        height: 25px;
    }

    .grid-canvas {
        border-width: 1px;
    }

    .upload-label {
        padding: 12px;
    }

    .upload-icon {
        font-size: 1.3rem;
    }

    .upload-text {
        font-size: 0.9rem;
    }

    .share-btn, .download-btn {
        padding: 14px;
        font-size: 0.95rem;
    }

    .button-group {
        box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3);
    }

    .footer {
        padding: 20px 10px;
        margin-top: 30px;
    }

    .footer-text {
        font-size: 0.85rem;
    }

    .resolution-info {
        padding: 10px;
        font-size: 0.9rem;
    }

    .slider-label {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .advanced-toggle {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .advanced-content {
        padding: 12px;
    }

    /* Better touch targets on small screens */
    .slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    .slider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
    }

    .header {
        padding: 15px 8px;
        margin-bottom: 15px;
    }

    .logo {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 0.85rem;
    }

    .controls-panel {
        padding: 15px;
    }

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

    .number-input {
        width: 55px;
        padding: 5px 6px;
        font-size: 0.85rem;
    }

    .preview-panel {
        padding: 10px;
    }

    .column-labels {
        margin-left: 40px;
        height: 22px;
    }

    .column-label {
        font-size: 0.6rem;
        min-width: 22px;
    }

    .row-labels {
        width: 40px;
    }

    .row-label {
        font-size: 0.6rem;
        height: 22px;
    }
}

.controls-panel {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 20px;
}

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

.control-group:last-child {
    margin-bottom: 0;
}

.upload-label {
    display: block;
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #ff6b9d 0%, #ff8fb3 100%);
    color: white;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.3);
    font-weight: 600;
}

.upload-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.4);
}

.upload-label:active {
    transform: translateY(0);
}

.upload-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 5px;
}

.upload-text {
    font-size: 1rem;
}

.upload-input {
    display: none;
}

.file-info {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}

.slider-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
}

.slider-label strong {
    color: #ff6b9d;
    font-size: 1.2em;
}

.slider-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider {
    flex: 1;
    height: 8px;
    border-radius: 5px;
    background: #ffe0ec;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    touch-action: none; /* Better touch control on mobile */
}

.number-input {
    width: 70px;
    padding: 8px 10px;
    border: 2px solid #ffe0ec;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: #ff6b9d;
    text-align: center;
    background: white;
    outline: none;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.number-input::-webkit-outer-spin-button,
.number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.number-input:focus {
    border-color: #ff6b9d;
    box-shadow: 0 0 0 3px rgba(255, 107, 157, 0.1);
}


.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b9d 0%, #ff8fb3 100%);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.4);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 12px rgba(255, 107, 157, 0.5);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b9d 0%, #ff8fb3 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.4);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 12px rgba(255, 107, 157, 0.5);
}

.resolution-info {
    padding: 12px;
    background: #ffe0ec;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    color: #ff6b9d;
    font-size: 1rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    color: #333;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
    accent-color: #ff6b9d;
}

.advanced-section {
    border: 2px solid #ffe0ec;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.advanced-toggle {
    width: 100%;
    padding: 12px 15px;
    background: linear-gradient(135deg, #ff6b9d 0%, #ff8fb3 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.3);
}

.advanced-section.expanded .advanced-toggle {
    border-radius: 12px 12px 0 0;
}

.advanced-toggle:hover {
    background: linear-gradient(135deg, #ff5a8a 0%, #ff7aa0 100%);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.4);
}

.advanced-toggle:active {
    transform: translateY(1px);
}

.advanced-toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    display: inline-block;
}

.advanced-section.expanded .advanced-toggle-icon {
    transform: rotate(180deg);
}

.advanced-toggle-text {
    flex: 1;
    text-align: left;
    margin-left: 8px;
}

.advanced-content {
    padding: 15px;
    background: #fffafc;
    border-top: 2px solid #ffe0ec;
}

.advanced-content .control-group {
    margin-bottom: 20px;
}

.advanced-content .control-group:last-child {
    margin-bottom: 0;
}

.button-group {
    display: flex;
    gap: 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.3);
    background: white;
}

.share-btn, .download-btn {
    flex: 1;
    padding: 12px;
    color: white;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.share-btn {
    background: linear-gradient(135deg, #8fb3ff 0%, #6b9dff 100%);
}

.share-btn::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 60%;
    background: rgba(255, 255, 255, 0.3);
}

.download-btn {
    background: linear-gradient(135deg, #ff6b9d 0%, #ff8fb3 100%);
}

.share-btn:hover:not(:disabled), .download-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.button-group:hover {
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.4);
}

.share-btn:active:not(:disabled), .download-btn:active:not(:disabled) {
    transform: translateY(0);
}

.share-btn:disabled, .download-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.share-btn:disabled:hover, .download-btn:disabled:hover {
    transform: none;
    filter: none;
}

/* Touch-friendly button styles */
button, .upload-label {
    -webkit-tap-highlight-color: rgba(255, 107, 157, 0.3);
    touch-action: manipulation; /* Improve touch responsiveness */
}

.preview-panel {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state {
    text-align: center;
    color: #999;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.empty-state p {
    font-size: 1.2rem;
    font-weight: 500;
}

.grid-container {
    width: 100%;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

.grid-wrapper {
    display: inline-block;
    position: relative;
    transition: transform 0.2s ease;
}

.column-labels {
    display: flex;
    margin-left: 50px;
    margin-bottom: 5px;
    height: 30px;
}

.column-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #ff6b9d;
    background: #ffe0ec;
    border-radius: 6px;
    min-width: 30px;
    padding: 2px 6px;
    margin-right: 1px;
}

.grid-row {
    display: flex;
}

.row-labels {
    display: flex;
    flex-direction: column;
    width: 50px;
    margin-right: 5px;
}

.row-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #ff6b9d;
    background: #ffe0ec;
    border-radius: 6px;
    height: 30px;
    margin-bottom: 1px;
}

.grid-canvas {
    border: 2px solid #ffe0ec;
    border-radius: 8px;
    display: block;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 40px;
}

.footer-text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    font-style: italic;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 10000;
    max-width: 90%;
    width: 400px;
    animation: toastSlideIn 0.4s ease-out forwards;
}

.toast.show {
    display: block;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
}

.toast-content {
    background: linear-gradient(135deg, #ff6b9d 0%, #ff8fb3 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(255, 107, 157, 0.4);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-message {
    flex: 1;
}

.toast-message strong {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.toast-message p {
    font-size: 0.875rem;
    margin: 0;
    line-height: 1.4;
    opacity: 0.95;
}

.toast-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.toast-close:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .toast {
        width: calc(100% - 40px);
        max-width: 400px;
        bottom: 15px;
    }

    .toast-content {
        padding: 14px 16px;
    }

    .toast-message strong {
        font-size: 0.95rem;
    }

    .toast-message p {
        font-size: 0.8rem;
    }
}

