*, *::before, *::after {
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: auto;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    width: 100%;
    background: #111111;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10px;
    padding-bottom: 10px;
    box-sizing: border-box;
    user-select: none;
    cursor: default;
    font-family: 'Courier New', Courier, monospace;
}

/* --- Wrapper: panel + canvas column side by side --- */
#game-wrapper {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

/* Canvas + bottom HUD row */
#game-canvas-wrap {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 1110px;
}

/* Game world viewport: canvas + left-edge hash marks + top HUD miner button */
.game-canvas-viewport {
    position: relative;
    flex-shrink: 0;
    width: 1110px;
    height: 702px;
}

/* [+] miner — placed after MINERS on the canvas strip; `left` set each frame in drawHUD */
.hud-top-miner-wrap {
    position: absolute;
    left: 0;
    top: 28px;
    width: auto;
    max-width: 220px;
    height: 60px;
    display: flex;
    align-items: center;
    z-index: 6;
    pointer-events: auto;
}

/* Short horizontal ticks: grow from the left edge to the right (axis-style hash marks) */
.game-world-hash-marks {
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 100%;
    pointer-events: none;
    box-sizing: border-box;
}

/* Positions (--gm-*) set in world.js from C.TOP_H … C.GROUND_Y (play band, below canvas UI) */
.game-world-hash-marks .hash-mark {
    position: absolute;
    left: 0;
    display: block;
    width: 5px;
    height: 1px;
    background: #a85510;
    border-radius: 0;
    transform: translateY(-50%);
}

.game-world-hash-marks .hash-mark-q1 {
    top: var(--gm-q1, 231px);
}

.game-world-hash-marks .hash-mark-q3 {
    top: var(--gm-q3, 517px);
}

/* ½ sky–ground — slightly longer tick to the right (~×0.35 vs original 14/22) */
.game-world-hash-marks .hash-mark-half {
    top: var(--gm-half, 374px);
    width: 8px;
}

