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

body {
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.85);
    padding: 20px;
    border-radius: 10px;
    color: white;
    min-width: 280px;
    max-width: 320px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#ui-overlay h1 {
    font-size: 28px;
    margin-bottom: 15px;
    text-align: center;
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.info {
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.info p {
    margin: 0;
    font-size: 14px;
    color: #aaa;
}

/* Progress Stats */
.progress-stats {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.stat-label {
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #00ffff;
}

.selected-piece-info {
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 5px;
    border: 1px solid #00ffff;
    transition: all 0.3s ease;
}

.selected-piece-info.highlight {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

.selected-piece-info h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #00ffff;
}

.selected-piece-info p {
    margin: 5px 0;
    font-size: 13px;
}

/* Pieces Overview */
.pieces-overview {
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pieces-overview h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #ffd700;
}

.pieces-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.piece-item {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    position: relative;
}

.piece-item:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.piece-item.selected {
    border-color: #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.6);
}

.piece-item.in-cube::after {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 12px;
    color: #00ff00;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

/* Collapsible Controls */
.controls-container {
    margin-bottom: 15px;
}

.toggle-btn {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

#toggle-icon {
    transition: transform 0.3s ease;
}

#toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.controls-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.controls-content.collapsed {
    max-height: 0;
}

.controls {
    font-size: 11px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.control-section {
    margin-top: 10px;
    margin-bottom: 5px;
    font-weight: bold;
    color: #ffd700 !important;
    font-size: 12px !important;
}

.controls p {
    margin: 4px 0;
}

/* Main Buttons */
button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 10px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

button:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#reset-btn {
    background: #ff9800;
}

#reset-btn:hover {
    background: #f57c00;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 300px;
}

.toast {
    padding: 12px 16px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    background: rgba(76, 175, 80, 0.95);
}

.toast.error {
    background: rgba(244, 67, 54, 0.95);
}

.toast.warning {
    background: rgba(255, 152, 0, 0.95);
}

.toast.info {
    background: rgba(33, 150, 243, 0.95);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes popIn {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    70% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.toast.hiding {
    animation: slideOut 0.3s ease forwards;
}

/* Responsive Design */
@media (max-width: 768px) {
    #ui-overlay {
        min-width: auto;
        max-width: none;
        left: 10px;
        right: 10px;
        top: 10px;
        max-height: 50vh;
    }

    #ui-overlay h1 {
        font-size: 22px;
    }

    .pieces-list {
        grid-template-columns: repeat(7, 1fr);
    }

    .progress-stats {
        flex-wrap: wrap;
    }

    .stat-item {
        min-width: 80px;
    }

    #toast-container {
        top: auto;
        bottom: 20px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}
