/* Kyle Cart 3D Game - Fullscreen Styles */

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

body {
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    cursor: crosshair;
}

/* Overlay UI on top of the game */
#game-ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

#top-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: all;
}

.back-button {
    text-decoration: none;
    color: white;
    font-weight: bold;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    font-size: 1rem;
}

.back-button:hover {
    background: rgba(102, 126, 234, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.connection-status {
    color: white;
    font-weight: bold;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    background: rgba(255, 165, 0, 0.6);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    font-size: 1rem;
    white-space: nowrap;
}

.connection-status.connected {
    background: rgba(0, 255, 0, 0.8);
}

.connection-status.disconnected {
    background: rgba(255, 0, 0, 0.6);
}

#score-display {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#instructions-overlay {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    border-radius: 10px;
    text-align: center;
    pointer-events: all;
    animation: fadeInOut 0.5s ease forwards;
}

#instructions-overlay p {
    color: white;
    margin: 0.5rem 0;
    font-size: 1.1rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

#instructions-overlay strong {
    color: #FFD700;
}

#loading-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 2rem 3rem;
    font-size: 1.5rem;
    color: white;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    z-index: 1000;
}

#error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 2rem 3rem;
    font-size: 1.2rem;
    color: #ff0000;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    border: 2px solid #ff0000;
    z-index: 1000;
}

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

/* Mobile Controls */
#mobile-controls {
    position: fixed;
    bottom: 30px;
    left: 0;
    right: 0;
    z-index: 200;
    display: none; /* Hidden on desktop, shown on touch devices */
    pointer-events: none;
    width: 100%;
}

/* Rocket Button - bottom left corner */
#btn-rocket {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 140px;  /* 2x bigger! */
    height: 140px;
    background: rgba(255, 68, 68, 0.3);
    backdrop-filter: blur(10px);
    border: 3px solid rgba(255, 100, 100, 0.6);
    border-radius: 50%;
    color: white;
    font-size: 4rem;  /* 2x bigger font! */
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 20px rgba(255, 68, 68, 0.4);
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: rocketPulse 2s ease-in-out infinite;
    z-index: 300;  /* On top of joystick! */
}

#btn-rocket:active {
    background: rgba(255, 68, 68, 0.7);
    border-color: rgba(255, 68, 68, 0.9);
    transform: scale(0.9);
    box-shadow: 0 2px 10px rgba(255, 68, 68, 0.8);
}

@keyframes rocketPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(255, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(255, 68, 68, 0.7);
    }
}

/* Tree Button - above rocket button */
#btn-tree {
    position: fixed;
    bottom: 190px;  /* Above rocket button */
    left: 30px;
    width: 140px;
    height: 140px;
    background: rgba(34, 139, 34, 0.3);
    backdrop-filter: blur(10px);
    border: 3px solid rgba(50, 205, 50, 0.6);
    border-radius: 50%;
    color: white;
    font-size: 4rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 20px rgba(34, 139, 34, 0.4);
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: treePulse 2s ease-in-out infinite;
    z-index: 300;
}

#btn-tree:active {
    background: rgba(34, 139, 34, 0.7);
    border-color: rgba(50, 205, 50, 0.9);
    transform: scale(0.9);
    box-shadow: 0 2px 10px rgba(34, 139, 34, 0.8);
}

@keyframes treePulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(34, 139, 34, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(50, 205, 50, 0.7);
    }
}

/* Brick Button - above tree button */
#btn-brick {
    position: fixed;
    bottom: 350px;  /* Above tree button */
    left: 30px;
    width: 140px;
    height: 140px;
    background: rgba(178, 34, 34, 0.3);
    backdrop-filter: blur(10px);
    border: 3px solid rgba(205, 92, 92, 0.6);
    border-radius: 50%;
    color: white;
    font-size: 4rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 20px rgba(178, 34, 34, 0.4);
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: brickPulse 2s ease-in-out infinite;
    z-index: 300;
}

#btn-brick:active {
    background: rgba(178, 34, 34, 0.7);
    border-color: rgba(205, 92, 92, 0.9);
    transform: scale(0.9);
    box-shadow: 0 2px 10px rgba(178, 34, 34, 0.8);
}

@keyframes brickPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(178, 34, 34, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(205, 92, 92, 0.7);
    }
}

/* Joystick for camera control */
#joystick-container {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: all;
    z-index: 200;  /* Below rocket button */
}

#joystick-base {
    position: relative;
    width: 1200px;  /* 10x bigger! */
    height: 1200px;
    background: transparent;  /* Totally transparent! */
    backdrop-filter: none;
    border: none;
    border-radius: 50%;
    box-shadow: none;
}

#joystick-stick {
    position: absolute;
    width: 500px;  /* 10x bigger! */
    height: 500px;
    background: transparent;  /* Totally transparent! */
    border: none;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
    box-shadow: none;
}

#joystick-label {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 0.9rem;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    pointer-events: none;
}

/* D-pad positioning - bottom right corner */
#dpad {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 180px;
    height: 180px;
    pointer-events: all;
    z-index: 250;  /* Above joystick, below rocket button */
}

.dpad-btn {
    position: absolute;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.dpad-btn:active {
    background: rgba(102, 126, 234, 0.6);
    border-color: rgba(102, 126, 234, 0.9);
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.5);
}

#btn-up {
    top: 0;
    left: 60px;
}

