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

body {
    overflow: hidden;
    font-family: Arial, sans-serif;
}

canvas {
    display: block;
}

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

#nameModal.hidden {
    display: none;
}

#nameForm {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

#nameForm h1 {
    color: white;
    margin-bottom: 10px;
    font-size: 28px;
}

#nameForm p {
    color: rgba(255,255,255,0.8);
    margin-bottom: 20px;
}

#nameInput {
    padding: 15px 20px;
    font-size: 18px;
    border: none;
    border-radius: 10px;
    width: 280px;
    margin-bottom: 15px;
    outline: none;
}

#nameSubmit {
    padding: 15px 40px;
    font-size: 18px;
    background: white;
    color: #764ba2;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s;
}

#nameSubmit:hover {
    transform: scale(1.05);
}

#info {
    position: absolute;
    top: 10px;
    left: 10px;
    color: white;
    font-size: 14px;
    background: rgba(0,0,0,0.5);
    padding: 10px;
    border-radius: 5px;
    display: none; /* Hidden initially */
}

#info.active {
    display: block;
}

#players {
    position: absolute;
    top: 10px;
    right: 10px;
    color: white;
    font-size: 14px;
    background: rgba(0,0,0,0.5);
    padding: 10px;
    border-radius: 5px;
    display: none; /* Hidden initially */
}

#players.active {
    display: block;
}

#messages {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    text-align: center;
    pointer-events: none;
}

.message {
    background: rgba(0,0,0,0.7);
    padding: 8px 16px;
    border-radius: 20px;
    margin-bottom: 8px;
    animation: fadeInOut 4s forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(20px); }
    10% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

#chatContainer {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: none; /* Hidden initially, shown after name entry */
    gap: 10px;
    z-index: 100;
    pointer-events: all;
}

#chatContainer.active {
    display: flex;
}

#chatInput {
    padding: 10px 15px;
    font-size: 14px;
    border: none;
    border-radius: 20px;
    width: 300px;
    background: rgba(255,255,255,0.9);
    outline: none;
}

#chatSend {
    padding: 10px 20px;
    font-size: 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
}

#chatSend:hover {
    background: #764ba2;
}

/* Mobile controls */
#mobileControls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none;
}

#mobileControls.active {
    display: block;
}

.mobile-joystick {
    position: absolute;
    bottom: 100px;
    left: 50px;
    width: 120px;
    height: 120px;
    pointer-events: all;
}

.joystick-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    border: 3px solid rgba(255,255,255,0.5);
    position: absolute;
}

.joystick-stick {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.8);
    border: 3px solid rgba(255,255,255,1);
    position: absolute;
    top: 35px;
    left: 35px;
    transition: all 0.1s;
}

.mobile-button {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    border: 3px solid rgba(255,255,255,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 20px;
    pointer-events: all;
    user-select: none;
}

.mobile-button:active {
    background: rgba(255,255,255,0.5);
}

#jumpButton {
    bottom: 100px;
    right: 50px;
}

#waveButton {
    bottom: 190px;
    right: 50px;
}

#throwButton {
    bottom: 100px;
    right: 140px;
}

#mobileVoiceButton {
    bottom: 190px;
    right: 140px;
    font-size: 24px;
    display: none; /* Hidden by default, shown when voice is enabled */
}

#mobileVoiceButton.active {
    background: rgba(0,200,0,0.5);
    border-color: rgba(0,255,0,0.8);
}

#lookArea {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 250px;
    pointer-events: all;
    touch-action: none;
}

#cvPrompt {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(102, 126, 234, 0.95);
    color: white;
    padding: 20px 40px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    z-index: 100;
    cursor: pointer;
}

#cvModal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 2000;
    color: #333;
}

#cvClose {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #764ba2;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
}

#cvOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1999;
}

/* Voice Chat UI */
#voiceButton {
    position: absolute;
    top: 40px;
    right: 10px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: none; /* Hidden initially */
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 100;
}

#voiceButton.active {
    background: rgba(0,200,0,0.6);
    border-color: rgba(0,255,0,0.6);
    box-shadow: 0 0 10px rgba(0,255,0,0.5);
}

#voiceButton.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#voiceButton:not(.disabled):hover {
    background: rgba(0,0,0,0.7);
    transform: scale(1.1);
}

#voiceButton.active:not(.disabled):hover {
    background: rgba(0,200,0,0.8);
}

#voiceButton.show {
    display: flex;
}

#voicePermissionModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2001;
}

#voicePermissionForm {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    max-width: 400px;
}

#voicePermissionForm h2 {
    color: white;
    margin-bottom: 10px;
    font-size: 24px;
}

#voicePermissionText {
    color: rgba(255,255,255,0.9);
    margin-bottom: 25px;
    font-size: 16px;
    line-height: 1.5;
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.primary-button {
    padding: 15px 30px;
    font-size: 16px;
    background: white;
    color: #764ba2;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s;
}

.primary-button:hover {
    transform: scale(1.05);
}

.secondary-button {
    padding: 15px 30px;
    font-size: 16px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.secondary-button:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

@media (max-width: 768px) {
    #chatContainer {
        bottom: 280px;
        z-index: 1001;
    }
    #chatInput {
        width: 200px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    #chatSend {
        touch-action: manipulation; /* Better touch response */
    }
    #info {
        font-size: 12px;
        padding: 5px;
        max-width: 200px;
    }
    #voiceButton {
        top: 35px;
        right: 5px;
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    #voicePermissionForm {
        padding: 30px;
        max-width: 90%;
    }
    .button-group {
        flex-direction: column;
    }
    .primary-button,
    .secondary-button {
        width: 100%;
    }
}