/* Player heli — green, a bit thicker; top set each frame in world.js */
.game-world-hash-marks .hash-mark-heli {
    display: none;
    width: 10px;
    height: 2px;
    background: #2d8f4a;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* Enemy heli — red tick on same Y scale as player tick */
.game-world-hash-marks .hash-mark-heli-enemy {
    display: none;
    width: 10px;
    height: 2px;
    background: #cc3333;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* --- Bottom HUD row (below canvas) --- */
.hud-bottom-row {
    width: 100%;
    box-sizing: border-box;
    background: #141414;
    border-top: 1px solid #2e2e2e;
    padding: 10px 14px;
    font: bold 16px "Courier New", monospace;
    letter-spacing: 0.5px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 14px;
    flex-shrink: 0;
}

/* Fuel + ammo + bombs — shared row layout */
.hud-bottom-armament {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    min-width: 0;
    flex: 1 1 auto;
}

/* Bottom row: fuel bar (replaces HELI HP text; HP still on sprite) */
.hud-bottom-fuel {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
    max-width: 420px;
}

/* Ammo / bombs — label + current/max text only */
.hud-bottom-stat {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex: 0 0 auto;
}

/* Far-right heli death tally on YOU / ENE rows */
.hud-heli-deaths {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.hud-stat-count {
    font: bold 16px "Courier New", monospace;
    letter-spacing: 0.5px;
    font-variant-numeric: tabular-nums;
    color: #c8d0d8;
    white-space: nowrap;
}

.hud-bottom-bombs .hud-stat-count {
    color: #d8a090;
}

.hud-fuel-label {
    color: #c8a030;
    font: bold 16px "Courier New", monospace;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.hud-fuel-bar-wrap {
    position: relative;
    flex: 1 1 auto;
    height: 10px;
    min-width: 120px;
    background: #2a2a2e;
    border: 1px solid #45454a;
    border-radius: 2px;
    overflow: hidden;
}

.hud-fuel-fill {
    position: relative;
    z-index: 0;
    height: 100%;
    width: 100%;
    transform-origin: left center;
    transform: scaleX(1);
    background: linear-gradient(180deg, #e8c040 0%, #b8860b 55%, #8a6510 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Fixed 50% line — turnaround cue (fuel remaining, not distance). */
.hud-fuel-halfmark {
    position: absolute;
    left: 50%;
    top: -1px;
    bottom: -1px;
    width: 2px;
    margin-left: -1px;
    z-index: 2;
    pointer-events: none;
    background: #cc2222;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.55),
        0 0 4px rgba(255, 60, 60, 0.45);
    border-radius: 1px;
}

.hud-fuel-fill.hud-fuel-fill--low {
    background: linear-gradient(180deg, #ff8844 0%, #cc4422 100%);
}

.hud-fuel-fill.hud-fuel-fill--empty {
    transform: scaleX(0);
}

/* Row identity label (YOU / ENE) at the left of each hud row */
.hud-row-label {
    font: bold 13px "Courier New", monospace;
    letter-spacing: 1px;
    flex-shrink: 0;
    padding-right: 10px;
    white-space: nowrap;
}
.hud-row-label--player { color: #44aaff; }
.hud-row-label--enemy  { color: #ff4422; }

/* Enemy heli row — same layout as player row but red-tinted */
.hud-bottom-row--enemy {
    border-top: 1px solid #1e1e1e;
}

/* Enemy row fuel label (red tint instead of gold) */
.hud-fuel-label--enemy {
    color: #cc6644;
}

/* Enemy fuel bar fill — red gradient */
.hud-fuel-fill--enemy {
    background: linear-gradient(180deg, #ff5533 0%, #cc2211 55%, #881100 100%);
}
.hud-fuel-fill--enemy.hud-fuel-fill--low {
    background: linear-gradient(180deg, #ff2200 0%, #aa1100 100%);
}

/* Enemy fuel bar halfmark — use a dimmer red line */
.hud-fuel-halfmark--enemy {
    background: #882222;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.55),
        0 0 4px rgba(200, 40, 40, 0.35);
}

/* Enemy stat counts — slightly dimmer red-white */
.hud-stat-count--enemy {
    color: #d0a8a0;
}
.hud-bottom-bombs .hud-stat-count--enemy {
    color: #cc8880;
}

/* Center lane: left FB | helipad fuel | right FB */
.hud-bottom-row--center-objectives {
    border-top: 1px solid #1e1e1e;
    justify-content: space-between;
    gap: 10px;
}

.hud-center-objectives-slot {
    flex: 1 1 0;
    min-width: 0;
    font: bold 15px "Courier New", monospace;
    letter-spacing: 0.4px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hud-center-objectives-slot:first-child {
    text-align: left;
}

.hud-center-objectives-slot:nth-child(2) {
    text-align: center;
    flex: 1.1 1 0;
}

.hud-center-objectives-slot:last-child {
    text-align: right;
}

.hud-center-objectives-slot--player {
    color: #44aaff;
}

.hud-center-objectives-slot--enemy {
    color: #ff4422;
}

.hud-center-objectives-slot--neutral {
    color: #8a9aaa;
}

.hud-center-objectives-slot--pad {
    color: #c8a030;
}

/* --- Temporary debug strip (below economy HUD) --- */
.debug-console {
    width: 100%;
    box-sizing: border-box;
    background: #0a0a0c;
    border-top: 1px solid #2a2a2e;
    padding: 6px 12px;
    flex-shrink: 0;
}

.debug-console pre {
    margin: 0;
    font: 12px/1.45 "Courier New", monospace;
    color: #6fd060;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: calc(1.45em * 9);
}

/* --- Miner buy button --- */
.hud-miner-btn {
    font: bold 16px "Courier New", monospace;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.hud-miner-btn--top {
    flex-shrink: 0;
}
.hud-miner-btn.affordable       { color: #e0e0e0; cursor: pointer; }
.hud-miner-btn.affordable:hover { color: #ffffff; }
.hud-miner-btn.unaffordable     { color: #7a7a7a; cursor: default; }

/* --- Left upgrade panel (360px) --- */
#ui-panel {
    width: 360px;
    min-height: 702px;
    align-self: stretch;
    background: #141414;
    border-right: 1px solid #333333;
    display: flex;
    flex-direction: column;
    padding: 14px 16px 12px;
    overflow: hidden;
    flex-shrink: 0;
}

.panel-section-label {
    font-size: 11px;
    letter-spacing: 3px;
    color: #8a8a8a;
    margin-bottom: 8px;
    flex-shrink: 0;
}

/* --- Tab bar --- */
.tab-bar {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    margin-bottom: 10px;
    flex-shrink: 0;
    min-height: 48px;
    border-bottom: 1px solid #2a2a2a;
}

.tab {
    font-size: 19px;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 8px 10px 10px;
    flex: 1 1 0;
    min-width: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
}

.tab.active   { color: #e8e8e8; border-bottom: 2px solid #c8c8c8; }
.tab.inactive { color: #909090; border-bottom: 2px solid transparent; }
.tab.inactive:hover { color: #b8b8b8; }

/* Tab highlight when purchases available */
.tab.tab-available {
    color: #ff8800;
    font-weight: 900;
}
.tab.active.tab-available {
    border-bottom-color: #ff8800;
}
.tab.inactive.tab-available:hover {
    color: #ffaa33;
}

/* --- Upgrade list --- */
.upgrade-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    overflow: hidden;
}

.upgrade-row {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 4px 4px;
    border-bottom: 1px solid #1e1e1e;
    cursor: default;
}

/* Inner flex row: sprite + info + own + buy */
.row-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 52px;
}

.row-sprite {
    flex-shrink: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.row-info {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    min-width: 0;
}

.row-name {
    font-size: 21px;
    font-weight: bold;
    letter-spacing: 1px;
    white-space: nowrap;
}

.row-stats {
    font-size: 16px;
    letter-spacing: 0.3px;
}

.row-unit-cost {
    font-size: 16px;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

.row-own {
    font-size: 16px;
    font-weight: bold;
    min-width: 28px;
    text-align: right;
    flex-shrink: 0;
}

.row-buy {
    font-size: 22px;
    font-weight: bold;
    min-width: 32px;
    text-align: center;
    flex-shrink: 0;
}

/* --- Affordability states --- */
.upgrade-row.affordable .row-name  { color: #e8e8e8; }
.upgrade-row.affordable .row-stats,
.upgrade-row.affordable .row-unit-cost { color: #a8a8a8; }
.upgrade-row.affordable .row-own   { color: #dcdcdc; }
.upgrade-row.affordable .row-buy   { color: #f0f0f0; cursor: pointer; }
.upgrade-row.affordable .row-buy:hover { color: #ffffff; }

.upgrade-row.unaffordable .row-name  { color: #a0a0a0; }
.upgrade-row.unaffordable .row-stats,
.upgrade-row.unaffordable .row-unit-cost { color: #8a8a8a; }
.upgrade-row.unaffordable .row-own   { color: #989898; }
.upgrade-row.unaffordable .row-buy   { color: #9a9a9a; cursor: default; }

.upgrade-row .row-own.none { color: #888888; }

/* Orange cost text */
.row-cost { color: #e0a040; }
.upgrade-row.unaffordable .row-cost { color: #a07030; }

/* row-buy locked state */
.row-buy-locked { color: #808080; cursor: default; }

/* --- UPGRADES tab: locked row style --- */
.upgrade-row-locked .row-name { color: #707070; }
.upgrade-row-locked .row-buy  { color: #707070; }

/* --- Help button (top-right of HUD strip, before timer) --- */
.help-btn {
    position: absolute;
    right: 72px;
    top: 28px;
    height: 60px;
    width: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font: bold 20px "Courier New", monospace;
    color: #cc2222;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 8;
    line-height: 1;
    user-select: none;
    transition: color 0.1s;
}
.help-btn:hover { color: #ff4444; }

/* --- Help modal overlay --- */
.help-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
}
.help-modal[hidden] { display: none; }

.help-modal-box {
    background: #141414;
    border: 1px solid #444;
    padding: 20px 24px 18px;
    max-width: 720px;
    width: 96vw;
    max-height: 90vh;
    overflow-y: auto;
    font-family: "Courier New", monospace;
    color: #d0d0d0;
}

.help-modal-title {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
    color: #e8e8e8;
    margin-bottom: 14px;
    border-bottom: 1px solid #333;
    padding-bottom: 8px;
}

.help-modal-cols {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
}

.help-modal-col {
    flex: 1 1 260px;
    min-width: 0;
}

.help-modal-col--dev {
    flex: 0 1 300px;
    border-left: 1px solid #2a2a2a;
    padding-left: 24px;
}

.help-modal-section {
    font-size: 11px;
    letter-spacing: 3px;
    color: #888;
    margin: 12px 0 5px;
    text-transform: uppercase;
}

.help-modal-section--dev {
    color: #994444;
}

.help-note {
    font-size: 11px;
    color: #666;
    letter-spacing: 1px;
    text-transform: none;
}

.help-modal-body {
    font-size: 13px;
    color: #b0b0b0;
    line-height: 1.6;
}

.help-keys-table {
    border-collapse: collapse;
    width: 100%;
}

.help-keys-table td {
    font-size: 13px;
    padding: 2px 10px 2px 0;
    vertical-align: top;
    white-space: nowrap;
}

.help-keys-table td:first-child {
    color: #e0c060;
    min-width: 100px;
    font-weight: bold;
}

.help-keys-table td:last-child {
    color: #b0b0b0;
    white-space: normal;
}

.help-modal-close {
    display: block;
    margin-top: 18px;
    font: bold 14px "Courier New", monospace;
    letter-spacing: 1px;
    color: #888;
    background: transparent;
    border: 1px solid #333;
    padding: 6px 14px;
    cursor: pointer;
    user-select: none;
}
.help-modal-close:hover { color: #c0c0c0; border-color: #555; }

/* --- Game canvas --- */
/* Orange aiming reticle (fallback: crosshair). Hotspot at center. */
#gameCanvas {
    display: block;
    width: 1110px;
    height: 702px;
    flex-shrink: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    vertical-align: top;
    cursor:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='23' height='23'%3E%3Ccircle cx='11.5' cy='11.5' r='2' fill='%23ff8822'/%3E%3Cpath stroke='%23ff8822' stroke-width='2' stroke-linecap='round' d='M11.5 1v4M11.5 18v4M1 11.5h4M18 11.5h4'/%3E%3C/svg%3E")
            11 11,
        crosshair;
}
