:root {
    --bg-dark: #0a0e17;
    --card-bg: #16213e;
    --accent: #00e1ff;
    --secondary: #e94560;
    --text: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container {
    padding: 20px;
    max-width: 1000px;
    width: 100%;
    text-align: center;
}

header h1 span {
    color: var(--accent);
}

.upload-bar {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.main-layout {
    display: flex;
    justify-content: center;
    gap: 40px;
    align-items: flex-start;
}

#puzzle-board {
    display: grid;
    width: 400px;
    height: 400px;
    background: #000;
    border: 4px solid var(--accent);
    box-shadow: 0 0 25px rgba(0, 225, 255, 0.2);
    touch-action: none;
    position: relative;
}

.puzzle-piece {
    border: 0.5px solid rgba(255, 255, 255, 0.1);
    cursor: grab;
    transition: transform 0.2s;
}

.dragging {
    opacity: 0.4;
}

.over {
    border: 2px solid var(--accent) !important;
    transform: scale(1.02);
}

.sidebar {
    width: 220px;
}

.ref-box {
    background: var(--card-bg);
    padding: 10px;
    border-radius: 8px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--accent);
}

#refImage {
    width: 100%;
    border-radius: 5px;
    display: none;
}

#refImage.active {
    display: block;
}

#placeholderText {
    font-size: 12px;
    color: #888;
}

button,
select {
    background: var(--card-bg);
    color: white;
    border: 1px solid var(--accent);
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

#startBtn {
    background: var(--accent);
    color: #000;
}

#startBtn:disabled {
    background: #444;
    border-color: #555;
    color: #888;
    cursor: not-allowed;
}

.secondary-btn {
    background: var(--secondary);
    border: none;
    width: 100%;
    margin-top: 10px;
    color: white;
}

@media (max-width: 850px) {
    .main-layout {
        flex-direction: column;
        align-items: center;
    }

    #puzzle-board {
        width: 320px;
        height: 320px;
    }

    .sidebar {
        width: 320px;
        flex-direction: row;
        gap: 10px;
    }

    .ref-box {
        width: 120px;
        min-height: 120px;
    }
}