body {
    margin: 0;
    overflow: hidden;
    background-color: #1a1a1a;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: none;
    user-select: none;
}

#game-container {
    width: 100vw;
    height: 100vh;
    display: block;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    box-sizing: border-box;
    z-index: 10;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    color: white;
    text-shadow: 2px 2px 0 #000;
    font-size: 24px;
    font-weight: bold;
    width: 100%;
}

.hud-left {
    display: flex;
    flex-direction: column;
}

.hud-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.start-cooldown {
    position: absolute;
    left: 50%;
    top: 16%;
    width: min(280px, 72vw);
    transform: translateX(-50%) scale(0.96);
    padding: 10px 12px;
    border: 1px solid rgba(0, 210, 211, 0.55);
    border-radius: 8px;
    background: rgba(8, 14, 22, 0.76);
    box-shadow: 0 0 24px rgba(0, 210, 211, 0.25);
    color: #ffffff;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease, transform 120ms ease;
}

.start-cooldown.visible {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.start-cooldown-label {
    font-size: 20px;
    font-weight: 900;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 8px;
}

.start-cooldown-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
}

.start-cooldown-fill {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #00d2d3, #ffd166);
    box-shadow: 0 0 14px rgba(255, 209, 102, 0.45);
    transform-origin: left center;
}

.controls-hint {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    text-align: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 20px;
    align-self: center;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Touch Controls Styling */
#touch-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    height: 180px;
    pointer-events: none;
    justify-content: space-between;
    padding: 0 40px;
    box-sizing: border-box;
    z-index: 50;
}

#joystick-zone {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    position: relative;
    pointer-events: auto;
    align-self: flex-end;
    margin-bottom: 20px;
}

#joystick-knob {
    width: 50px;
    height: 50px;
    background: rgba(255, 153, 0, 0.8);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

#action-zone {
    display: flex;
    gap: 15px;
    align-self: flex-end;
    pointer-events: auto;
    margin-bottom: 20px;
}

.action-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    touch-action: none;
}

.action-btn:active,
.action-btn.active {
    background: rgba(255, 153, 0, 0.8);
    transform: scale(0.95);
}

#btn-jump {
    width: 80px;
    height: 80px;
    font-size: 16px;
    background: rgba(0, 100, 255, 0.4);
}

#btn-shoot {
    background: rgba(255, 50, 50, 0.4);
}

#message-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;
    color: white;
    z-index: 100;
    pointer-events: auto;
}

h1 {
    margin: 0 0 20px 0;
    color: #ff9900;
    text-shadow: 0 0 15px orange;
    font-size: 3em;
    text-align: center;
}

.hud-btn {
    pointer-events: auto;
    background: linear-gradient(135deg, rgba(30,30,45,0.7), rgba(10,10,20,0.9));
    border: 1px solid rgba(255,255,255,0.1);
    border-bottom: 3px solid #ff9900;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 30px;
    color: white;
    cursor: pointer;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.5);
    text-transform: uppercase;
    transition: transform 0.1s, box-shadow 0.1s;
}

.hud-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

.hidden {
    display: none !important;
}

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

#snack-container {
    width: 200px;
    height: 20px;
    background: #333;
    border: 2px solid white;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 5px;
    margin-bottom: 10px;
}

#snack-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #00ffcc, #009977);
    transition: width 0.3s;
}

#minimap-container {
    margin-top: 10px;
    border: 3px solid #444;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.8);
    width: 150px;
    height: 150px;
    position: relative;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

#minimap {
    display: block;
    width: 100%;
    height: 100%;
}

.modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 200;
    pointer-events: auto;
}

.modal-content {
    background: #1a1a1a;
    border: 2px solid #ff9900;
    border-radius: 10px;
    padding: 30px;
    color: white;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 0 30px rgba(255, 153, 0, 0.4);
}

.shop-content {
    width: min(720px, 92vw);
    max-height: 86vh;
    overflow-y: auto;
    text-align: left;
}

.shop-content h2 {
    margin: 0 0 10px;
    color: #ffd166;
    text-align: center;
}

.shop-balance {
    margin-bottom: 14px;
    padding: 10px;
    border: 1px solid rgba(255, 209, 102, 0.35);
    background: rgba(255, 209, 102, 0.08);
    color: #ffd166;
    font-weight: 800;
    text-align: center;
}

.shop-upgrades {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.upgrade-row {
    display: grid;
    grid-template-columns: 1fr 96px;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

.upgrade-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #ffffff;
    font-weight: 800;
}

.upgrade-title span {
    color: #00d2d3;
    white-space: nowrap;
}

.upgrade-desc {
    margin-top: 4px;
    color: #b8c2cc;
    font-size: 0.92rem;
    line-height: 1.35;
}

.upgrade-buy {
    min-height: 42px;
    border: 2px solid #ffd166;
    background: rgba(255, 209, 102, 0.12);
    color: #ffd166;
    font-weight: 900;
    cursor: pointer;
}

.upgrade-buy:disabled {
    border-color: #555;
    color: #777;
    cursor: default;
}

.run-upgrade-content {
    width: min(760px, 92vw);
}

.run-upgrade-content h2 {
    margin-top: 0;
    color: #00d2d3;
}

.run-upgrade-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.run-upgrade-card {
    min-height: 150px;
    display: grid;
    gap: 8px;
    align-content: start;
    padding: 14px;
    border: 2px solid #00d2d3;
    background: rgba(0, 210, 211, 0.1);
    color: #ffffff;
    text-align: left;
    cursor: pointer;
}

.run-upgrade-card:hover {
    background: rgba(0, 210, 211, 0.18);
}

.run-upgrade-name {
    color: #ffffff;
    font-weight: 900;
}

.run-upgrade-level {
    color: #ffd166;
    font-weight: 800;
}

.run-upgrade-desc {
    color: #b8c2cc;
    line-height: 1.35;
}

#dim-alert {
    position: absolute;
    top: 30%;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 4rem;
    color: #fff;
    font-weight: 900;
    text-transform: uppercase;
    text-shadow: 0 0 40px #fff;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s, transform 0.5s;
    transform: scale(0.5);
    z-index: 150;
}

#flash {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
    z-index: 100;
}

@media (max-width: 1024px) {
    #touch-controls { display: flex; }
    .controls-hint { display: none; }
    #minimap-container { width: 80px; height: 80px; border-width: 2px; }
    .upgrade-row { grid-template-columns: 1fr; }
    .upgrade-buy { width: 100%; }
    .run-upgrade-options { grid-template-columns: 1fr; }
}
