* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'SimHei', sans-serif;
    background: #0a0a0f;
    color: #fff;
    overflow: hidden;
    user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-canvas {
    display: block;
    background: #1a1a2e;
    cursor: crosshair;
}

#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 10;
}

.ui-top {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 15px 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
}

.ui-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 15px 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.value {
    font-size: 20px;
    font-weight: bold;
    color: #fff;
}

.value.gold {
    color: #ffd700;
}

.hp-bar {
    position: relative;
    width: 200px;
    height: 24px;
    background: #333;
    border-radius: 12px;
    border: 2px solid #555;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    background: linear-gradient(to right, #ff4444, #ff6666);
    transition: width 0.3s ease;
    width: 100%;
}

.hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    z-index: 1;
}

.current-weapon {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.5);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #feca57;
}

.current-weapon .label {
    font-size: 14px;
    color: #888;
}

.current-weapon .value {
    font-size: 16px;
    font-weight: bold;
    color: #feca57;
}

.current-weapon-fixed {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.7);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #feca57;
    z-index: 100;
}

.current-weapon-fixed .label {
    font-size: 14px;
    color: #888;
}

.current-weapon-fixed .value {
    font-size: 16px;
    font-weight: bold;
    color: #feca57;
}

.speed-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    border: 2px solid #4ecdc4;
    color: #4ecdc4;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
    pointer-events: auto;
}

.speed-btn:hover {
    background: rgba(78, 205, 196, 0.3);
    transform: scale(1.1);
}

.speed-btn:active {
    transform: scale(0.95);
}

.status-info {
    display: flex;
    gap: 15px;
}

.mercenary-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.5);
    padding: 10px 20px;
    border-radius: 25px;
    border: 1px solid #444;
}

.mercenary-info .label {
    font-size: 14px;
    color: #888;
}

