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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Courier New', monospace;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    display: none;
}

#crosshair.crosshair-weapon {
    color: #FF4444;
    font-size: 32px;
}

#hotbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 4px;
    z-index: 10;
}

.hotbar-slot {
    width: 50px;
    height: 50px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hotbar-slot.selected {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

.hotbar-block {
    width: 32px;
    height: 32px;
    border-radius: 2px;
}

.block-color-grass { background-color: #4CAF50; }
.block-color-dirt { background-color: #8B6914; }
.block-color-stone { background-color: #808080; }
.block-color-wood { background-color: #B8860B; }
.block-color-leaves { background-color: #228B22; }

#fly-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    pointer-events: none;
    z-index: 10;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    display: none;
    opacity: 0.7;
}

#water-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(63, 118, 228, 0.35);
    pointer-events: none;
    z-index: 5;
    display: none;
}

/* Health bar */
#health-container {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 200px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    z-index: 10;
    display: none;
}

#health-bar {
    width: 100%;
    height: 100%;
    background-color: #4CAF50;
    transition: width 0.2s;
}

#health-bar.health-low {
    background-color: #FFC107;
}

#health-bar.health-critical {
    background-color: #F44336;
}

#health-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 11px;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

/* Damage flash */
#damage-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 0, 0, 0.3);
    pointer-events: none;
    z-index: 8;
    display: none;
    opacity: 0;
}

/* Weapon indicator */
#weapon-indicator {
    position: fixed;
    bottom: 80px;
    right: 20px;
    color: #AAA;
    font-size: 14px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    display: none;
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.5);
}

#weapon-indicator.weapon-mode-gun {
    color: #FF4444;
    border-color: #FF4444;
}

/* Boss bar */
#boss-bar {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    z-index: 15;
    text-align: center;
    display: none;
}

#boss-bar-name {
    color: #D580FF;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    display: block;
    margin-bottom: 4px;
}

#boss-bar-track {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(200, 100, 255, 0.5);
}

#boss-bar-fill {
    width: 100%;
    height: 100%;
    background-color: #9B30FF;
    transition: width 0.3s;
}

/* Death overlay */
#death-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(100, 0, 0, 0.7);
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
}

#death-content {
    text-align: center;
    color: #fff;
}

#death-content h1 {
    font-size: 48px;
    margin-bottom: 16px;
    color: #FF4444;
}

#death-content p {
    font-size: 20px;
    opacity: 0.8;
}

/* Victory message */
#victory-message {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FFD700;
    font-size: 36px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 20;
    display: none;
}

.hidden {
    display: none !important;
}

.visible-block {
    display: block !important;
}

.visible-flex {
    display: flex !important;
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    cursor: pointer;
}

#overlay-content {
    text-align: center;
    color: #fff;
}

#overlay-content h1 {
    font-size: 48px;
    margin-bottom: 16px;
    letter-spacing: 4px;
}

#overlay-content p {
    font-size: 20px;
    opacity: 0.8;
}

#overlay-content h2 {
    font-size: 32px;
    margin-bottom: 16px;
    letter-spacing: 2px;
}

/* Multiplayer UI */
.mp-btn {
    display: block;
    width: 240px;
    margin: 10px auto;
    padding: 12px 20px;
    font-size: 18px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #fff;
    background: rgba(76, 175, 80, 0.6);
    border: 2px solid rgba(76, 175, 80, 0.8);
    cursor: pointer;
    letter-spacing: 1px;
    transition: background 0.2s;
}

.mp-btn:hover {
    background: rgba(76, 175, 80, 0.9);
}

.mp-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.mp-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mp-input {
    display: block;
    width: 240px;
    margin: 10px auto;
    padding: 10px 14px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    text-align: center;
    outline: none;
}

.mp-input:focus {
    border-color: rgba(76, 175, 80, 0.8);
}

.mp-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Host info bar */
#host-info {
    position: fixed;
    top: 50px;
    right: 20px;
    color: #fff;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    pointer-events: none;
    z-index: 10;
    display: none;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.host-info-label {
    opacity: 0.6;
}

.host-info-code {
    color: #4CAF50;
    font-weight: bold;
    letter-spacing: 1px;
}

#player-count {
    opacity: 0.6;
    margin-left: 8px;
}

/* =========================
   Touch controls (mobile)
   ========================= */
#touch-controls {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Joystick area — left side */
#touch-joystick {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40%;
    height: 60%;
    pointer-events: auto;
}

#touch-joystick-base,
#touch-joystick-knob {
    position: absolute;
    border-radius: 50%;
    display: none;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#touch-joystick-base {
    width: 100px;
    height: 100px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

#touch-joystick-knob {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

#touch-joystick-base.touch-joystick-active,
#touch-joystick-knob.touch-joystick-active {
    display: block;
}

/* Action buttons — right side */
#touch-buttons {
    position: absolute;
    bottom: 90px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
}

.touch-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    letter-spacing: 1px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.touch-btn:active {
    background: rgba(255, 255, 255, 0.25);
}

/* Mobile hotbar adjustments */
@media (pointer: coarse) {
    .hotbar-slot {
        width: 44px;
        height: 44px;
    }

    .hotbar-block {
        width: 28px;
        height: 28px;
    }

    #hotbar {
        bottom: 14px;
    }

    #weapon-indicator {
        bottom: auto;
        top: 46px;
        left: 20px;
        right: auto;
    }

    /* Prevent browser touch behaviors on game elements */
    #game-canvas,
    #touch-controls {
        touch-action: none;
    }
}
