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

:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --accent: #81f9e6;
    --accent-hover: #feb7ac;
    --accent-gradient: linear-gradient(135deg, #feb7ac 0%, #81f9e6 100%);
    --accent-gradient-hover: linear-gradient(135deg, #ffc4bb 0%, #95fdf1 100%);
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    background-image: url('background.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--text-primary);
    min-height: 100vh;
    padding: 10px;
}

.header {
    max-width: 1400px;
    margin: 0 auto 20px auto;
    padding: 0 20px;
}

.logo {
    height: 48px;
    width: auto;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.logo:hover {
    transform: scale(1.05);
}

@media (max-width: 767px) {
    .header {
        padding: 0 10px;
        margin-bottom: 15px;
    }
    
    .logo {
        height: 40px;
    }
}

@media (min-width: 768px) {
    body {
        padding: 20px;
    }
}

.container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 140px); /* Account for footer and padding */
}

@media (max-width: 767px) {
    .container {
        grid-template-columns: 1fr;
        gap: 15px;
        min-height: auto;
    }
}

.left-pane {
    background: rgba(45, 45, 45, 0.3);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

@media (max-width: 767px) {
    .left-pane {
        padding: 16px;
        border-radius: 8px;
    }
}

.left-pane h1 {
    font-size: 24px;
    margin-bottom: 24px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

.control-group {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

@media (max-width: 767px) {
    .control-group {
        margin-bottom: 16px;
    }
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.control-group input[type="text"],
.control-group input[type="color"],
.control-group select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(61, 61, 61, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid transparent;
    background-image: var(--accent-gradient), linear-gradient(rgba(61, 61, 61, 0.4), rgba(61, 61, 61, 0.4));
    background-origin: border-box;
    background-clip: padding-box, border-box;
    border-radius: 6px;
    color: #2a2a2a;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(1);
    transform-origin: center;
}

@media (max-width: 767px) {
    .control-group input[type="text"],
    .control-group input[type="color"],
    .control-group select {
        padding: 12px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
        font-weight: 600;
    }
}

/* Style select options */
.control-group select option {
    background: rgba(45, 45, 45, 0.95);
    color: #2a2a2a;
    font-weight: 600;
}

/* Placeholder styling */
.control-group input[type="text"]::placeholder {
    color: rgba(42, 42, 42, 0.6);
    font-weight: 500;
}

.control-group input[type="text"]:hover,
.control-group select:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(254, 183, 172, 0.15);
}

.control-group input[type="text"]:active,
.control-group select:active {
    transform: scale(0.98);
}

.control-group input[type="text"]:focus,
.control-group select:focus {
    outline: none;
    background-image: var(--accent-gradient-hover), linear-gradient(rgba(61, 61, 61, 0.5), rgba(61, 61, 61, 0.5));
    box-shadow: 0 0 0 3px rgba(254, 183, 172, 0.3), 0 4px 16px rgba(129, 249, 230, 0.2);
    transform: scale(1.03);
    animation: inputPulse 2s ease-in-out infinite;
}

@keyframes inputPulse {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(254, 183, 172, 0.3), 0 4px 16px rgba(129, 249, 230, 0.2);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(254, 183, 172, 0.4), 0 4px 20px rgba(129, 249, 230, 0.3);
    }
}

.control-group input[type="color"] {
    height: 45px;
    cursor: pointer;
    padding: 4px;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(1);
    border-radius: 8px;
}

.control-group input[type="color"]:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(254, 183, 172, 0.25);
}

.control-group input[type="color"]:active {
    transform: scale(0.95);
}

.control-group input[type="color"]:focus {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(129, 249, 230, 0.3);
    animation: colorPulse 1.5s ease-in-out infinite;
}

@keyframes colorPulse {
    0%, 100% {
        transform: scale(1.08);
    }
    50% {
        transform: scale(1.1);
    }
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: rgba(61, 61, 61, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
}

.control-group input[type="range"]:hover {
    height: 8px;
    box-shadow: 0 2px 8px rgba(254, 183, 172, 0.2);
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-gradient);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(1);
    box-shadow: 0 2px 8px rgba(254, 183, 172, 0.3);
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-gradient-hover);
    transform: scale(1.4);
    box-shadow: 0 4px 16px rgba(129, 249, 230, 0.5);
    animation: thumbBounce 0.6s ease-in-out;
}

.control-group input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.2);
    animation: thumbPulse 0.3s ease-in-out;
}

@keyframes thumbBounce {
    0%, 100% {
        transform: scale(1.4);
    }
    50% {
        transform: scale(1.6);
    }
}

@keyframes thumbPulse {
    0%, 100% {
        transform: scale(1.2);
    }
    50% {
        transform: scale(1.3);
    }
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-gradient);
    cursor: pointer;
    border-radius: 50%;
    border: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(1);
    box-shadow: 0 2px 8px rgba(254, 183, 172, 0.3);
}

.control-group input[type="range"]::-moz-range-thumb:hover {
    background: var(--accent-gradient-hover);
    transform: scale(1.4);
    box-shadow: 0 4px 16px rgba(129, 249, 230, 0.5);
}

