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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
    font-feature-settings: 'ss01', 'cv01';
    background: #c9c9c9;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

#app {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Start Screen */
#start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 30px;
    text-align: center;
    color: rgba(0, 0, 0, 0.75);
    position: relative;
    z-index: 1;
}

#start-screen .emoji {
    font-size: 120px;
    margin-bottom: 40px;
    display: block;
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

#start-btn {
    padding: 50px 90px;
    background: transparent;
    border: none;
    color: #fff;
    font-family: 'Courier New', Courier, monospace;
    font-size: 72px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 8px;
    text-shadow:
        0 0 10px rgba(255, 255, 255, 0.8),
        0 0 20px rgba(255, 255, 255, 0.6),
        0 0 30px rgba(255, 255, 255, 0.4),
        3px 3px 0px rgba(0, 0, 0, 0.3);
    touch-action: manipulation;
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) backwards, pulse 2s ease-in-out infinite;
    animation-delay: 0.2s, 0.8s;
}

#start-btn:hover {
    transform: scale(1.1);
    text-shadow:
        0 0 15px rgba(255, 255, 255, 1),
        0 0 30px rgba(255, 255, 255, 0.8),
        0 0 45px rgba(255, 255, 255, 0.6),
        4px 4px 0px rgba(0, 0, 0, 0.4);
}

#start-btn:active {
    transform: scale(1.05);
}

/* Header */
#header {
    display: none;
}

/* Main View */
#main-view {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Upload Container */
.upload-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 20px 240px 20px;
    position: relative;
}

#upload-zone {
    width: 100%;
    max-width: 450px;
    padding: 60px 30px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(1rem);
    -webkit-backdrop-filter: blur(1rem);
    border-radius: 1.2rem;
    border: 3px dashed rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.1));
}

#upload-zone:hover {
    border-color: rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-4px);
    filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.15));
}

#upload-zone.dragover {
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.75);
    background: rgba(255, 255, 255, 0.5);
}

.upload-content {
    text-align: center;
    pointer-events: none;
}

.upload-text {
    color: rgba(0, 0, 0, 0.75);
    font-size: 18px;
    font-weight: 600;
}

/* Canvas Container */
#canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    max-height: calc(100vh - 260px);
}

#displayCanvas {
    max-width: 90%;
    max-height: 90%;
    width: auto;
    height: auto;
    border-radius: 1.2rem;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.2));
    object-fit: contain;
}

/* Controls */
#controls {
    position: absolute;
    bottom: 210px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 600px;
    width: auto;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    z-index: 10;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-wrap: wrap;
}

#controls.with-art-mode {
    bottom: 240px;
}

.btn {
    min-width: 50px;
    width: 50px;
    min-height: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(1rem);
    -webkit-backdrop-filter: blur(1rem);
    border: none;
    border-radius: 50%;
    color: rgba(0, 0, 0, 0.75);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    flex-shrink: 0;
}

.btn:hover {
    transform: translateY(-4px);
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.15));
}

.btn:active {
    transform: translateY(-2px) scale(0.95);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

#scramble-btn {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.4);
    font-size: 20px;
}

.btn svg {
    width: 20px;
    height: 20px;
    stroke: rgba(0, 0, 0, 0.75);
    stroke-width: 2;
    fill: none;
}

/* Settings Panel */
#settings-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 500px;
    width: calc(100% - 40px);
    padding: 15px 18px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(1rem);
    -webkit-backdrop-filter: blur(1rem);
    border-radius: 1.2rem;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.1));
    z-index: 9;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.setting-row label {
    color: rgba(0, 0, 0, 0.75);
    font-weight: 600;
    font-size: 14px;
}

.setting-row select,
.setting-row input[type="number"] {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    color: rgba(0, 0, 0, 0.75);
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.setting-row select {
    min-width: 100px;
}

.setting-row input[type="number"] {
    width: 90px;
}

.setting-row select:focus,
.setting-row input[type="number"]:focus {
    outline: none;
    border-color: rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.6);
}

.setting-row.custom-grid {
    gap: 10px;
}

.setting-row.art-mode-row {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 10px;
    border-radius: 8px;
    margin: 3px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    color: rgba(0, 0, 0, 0.75);
    font-weight: 600;
    font-size: 14px;
}

