.font-pixel {
    font-family: 'Press Start 2P', cursive;
}

canvas {
    image-rendering: pixelated;
    touch-action: none;
    width: 100vw;
    height: 100vh;
}

/* 3D-Effekt Menü - disabled on mobile for cleaner look */
.ergonomic-menu {
    transform: perspective(600px) rotateY(12deg);
    transform-origin: left center;
}

@media (max-width: 640px) {
    .ergonomic-menu {
        transform: none;
    }
}

.pointer-events-none-wrapper {
    pointer-events: none;
}

.pointer-events-auto-child {
    pointer-events: auto;
}

/* Slider Styling */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 10px;
    background: #ffffff;
    cursor: pointer;
    border: 2px solid #000;
    margin-top: -6px;
    box-shadow: 2px 2px 0px #000;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #4b5563;
    border: 1px solid #000;
}

body {
    overflow: hidden;
    background: #0f172a;
}

/* Inventory Expansion Styles */
.inventory-panel {
    background: rgba(15, 23, 42, 0.98);
    border-top: 4px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateY(100%);
    z-index: 50;
}

.inventory-panel.open {
    transform: translateY(0);
}

.inventory-item {
    background-color: transparent;
    border: none;
    transition: all 0.15s ease-out;
}

.inventory-item:hover {
    transform: translateX(4px);
}

.inventory-item.active .item-box {
    box-shadow: 0 0 0 2px #facc15, 0 0 12px rgba(250, 204, 21, 0.4);
}

.item-box {
    border-right: 4px solid rgba(0, 0, 0, 0.5);
    transition: all 0.15s ease-out;
}

::-webkit-scrollbar {
    display: none;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 640px) {

    /* Smaller tool buttons on mobile */
    .mat-btn {
        width: 5.5rem !important;
        height: 1.75rem !important;
        font-size: 6px !important;
        padding-left: 0.5rem !important;
    }

    /* Smaller header buttons */
    .pointer-events-auto-child button {
        font-size: 6px !important;
        padding: 0.35rem 0.5rem !important;
    }

    /* Inventory panel adjustments */
    .inventory-panel {
        padding: 1rem;
        max-height: 60vh;
    }

    .inventory-panel h2 {
        font-size: 10px !important;
    }

    /* Grid columns for mobile */
    #bigInventoryGrid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .item-box {
        height: 2rem !important;
    }

    /* Limit scroll area to ~3 rows (6 items) */
    .inventory-scroll-area {
        max-height: 260px;
    }

    /* Settings panel mobile */
    #settingsPanel {
        width: 90vw !important;
        max-width: 280px;
        right: 0 !important;
        font-size: 8px !important;
    }

    /* Target the big inventory panel and make it a flex container */
    .inventory-panel {
        display: flex;
        flex-direction: column;
        overflow: hidden !important;
        /* Let children handle scrolling */
    }

    .inventory-scroll-area {
        overflow-y: auto;
        flex: 1;
        -webkit-overflow-scrolling: touch;
    }

    /* Worlds panel mobile */
    #worldsPanel {
        width: 90vw !important;
        max-width: 200px;
    }

    /* Status bar smaller */
    .text-\[6px\] {
        font-size: 5px !important;
    }

    /* Tool indicator smaller */
    .text-\[8px\] {
        font-size: 6px !important;
    }
}

/* ===== TABLET / IPAD OPTIMIZATION ===== */
/* Adjusted to be roughly 1.1x original size (reduced from 1.5x) */
@media screen and (min-width: 768px) and (max-width: 1366px) {

    /* 1.1x size for material buttons (Tools) - 25% smaller than the previous 1.5x */
    .mat-btn {
        width: 8rem !important;
        height: 2.5rem !important;
        font-size: 10px !important;
        padding-left: 0.6rem !important;
        border-right-width: 5px !important;
    }

    /* Target the extension button as well */
    .ergonomic-menu>button.mat-btn {
        width: 8rem !important;
        height: 2.5rem !important;
    }

    /* Header buttons ([WELTEN], [OPT], LEEREN, etc.) */
    .pointer-events-auto-child button {
        font-size: 10px !important;
        padding: 0.5rem 0.6rem !important;
        /* Reduced horizontal padding to fit text */
        border-bottom-width: 2px !important;
        min-width: 120px;
        /* Ensure enough width for [ WELTEN ] */
    }

    /* Adjust the gap between tools */
    .ergonomic-menu,
    #tools-container {
        gap: 0.6rem !important;
    }

    /* Inventory items */
    .item-box {
        height: 3rem !important;
    }

    .item-box span {
        font-size: 10px !important;
    }

    /* Adjust font size for tool indicator and status */
    #currentMat,
    #fps,
    #entityCount {
        font-size: 10px !important;
    }

    /* Settings panel tablet adjustments */
    #settingsPanel {
        width: 280px !important;
        font-size: 10px !important;
    }

    #worldsPanel {
        width: 560px !important;
        /* Even wider for better name visibility */
        max-width: 90vw;
        font-size: 10px !important;
    }

    #worldsPanel button {
        padding-top: 0.7rem !important;
        padding-bottom: 0.7rem !important;
    }
}

/* Very small screens (iPhone SE etc) */
@media (max-width: 380px) {
    .mat-btn {
        width: 4.5rem !important;
        font-size: 5px !important;
    }

    .inventory-panel {
        padding: 0.75rem;
    }
}

/* --- RANGE SLIDERS --- */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    input[type=range]::-webkit-slider-thumb {
        -webkit-appearance: none;
        height: 16px;
        width: 16px;
        border-radius: 2px;
        background: #e5e7eb;
        cursor: pointer;
        margin-top: -7px;
        box-shadow: none;
        border: none;
    }

    input[type=range]::-webkit-slider-runnable-track {
        width: 100%;
        height: 2px;
        cursor: pointer;
        background: #4b5563;
        border-radius: 1px;
        border: none;
    }

    /* Mozilla Firefox */
    input[type=range]::-moz-range-thumb {
        height: 16px;
        width: 16px;
        border-radius: 2px;
        background: #e5e7eb;
        cursor: pointer;
        border: none;
    }

    input[type=range]::-moz-range-track {
        width: 100%;
        height: 2px;
        cursor: pointer;
        background: #4b5563;
        border-radius: 1px;
    }