.control-group input[type="range"]::-moz-range-thumb:active {
    transform: scale(1.2);
}

.value-display {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    cursor: pointer;
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
    background: var(--accent-gradient);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(1);
}

.checkbox-label input[type="checkbox"]:hover {
    transform: scale(1.2);
}

.checkbox-label input[type="checkbox"]:checked {
    transform: scale(1.15);
    animation: checkboxCheck 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.checkbox-label input[type="checkbox"]:active {
    transform: scale(0.9);
}

@keyframes checkboxCheck {
    0% {
        transform: scale(1.15);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1.15);
    }
}

.checkbox-label span {
    font-size: 14px;
    color: var(--text-primary);
}

.upload-label {
    position: relative;
    display: inline-block;
    width: 100%;
    margin-top: 8px;
}

.upload-label input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.upload-button {
    display: block;
    padding: 10px 12px;
    background: rgba(61, 61, 61, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 14px;
    transform: scale(1);
}

.upload-button:hover {
    background: var(--accent-gradient);
    border-color: transparent;
    color: var(--bg-primary);
    font-weight: 600;
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 20px rgba(254, 183, 172, 0.4);
    animation: buttonShimmer 1.5s ease-in-out infinite;
}

.upload-button:active {
    transform: scale(0.95) translateY(0);
    animation: none;
}

@keyframes buttonShimmer {
    0%, 100% {
        box-shadow: 0 6px 20px rgba(254, 183, 172, 0.4);
    }
    50% {
        box-shadow: 0 8px 24px rgba(129, 249, 230, 0.5);
    }
}

.or {
    display: block;
    text-align: center;
    margin: 12px 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.font-display {
    margin-top: 8px;
    padding: 8px;
    background: rgba(61, 61, 61, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    min-height: 20px;
}

.right-pane {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.preview-container {
    background: rgba(45, 45, 45, 0.3);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    flex: 1;
    overflow: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

@media (max-width: 767px) {
    .preview-container {
        padding: 16px;
        border-radius: 8px;
        min-height: 300px;
    }
}

.preview-container h2 {
    font-size: 20px;
    margin-bottom: 16px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

#preview-canvas {
    background: rgba(26, 26, 26, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    max-width: 100%;
    height: auto;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease;
    /* Prevent CSS scaling that causes blurriness */
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
}

#preview-canvas.no-antialiasing {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.bake-button {
    padding: 16px 32px;
    background: var(--accent-gradient);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(254, 183, 172, 0.3);
    position: relative;
    overflow: hidden;
}

@media (max-width: 767px) {
    .bake-button {
        padding: 14px 24px;
        font-size: 15px;
        width: 100%;
    }
}

.bake-button:hover {
    background: var(--accent-gradient-hover);
    box-shadow: 0 6px 16px rgba(129, 249, 230, 0.4);
    transform: translateY(-2px);
}

.bake-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(254, 183, 172, 0.3);
}

.bake-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.reset-button {
    width: 100%;
    padding: 12px 24px;
    background: rgba(61, 61, 61, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(1);
}

@media (max-width: 767px) {
    .reset-button {
        padding: 14px 20px;
        font-size: 15px;
    }
}

.reset-button:hover {
    background: rgba(64, 64, 64, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid transparent;
    background-image: var(--accent-gradient), linear-gradient(rgba(64, 64, 64, 0.5), rgba(64, 64, 64, 0.5));
    background-origin: border-box;
    background-clip: padding-box, border-box;
    color: var(--text-primary);
    transform: scale(1.03) translateY(-2px);
    box-shadow: 0 6px 20px rgba(254, 183, 172, 0.3);
}

.reset-button:active {
    transform: scale(0.97) translateY(0);
    animation: resetBounce 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes resetBounce {
    0%, 100% {
        transform: scale(0.97);
    }
    50% {
        transform: scale(0.95);
    }
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

.footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.footer a {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 600;
}

.footer a:hover {
    background: var(--accent-gradient-hover);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: underline;
}

/* Custom Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-gradient);
    border-radius: 6px;
    border: 2px solid rgba(26, 26, 26, 0.2);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-gradient-hover);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(254, 183, 172, 0.4);
}

::-webkit-scrollbar-thumb:active {
    background: var(--accent-gradient);
    transform: scale(0.95);
}

::-webkit-scrollbar-corner {
    background: var(--bg-primary);
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(254, 183, 172, 0.6) var(--bg-primary);
}

@media (max-width: 1024px) and (min-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .left-pane {
        max-height: 60vh;
    }
}

@media (max-width: 767px) {
    .left-pane h1 {
        font-size: 20px;
        margin-bottom: 16px;
    }
    
    .preview-container h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .control-group label {
        font-size: 13px;
    }
    
    .upload-button {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    #preview-canvas {
        width: 100%;
        height: auto;
        max-height: 400px;
    }
    
    .footer {
        padding: 15px 10px;
        font-size: 12px;
    }
    
    body {
        background-attachment: scroll; /* Better performance on mobile */
    }
}