/* Stats Row */
.stats-row {
    display: flex;
    gap: 30px;
    justify-content: center;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.art-mode-note {
    text-align: center;
    color: rgba(0, 0, 0, 0.5);
    font-size: 11px;
    font-weight: 500;
    margin-top: 8px;
    letter-spacing: 0.3px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat span {
    color: rgba(0, 0, 0, 0.75);
    font-size: 18px;
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
}

.stat label {
    color: rgba(0, 0, 0, 0.6);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Status Message */
#status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(0, 0, 0, 0.75);
    font-size: 16px;
    text-align: center;
    padding: 25px 30px;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(1rem);
    -webkit-backdrop-filter: blur(1rem);
    border-radius: 1.2rem;
    max-width: 80%;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
    z-index: 100;
    font-weight: 600;
}

/* Hidden State */
.hidden {
    display: none !important;
}

/* Particles Animation */
.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    pointer-events: none;
    animation: float linear forwards;
    animation-duration: 1.5s;
    z-index: 0;
}

.particle.slow {
    animation-duration: 4s;
}

@keyframes float {
    0% {
        transform: translateY(0px) translateX(0px);
        opacity: 0;
    }
    5% {
        opacity: 0.8;
    }
    95% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(-110vh) translateX(var(--drift));
        opacity: 0;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.02);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    #start-btn {
        font-size: 48px;
        padding: 30px 50px;
    }

    #start-screen .emoji {
        font-size: 80px;
    }

    .upload-container {
        padding: 20px 20px 260px 20px;
    }

    #upload-zone {
        max-width: 380px;
        padding: 50px 25px;
    }

    .upload-text {
        font-size: 16px;
    }

    #canvas-container {
        padding: 15px;
        max-height: calc(100vh - 290px);
    }

    #displayCanvas {
        max-width: 95%;
        max-height: 95%;
    }

    #controls {
        bottom: 230px;
        gap: 12px;
        max-width: 500px;
        padding: 12px;
    }

    #controls.with-art-mode {
        bottom: 260px;
    }

    .btn {
        min-width: 45px;
        width: 45px;
        min-height: 45px;
        height: 45px;
        font-size: 18px;
    }

    #scramble-btn {
        min-width: 45px;
        width: 45px;
        min-height: 45px;
        height: 45px;
        font-size: 18px;
    }

    .btn svg {
        width: 18px;
        height: 18px;
    }

    #settings-panel {
        padding: 12px 15px;
        gap: 10px;
        bottom: 15px;
        width: calc(100% - 30px);
        max-width: 450px;
    }

    .setting-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .setting-row input[type="number"] {
        width: 80px;
    }

    .stats-row {
        gap: 20px;
        padding-top: 10px;
    }

    .stat span {
        font-size: 16px;
    }

    .stat label {
        font-size: 9px;
    }

    .art-mode-note {
        font-size: 10px;
        margin-top: 6px;
    }
}

@media (max-width: 480px) {
    #start-btn {
        font-size: 36px;
        padding: 20px 40px;
        letter-spacing: 4px;
    }

    .upload-container {
        padding: 20px 20px 270px 20px;
    }

    #upload-zone {
        max-width: 300px;
        padding: 40px 20px;
    }

    #controls {
        bottom: 220px;
        gap: 10px;
        max-width: 400px;
        padding: 10px;
    }

    #controls.with-art-mode {
        bottom: 250px;
    }

    .btn {
        min-width: 42px;
        width: 42px;
        min-height: 42px;
        height: 42px;
        font-size: 16px;
    }

    #scramble-btn {
        min-width: 42px;
        width: 42px;
        min-height: 42px;
        height: 42px;
        font-size: 16px;
    }

    .btn svg {
        width: 16px;
        height: 16px;
    }

    #settings-panel {
        padding: 10px 12px;
        gap: 8px;
        bottom: 12px;
        width: calc(100% - 24px);
        max-width: 400px;
    }

    .setting-row label {
        font-size: 13px;
    }

    .setting-row select,
    .setting-row input[type="number"] {
        font-size: 13px;
        padding: 6px 12px;
    }

    .setting-row input[type="number"] {
        width: 75px;
    }

    .stats-row {
        gap: 15px;
        padding-top: 8px;
    }

    .stat span {
        font-size: 15px;
    }

    .stat label {
        font-size: 9px;
    }

    .art-mode-note {
        font-size: 10px;
        margin-top: 5px;
    }
}

/* Prevent zoom on iOS */
@media screen and (max-width: 768px) {
    select,
    input {
        font-size: 16px;
    }
}
