:root {
    --primary: #ff80ab;
    --primary-dark: #c94b7b;
    --secondary: #81c784;
    --bg: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text: #f8fafc;
    --accent: #f472b6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 32px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 540px;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
    font-weight: 800;
}

.subtitle {
    color: #94a3b8;
    margin-bottom: 32px;
    font-size: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.grid-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 18px;
    display: inline-flex;
}

.grid-btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: #94a3b8;
}

.grid-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.grid-btn.active {
    background: #38bdf8;
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

.puzzle-board {
    display: grid;
    /* grid-template-columns: repeat(3, 1fr);  -- Removed for dynamic control in JS */
    /* grid-template-rows: repeat(3, 1fr);     -- Removed for dynamic control in JS */
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 20px;
    aspect-ratio: 1 / 1;
    margin-bottom: 32px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.tile {
    background-size: 300% 300%;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), filter 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tile:hover {
    transform: scale(1.02);
    filter: brightness(1.1);
    z-index: 10;
}

.tile.empty {
    background: rgba(255, 255, 255, 0.03) !important;
    cursor: default;
    box-shadow: none;
}

.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border-radius: 14px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 10px 15px -3px rgba(255, 128, 171, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(255, 128, 171, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Overlay / Modal */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

.modal-content {
    background: var(--bg);
    padding: 24px;
    border-radius: 24px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 50px rgba(255, 128, 171, 0.2);
}

.original-img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 12px;
    display: block;
}

.close-btn {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 35px;
    height: 35px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: white;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Win screen */
.win-overlay {
    background: radial-gradient(circle, rgba(255, 128, 171, 0.2) 0%, rgba(15, 23, 42, 0.95) 100%);
}

.win-title {
    font-size: 3.5rem;
    margin-bottom: 16px;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(255, 128, 171, 0.5);
}