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

:root {
    --primary: #ff66a3; /* Daisy Pink */
    --accent: #ffeb3b;  /* Daisy Yellow */
    --bg-gradient: linear-gradient(135deg, #1a1c29 0%, #2d3446 100%);
    --surface: rgba(30, 35, 50, 0.7);
    --text: #f0f0f0;
    --card-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    --board-size: 400px;
    --board-size-m: 300px;
}

body {
    font-family: 'Pretendard', 'Outfit', 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.1);
    animation: fadeIn 0.8s ease-out;
}

header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 20px;
    letter-spacing: -0.5px;
    text-shadow: 0 0 20px rgba(255, 102, 163, 0.3);
}

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: 12px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
}

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

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

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

select, button {
    padding: 12px 20px;
    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: #2d3446;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

button {
    background: var(--primary);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(255, 102, 163, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 102, 163, 0.4);
    background: #ff4d91;
}

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

button.secondary {
    background: #4a5568;
}

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

#preview-btn:hover {
    background: #45a049;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}

/* Puzzle Board */
.puzzle-wrapper {
    position: relative;
    width: var(--board-size);
    height: var(--board-size);
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    background: #111;
    border: 6px solid #2d3446;
}

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

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

.tile:hover:not(.empty) {
    z-index: 5;
    box-shadow: inset 0 0 15px rgba(255,255,255,0.2);
    filter: brightness(1.1);
}

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

/* Overlay & Modals */
#overlay.hidden {
    display: none;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    background: rgba(26, 28, 41, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay-content h2 {
    color: var(--accent);
    font-size: 4rem;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(255, 235, 59, 0.6);
    font-weight: 900;
}

.overlay-content p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 25px;
}

#restart-btn {
    animation: fadeIn 1s ease-in 1s forwards;
    display: inline-block;
}

#restart-btn.hidden {
    display: none;
}

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

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

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

.modal-content {
    background: #2d3446;
    padding: 30px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6);
    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: 30px;
    cursor: pointer;
    color: #fff;
    opacity: 0.6;
}

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

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

footer {
    margin-top: 30px;
    opacity: 0.4;
    font-size: 12px;
}

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

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

/* Responsive */
@media (max-width: 450px) {
    .container {
        padding: 20px;
    }
    .puzzle-wrapper {
        width: var(--board-size-m);
        height: var(--board-size-m);
    }
    .tile {
        background-size: var(--board-size-m) var(--board-size-m);
    }
}