#btn-down {
    bottom: 0;
    left: 60px;
}

#btn-left {
    top: 60px;
    left: 0;
}

#btn-right {
    top: 60px;
    right: 0;
}

/* Show mobile controls on touch devices */
@media (hover: none) and (pointer: coarse) {
    #mobile-controls {
        display: block;
    }
}

/* Responsive Design */
/* Object Builder Modal */
#object-builder-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: linear-gradient(135deg, rgba(20, 20, 40, 0.95), rgba(40, 20, 60, 0.95));
    border: 2px solid rgba(102, 126, 234, 0.5);
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(102, 126, 234, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h2 {
    color: white;
    margin: 0 0 0.5rem 0;
    font-size: 1.8rem;
    text-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.modal-subtitle {
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 1.5rem 0;
    font-size: 1rem;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(255, 68, 68, 0.8);
    border-color: rgba(255, 68, 68, 1);
    transform: rotate(90deg);
}

.modal-body {
    color: white;
}

/* Conversation History */
.conversation-history {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1rem;
    min-height: 100px;
}

.history-message {
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    border-radius: 8px;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.system-message {
    background: rgba(102, 126, 234, 0.2);
    border-left: 3px solid rgba(102, 126, 234, 0.8);
    color: rgba(255, 255, 255, 0.9);
}

.user-message {
    background: rgba(0, 255, 200, 0.15);
    border-left: 3px solid rgba(0, 255, 200, 0.8);
    color: white;
}

.user-message strong {
    color: rgba(0, 255, 200, 1);
}

.assistant-message {
    background: rgba(138, 43, 226, 0.15);
    border-left: 3px solid rgba(138, 43, 226, 0.8);
    color: rgba(255, 255, 255, 0.95);
}

.assistant-message strong {
    color: rgba(138, 43, 226, 1);
}

.loading-message {
    background: rgba(255, 165, 0, 0.15);
    border-left: 3px solid rgba(255, 165, 0, 0.8);
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
}

/* Preview Container */
.preview-container {
    position: relative;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    height: 300px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#preview-canvas {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    display: none; /* Hidden until Step 3 */
}

.preview-placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.2rem;
    text-align: center;
}

/* Input Area */
.input-area {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#user-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(102, 126, 234, 0.4);
    border-radius: 10px;
    padding: 0.875rem 1rem;
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

#user-input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.8);
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.3);
}

#user-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.send-btn {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.8), rgba(138, 43, 226, 0.8));
    border: 2px solid rgba(102, 126, 234, 0.6);
    border-radius: 10px;
    padding: 0.875rem 1.5rem;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(102, 126, 234, 1), rgba(138, 43, 226, 1));
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.5);
}

.send-btn:active:not(:disabled) {
    transform: translateY(0);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-icon {
    font-size: 1.2rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
}

.action-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.save-btn {
    background: linear-gradient(135deg, rgba(0, 200, 100, 0.6), rgba(0, 150, 80, 0.6));
    border-color: rgba(0, 200, 100, 0.4);
    color: white;
}

.save-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(0, 200, 100, 0.8), rgba(0, 150, 80, 0.8));
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 200, 100, 0.4);
}

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

.clear-btn {
    background: rgba(255, 68, 68, 0.3);
    border-color: rgba(255, 68, 68, 0.4);
    color: white;
}

.clear-btn:hover {
    background: rgba(255, 68, 68, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 68, 68, 0.4);
}

/* Scrollbar styling for conversation history */
.conversation-history::-webkit-scrollbar {
    width: 8px;
}

.conversation-history::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.conversation-history::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 4px;
}

.conversation-history::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

@media (max-width: 768px) {
    #top-bar {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .back-button,
    #score-display {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }

    #instructions-overlay {
        bottom: 230px; /* Move up to avoid D-pad */
        padding: 0.75rem 1.5rem;
        left: 50%;
        right: auto;
        max-width: 300px;
    }

    #instructions-overlay p {
        font-size: 0.85rem;
        margin: 0.3rem 0;
    }
    
    #mobile-controls {
        display: block;
    }
    
    #btn-rocket {
        bottom: 20px;
        left: 20px;
        width: 120px;  /* 2x bigger for mobile! */
        height: 120px;
        font-size: 3.2rem;  /* 2x bigger font! */
    }
    
    #btn-tree {
        bottom: 160px;  /* Above rocket on mobile */
        left: 20px;
        width: 120px;
        height: 120px;
        font-size: 3.2rem;
    }
    
    #btn-brick {
        bottom: 300px;  /* Above tree on mobile */
        left: 20px;
        width: 120px;
        height: 120px;
        font-size: 3.2rem;
    }
    
    #joystick-container {
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }
    
    #joystick-base {
        width: 1000px;  /* 10x bigger for mobile too! */
        height: 1000px;
    }
    
    #joystick-stick {
        width: 420px;  /* 10x bigger for mobile too! */
        height: 420px;
    }
    
    #joystick-label {
        font-size: 0.8rem;
        top: -22px;
    }
    
    #dpad {
        width: 150px;
        height: 150px;
        bottom: 20px;
        right: 20px;
    }
    
    .dpad-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    #btn-up {
        left: 50px;
    }
    
    #btn-down {
        left: 50px;
    }
    
    #btn-left {
        top: 50px;
    }
    
    #btn-right {
        top: 50px;
    }
}
