* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f0f8ff;
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ddd;
}

h1, h2, h3 {
    color: #2c3e50;
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

.game-container {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
    height: calc(100vh - 120px);
}

.elements-panel, .discoveries-panel, .crafting-area {
    background-color: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.elements-panel h2, .discoveries-panel h2, .crafting-area h2 {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

#elementsContainer, #discoveriesContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.element {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: grab;
    user-select: none;
    text-align: center;
    font-weight: bold;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
    padding: 5px;
}

.element:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.element.dragging {
    opacity: 0.7;
    transform: scale(1.05);
}

.category-tag {
    position: absolute;
    bottom: 2px;
    font-size: 8px;
    opacity: 0.7;
    font-weight: normal;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 1px 3px;
    border-radius: 3px;
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 15px;
}

.category-filter {
    font-size: 0.8em;
    padding: 3px 8px;
    background-color: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 15px;
    cursor: pointer;
}

.category-filter.active {
    background-color: #3498db;
    color: white;
}

.progress-container {
    width: 100%;
    background-color: #f0f0f0;
    border-radius: 10px;
    margin: 15px 0;
    height: 15px;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: #2ecc71;
    width: 0;
    transition: width 0.5s ease;
}

.progress-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #333;
}

.achievement-popup {
    position: fixed;
    top: 20px;
    right: -300px;
    width: 280px;
    background-color: #fff;
    border-left: 5px solid #f1c40f;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    padding: 15px;
    display: flex;
    align-items: center;
    z-index: 1000;
    transition: right 0.5s ease;
}

.achievement-popup.show {
    right: 20px;
}

.achievement-icon {
    font-size: 30px;
    margin-right: 15px;
}

.achievement-content h4 {
    margin: 0 0 5px 0;
    color: #f39c12;
}

.achievement-content p {
    margin: 0;
    font-size: 12px;
    color: #555;
}

.milestone-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    padding: 20px;
    text-align: center;
    z-index: 1000;
    animation: scaleIn 0.3s ease;
}

.milestone-popup h3 {
    margin-top: 0;
    color: #f39c12;
}

.milestone-popup button {
    margin-top: 15px;
}

@keyframes scaleIn {
    from { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.hints-panel {
    background-color: #fcf8e3;
    border-radius: 5px;
    padding: 10px 15px;
    margin-top: 15px;
    font-size: 0.9em;
    color: #8a6d3b;
}

.hints-panel h4 {
    margin-top: 0;
    margin-bottom: 8px;
}

.hints-panel p {
    margin: 5px 0;
}

.crafting-container {
    height: 60%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.drop-zone {
    width: 90%;
    height: 200px;
    border: 3px dashed #ccc;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    transition: background-color 0.3s;
}

.drop-zone.active {
    background-color: rgba(52, 152, 219, 0.1);
    border-color: #3498db;
}

.result-container {
    text-align: center;
    margin-top: 20px;
    padding: 20px;
    border-radius: 10px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    animation: fadeIn 0.5s ease-out;
}

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

.result {
    margin: 10px auto;
    transform: scale(1.2);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.new-discovery {
    animation: pulse 0.5s ease-in-out;
}

.crafting-area {
    display: flex;
    flex-direction: column;
}

#discoveryCount {
    font-size: 0.8em;
    color: #7f8c8d;
}

@media (max-width: 768px) {
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 15px;
        height: auto;
    }
    
    .elements-panel, .discoveries-panel, .crafting-area {
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .drop-zone {
        height: 150px;
    }
    
    .element {
        width: 70px;
        height: 70px;
        font-size: 0.9em;
    }
    
    header {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .progress-container {
        margin: 10px 0;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .game-container {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 15px;
    }
    
    .crafting-area {
        grid-column: 1 / 3;
        grid-row: 1;
    }
    
    .elements-panel {
        grid-column: 1;
        grid-row: 2;
    }
    
    .discoveries-panel {
        grid-column: 2;
        grid-row: 2;
    }
}

@media (min-width: 1025px) {
    /* Desktop layout remains the same */
}