* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #87CEEB 0%, #E0F7FA 100%);
    min-height: 100vh;
    overflow: hidden;
    user-select: none; /* Prevent text selection while dragging */
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

header {
    text-align: center;
    padding: 15px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

h1 {
    color: #d32f2f;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 1.8rem;
    margin: 0;
}

/* Input Section */
.input-section {
    display: flex;
    gap: 10px;
    margin-top: 5px;
    width: 100%;
    max-width: 600px;
}

input[type="text"] {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    border-color: #2196f3;
}

/* Instructions Panel */
.instructions {
    background: #fff9c4;
    padding: 15px 25px;
    border-radius: 15px;
    border-left: 5px solid #fbc02d;
    max-width: 600px;
    width: 90%;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.5s ease;
    opacity: 1;
    transform: translateY(0);
}

.instructions.hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.instructions h3 {
    color: #f57f17;
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.instructions p {
    color: #333;
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.primary-btn {
    background: linear-gradient(135deg, #ff4081, #f50057);
    color: white;
    padding: 12px 25px;
    font-size: 1rem;
}

.secondary-btn {
    background: #e0e0e0;
    color: #333;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Scene */
.scene {
    flex: 1;
    position: relative;
    perspective: 1000px;
    overflow: hidden;
    cursor: crosshair;
}

.ground {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 150px;
    background: linear-gradient(to bottom, #4caf50 0%, #388e3c 100%);
    transform: rotateX(45deg) scale(2);
    transform-origin: bottom;
    box-shadow: inset 0 20px 50px rgba(0,0,0,0.2);
    z-index: 0;
}

.bricks-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Allow clicking through to ground if needed, but bricks have pointer-events: auto */
}

/* Bricks */
.brick {
    width: 80px;
    height: 40px;
    position: absolute; /* Changed for free movement */
    transform-style: preserve-3d;
    cursor: grab;
    pointer-events: auto;
    transition: box-shadow 0.2s;
    /* Default shadow */
    filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.3));
}

.brick:active {
    cursor: grabbing;
    z-index: 1000 !important; /* Bring to front when dragging */
    filter: drop-shadow(5px 10px 15px rgba(0,0,0,0.4));
    transform: scale(1.05);
}

.brick-face {
    width: 100%;
    height: 100%;
    border: 2px solid rgba(0,0,0,0.15);
    border-radius: 4px;
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Standard 2x4 look */
    padding: 4px;
    box-sizing: border-box;
    gap: 2px;
}

.brick-2x2 { width: 40px; }
.brick-2x2 .brick-face { grid-template-columns: repeat(2, 1fr); }

.stud {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(0,0,0,0.15);
    box-shadow: inset 1px 1px 2px rgba(255,255,255,0.4), 1px 1px 1px rgba(0,0,0,0.1);
}

/* Colors */
.red { background: #e53935; border-bottom: 4px solid #b71c1c; }
.blue { background: #1e88e5; border-bottom: 4px solid #0d47a1; }
.yellow { background: #fdd835; border-bottom: 4px solid #f9a825; }
.green { background: #43a047; border-bottom: 4px solid #1b5e20; }
.orange { background: #fb8c00; border-bottom: 4px solid #e65100; }
.white { background: #f5f5f5; border-bottom: 4px solid #bdbdbd; }
.black { background: #424242; border-bottom: 4px solid #212121; }

/* Animation Classes */
@keyframes fallFromSky {
    0% {
        transform: translateY(-800px) rotate(10deg);
        opacity: 0;
    }
    70% {
        transform: translateY(20px) rotate(-5deg);
        opacity: 1;
    }
    100% {
        transform: translateY(0) rotate(0);
        opacity: 1;
    }
}

.animate-fall {
    animation: fallFromSky 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Cloud Decorations */
.cloud {
    position: absolute;
    background: white;
    border-radius: 50px;
    opacity: 0.8;
    animation: floatCloud linear infinite;
    z-index: 1;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

@keyframes floatCloud {
    from { left: -200px; }
    to { left: 120%; }
}
