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

body {
    font-family: 'Pretendard', sans-serif;
    background: linear-gradient(135deg, #1a1c29 0%, #2d3446 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #f0f0f0;
}

.container {
    background: rgba(30, 35, 50, 0.7);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 90vw;
    border: 1px solid rgba(255,255,255,0.1);
}

h1 {
    color: #ff66a3;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.controls {
    margin-bottom: 20px;
}

select, button {
    padding: 10px 15px;
    font-size: 16px;
    border: none;
    border-radius: 10px;
    margin: 5px;
    outline: none;
    cursor: pointer;
    font-family: inherit;
}

select {
    background: #2d3446;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

button {
    background: #e91e63;
    color: white;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(233, 30, 99, 0.3);
}

#preview-btn {
    background: #4caf50;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}
#preview-btn:hover {
    background: #388e3c;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

button:hover {
    background: #c2185b;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233, 30, 99, 0.4);
}

.puzzle-wrapper {
    position: relative;
    width: 400px;
    height: 400px;
    margin: 0 auto;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
    background: #111;
    border: 4px solid #333;
}

@media (max-width: 450px) {
    .puzzle-wrapper {
        width: 300px;
        height: 300px;
    }
}

#puzzle-board {
    display: grid;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.tile {
    background-size: 400px 400px; 
    border: 1px solid rgba(255,255,255,0.8);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.tile.empty {
    background: rgba(255,255,255,0.3) !important;
    border: 1px dashed rgba(255,255,255,0.6);
    cursor: default;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

@media (max-width: 450px) {
    .tile {
        background-size: 300px 300px; 
    }
}

.tile.selected {
    border: 3px solid #ffeb3b;
    transform: scale(0.95);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
    z-index: 10;
}

#full-image, #overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s;
    background-size: cover;
    background-position: center;
}

#overlay {
    z-index: 30;
    background: rgba(255,255,255,0.85);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#overlay h2 {
    color: #e91e63;
    margin-bottom: 20px;
    font-size: 28px;
}

#original-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#original-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-content img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

#close-modal-btn {
    background: #e91e63;
}

.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}
