body {
    margin: 0;
    overflow: hidden;
    background-color: #222;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

#gameContainer {
    aspect-ratio: 16 / 9;
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    margin: auto;
}

canvas {
    background: #000;
    display: block;
    border-radius: 4px;
    width: 100%;
    height: 100%;
}

#mobileControls {
    position: absolute;
    bottom: 10px;
    /* Pushed lower to the screen edge */
    left: 10px;
    right: 10px;
    display: none;
    justify-content: flex-start;
    align-items: flex-end;
    gap: 12px;
    z-index: 20;
    opacity: 0.8;
}

@media (max-width: 1366px) and (pointer: coarse),
(max-width: 1024px),
(hover: none) and (pointer: coarse) {
    #mobileControls {
        display: flex;
    }
}

.dpad {
    display: flex;
    gap: 10px;
}

.ctrl-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    border-radius: 50%;
    width: 77px;
    height: 77px;
    font-size: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    touch-action: none;
    cursor: pointer;
}

.ctrl-btn:active {
    background: rgba(255, 255, 255, 0.5);
}

.shoot-btn {
    width: 99px;
    height: 99px;
    font-size: 44px;
    background: rgba(255, 87, 34, 0.4);
    border-color: #FF5722;
    margin-left: auto !important;
}

.dash-btn {
    width: 86px;
    height: 86px;
    font-size: 18px;
    font-weight: 800;
    background: rgba(0, 188, 212, 0.35);
    border-color: #00BCD4;
    flex: 0 0 auto;
}

#ui-layer {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 20px;
    display: flex;
    pointer-events: none;
    text-shadow: 1px 1px 2px black;
}

#ui-layer button {
    pointer-events: auto;
}

.stat {
    font-size: 18px;
    font-weight: bold;
    margin-right: 15px;
    display: inline-block;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 10px;
    border-radius: 4px;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

h1 {
    font-size: 48px;
    margin: 0 0 20px 0;
    color: #FF9800;
    text-shadow: 2px 2px 0 #fff;
}

p {
    font-size: 20px;
    color: #ddd;
    max-width: 600px;
    text-align: center;
    line-height: 1.5;
}

.blink {
    animation: blinker 1.5s linear infinite;
    color: #4CAF50;
    font-weight: bold;
    margin-top: 30px;
    font-size: 24px;
    cursor: pointer;
}

.progression-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(86px, 1fr));
    gap: 8px;
    width: min(620px, 86vw);
    margin-top: 12px;
}

.progression-summary div {
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    font-size: 14px;
}

.progression-summary span {
    color: #FFD700;
    font-size: 20px;
    font-weight: 800;
}

@keyframes blinker {
    50% {
        opacity: 0;
    }
}

#message {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px #000;
    text-align: center;
    display: none;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 30px;
    border-radius: 20px;
    pointer-events: none;
}

#gameOverScreen,
#levelCompleteScreen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    min-width: 400px;
    height: auto;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0px 10px 40px rgba(0,0,0,0.8);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.modal {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 90;
    background: rgba(0, 0, 0, 0.72);
}

.modal-content {
    background: rgba(11, 18, 26, 0.96);
    border: 2px solid rgba(0, 188, 212, 0.75);
    border-radius: 12px;
    padding: 24px;
    width: min(620px, 90vw);
    color: white;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.65);
}

.shop-upgrades,
.run-upgrade-options {
    display: grid;
    gap: 10px;
    margin: 18px 0;
}

.upgrade-row,
.run-upgrade-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    padding: 12px;
    text-align: left;
}

.upgrade-title,
.run-upgrade-name {
    font-weight: 800;
    color: #FFD700;
}

.upgrade-desc,
.run-upgrade-desc {
    color: #d7e7ea;
    font-size: 14px;
}

.upgrade-buy,
.run-upgrade-card {
    cursor: pointer;
}

.upgrade-buy {
    min-width: 74px;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: #00BCD4;
    color: #05161a;
    font-weight: 900;
}

.upgrade-buy:disabled {
    cursor: not-allowed;
    background: #4b5563;
    color: #d1d5db;
}

.run-upgrade-card {
    grid-template-columns: 1fr;
    color: white;
    background: rgba(255, 152, 0, 0.16);
}

#gameOverScreen {
    border: 4px solid #F44336;
}

#levelCompleteScreen {
    border: 4px solid #4CAF50;
}

#gameOverScreen h1,
#levelCompleteScreen h1 {
    font-size: 64px;
    margin: 0 0 20px 0;
    text-shadow: 4px 4px 0 #fff;
}

#gameOverScreen h1 {
    color: #F44336;
}

#levelCompleteScreen h1 {
    color: #4CAF50;
}

.go-stat {
    font-size: 24px;
    color: #fff;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 10px;
    min-width: 300px;
    text-align: center;
}

.go-btn {
    padding: 15px 30px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    margin: 10px 20px;
    transition: transform 0.2s;
}

.go-btn:hover {
    transform: scale(1.05);
}

#btnScreenshot {
    background: #03A9F4;
    color: white;
}

#btnRestart {
    background: #4CAF50;
    color: white;
}

.gp-focus {
    outline: 4px solid #FFD700 !important;
    transform: scale(1.05);
    box-shadow: 0 0 15px #FFD700;
}
