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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    font-family: 'Courier New', monospace;
    background: #1a1a1a;
    color: #fff;
    touch-action: manipulation;
    -webkit-overflow-scrolling: none;
}

body {
    display: flex;
    flex-direction: column;
}

.game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Top UI - Fixed at top */
.top-ui {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.9);
    border-bottom: 2px solid #333;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
    z-index: 100;
}

.resources {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.resource-item {
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    border: 1px solid #333;
}

.resource-icon {
    font-size: 20px;
}

.controls-info {
    font-size: 11px;
    color: #aaa;
    display: none; /* Hide on mobile, show menu button instead */
}

.menu-button {
    position: fixed;
    top: 8px;
    right: 8px;
    width: 48px;
    height: 48px;
    background: rgba(74, 159, 74, 0.8);
    border: 2px solid #4a9f4a;
    border-radius: 8px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    touch-action: manipulation;
}

.menu-button:active {
    transform: scale(0.95);
}

/* Canvas Container - Fills remaining space */
.canvas-container {
    flex: 1;
    width: 100%;
    min-height: 0; /* Important for flex children */
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0a0a0a;
    overflow: hidden;
    touch-action: none;
    position: relative;
}

#gameCanvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    display: block;
    background: #0a1a0a;
    border: 2px solid #3a4a3a;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    border-radius: 4px;
    max-width: 100%;
    height: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

/* Building Menu - Modal */
.building-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.building-menu.open {
    transform: translateX(0);
}

.building-menu-content {
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

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

.menu-title {
    font-size: 20px;
    font-weight: bold;
    color: #4a9f4a;
}

.close-menu-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 0, 0, 0.3);
    border: 2px solid #ff4444;
    border-radius: 6px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.close-menu-btn:active {
    transform: scale(0.9);
}

.building-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.build-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: rgba(40, 40, 40, 0.9);
    border: 2px solid #555;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    font-family: inherit;
    width: 100%;
    max-width: 100%;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.build-btn:hover {
    background: rgba(60, 60, 60, 0.9);
    border-color: #4a9f4a;
    transform: translateY(-2px);
}

.build-btn:active {
    transform: translateY(0);
}

.build-btn.selected {
    border-color: #4a9f4a;
    background: rgba(74, 159, 74, 0.2);
    box-shadow: 0 0 10px rgba(74, 159, 74, 0.5);
}

.build-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.build-btn:not(.disabled) {
    pointer-events: auto;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: 2px solid #666;
    border-radius: 4px;
    image-rendering: pixelated;
}

.goo-station-icon {
    background: linear-gradient(135deg, #4a9f4a 0%, #2d6a2d 100%);
    border-color: #6a9f6a;
}

.worker-icon {
    background: linear-gradient(135deg, #9f9f4a 0%, #6a6a2d 100%);
    border-color: #9f9f6a;
}

.farm-icon {
    background: linear-gradient(135deg, #6a4a2d 0%, #4a2d1a 100%);
    border-color: #8a6a4a;
}

.btn-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.btn-name {
    font-size: 14px;
    font-weight: bold;
}

.btn-cost {
    font-size: 12px;
    color: #4a9f4a;
    font-weight: bold;
}

.btn-desc {
    font-size: 10px;
    color: #aaa;
    font-style: italic;
}

.menu-info {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #333;
    font-size: 12px;
    color: #aaa;
    text-align: center;
}

.menu-info p {
    margin: 5px 0;
}

/* Info Panel */
.info-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    border: 3px solid #4a9f4a;
    border-radius: 10px;
    padding: 20px;
    min-width: 300px;
    z-index: 1000;
    box-shadow: 0 0 30px rgba(74, 159, 74, 0.5);
}

.info-panel.hidden {
    display: none;
}

/* Mine Button */
.mine-button {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}

.mine-button.hidden {
    display: none;
}

.mine-btn {
    background: rgba(139, 111, 71, 0.9) !important;
    border-color: #8b6f47 !important;
    min-width: 200px;
}

.mine-btn:hover {
    background: rgba(159, 131, 91, 0.95) !important;
    border-color: #ab8f67 !important;
}

@media (max-width: 768px) {
    .mine-button {
        bottom: 10px;
        width: 90%;
        max-width: 300px;
    }
    
    .mine-btn {
        width: 100%;
    }
}

#infoContent {
    text-align: center;
}

/* Mobile-first responsive */
@media (min-width: 769px) {
    .controls-info {
        display: block;
        font-size: 12px;
    }
    
    .menu-button {
        display: none;
    }
    
    .resource-item {
        font-size: 16px;
    }
    
    .building-menu-content {
        max-width: 600px;
    }
}
