* {
    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;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#game-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 1200px;
    width: 100%;
}

header {
    background: linear-gradient(135deg, #5f9ea0 0%, #4a7c7e 100%);
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
}

header h1 {
    margin-bottom: 15px;
    font-size: 2em;
}

#hud {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.hud-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 1.1em;
}

main {
    display: flex;
    padding: 20px;
    gap: 20px;
}

#gameCanvas {
    border: 3px solid #4a7c7e;
    border-radius: 8px;
    background: #8fbc8f;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#controls {
    min-width: 200px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 8px;
}

#controls h3 {
    margin-bottom: 12px;
    color: #4a7c7e;
}

#controls ul {
    list-style: none;
    margin-bottom: 20px;
}

#controls li {
    margin: 8px 0;
    font-size: 0.95em;
}

kbd {
    background: #333;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85em;
    margin: 0 2px;
}

.tool-slots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tool {
    padding: 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9em;
}

.tool:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.tool.active {
    border-color: #4a7c7e;
    background: #e6f3f3;
    font-weight: bold;
}

footer {
    background: #f5f5f5;
    padding: 15px 20px;
    border-radius: 0 0 12px 12px;
    text-align: center;
    color: #666;
}

/* Dialog Box Styles */
#dialog-box, #shop-menu, #inventory-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.dialog-content, .shop-content, .inventory-content {
    background: white;
    border-radius: 12px;
    padding: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.dialog-header, .shop-header, .inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.dialog-emoji {
    font-size: 2em;
    margin-right: 10px;
}

.dialog-name {
    font-size: 1.4em;
    font-weight: bold;
    color: #333;
    flex: 1;
}

.dialog-close, .shop-close, .inventory-close {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #999;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.dialog-close:hover, .shop-close:hover, .inventory-close:hover {
    background: #f0f0f0;
    color: #333;
}

.dialog-text {
    font-size: 1.1em;
    margin: 20px 0;
    line-height: 1.6;
    color: #555;
}

.dialog-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.dialog-options button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #5f9ea0 0%, #4a7c7e 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s;
}

.dialog-options button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Shop Menu Styles */
.shop-title {
    color: #4a7c7e;
    margin: 0;
}

.shop-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.shop-item {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px solid transparent;
}

.shop-item:hover {
    background: #e0f2f1;
    border-color: #4a7c7e;
    transform: translateY(-2px);
}

.item-emoji {
    font-size: 2em;
}

.item-name {
    flex: 1;
    font-weight: bold;
    color: #333;
}

.item-price {
    color: #4a7c7e;
    font-weight: bold;
    font-size: 1.1em;
}

/* Inventory Styles */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.inventory-item {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid #ddd;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.inventory-item:not(.empty):hover {
    background: #e0f2f1;
    border-color: #4a7c7e;
    transform: scale(1.05);
}

.inventory-item.empty {
    background: #fafafa;
    color: #ccc;
    cursor: default;
}

.inventory-item span:first-child {
    font-size: 1.5em;
}

.inventory-item span:last-child {
    font-size: 0.85em;
    color: #666;
}

/* Quest Tracker */
#quest-tracker {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #ddd;
}

#quest-list {
    font-size: 0.9em;
    color: #666;
    margin-top: 10px;
}

/* Mobile Touch Controls */
#mobile-controls {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    z-index: 100;
    pointer-events: none;
}

#mobile-controls > div {
    pointer-events: all;
}

.joystick-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 120px;
}

.joystick-base {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    position: relative;
    border: 3px solid rgba(255, 255, 255, 0.5);
}

.joystick-stick {
    width: 50px;
    height: 50px;
    background: rgba(95, 158, 160, 0.8);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid white;
}

.action-buttons {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(95, 158, 160, 0.8);
    border: 3px solid white;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.action-btn:active {
    transform: scale(0.9);
    background: rgba(95, 158, 160, 1);
}

.action-row {
    display: flex;
    gap: 10px;
}

@media (max-width: 768px) {
    main {
        flex-direction: column;
    }

    #gameCanvas {
        width: 100%;
        height: auto;
    }

    #controls {
        display: none;
    }

    #mobile-controls {
        display: block;
    }

    .dialog-content, .shop-content, .inventory-content {
        width: 95%;
        max-width: none;
        padding: 15px;
    }

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

    .shop-items {
        grid-template-columns: 1fr;
    }
}
