.puzzle-page {
    width: 100%;
    padding-bottom: 20px;
}

.puzzle-fullscreen-wrap {
    position: relative;
    width: 100%;
}

.puzzle-game {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.puzzle-hud {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.puzzle-hud h2 {
    font-family: 'Be My Glittertine', Arial, sans-serif;
    font-size: 36px;
    font-weight: normal;
    color: #FF0068;
    margin: 0;
}

.puzzle-hud-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.puzzle-fullscreen-btn {
    font-family: Arial, sans-serif;
    font-size: 13px;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(254, 144, 145, 0.6);
    border-radius: 12px;
    padding: 6px 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.puzzle-fullscreen-btn:hover {
    border-color: #FE9091;
    background: rgba(255, 0, 104, 0.25);
}

.puzzle-fullscreen-wrap:fullscreen,
.puzzle-fullscreen-wrap:-webkit-full-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 24px;
    box-sizing: border-box;
    background: radial-gradient(circle, rgba(254, 144, 145, 0.35) 0%, rgba(0, 0, 0, 1) 85%);
}

.puzzle-fullscreen-wrap:fullscreen .puzzle-game,
.puzzle-fullscreen-wrap:-webkit-full-screen .puzzle-game {
    max-width: min(96vw, 900px);
    width: 100%;
}

.puzzle-fullscreen-wrap:fullscreen .puzzle-board,
.puzzle-fullscreen-wrap:-webkit-full-screen .puzzle-board {
    max-width: min(92vw, 860px);
}

.puzzle-timer {
    font-family: Arial, sans-serif;
    font-size: 20px;
    color: #FE9091;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(254, 144, 145, 0.6);
    border-radius: 12px;
    padding: 6px 14px;
    min-width: 64px;
    text-align: center;
}

.puzzle-hint {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.65);
    margin: 0;
    text-align: center;
}

.puzzle-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(6, 1fr);
    width: 100%;
    max-width: 500px;
    aspect-ratio: 5 / 3;
    gap: 2px;
    padding: 4px;
    border: 2px solid rgba(254, 144, 145, 0.8);
    border-radius: 16px;
    background-color: rgba(0, 0, 0, 0.85);
    box-sizing: border-box;
    touch-action: manipulation;
}

.puzzle-piece {
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    cursor: pointer;
    background-repeat: no-repeat;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.puzzle-piece:hover {
    border-color: rgba(254, 144, 145, 0.7);
    z-index: 1;
}

.puzzle-piece.selected {
    border-color: #FF0068;
    box-shadow: 0 0 10px rgba(255, 0, 104, 0.8);
    transform: scale(1.05);
    z-index: 2;
}

.puzzle-celebration {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.puzzle-celebration.visible {
    opacity: 1;
    pointer-events: auto;
}

.puzzle-celebration-card {
    text-align: center;
    padding: 32px 40px;
    max-width: 420px;
    width: calc(100% - 40px);
    box-sizing: border-box;
    border: 2px solid rgba(254, 144, 145, 0.9);
    border-radius: 24px;
    background: radial-gradient(circle, rgba(254, 144, 145, 0.25) 0%, rgba(0, 0, 0, 0.95) 70%);
    box-shadow: 0 0 40px rgba(255, 0, 104, 0.4);
    animation: puzzle-pop 0.5s ease;
}

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

.puzzle-celebration-card h3 {
    font-family: 'Be My Glittertine', Arial, sans-serif;
    font-size: 42px;
    font-weight: normal;
    color: #FF0068;
    margin: 0 0 8px;
}

.puzzle-celebration-card p {
    font-family: Arial, sans-serif;
    font-size: 18px;
    color: #ffffff;
    margin: 0 0 20px;
}

.puzzle-celebration-time {
    font-size: 24px;
    color: #FE9091;
    margin-bottom: 16px !important;
}

.puzzle-celebration-image {
    display: block;
    width: 100%;
    max-width: 360px;
    height: auto;
    margin: 0 auto 20px;
    border-radius: 12px;
    border: 2px solid rgba(254, 144, 145, 0.6);
    box-shadow: 0 4px 20px rgba(255, 0, 104, 0.3);
    object-fit: contain;
}

.puzzle-celebration-btn {
    font-family: 'Be My Glittertine', Arial, sans-serif;
    font-size: 24px;
    color: #ffffff;
    background: linear-gradient(135deg, #ff0068 0%, #fe9091 100%);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 10px 28px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.puzzle-celebration-btn:hover {
    transform: scale(1.05);
}

.puzzle-confetti {
    position: fixed;
    top: -20px;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 201;
    animation: puzzle-confetti-fall linear forwards;
}

@keyframes puzzle-confetti-fall {
    to {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

@media (max-width: 520px) {
    .puzzle-page {
        padding-bottom: 12px;
    }

    .puzzle-game {
        max-width: 100%;
        width: 100%;
        padding: 0 4px;
        box-sizing: border-box;
        gap: 8px;
    }

    .puzzle-hud {
        flex-wrap: wrap;
        gap: 6px;
    }

    .puzzle-hud h2 {
        font-size: 24px;
        flex: 1 1 auto;
        min-width: 0;
    }

    .puzzle-hud-actions {
        flex-shrink: 0;
        gap: 6px;
    }

    .puzzle-fullscreen-btn {
        font-size: 11px;
        padding: 5px 8px;
    }

    .puzzle-timer {
        font-size: 15px;
        padding: 4px 8px;
        min-width: 52px;
    }

    .puzzle-hint {
        font-size: 13px;
        padding: 0 4px;
    }

    .puzzle-board {
        width: min(100%, calc(100vw - 48px));
        max-width: none;
        gap: 1px;
        padding: 2px;
        border-radius: 12px;
    }

    .puzzle-piece {
        border-radius: 2px;
    }

    .puzzle-piece.selected {
        transform: scale(1.03);
    }

    .puzzle-celebration-card {
        margin: 0 16px;
        padding: 24px 20px;
    }

    .puzzle-celebration-card h3 {
        font-size: 32px;
    }

    .puzzle-celebration-image {
        max-width: 100%;
    }
}
