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

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    text-align: center;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    margin-bottom: 10px;
    color: #333;
    font-size: 2.5em;
}

.instructions {
    margin-bottom: 25px;
    color: #555;
    font-size: 0.95em;
    line-height: 1.4;
}

.subtitle {
    margin-top: -20px;
    margin-bottom: 30px;
    color: #666;
    font-size: 1em;
}

.grid-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 100px);
    grid-template-rows: repeat(4, 100px);
    gap: 10px;
    position: relative;
    width: fit-content;
}

.row-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 0px;
}

.row-button {
    width: 40px;
    height: 100px;
    background: linear-gradient(135deg, #555 0%, #333 100%);
    border: 2px solid #222;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    transition: all 0.2s ease;
}

.row-button:hover {
    background: linear-gradient(135deg, #666 0%, #444 100%);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.color-wheel {
    display: none;
    position: fixed;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, #f0f0f0 100%);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    pointer-events: none;
}

.color-wheel.active {
    display: flex;
    pointer-events: auto;
}

.color-option {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    cursor: pointer;
    border: 4px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option[data-color="purple"] {
    background: #667eea;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.color-option[data-color="green"] {
    background: #2ecc71;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
}

.color-option[data-color="yellow"] {
    background: #f1c40f;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.color-option[data-color="blue"] {
    background: #3498db;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
}

.color-option[data-color="grey"] {
    background: #999;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.square {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid #555;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
    color: white;
    cursor: grab;
    user-select: none;
    /* animate position and background changes */
    transition: box-shadow 0.2s ease, background 0.25s ease, left 220ms ease, top 220ms ease, transform 180ms ease;
    position: relative;
}

.square:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.square:active {
    cursor: grabbing;
}

.square.dragging {
    opacity: 0.8;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.square.swapping {
    z-index: 800;
    transform: scale(1.03);
}

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

    .container {
        padding: 8px;
        border-radius: 10px;
        max-width: 100vw;
        overflow-x: hidden;
        width: 100%;
    }

    h1 {
        margin-bottom: 5px;
        font-size: 1.4em;
    }

    .instructions {
        margin-bottom: 12px;
        font-size: 0.7em;
        line-height: 1.3;
        word-wrap: break-word;
        white-space: normal;
    }

    .subtitle {
        margin-top: -3px;
        margin-bottom: 8px;
        font-size: 0.75em;
    }

    .grid-wrapper {
        flex-direction: row;
        gap: 3px;
        align-items: flex-start;
    }

    .row-buttons {
        flex-direction: column;
        gap: 3px;
    }

    .row-button {
        height: 50px;
        width: 25px;
        font-size: 14px;
    }

    .color-wheel {
        width: 180px;
        height: 180px;
    }

    .color-option {
        width: 45px;
        height: 45px;
        border-width: 2px;
    }

    .grid {
        grid-template-columns: repeat(4, 50px);
        grid-template-rows: repeat(4, 50px);
        gap: 3px;
    }

    .square {
        font-size: 0.75em;
        border: 2px solid #555;
    }
}
