body {
    margin: 0;
    overflow: hidden;
    background-color: #111;
    font-family: sans-serif;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

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

canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: none; /* Hide default cursor */
}

#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allows mouse events to pass through */
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border: 1px solid white;
    border-radius: 50%;
    box-shadow: 0 0 5px white;
}

#hud {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

#health-bar {
    width: 200px;
    height: 20px;
    background-color: #555;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

#health-fill {
    width: 100%;
    height: 100%;
    background-color: #ff0000;
    transition: width 0.5s ease-in-out;
}

#hunger-bar {
    width: 200px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid white;
    border-radius: 5px;
    overflow: hidden;
}

#hunger-fill {
    height: 100%;
    background-color: orange;
    transition: width 0.2s;
}

.button {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 10px 2px;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.3s, transform 0.1s;
}

.button:hover {
    background-color: #45a049;
    transform: scale(1.05);
}

#hotbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 5px;
}

.slot {
    width: 50px;
    height: 50px;
    border: 2px solid #555;
    margin: 2px;
    background-size: cover;
    background-position: center;
}

.slot.selected {
    border-color: #fff;
}

#inventory {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
}

#inventory-grid {
    display: grid;
    grid-template-columns: repeat(9, 54px);
    gap: 5px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
}

#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    display: none; /* Hidden by default */
}

#joystick-container {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 120px;
    height: 120px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
}

#joystick {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
}

#action-buttons {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
}

#action-buttons button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 10px;
    font-size: 1.5em;
}

@media (max-width: 768px) {
    #mobile-controls {
        display: block;
    }
}

.button:active {
    transform: scale(0.95);
}

#status-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
    opacity: 0;
}

#message-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    text-align: center;
    pointer-events: auto;
    z-index: 1000;
}

#message-box h3 {
    margin-top: 0;
    color: #4CAF50;
}

#message-box p {
    margin-bottom: 20px;
}

#user-info {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
}

#loading-screen {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #1a1a1a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#main-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 3000;
}

#main-menu h1 {
    font-size: 4em;
    color: white;
    margin-bottom: 20px;
    text-shadow: 0 0 10px black;
}

#main-menu button {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: block;
    font-size: 16px;
    margin: 10px auto;
    cursor: pointer;
    border-radius: 8px;
    width: 200px;
    transition: background-color 0.3s, transform 0.1s;
}

#main-menu button:hover {
    background-color: #45a049;
    transform: scale(1.05);
}
