/* --- Basic Setup --- */
        body, html {
            margin: 0;
            padding: 0;
            overflow: hidden;
            background-color: #2c3e50;
            color: white;
            font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', sans-serif;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            overscroll-behavior: none;
            user-select: none;
            -webkit-user-select: none;
            -ms-user-select: none;
            -moz-user-select: none;
        }

        #game-canvas {
            display: block;
            background-color: #34495e;
            touch-action: none;
        }

        /* --- UI Elements --- */
        .ui-container {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none; /* Allow canvas clicks through */
            z-index: 10;
        }

        /* Top Bar: Score & Inventory */
        #top-bar {
            position: absolute;
            top: 10px;
            left: 10px;
            right: 10px;
            background: rgba(0, 0, 0, 0.6);
            padding: 10px 15px;
            border-radius: 12px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 10px;
            pointer-events: auto;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        #score-display, .inventory-item {
            font-size: 16px;
            font-weight: 600;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
        }

        #score-display {
            color: #f1c40f; /* Gold */
        }
        
        .inventory-item {
            background: rgba(255, 255, 255, 0.1);
            padding: 5px 10px;
            border-radius: 8px;
        }

        /* Build Menu */
        #build-menu {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.7);
            padding: 8px;
            border-radius: 16px;
            display: flex;
            gap: 8px;
            pointer-events: auto;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .build-button {
            width: 50px;
            height: 50px;
            background-color: #555;
            background-size: 60%;
            background-position: center;
            background-repeat: no-repeat;
            border: 2px solid #777;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.1s ease;
            font-size: 24px;
            line-height: 50px;
            text-align: center;
            color: white;
            font-weight: bold;
        }

        .build-button:active, .build-button.selected {
            background-color: #777;
            border-color: #fff;
            transform: scale(1.1);
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
        }

        /* Action Buttons (Mine, Craft) */
        #action-buttons {
            position: absolute;
            bottom: 30px;
            right: 30px;
            display: flex;
            flex-direction: column;
            gap: 15px;
            pointer-events: auto;
        }

        .action-button {
            width: 65px;
            height: 65px;
            background-color: #e67e22; /* Orange */
            border: 3px solid #d35400;
            border-radius: 50%;
            font-size: 30px;
            color: white;
            text-align: center;
            line-height: 60px;
            cursor: pointer;
            box-shadow: 0 5px 10px rgba(0,0,0,0.3);
            transition: all 0.1s ease;
        }

        .action-button:active {
            transform: scale(0.95);
            background-color: #d35400;
        }

        #craft-button {
            background-color: #3498db; /* Blue */
            border-color: #2980b9;
        }

        #craft-button:active {
            background-color: #2980b9;
        }

        #shop-button {
            background-color: #8e44ad; /* Purple */
            border-color: #71368a;
        }

        #shop-button:active {
            background-color: #71368a;
        }

        /* Joystick */
        #joystick-area {
            position: absolute;
            bottom: 30px;
            left: 30px;
            width: 120px;
            height: 120px;
            background: rgba(0, 0, 0, 0.2);
            border-radius: 50%;
            pointer-events: auto;
        }

        #joystick-knob {
            position: absolute;
            width: 60px;
            height: 60px;
            background: rgba(255, 255, 255, 0.5);
            border-radius: 50%;
            top: 30px;
            left: 30px;
        }
        
        /* Modal for Crafting & Shop */
        #craft-modal, #shop-modal-backdrop { 
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            display: none; /* Hidden by default */
            justify-content: center;
            align-items: center;
            z-index: 100;
            pointer-events: auto;
        }

        #craft-content {
            background: #4a637c;
            padding: 20px;
            border-radius: 16px;
            width: 85%;
            max-width: 400px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        #craft-content h2 {
            margin-top: 0;
            text-align: center;
            color: #ecf0f1;
        }

        .craft-recipe {
            background: #34495e;
            padding: 15px;
            border-radius: 12px;
            margin-bottom: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .craft-info {
            font-size: 16px;
        }
        .craft-info span {
            display: block;
            font-size: 14px;
            color: #bdc3c7;
        }

        .craft-button {
            padding: 10px 15px;
            background: #2ecc71;
            border: none;
            border-bottom: 3px solid #27ae60;
            border-radius: 8px;
            color: white;
            font-weight: 600;
            font-size: 16px;
            cursor: pointer;
        }

        .craft-button:active {
            transform: translateY(2px);
            border-bottom-width: 1px;
        }

        #close-modal, #close-shop-modal {
            display: block;
            margin: 15px auto 0;
            padding: 10px 20px;
            background: #e74c3c;
            border: none;
            border-bottom: 3px solid #c0392b;
            border-radius: 8px;
            color: white;
            font-weight: 600;
            font-size: 16px;
        }
        
        /* Message Box */
        #message-box {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(231, 76, 60, 0.9);
            color: white;
            padding: 15px 25px;
            border-radius: 12px;
            z-index: 200;
            font-size: 16px;
            font-weight: 600;
            display: none;
            text-align: center;
            box-shadow: 0 5px 20px rgba(0,0,0,0.4);
        }

        /* Loading Screen */
        #loading-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: #2c3e50;
            color: #ecf0f1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            z-index: 500;
            font-size: 20px;
        }

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

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