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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow: hidden;
}

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

/* Header */
.game-header {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.back-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.game-header h1 {
    flex: 1;
    text-align: center;
    color: #333;
    font-size: 2em;
}

.stats {
    display: flex;
    gap: 20px;
    background: rgba(102, 126, 234, 0.1);
    padding: 10px 20px;
    border-radius: 8px;
}

.stat {
    font-weight: 600;
    color: #333;
}

.stat-label {
    color: #666;
    margin-right: 5px;
}

/* Main Content Layout */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 15px;
    padding: 15px;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.sidebar h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.search-box {
    margin-bottom: 10px;
}

.search-box input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
}

.sort-buttons {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.sort-btn {
    flex: 1;
    padding: 8px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s;
}

.sort-btn:hover {
    background: #f5f5f5;
}

.sort-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.element-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
    padding-right: 5px;
}

.element-list::-webkit-scrollbar {
    width: 8px;
}

.element-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.element-list::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.element-item {
    background: white;
    border: 2px solid #e0e0e0;
    padding: 12px;
    border-radius: 8px;
    cursor: grab;
    font-weight: 600;
    color: #333;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.element-item:active {
    cursor: grabbing;
}

.element-item:hover {
    transform: translateX(5px);
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.element-item.new {
    animation: newElementPulse 1s ease-out;
    border-color: #ffd700;
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
}

.element-badge {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #000;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    margin-left: auto;
}

@keyframes newElementPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.clear-btn, .reset-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    margin-top: 8px;
}

.clear-btn {
    background: #ff9800;
    color: white;
}

.clear-btn:hover {
    background: #f57c00;
    transform: translateY(-2px);
}

.reset-btn {
    background: #f44336;
    color: white;
}

.reset-btn:hover {
    background: #d32f2f;
    transform: translateY(-2px);
}

/* Workspace */
.workspace {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.workspace-header {
    margin-bottom: 15px;
}

.workspace-header h3 {
    color: #333;
    font-size: 1.4em;
    margin-bottom: 5px;
}

.instruction {
    color: #666;
    font-size: 14px;
}

.workspace-canvas {
    flex: 1;
    background: #f8f9fa;
    border: 3px dashed #ddd;
    border-radius: 12px;
    position: relative;
    overflow: auto;
}

.hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #999;
    pointer-events: none;
}

.hint-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

.hint p {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.hint-sub {
    font-size: 14px !important;
    font-weight: 400 !important;
    color: #bbb !important;
}

.workspace-element {
    position: absolute;
    background: white;
    border: 3px solid #667eea;
    padding: 15px 20px;
    border-radius: 12px;
    cursor: grab;
    font-weight: 600;
    color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    user-select: none;
    transition: box-shadow 0.3s;
    font-size: 16px;
}

.workspace-element:active {
    cursor: grabbing;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.workspace-element.dragging {
    opacity: 0.6;
    z-index: 1000;
}

.workspace-element.drag-over {
    border-color: #4caf50;
    border-width: 4px;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

/* Discoveries */
.discoveries {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.discoveries h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.discoveries-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 5px;
}

.discoveries-list::-webkit-scrollbar {
    width: 8px;
}

.discoveries-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.discoveries-list::-webkit-scrollbar-thumb {
    background: #ffd700;
    border-radius: 4px;
}

.no-discoveries {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    line-height: 1.8;
}

.discovery-item {
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
    border: 2px solid #ffd700;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    color: #333;
    animation: discoverySlideIn 0.5s ease-out;
}

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

.discovery-time {
    font-size: 11px;
    color: #999;
    font-weight: 400;
    margin-top: 4px;
}

/* Result Popup */
.result-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    transition: transform 0.3s ease-out;
    text-align: center;
    min-width: 300px;
}

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

.result-popup.hidden {
    display: none;
}

.result-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: popupBounce 0.6s ease-out;
}

@keyframes popupBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.result-element {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 15px;
}

.result-message {
    font-size: 18px;
    color: #667eea;
    font-weight: 600;
}

.result-message.new-discovery {
    color: #ffd700;
    font-size: 20px;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .discoveries {
        order: -1;
        max-height: 150px;
    }

    .sidebar {
        order: 1;
        max-height: 200px;
    }

    .workspace {
        order: 0;
    }

    .game-header h1 {
        font-size: 1.5em;
    }
}

@media (max-width: 768px) {
    .game-header {
        flex-wrap: wrap;
        padding: 10px 15px;
    }

    .game-header h1 {
        font-size: 1.3em;
        width: 100%;
        order: -1;
        margin-bottom: 10px;
    }

    .stats {
        font-size: 12px;
        padding: 8px 12px;
    }

    .main-content {
        padding: 10px;
        gap: 10px;
    }

    .workspace-element {
        padding: 12px 16px;
        font-size: 14px;
    }

    .result-popup {
        padding: 30px 20px;
        min-width: 250px;
    }

    .result-icon {
        font-size: 48px;
    }

    .result-element {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .sort-buttons {
        flex-direction: column;
    }

    .workspace-header h3 {
        font-size: 1.2em;
    }

    .instruction {
        font-size: 12px;
    }
}
