* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    touch-action: none;
}

body {
    overflow: hidden;
    background: #1a2a1a;
    font-family: 'Exo 2', sans-serif;
}

#canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#hud-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    pointer-events: none;
    z-index: 10;
}

#hud-top > div {
    background: rgba(0, 0, 0, 0.7);
    padding: 6px 14px;
    border-radius: 20px;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    color: #fff;
    font-size: 14px;
    text-shadow: 0 0 8px rgba(0, 255, 200, 0.5);
}

#timer {
    font-size: 20px;
    letter-spacing: 2px;
}

#commander-hp {
    font-size: 13px;
}

#timer.warning {
    color: #ff4444;
    animation: pulse-red 0.5s infinite;
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

#score.flash {
    animation: score-flash 0.3s;
}

@keyframes score-flash {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); color: #ffd700; }
    100% { transform: scale(1); }
}

#hud-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 20px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.75);
    border-radius: 20px 20px 0 0;
    z-index: 10;
}

.cmd-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.1s, filter 0.1s;
    background: rgba(40, 40, 40, 0.9);
}

.cmd-btn:active:not(:disabled) {
    transform: scale(0.9);
    filter: brightness(1.5);
}

.cmd-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#btn-attack {
    border-color: #ff4444;
    box-shadow: 0 0 12px rgba(255, 68, 68, 0.3);
}

#btn-attack.active {
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.8);
    animation: btn-glow-red 1.5s infinite;
}

#btn-gather {
    border-color: #ffaa00;
    box-shadow: 0 0 12px rgba(255, 170, 0, 0.3);
}

#btn-gather.active {
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.8);
    animation: btn-glow-gold 1.5s infinite;
}

#btn-recall {
    border-color: #4488ff;
    box-shadow: 0 0 12px rgba(68, 136, 255, 0.5);
}

@keyframes btn-glow-red {
    0%, 100% { box-shadow: 0 0 12px rgba(255, 68, 68, 0.5); }
    50% { box-shadow: 0 0 25px rgba(255, 68, 68, 0.9); }
}

@keyframes btn-glow-gold {
    0%, 100% { box-shadow: 0 0 12px rgba(255, 170, 0, 0.5); }
    50% { box-shadow: 0 0 25px rgba(255, 170, 0, 0.9); }
}

.btn-icon {
    font-size: 24px;
    line-height: 1;
}

.btn-label {
    font-size: 9px;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    color: #ccc;
    margin-top: 2px;
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ffaa00;
    color: #000;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge.hidden { display: none; }

#title-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a1a0a;
}

.title-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, #1a3a2a 0%, #0a1a0a 70%);
    pointer-events: none;
}

.title-content {
    position: relative;
    text-align: center;
    padding: 20px;
    z-index: 2;
}

.title-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 255, 180, 0.15) 0%, transparent 70%);
    animation: title-pulse 3s infinite;
    pointer-events: none;
}

@keyframes title-pulse {
    0%, 100% { transform: translate(-50%, -60%) scale(1); opacity: 0.6; }
    50% { transform: translate(-50%, -60%) scale(1.1); opacity: 1; }
}

.title-content h1 {
    font-family: 'Orbitron', monospace;
    font-weight: 900;
    font-size: clamp(28px, 8vw, 48px);
    color: #fff;
    text-shadow: 0 0 20px rgba(0, 255, 180, 0.8), 0 0 40px rgba(0, 255, 180, 0.4);
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.subtitle {
    color: #88ccaa;
    font-size: 14px;
    margin-bottom: 24px;
}

.instructions {
    color: #aaa;
    font-size: 12px;
    margin-bottom: 32px;
    line-height: 1.8;
}

#btn-start {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 20px;
    padding: 16px 48px;
    border: none;
    border-radius: 40px;
    background: linear-gradient(135deg, #00cc88, #00aa66);
    color: #fff;
    cursor: pointer;
    letter-spacing: 3px;
    box-shadow: 0 0 30px rgba(0, 204, 136, 0.5);
    animation: start-pulse 2s infinite;
    position: relative;
    z-index: 10;
    touch-action: manipulation;
}

@keyframes start-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 204, 136, 0.4); }
    50% { box-shadow: 0 0 40px rgba(0, 204, 136, 0.8); }
}

#btn-start:active {
    transform: scale(0.95);
}

#btn-restart {
    position: relative;
    z-index: 10;
    touch-action: manipulation;
}

#btn-start, #btn-restart {
    -webkit-tap-highlight-color: rgba(0, 204, 136, 0.3);
}

.footer-link {
    margin-top: 40px;
}

.footer-link a {
    color: #556;
    font-size: 11px;
    text-decoration: none;
}

.footer-link a:hover {
    color: #88ccaa;
}

#gameover-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
}

#gameover-screen.hidden { display: none; }

.gameover-content {
    text-align: center;
    padding: 32px;
    background: rgba(20, 30, 20, 0.95);
    border-radius: 20px;
    border: 2px solid rgba(0, 255, 180, 0.3);
    max-width: 320px;
    width: 90%;
    animation: slide-up 0.5s ease-out;
}

@keyframes slide-up {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.gameover-content h2 {
    font-family: 'Orbitron', monospace;
    font-weight: 900;
    font-size: 28px;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
    margin-bottom: 16px;
}

#final-score {
    font-family: 'Orbitron', monospace;
    font-size: 36px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
}

#star-rating {
    font-size: 28px;
    margin-bottom: 16px;
}

#stats-breakdown {
    font-size: 13px;
    color: #aaa;
    line-height: 2;
    margin-bottom: 24px;
}

#btn-restart {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 16px;
    padding: 14px 36px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(135deg, #00cc88, #00aa66);
    color: #fff;
    cursor: pointer;
    letter-spacing: 2px;
}

#btn-restart:active {
    transform: scale(0.95);
}

#minimap-container {
    position: fixed;
    top: 50px;
    right: 8px;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    border: 2px solid rgba(0, 255, 180, 0.3);
    overflow: hidden;
    opacity: 0.8;
    z-index: 10;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.5);
}

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