:root {
    --primary-color: #7b2cbf;
    --primary-hover: #9d4edd;
    --secondary-color: #3c096c;
    --bg-gradient: linear-gradient(135deg, #10002b 0%, #240046 100%);
    --text-color: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

h1, h2 {
    font-family: 'Gowun Dodum', sans-serif;
}

.container {
    width: 90%;
    max-width: 800px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    z-index: 10;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(to right, #e0aaff, #c77dff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    align-items: center;
}

.difficulty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0,0,0,0.2);
    padding: 0.5rem 1rem;
    border-radius: 50px;
}

select {
    background: transparent;
    color: white;
    border: none;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

select option {
    background: var(--secondary-color);
    color: white;
}

.btn {
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(123, 44, 191, 0.4);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(157, 78, 221, 0.6);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid var(--glass-border);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

main {
    display: flex;
    justify-content: center;
}

#puzzleBoard {
    display: grid;
    gap: 2px;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    position: relative;
    overflow: hidden;
}

.puzzle-tile {
    width: 100%;
    height: 100%;
    background-size: cover;
    cursor: grab;
    border-radius: 4px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.puzzle-tile:active {
    cursor: grabbing;
    transform: scale(0.95);
    box-shadow: 0 0 15px var(--primary-hover);
    z-index: 10;
}

.puzzle-tile.preview-mode {
    cursor: default;
}

.puzzle-tile.dragging {
    opacity: 0.5;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.show {
    display: flex;
    opacity: 1;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1rem;
    max-width: 90%;
    max-height: 90vh;
    box-shadow: var(--glass-shadow);
}

.success-content {
    text-align: center;
    padding: 3rem 2rem;
    background: linear-gradient(135deg, rgba(60, 9, 108, 0.9), rgba(36, 0, 70, 0.9));
}

.success-content h2 {
    font-size: 2.5rem;
    color: #ffd700;
    margin-bottom: 1rem;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.success-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #e0aaff;
}

.success-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s;
    line-height: 1;
    background: rgba(0,0,0,0.5);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--primary-hover);
    background: rgba(255,255,255,0.1);
}

#originalImg {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 10px;
    display: block;
}

@media (max-width: 600px) {
    header h1 {
        font-size: 1.8rem;
    }
    .controls {
        flex-direction: column;
    }
    .btn {
        width: 100%;
    }
    .success-actions {
        flex-direction: column;
    }
}

.empty-tile {
    background: rgba(0, 0, 0, 0.4) !important;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
    cursor: default !important;
    border-radius: 4px;
}

