/* Puzzle Game Styles */

.puzzle-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-color);
}

/* Main nav bar (matches landing page) */
.puzzle-nav {
    background-color: var(--bg-color);
    box-shadow: 0 20px 40px rgba(138, 80, 50, 0.08);
    z-index: 20;
}

.puzzle-nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1536px;
    margin: 0 auto;
    padding: 16px 32px;
}

.puzzle-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    text-decoration: none;
    letter-spacing: -0.05em;
    transition: opacity 0.3s;
}

.puzzle-logo:hover {
    opacity: 0.8;
}

.puzzle-nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.puzzle-nav-link {
    color: var(--secondary-color);
    text-decoration: none;
    padding: 4px 16px;
    transition: all 0.5s;
}

.puzzle-nav-link:hover {
    color: var(--primary-color);
    transform: scale(1.05);
}

.puzzle-nav-link.active {
    color: var(--primary-color);
    border-bottom: 4px solid var(--primary-color);
    border-radius: 9999px;
}

/* Hamburger button (puzzle page) */
.puzzle-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.puzzle-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-color);
    transition: all 0.3s;
}

/* Mobile dropdown menu (puzzle page) */
.puzzle-mobile-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 32px 16px;
    border-top: 1px solid var(--border-color);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.puzzle-mobile-menu.hidden {
    display: none;
}

.puzzle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 24px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.puzzle-logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-color);
    text-decoration: none;
    letter-spacing: -0.05em;
}

.header-link {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 0.3s;
}

.header-link:hover {
    color: var(--primary-color);
}

.header-left,
.header-right {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left {
    justify-content: flex-start;
}

.header-right {
    justify-content: flex-end;
}

.header-center {
    flex: 1;
    text-align: center;
}

.progress-info {
    font-size: 0.9rem;
    color: var(--secondary-color);
    font-weight: 600;
}

.piece-count-select {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background-color: white;
    color: var(--text-color);
    cursor: pointer;
    transition: border-color 0.2s;
}

.piece-count-select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.puzzle-main {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.canvas-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#puzzle-canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    background-color: #b8b0a4;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15), 0 10px 15px -3px rgba(138, 80, 50, 0.1);
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#puzzle-canvas:active {
    cursor: grabbing;
}

/* Reference overlay */
.reference-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.reference-content {
    max-width: 90%;
    max-height: 90%;
    text-align: center;
}

.reference-content img {
    max-width: 100%;
    max-height: calc(90vh - 120px);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
}

/* Completion message */
.completion-message {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.completion-content {
    position: relative;
    background-color: var(--card-bg);
    padding: 60px 80px;
    border-radius: 16px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.5s ease-out;
}

.completion-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--secondary-color);
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;
}

.completion-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-color);
}

.completion-content h2 {
    font-size: 3rem;
    color: var(--success-color);
    margin-bottom: 20px;
}

.completion-content p {
    font-size: 1.25rem;
    margin-bottom: 30px;
    color: var(--secondary-color);
}

.completion-time:not(:empty) {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 30px;
}

.completion-time:empty {
    display: none;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.puzzle-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background-color: var(--card-bg);
    box-shadow: 0 -1px 3px 0 rgb(0 0 0 / 0.1);
}

.controls {
    display: flex;
    gap: 10px;
}

.help-text {
    color: var(--secondary-color);
    font-size: 0.875rem;
}

.help-text p {
    margin: 0;
}

/* Responsive — tablet and below */
@media (max-width: 768px) {
    .puzzle-nav-inner {
        padding: 16px;
    }

    .puzzle-nav-links {
        display: none;
    }

    .puzzle-hamburger {
        display: flex;
    }

    .puzzle-mobile-menu {
        padding: 8px 16px 16px;
    }

    .puzzle-header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 16px;
    }

    .header-left,
    .header-center,
    .header-right {
        justify-content: center;
    }

    .header-right {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .header-center h1 {
        font-size: 1.5rem;
    }

    .puzzle-footer {
        padding: 10px 16px;
    }

    .help-text {
        display: none;
    }

    .puzzle-main {
        padding: 10px;
    }

    .reference-overlay {
        padding: 16px;
    }

    .completion-content {
        padding: 32px 24px;
        margin: 16px;
        max-width: calc(100vw - 32px);
    }

    .completion-content h2 {
        font-size: 1.75rem;
    }

    .completion-content p {
        font-size: 1rem;
        margin-bottom: 20px;
    }

    .completion-time:not(:empty) {
        font-size: 1.25rem;
    }

    .btn-small {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* Responsive — small phones */
@media (max-width: 480px) {
    .puzzle-nav-inner {
        padding: 12px;
    }

    .puzzle-header {
        gap: 8px;
        padding: 8px 12px;
    }

    .header-right {
        gap: 6px;
    }

    .btn-small {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .piece-count-select {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .progress-info {
        font-size: 0.8rem;
    }

    .puzzle-main {
        padding: 6px;
    }

    .completion-content {
        padding: 24px 16px;
    }

    .completion-content h2 {
        font-size: 1.5rem;
    }
}
