html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;

    background: url("../img/bck_menu.jpg") center / contain no-repeat,
                linear-gradient(rgba(72,72,72,0.9), rgba(72,72,72,0.9)),
                url("../img/bck_city_tile.png") repeat;

    font-family: "Courier New", monospace;
    color: #ffffff;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

#menuScreen,
#optionsScreen {
    /* Sit inside the dark gray rectangle of bck_menu.jpg.
       The image is square, rendered at min(100vw,100vh) via contain.
       The gray area spans ~20–80% horizontally and ~22–82% vertically. */
    --img-side: min(100vw, 100vh);
    width:      calc(var(--img-side) * 0.60);
    display:    flex;
    flex-direction: column;
    align-items: center;
    overflow:   hidden;
}

#menuScreen    { max-height: calc(var(--img-side) * 0.43); }
#optionsScreen { max-height: calc(var(--img-side) * 0.43); }

#optTitle,
#title {
    font-size:      clamp(20px, 6.4vmin, 51px);
    margin:         0 0 clamp(10px, 1.0vmin, 32px) 0;
    letter-spacing: clamp(2px, 1vmin, 8px);
    color:          #ffff80;
    align-self:     center;
    flex-shrink:    0;
    white-space:    nowrap;
}

#menu,
#optionsList {
    list-style: none;
    padding:    0;
    margin:     0;
    width:      100%;
    flex:       1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

#menu::-webkit-scrollbar,
#optionsList::-webkit-scrollbar {
    width: 4px;
}
#menu::-webkit-scrollbar-track,
#optionsList::-webkit-scrollbar-track {
    background: transparent;
}
#menu::-webkit-scrollbar-thumb,
#optionsList::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.menu-item {
    display:     flex;
    align-items: center;
    gap:         clamp(6px,  1.6vmin, 16px);
    font-size:   clamp(12px, 4vmin,   26px);
    padding:     clamp(4px,  1.2vmin, 10px) clamp(8px, 2.8vmin, 24px);
    margin:      clamp(2px,  0.9vmin,  8px) 0;
    cursor:      pointer;
    user-select: none;
    transition:  background-color 0.15s, color 0.15s;
}

.menu-icon {
    width:           clamp(20px, 6.2vmin, 40px);
    height:          clamp(20px, 6.2vmin, 40px);
    flex-shrink:     0;
    image-rendering: pixelated;
}

.menu-icon-emoji {
    display:         flex;
    align-items:     center;
    justify-content: center;
    width:           clamp(20px, 6.2vmin, 40px);
    height:          clamp(20px, 6.2vmin, 40px);
    font-size:       clamp(14px, 4.4vmin, 28px);
    font-family:     "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", serif;
}

.menu-item:hover {
    background: #ffff80;
    color: #2e2c9b;
}

.menu-item.selected {
    background: #ffff80;
    color: #2e2c9b;
}

#gameContainer {
    display: none;
    position: relative;
    width: min(90vw, calc(90vh * 1.5));
    aspect-ratio: 3 / 2;
    container-type: inline-size;
}

#gameCanvas {
    display: block;
    border: 4px solid #ffffff;
    box-sizing: border-box;
    background: #205020;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 100%;
    height: 100%;
}

#scoreDisplay {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: calc(26cqw / 9);
    display: flex;
    align-items: center;
    font-family: "Courier New", monospace;
    font-size: calc(100cqw / 60);
    font-weight: bold;
    color: #ffffff;
    pointer-events: none;
    white-space: nowrap;
}

#scoreDisplay.flash-red   { color: #ff4444; }
#scoreDisplay.flash-green { color: #44ff44; }

#hudPanel {
    position: fixed;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: row;
	flex-wrap: balance;
	justify-content: center;
    gap: 6px;
    align-items: center;
    max-width: calc(100vw - 32px);
    overflow-x: auto;
    overflow-y: hidden;
}

@media (min-aspect-ratio: 3/2) {
    #hudPanel {
        bottom: auto;
        top: 50%;
        transform: translateY(-50%);
        flex-direction: column;
        max-width: none;
        max-height: calc(100vh - 32px);
        overflow-x: hidden;
        overflow-y: auto;
    }
}

.hud-btn {
    position: relative;
    width: 80px;
    height: 80px;
    overflow: hidden;
    padding: 0;
    background: #00008b;
    color: #7fffff;
    border: 6px solid #7fffff;
    cursor: pointer;
    box-shadow: 6px 6px 0 #000, inset 2px 2px 0 #aaffff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none;
    user-select: none;
}

/* active state: cyan fill */
.hud-btn[data-active='1'] {
    background: #0055aa;
    box-shadow: 3px 3px 0 #000, inset 1px 1px 0 #aaffff;
}

/* inactive state: dark, dimmed */
.hud-btn[data-active='0'] {
    background: #000033;
    color: #336688;
    border-color: #336688;
    box-shadow: 3px 3px 0 #000;
}

/* hover: C64 reverse-video flash */
.hud-btn:hover {
    background: #7fffff;
    color: #00008b;
    border-color: #00008b;
    box-shadow: 3px 3px 0 #000, inset 1px 1px 0 #ffffff;
}

/* tooltip — above button by default (horizontal bar at bottom) */
.hud-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #00008b;
    color: #7fffff;
    border: 3px solid #7fffff;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 6px 9px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
    box-shadow: 3px 3px 0 #000;
    z-index: 300;
}

/* tooltip — to the left when panel is vertical (right side of screen) */
@media (min-aspect-ratio: 3/2) {
    .hud-btn::after {
        bottom: auto;
        top: 50%;
        left: auto;
        right: calc(100% + 10px);
        transform: translateY(-50%);
    }
}

.hud-btn:hover::after {
    opacity: 1;
}

#resultOverlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100;
}

#resultOverlay img {
    max-width: 80vw;
    max-height: 80vh;
    object-fit: contain;
}

#vehicleTooltip {
    position: fixed;
    padding: 7px 10px;
    background: rgba(0, 0, 0, 0.82);
    color: #ffffff;
    font-family: "Courier New", monospace;
    font-size: 12px;
    line-height: 1.6;
    border: 1px solid #888;
    pointer-events: none;
    white-space: nowrap;
    z-index: 200;
}

.tt-deadlock {
    color: #ff4444;
    font-weight: bold;
}

body.game-active {
    background: url("../img/bck_city_tile.png") repeat;
}
