/* Block Building Game Styles */
.block-game-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Game Header */
.game-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding: 10px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
    gap: 20px;
}

/* Theme Selector */
.theme-selector {
    display: flex;
    gap: 10px;
}

.theme-btn {
    width: 60px;
    height: 60px;
    border: 3px solid transparent;
    border-radius: 15px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.theme-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.theme-btn.active {
    border-color: #FFE66D;
    background: linear-gradient(135deg, #FFE66D 0%, #FFC947 100%);
    animation: pulse 2s infinite;
}

.theme-icon {
    font-size: 32px;
}

/* Action Buttons */
.action-buttons,
.control-buttons {
    display: flex;
    gap: 10px;
}

.action-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.action-btn:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #FFE66D 0%, #FFC947 100%);
}

.action-btn:active {
    transform: scale(0.95);
}

.btn-icon {
    font-size: 24px;
}

/* Game Container */
.game-container {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* 3D Canvas */
.game-canvas {
    flex: 1;
    position: relative;
    cursor: crosshair;
    border: 3px dashed rgba(255, 230, 109, 0.5);
    border-radius: 10px;
    overflow: hidden;
    min-height: 0; /* Allow flex shrinking */
}

.game-canvas:hover {
    border-color: rgba(255, 230, 109, 0.8);
}

.game-canvas:active {
    cursor: crosshair;
}

/* Ensure canvas fills container properly */
.game-canvas canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
}

/* Block Rotation Control */
.rotation-control {
    position: absolute;
    top: 80px;
    right: 20px;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

.rotation-preview {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.preview-block {
    font-size: 32px;
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.rotation-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFE66D 0%, #FFC947 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(255, 230, 109, 0.3);
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.rotation-btn:active {
    transform: scale(0.95);
}

.rotation-icon {
    font-size: 24px;
    display: inline-block;
    animation: none;
}

.rotation-btn:active .rotation-icon {
    animation: spin-once 0.5s ease;
}

@keyframes spin-once {
    from { transform: rotate(0deg); }
    to { transform: rotate(90deg); }
}

/* Rotation states for preview */
.rotation-preview[data-rotation="0"] .preview-block {
    transform: rotate(0deg);
}

.rotation-preview[data-rotation="1"] .preview-block {
    transform: rotate(90deg);
}

.rotation-preview[data-rotation="2"] .preview-block {
    transform: rotate(180deg);
}

.rotation-preview[data-rotation="3"] .preview-block {
    transform: rotate(270deg);
}

/* Edge Controls */
.edge-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.edge-btn, .corner-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: all;
    user-select: none;
    -webkit-user-select: none;
}

/* No hover effect to prevent accidental block placement */

.edge-btn:active, .corner-btn:active {
    transform: scale(0.95);
}

/* Edge positioning */
.edge-top {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.edge-bottom {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.edge-left {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.edge-right {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

/* Corner positioning */
.corner-top-left {
    top: 20px;
    left: 20px;
}

.corner-top-right {
    top: 20px;
    right: 20px;
}

.corner-bottom-left {
    bottom: 20px;
    left: 20px;
}

.corner-bottom-right {
    bottom: 20px;
    right: 20px;
}

/* Corner buttons styling */
.corner-btn {
    width: 45px;
    height: 45px;
    font-size: 20px;
    background: rgba(255, 200, 100, 0.9);
}

/* Placement Hint */
.placement-hint {
    position: absolute;
    top: 20px;
    left: 20px;
    text-align: center;
    pointer-events: none;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: opacity 0.5s ease;
    max-width: 200px;
}

.hint-emoji {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
    animation: bounce 1s ease infinite;
}

.hint-text {
    font-size: 14px;
    color: #333;
    font-weight: bold;
    line-height: 1.2;
}

/* Block Selection Panel */
.block-panel {
    width: 120px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    padding: 10px;
    z-index: 50;
}

.block-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    opacity: 0.7;
    animation: bounceScroll 2s infinite;
    pointer-events: none;
    z-index: 5;
}

.scroll-arrow {
    font-size: 12px;
}

.scroll-text {
    font-size: 8px;
    font-weight: bold;
    color: #666;
}

@keyframes bounceScroll {
    0%, 20%, 50%, 80%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    40% {
        transform: translateX(-50%) translateY(-5px);
    }
    60% {
        transform: translateX(-50%) translateY(-3px);
    }
}

.block-item {
    aspect-ratio: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.block-item:hover {
    transform: scale(1.1);
    z-index: 10;
}

.block-item.selected {
    animation: wiggle 0.5s ease infinite;
    box-shadow: 0 0 20px rgba(255, 230, 109, 0.8);
}

.block-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    position: relative;
}

.block-emoji {
    font-size: 40px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

/* Different block shapes preview */
.cube-preview {
    clip-path: polygon(20% 0%, 80% 0%, 100% 20%, 100% 80%, 80% 100%, 20% 100%, 0% 80%, 0% 20%);
}

.long-preview {
    clip-path: polygon(10% 30%, 90% 30%, 90% 70%, 10% 70%);
}

.roof-preview {
    clip-path: polygon(50% 0%, 100% 40%, 100% 100%, 0% 100%, 0% 40%);
}

.cylinder-preview {
    border-radius: 50%;
}

.arch-preview {
    clip-path: polygon(0% 100%, 0% 40%, 20% 20%, 80% 20%, 100% 40%, 100% 100%);
}

.pyramid-preview {
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.sphere-preview {
    border-radius: 50%;
}

.wedge-preview {
    clip-path: polygon(0% 0%, 100% 100%, 0% 100%);
}

.tower-preview {
    border-radius: 50%;
    clip-path: polygon(20% 0%, 80% 0%, 90% 100%, 10% 100%);
}

.plate-preview {
    clip-path: polygon(0% 40%, 0% 60%, 100% 60%, 100% 40%);
}

.stairs-preview {
    clip-path: polygon(0% 100%, 0% 70%, 33% 70%, 33% 40%, 66% 40%, 66% 10%, 100% 10%, 100% 100%);
}

.cross-preview {
    clip-path: polygon(40% 0%, 60% 0%, 60% 40%, 100% 40%, 100% 60%, 60% 60%, 60% 100%, 40% 100%, 40% 60%, 0% 60%, 0% 40%, 40% 40%);
}

/* Achievement Popup */
.achievement-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: white;
    border-radius: 30px;
    padding: 40px;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.achievement-popup.show {
    transform: translate(-50%, -50%) scale(1);
}

.achievement-icon {
    font-size: 80px;
    display: block;
    margin-bottom: 20px;
    animation: bounce 1s ease infinite;
}

.achievement-title {
    font-size: 36px;
    color: #333;
    margin: 10px 0;
    font-weight: bold;
}

.achievement-text {
    font-size: 20px;
    color: #666;
    margin: 10px 0;
}

.achievement-close {
    margin-top: 20px;
    padding: 15px 30px;
    font-size: 18px;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.achievement-close:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.tutorial-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.tutorial-content {
    background: white;
    border-radius: 30px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
}

.tutorial-step {
    margin: 20px 0;
}

.tutorial-icon {
    font-size: 60px;
    display: block;
    margin-bottom: 20px;
    animation: point 1s ease infinite;
}

.tutorial-step p {
    font-size: 24px;
    color: #333;
    margin: 10px 0;
    font-weight: bold;
}

.tutorial-skip {
    padding: 15px 40px;
    font-size: 20px;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, #95E77E 0%, #76C442 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.tutorial-skip:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(149, 231, 126, 0.4);
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 3px 10px rgba(255, 230, 109, 0.3);
    }
    50% {
        box-shadow: 0 3px 20px rgba(255, 230, 109, 0.6);
    }
}

@keyframes wiggle {
    0%, 100% {
        transform: rotate(-3deg);
    }
    50% {
        transform: rotate(3deg);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes point {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-10px) rotate(-10deg);
    }
    75% {
        transform: translateY(-10px) rotate(10deg);
    }
}

/* Responsive Design - Simplified for edge controls */
@media (max-width: 768px) {
    /* Smaller rotation control on mobile */
    .rotation-control {
        top: 70px;
        right: 15px;
        gap: 8px;
    }
    
    .rotation-preview {
        width: 50px;
        height: 50px;
    }
    
    .preview-block {
        font-size: 28px;
    }
    
    .rotation-btn {
        width: 45px;
        height: 45px;
    }
    
    .rotation-icon {
        font-size: 20px;
    }
    .header-content {
        padding: 5px;
        gap: 8px;
    }
    
    .theme-btn {
        width: 40px;
        height: 40px;
    }
    
    .theme-icon {
        font-size: 20px;
    }
    
    .action-btn {
        width: 35px;
        height: 35px;
    }
    
    .btn-icon {
        font-size: 18px;
    }
    
    .block-panel {
        width: 60px;
        padding: 4px;
    }
    
    .block-emoji {
        font-size: 20px;
    }
    
    .block-item {
        margin: 2px 0;
    }
    
    /* Smaller edge controls on mobile */
    .edge-btn, .corner-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .corner-btn {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .header-content {
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        padding: 6px;
    }
    
    .theme-selector {
        order: 2;
        width: 100%;
        justify-content: center;
        gap: 6px;
    }
    
    .theme-btn {
        width: 32px;
        height: 32px;
    }
    
    .theme-icon {
        font-size: 16px;
    }
    
    .control-buttons {
        order: 1;
        gap: 4px;
    }
    
    .action-btn {
        width: 30px;
        height: 30px;
    }
    
    .btn-icon {
        font-size: 14px;
    }
    
    /* Even smaller edge controls on small mobile */
    .edge-btn, .corner-btn {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .corner-btn {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    
    /* Optimize block panel for mobile */
    .block-panel {
        width: 50px;
        padding: 2px;
    }
    
    .block-emoji {
        font-size: 16px;
    }
}

/* Ghost block preview */
.ghost-block {
    opacity: 0.5;
    pointer-events: none;
}

/* Grid helper */
.grid-helper {
    opacity: 0.3;
}

/* Loading spinner */
.loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 60px;
    animation: spin 1s linear infinite;
    z-index: 3000;
}

@keyframes spin {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}