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

body {
    background-color: #0f172a;
    color: #e2e8f0;
    font-family: 'Courier New', Courier, monospace;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
}

#canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    width: 100%;
    position: relative; /* Ensure it is isolated from the header */
}

#gameCanvas {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    background-color: #1e293b;
    border: 2px solid #334155;
    cursor: crosshair;
    image-rendering: pixelated; /* Ensures crisp scaling */
    transform-origin: center center; /* Ensure scaling happens from the center */
}

#ui {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #0f172a;
    border-bottom: 2px solid #334155;
    z-index: 10;
    width: 100%;
    flex-shrink: 0;
    position: relative; /* Ensure it stays in document flow but above canvas if needed */
    box-sizing: border-box; /* Ensure padding doesn't add to height */
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 10px;
}

#ui-left {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 200px;
}

#dashboard {
    flex: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    visibility: hidden; /* Hide initially to prevent layout shifts */
}

#ui-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 200px;
}

#funds {
    font-size: 1.2rem;
    color: #4ade80;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(74, 222, 128, 0.3);
    text-align: center;
}

#modeSwitch {
    display: flex;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    background: #1e293b;
    border: 1px solid #475569;
    color: #94a3b8;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: #334155;
    color: #e2e8f0;
}

.mode-btn.active {
    background: #0ea5e9;
    color: white;
    border-color: #38bdf8;
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.4);
}

#btnCombat.active {
    background: #ef4444;
    border-color: #f87171;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

#shop {
    display: flex;
    flex-direction: row;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap; /* Allow shop buttons to wrap if extremely small */
    transition: opacity 0.2s ease;
}

.shop-btn {
    background: #1e293b;
    border: 1px solid #475569;
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: inherit;
    transition: all 0.2s ease;
    gap: 5px;
    min-width: 100px;
}

.shop-btn:hover:not(:disabled) {
    background: #334155;
    border-color: #64748b;
}

.shop-btn.selected {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.shop-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #0f172a;
}

.shop-btn .cost {
    color: #fbbf24;
}

#title {
    color: #38bdf8;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
    margin-bottom: 5px;
    margin-top: 0;
}

#instruction {
    background: rgba(15, 23, 42, 0.7);
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #334155;
    display: flex;
    align-items: center;
    height: 48px;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: color 0.3s ease;
    margin-bottom: 0;
    font-size: 0.9rem;
}

.ready {
    color: #4ade80 !important;
}