.mercenary-info .value {
    font-size: 16px;
    font-weight: bold;
    color: #fff;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    max-width: 600px;
    padding: 40px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    border: 2px solid #4a5568;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.overlay-content h1 {
    font-size: 48px;
    margin-bottom: 10px;
    background: linear-gradient(to right, #ff6b6b, #feca57);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overlay-content h2 {
    font-size: 32px;
    margin-bottom: 20px;
    color: #feca57;
}

.subtitle {
    font-size: 18px;
    color: #888;
    margin-bottom: 30px;
    letter-spacing: 3px;
}

.instructions {
    background: rgba(0,0,0,0.3);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    text-align: left;
}

.instructions h3 {
    color: #feca57;
    margin-bottom: 15px;
    font-size: 18px;
}

.instructions ul {
    list-style: none;
}

.instructions li {
    padding: 8px 0;
    color: #ccc;
    font-size: 14px;
}

.instructions li strong {
    color: #fff;
}

.btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    display: inline-block;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    background: linear-gradient(135deg, #7f8c8d, #95a5a6);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 4px 15px rgba(127, 140, 141, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(127, 140, 141, 0.6);
}

.btn-secondary:active {
    transform: translateY(0);
}

.home-btn {
    font-size: 14px;
    padding: 8px 20px;
}

.btn-large {
    padding: 15px 50px;
    font-size: 20px;
    margin-top: 20px;
}

.btn-upgrade {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn-upgrade:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.btn-upgrade:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.gold-earned,
.current-gold {
    font-size: 18px;
    margin: 10px 0;
    color: #ccc;
}

.gold-earned span,
.current-gold span {
    color: #ffd700;
    font-weight: bold;
}

.upgrade-panel {
    max-width: 800px;
}

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

.unlock-hint {
    font-size: 11px;
    color: #feca57;
    display: block;
    margin-top: 5px;
}

.upgrade-card {
    background: rgba(0,0,0,0.3);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #444;
    transition: all 0.3s ease;
}

.upgrade-card:hover {
    border-color: #666;
    background: rgba(0,0,0,0.4);
}

.upgrade-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.upgrade-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #fff;
}

.upgrade-desc {
    font-size: 13px;
    color: #999;
    margin-bottom: 10px;
    min-height: 36px;
}

.upgrade-level {
    font-size: 14px;
    color: #feca57;
    margin-bottom: 5px;
}

.gameover-stats {
    font-size: 18px;
    line-height: 2;
    margin: 30px 0;
    color: #ccc;
}

.gameover-stats span {
    color: #feca57;
    font-weight: bold;
    font-size: 24px;
}

@media (max-width: 768px) {
    .ui-top {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 4px;
        padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 6px;
    }
    
    .ui-top .stat {
        flex: 1;
        min-width: 0;
    }
    
    .ui-top .stat:nth-child(1) {
        flex: 2;
    }
    
    .stat {
        min-width: auto;
        gap: 2px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    
    .stat .label {
        font-size: 9px;
        color: #666;
    }
    
    .stat .value {
        font-size: 14px;
    }
    
    .hp-bar {
        width: 100%;
        height: 14px;
        border-width: 1px;
    }
    
    .hp-text {
        font-size: 9px;
    }
    
    .ui-bottom {
        padding: 8px;
        align-items: center;
    }
    
    .current-weapon {
        padding: 6px 12px;
        border-radius: 15px;
    }
    
    .current-weapon .label {
        font-size: 12px;
    }
    
    .current-weapon .value {
        font-size: 14px;
    }
    
    .current-weapon-fixed {
        bottom: 15px;
        left: 15px;
        padding: 6px 12px;
    }
    
    .current-weapon-fixed .label {
        font-size: 12px;
    }
    
    .current-weapon-fixed .value {
        font-size: 14px;
    }
    
    .speed-btn {
        width: 50px;
        height: 50px;
        font-size: 16px;
        bottom: 15px;
        right: 15px;
    }
    
    .status-info {
        gap: 8px;
    }
    
    .mercenary-info,
    .auto-attack-info {
        padding: 8px 14px;
        gap: 6px;
    }
    
    .mercenary-info .label,
    .auto-attack-info .label {
        font-size: 12px;
    }
    
    .mercenary-info .value,
    .auto-attack-info .value {
        font-size: 14px;
    }
    
    .auto-attack-info .hint {
        display: none;
    }
    
    .overlay-content {
        padding: 20px;
        max-width: 90vw;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .overlay-content h1 {
        font-size: 32px;
    }
    
    .overlay-content h2 {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }
    
    .instructions {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .instructions li {
        font-size: 12px;
        padding: 5px 0;
    }
    
    .upgrade-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin: 15px 0;
    }
    
    .upgrade-card {
        padding: 12px;
    }
    
    .upgrade-icon {
        font-size: 28px;
        margin-bottom: 6px;
    }
    
    .upgrade-card h3 {
        font-size: 14px;
        margin-bottom: 5px;
    }
    
    .upgrade-desc {
        font-size: 11px;
        min-height: 30px;
        margin-bottom: 6px;
    }
    
    .upgrade-level {
        font-size: 12px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .btn-large {
        padding: 12px 30px;
        font-size: 16px;
        margin-top: 15px;
    }
    
    .btn-upgrade {
        margin-top: 6px;
        padding: 8px;
        font-size: 12px;
    }
    
    .gold-earned,
    .current-gold {
        font-size: 14px;
        margin: 5px 0;
    }
    
    .gameover-stats {
        font-size: 14px;
        margin: 20px 0;
    }
    
    .gameover-stats span {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .ui-top {
        gap: 3px 6px;
        padding: calc(env(safe-area-inset-top, 0px) + 4px) 6px 4px;
    }
    
    .stat {
        gap: 2px;
    }
    
    .stat .label {
        font-size: 8px;
    }
    
    .stat .value {
        font-size: 12px;
    }
    
    .hp-bar {
        height: 12px;
    }
    
    .hp-text {
        font-size: 8px;
    }
    
    .ui-bottom {
        padding: 6px;
    }
    
    .current-weapon {
        padding: 4px 10px;
    }
    
    .current-weapon .label {
        font-size: 10px;
    }
    
    .current-weapon .value {
        font-size: 12px;
    }
    
    .current-weapon-fixed {
        bottom: 12px;
        left: 12px;
        padding: 4px 10px;
    }
    
    .current-weapon-fixed .label {
        font-size: 10px;
    }
    
    .current-weapon-fixed .value {
        font-size: 12px;
    }
    
    .speed-btn {
        width: 44px;
        height: 44px;
        font-size: 14px;
        bottom: 12px;
        right: 12px;
    }
    
    .upgrade-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .upgrade-card {
        padding: 10px;
    }
    
    .upgrade-icon {
        font-size: 24px;
    }
    
    .unlock-hint {
        font-size: 10px;
    }
    
    .ui-bottom {
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    }
}

@media (pointer: coarse) {
    #game-canvas {
        cursor: default;
    }
}
