:root {
    --bg-color: #000;
    --text-main: #fff;
    --text-muted: #aaa;
    --border-muted: #888;
    --border-main: #fff;
    --overlay-bg: rgba(0, 0, 0, 0.88);
    --hud-bg: rgba(0, 0, 0, 0.55);
    --touch-bg: rgba(255, 255, 255, 0.12);
    --touch-border: rgba(255, 255, 255, 0.4);
    --touch-active-bg: rgba(255, 255, 255, 0.35);
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'VT323', 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: min(100vw, calc(100vh * (16 / 10)));
    height: min(100vh, calc(100vw * (10 / 16)));
    aspect-ratio: 16 / 10;
    display: flex;
    justify-content: center;
    align-items: center;
    container-type: inline-size;
}

canvas {
    background-color: var(--bg-color);
    border: 2px solid var(--border-main);
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Top center HUD */
#hud-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8cqi 2cqi;
    box-sizing: border-box;
    font-size: clamp(22px, 2.6cqi, 50px);
    color: var(--text-main);
    background: var(--hud-bg);
    pointer-events: none;
    z-index: 5;
    letter-spacing: 1px;
}

#lives-display {
    color: var(--text-main);
    font-size: clamp(20px, 2.4cqi, 44px);
    letter-spacing: 3px;
}

.hud-panel {
    position: absolute;
    top: 4.2cqi;
    pointer-events: none;
    font-size: clamp(20px, 2.3cqi, 44px);
    color: var(--text-main);
    line-height: 1.5;
    z-index: 5;
}

#hud-left {
    left: 1.5cqi;
}

#hud-right {
    right: 1.5cqi;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    display: none;
}

.overlay.active {
    display: flex !important;
}


.overlay h1 {
    font-size: clamp(48px, 6.5cqi, 120px);
    margin-bottom: 10px;
    text-transform: uppercase;
    text-align: center;
}

.overlay p {
    font-size: clamp(24px, 2.8cqi, 48px);
    margin-bottom: 20px;
    text-align: center;
}

#highscore-list-container, #game-over-highscore-list-container {
    font-size: clamp(24px, 2.6cqi, 46px);
    margin-bottom: 20px;
    color: var(--text-main);
    text-align: center;
    width: min(420px, 40cqi);
}

#highscore-list-container h3, #game-over-highscore-list-container h3 {
    margin: 0 0 10px 0;
    font-size: clamp(28px, 3cqi, 54px);
    border-bottom: 2px solid var(--border-main);
    padding-bottom: 5px;
}

.hs-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.hs-name {
    text-align: left;
}

.hs-score {
    text-align: right;
}

#game-over-score {
    font-size: clamp(32px, 3.5cqi, 64px);
    margin-bottom: 15px;
    color: var(--text-main);
}

/* Initials input */
#initials-wrapper {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 16px;
}

#initials-display {
    display: flex;
    gap: 18px;
}

.side-hint {
    font-size: clamp(20px, 2.2cqi, 40px);
    color: var(--text-muted);
    width: 140px;
    text-align: left;
    line-height: 1.2;
}

.init-char {
    font-size: clamp(72px, 7cqi, 130px);
    width: clamp(70px, 6.5cqi, 120px);
    text-align: center;
    border-bottom: 4px solid var(--border-muted);
    color: var(--text-main);
    transition: color 0.1s, border-color 0.1s;
}

.init-char.active {
    color: var(--text-main);
    border-color: var(--border-main);
}

#initials-hint {
    font-size: clamp(18px, 2cqi, 36px);
    color: var(--text-muted);
    margin-bottom: 24px;
}

#hs-score-display {
    font-size: clamp(32px, 3.5cqi, 64px);
    margin-bottom: 16px;
    color: var(--text-main);
}

/* Primary Action Buttons */
button, .btn-primary {
    background: var(--bg-color);
    color: var(--text-main);
    border: 3px solid var(--border-main);
    padding: 16px 36px;
    font-size: clamp(32px, 3.8cqi, 68px);
    font-family: 'VT323', 'Courier New', Courier, monospace;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    margin-top: 10px;
}

button:hover, .btn-primary:hover {
    background: var(--text-main);
    color: var(--bg-color);
}

/* Virtual Mobile Touch Controls */
.touch-overlay {
    position: absolute;
    bottom: 24px;
    left: 0;
    width: 100%;
    padding: 0 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 6;
    box-sizing: border-box;
}

.touch-overlay.hidden {
    display: none;
}

.touch-group-left, .touch-group-right {
    display: flex;
    gap: 16px;
    pointer-events: auto;
}

.touch-btn {
    width: clamp(76px, 8.5cqi, 140px);
    height: clamp(76px, 8.5cqi, 140px);
    background: var(--touch-bg);
    border: 3px solid var(--touch-border);
    border-radius: 50%;
    color: var(--text-main);
    font-size: clamp(32px, 3.6cqi, 60px);
    font-family: 'VT323', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin: 0;
    padding: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: transform 0.1s, background-color 0.1s, border-color 0.1s;
    touch-action: manipulation;
}

.touch-btn.touch-action-btn {
    width: clamp(110px, 12cqi, 190px);
    height: clamp(76px, 8.5cqi, 140px);
    border-radius: 16px;
    font-size: clamp(28px, 3.2cqi, 54px);
    letter-spacing: 1px;
}

.touch-btn:active, .touch-btn.active {
    background: var(--touch-active-bg);
    border-color: var(--border-main);
    transform: scale(0.92);
}

/* Mobile & Small Screen Responsive Adjustments */
@media (max-width: 768px) {
    .hud-panel {
        font-size: 16px;
        line-height: 1.4;
    }
    #hud-top {
        font-size: 18px;
        padding: 4px 10px;
    }
    .overlay h1 {
        font-size: 40px;
    }
    .overlay p {
        font-size: 18px;
    }
    .touch-btn {
        width: 58px;
        height: 58px;
        font-size: 22px;
    }
    .touch-btn.touch-action-btn {
        width: 76px;
        height: 58px;
        font-size: 20px;
    }
}
