* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    background-color: #f5f5f5;
    margin: 0;
    padding: clamp(16px, 4vw, 30px) 12px;
    user-select: none;
}

h1 {
    color: #333;
    margin: 0 0 20px;
}

.container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: clamp(20px, 5vw, 60px);
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.box-container {
    text-align: center;
}

.swatches {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: clamp(16px, 4vw, 40px);
    flex-wrap: wrap;
}

.color-box {
    width: clamp(110px, 28vw, 150px);
    height: clamp(110px, 28vw, 150px);
    border: 4px solid #fff;
    border-radius: 12px;
    background-color: #000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin: 0 auto 10px;
}

.picker-wrapper {
    background: #fff;
    padding: clamp(14px, 3vw, 20px);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(100%, 420px);
}

.wheel-container {
    position: relative;
    width: min(70vw, 320px);
    aspect-ratio: 1 / 1;
    height: auto;
    margin-bottom: 20px;
    touch-action: none;
}

.hue-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.ring-mask {
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    background-color: #fff;
    pointer-events: none;
}


.sv-box {
    position: absolute;
    top: 18%;
    left: 18%;
    width: 64%;
    height: 64%;
    background-color: red;
    cursor: pointer;
    box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.5);
}

.sv-overlay-white {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
    pointer-events: none;
}
.sv-overlay-black {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));
    pointer-events: none;
}

.handle {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#hue-handle {
    background-color: transparent;
    border: 3px solid #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5), inset 0 0 3px rgba(0, 0, 0, 0.5);
}

#sv-handle {
    background-color: transparent;
    border-color: #fff;
    box-shadow: 0 0 4px #000, inset 0 0 2px #000;
}

.info-panel {
    font-family: monospace;
    font-size: 16px;
    margin-bottom: 15px;
    color: #555;
}

.info-panel span {
    font-weight: bold;
    color: #111;
    display: inline-block;
    width: 45px;
    text-align: left;
}

button {
    padding: 10px 24px;
    font-size: 16px;
    margin: 0 8px;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    background-color: #4CAF50;
    color: white;
    font-weight: bold;
    transition: background 0.2s;
}

button:hover {
    background-color: #45a049;
}

.btn-secondary {
    background-color: #2196F3;
}

.btn-secondary:hover {
    background-color: #1e88e5;
}

.actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.actions button {
    margin: 0;
}

#result {
    margin-top: 20px;
    font-size: 18px;
    line-height: 1.6;
}

.diff-text {
    font-weight: bold;
    color: #e53935;
    font-size: 20px;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
        align-items: center;
        margin-bottom: 22px;
    }

    .swatches {
        width: 100%;
        flex-wrap: nowrap;
        justify-content: center;
    }
}

@media (max-width: 420px) {
    .actions {
        width: 100%;
    }

    .actions button {
        flex: 1 1 100%;
    }
}
