:root {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface-hover: #25254a;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --success: #00b894;
    --danger: #e17055;
    --text: #f0f0f0;
    --text-dim: #888;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--surface);
    margin-bottom: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.accent {
    color: var(--accent);
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: var(--surface);
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--surface-hover);
}

/* Info Bar */
.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-weight: 600;
}

.puzzle-number {
    color: var(--accent-light);
}

.timer {
    font-size: 1.3rem;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.progress {
    color: var(--success);
}

/* Game Area */
.game-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.image-container {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: crosshair;
    aspect-ratio: 4/3;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

.image-container:hover {
    box-shadow: 0 4px 25px rgba(108, 92, 231, 0.2);
}

.image-container canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.image-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.4rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(0,0,0,0.6);
    color: var(--text-dim);
}

/* Navigation bar */
.nav-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.nav-label {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 600;
}

.btn-nav {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--surface-hover);
}

.btn-nav:hover {
    background: var(--surface-hover);
}

/* Difference indicators */
.diff-indicators {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.diff-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--text-dim);
    transition: all 0.3s;
}

.diff-dot.found {
    background: var(--success);
    border-color: var(--success);
    transform: scale(1.2);
    animation: pop 0.3s ease;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1.2); }
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow);
}

.modal-content h2 {
    margin-bottom: 1rem;
}

.modal-content p {
    margin-bottom: 0.75rem;
    color: var(--text-dim);
    text-align: left;
    line-height: 1.6;
}

.win-time, .win-score {
    font-size: 1.1rem;
    color: var(--text) !important;
    text-align: center !important;
}

.share-preview {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-line;
    text-align: left;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    margin: 0.25rem;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-secondary:hover {
    background: #2f2f5a;
}

.copied-msg {
    margin-top: 0.5rem;
    color: var(--success);
    font-weight: 600;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent-light);
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}

/* Circle highlight for found differences */
.diff-circle {
    position: absolute;
    border: 3px solid var(--success);
    border-radius: 50%;
    pointer-events: none;
    animation: circle-appear 0.4s ease;
    box-shadow: 0 0 10px rgba(0, 184, 148, 0.5);
}

@keyframes circle-appear {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}

/* Wrong click feedback */
.wrong-click {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 2px solid var(--danger);
    border-radius: 50%;
    pointer-events: none;
    animation: wrong-fade 0.6s ease forwards;
}

@keyframes wrong-fade {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Responsive */
@media (max-width: 768px) {
    .game-area {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .info-bar {
        font-size: 0.85rem;
    }

    .timer {
        font-size: 1.1rem;
    }
}

@media (max-width: 400px) {
    #app {
        padding: 0.5rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .modal-content {
        padding: 1.5rem;
    }
}
