/* Reset and Fonts */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #f78fb3; /* Soft Lotus Pink */
    --accent: #55efc4;  /* Fresh Mint Green */
    --bg-gradient: linear-gradient(135deg, #2d3436 0%, #000000 100%);
    --surface: rgba(45, 52, 54, 0.7);
    --text: #ffffff;
    --card-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    --board-size: 400px;
    --board-size-m: 300px;
}

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

/* Container & Layout */
.container {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--card-shadow);
    text-align: center;
    max-width: 90vw;
    border: 1px solid rgba(255,255,255,0.05);
    animation: fadeIn 0.8s ease-out;
}

header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 20px;
    letter-spacing: -1px;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(247, 143, 179, 0.4);
}

header .accent {
    color: var(--accent);
}

.stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
}

.stat-item {
    background: rgba(0,0,0,0.3);
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

.stat-item .label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
}

.stat-item .value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Controls */
.controls {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

select, button {
    padding: 12px 24px;
    font-size: 15px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

select {
    background: #444;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
}

button {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(247, 143, 179, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(247, 143, 179, 0.4);
    filter: brightness(1.1);
}

button:active {
    transform: scale(0.96);
}

button.secondary {
    background: #636e72;
}

#preview-btn {
    background: #00b894;
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.3);
}

/* Puzzle Board */
.puzzle-wrapper {
    position: relative;
    width: var(--board-size);
    height: var(--board-size);
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    background: #000;
    border: 8px solid #2d3436;
}

#puzzle-board {
    display: grid;
    width: 100%;
    height: 100%;
}

.tile {
    background-size: var(--board-size) var(--board-size);
    border: 1px solid rgba(255,255,255,0.08);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease-out;
    box-sizing: border-box;
}

.tile:hover:not(.empty) {
    z-index: 10;
    transform: scale(1.02);
    box-shadow: inset 0 0 20px rgba(255,255,255,0.15);
    filter: brightness(1.15);
}

.tile.empty {
    background: #1e272e !important;
    border: none;
    cursor: default;
    box-shadow: inset 5px 5px 20px rgba(0,0,0,0.4);
}

/* Overlay & Modals */
#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#overlay.hidden {
    display: none;
}

.overlay-content h2 {
    color: var(--primary);
    font-size: 3rem;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(247, 143, 179, 0.6);
    font-weight: 800;
}

.overlay-content p {
    font-size: 1.1rem;
    opacity: 0.8;
    margin-bottom: 30px;
}

.trophy-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 15px var(--primary));
}

#original-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#original-modal.hidden {
    display: none;
}

.modal-content {
    background: #1e272e;
    padding: 30px;
    border-radius: 30px;
    text-align: center;
    max-width: 90vw;
    border: 1px solid rgba(255,255,255,0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-icon {
    font-size: 36px;
    cursor: pointer;
    color: #fff;
    opacity: 0.5;
}

.close-icon:hover {
    opacity: 1;
}

.modal-content img {
    max-width: 100%;
    max-height: 65vh;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    margin-bottom: 20px;
}

footer {
    margin-top: 40px;
    opacity: 0.3;
    font-size: 12px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Responsive */
@media (max-width: 450px) {
    .container {
        padding: 25px 15px;
    }
    .puzzle-wrapper {
        width: var(--board-size-m);
        height: var(--board-size-m);
    }
    .tile {
        background-size: var(--board-size-m) var(--board-size-m);
    }
    header h1 {
        font-size: 2.2rem;
    }
}
