#game-container {
    position: relative;
    width: 100%;
    /* max-width removed to allow full size */
    flex-grow: 1;
    height: 100%;
    min-height: 600px; /* Ensure at least some height */
    background-color: #222;
    border: 4px solid #444;
    overflow: hidden; /* Prevent canvas from spilling out if resized poorly */
}

.game-view {
    display: flex;
    justify-content: flex-start;
    gap: 20px;
    height: calc(100vh - 220px); /* Adjust based on header + log height */
    padding: 10px;
    box-sizing: border-box;
}

#event-log {
    height: 120px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #444;
    margin: 0 10px 10px 10px;
    padding: 10px;
    overflow-y: auto;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: #eee;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-entry {
    line-height: 1.4;
}

.log-good { color: #4f4; }
.log-bad { color: #f44; }
.log-neutral { color: #ccc; }
.log-item { color: #fb0; }

#sidebar-left {
    width: 250px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.resource-panel {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 15px;
    border: 2px solid #444;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    height: 100%;
    box-sizing: border-box;
    overflow-y: auto;
}

.resource-panel h3 {
    margin-top: 10px;
    text-align: center;
    border-bottom: 2px solid #444;
    padding-bottom: 5px;
    margin-bottom: 10px;
    color: #ffd700;
}

#hero-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#hero-list li {
    padding: 8px 5px;
    border-bottom: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 4px;
}

.header-controls {
    display: flex;
    gap: 40px;
    align-items: center;
    margin-right: 20px;
}

.header-stat {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    color: #ffd700;
    white-space: nowrap; /* Prevent wrapping */
    display: flex;
    align-items: center;
    gap: 10px;
}

progress {
    appearance: none;
    width: 100px;
    height: 20px;
    border: 2px solid #fff;
    background: #444;
}

progress::-webkit-progress-bar {
    background: #444;
}

progress::-webkit-progress-value {
    background: #0f0;
}

progress[value^="2"]::-webkit-progress-value, progress[value^="1"]::-webkit-progress-value {
    background: #f00; /* Low HP color (simple selector approximation) - Better to do via JS classes but this works for basic styling */
}

#gold-timer-bar::-webkit-progress-value {
    background: #ffd700; /* Gold */
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Removed #resources styling since it moved to header */

#card-hand {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 10px;
    pointer-events: auto;
}

.card-option {
    width: 80px;
    height: 100px;
    background: #555;
    border: 2px solid #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 5px;
    cursor: grab;
    transition: transform 0.1s;
    user-select: none;
}

.card-option:hover {
    transform: translateY(-5px);
    background: #666;
}

.card-option:active {
    cursor: grabbing;
}

.card-preview {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    text-align: center;
    color: #ddd;
}

.card-cost {
    font-size: 10px;
    color: #ffd700;
}

.full-width {
    width: 100%;
}

.spacer {
    height: 15px;
}

.btn.disabled {
    cursor: not-allowed;
    filter: grayscale(100%);
}

/* Help Modal */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #222;
    border: 4px solid #444;
    padding: 20px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.9);
}

#hero-modal {
    max-height: 80vh;
    overflow-y: auto;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

.help-section {
    margin-bottom: 20px;
}

.help-section h3 {
    color: #ffd700;
    font-size: 16px;
    margin-bottom: 10px;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}

.help-section p, .help-section ul {
    font-size: 12px;
    line-height: 1.6;
    color: #ccc;
}

.help-section ul {
    padding-left: 20px;
}

.help-section li {
    margin-bottom: 8px;
}

.icon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 12px;
}

@media (max-width: 768px) {
    /* Allow scrolling within the main app container */
    #app {
        overflow-y: auto;
        display: block; /* Switch to block to simplify scrolling behavior on mobile */
    }

    header {
        flex-direction: column;
        gap: 10px;
        height: auto;
        padding-bottom: 10px;
    }

    .header-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        margin-right: 0;
        width: 100%;
    }

    .header-stat {
        font-size: 10px;
        flex: 1 1 40%; /* Allow wrapping */
        justify-content: center;
    }

    /* Fix header buttons to not take full width */
    .header-controls .btn {
        width: auto;
        flex: 1 1 auto;
        min-width: 70px;
        margin-top: 0;
    }

    /* Re-order Game View */
    .game-view {
        flex-direction: column;
        height: auto;
        flex: none; /* Override global flex: 1 1 0 */
        padding: 5px;
        gap: 10px;
    }

    /* Game Canvas on Top and Large */
    #game-container {
        order: 1;
        width: 100%;
        height: 60vh; /* Give it 60% of viewport height */
        min-height: 300px;
        border-width: 2px;
    }

    /* Sidebar below Game */
    #sidebar-left {
        order: 2;
        width: 100%;
        height: auto;
    }

    .resource-panel {
        height: auto; /* Let it grow with content */
        max-height: 400px; /* But cap it so it doesn't dominate if list is long */
    }

    /* Event Log at bottom */
    #event-log {
        height: 100px;
        margin: 5px;
        flex: none;
    }

    /* Adjust buttons in sidebar */
    .btn.small-btn {
        padding: 8px;
        font-size: 11px;
    }
}

/* Party System Styles */
.party-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px dashed #666;
    padding: 5px;
    margin-bottom: 10px;
    min-height: 40px;
    transition: background 0.2s, border-color 0.2s;
}

.party-box.drag-over {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.15);
}

.party-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: #8df;
    margin-bottom: 5px;
    padding-bottom: 2px;
    border-bottom: 1px solid #444;
}

.party-members {
    list-style: none;
    padding: 0;
    margin: 0;
    min-height: 20px;
}

.party-members li {
    padding: 4px;
    background: rgba(255, 255, 255, 0.1);
    margin-bottom: 2px;
    font-size: 10px;
    cursor: grab;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hero-draggable {
    cursor: grab;
}

.hero-draggable:active {
    cursor: grabbing;
}

/* Add drag-over style for the main hero list to indicate it accepts drops */
#hero-list {
    min-height: 50px; /* Ensure it has height even when empty for dropping */
    transition: background 0.2s, border-color 0.2s;
}

#hero-list.drag-over {
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed #fff;
}
