body {
    margin: 0;
    overflow: hidden;
    background: #1a1a1a;
    font-family: Arial, sans-serif;
    color: #fff;
}

/* CANVAS */
#gameCanvas {
    width: 100vw;
    height: 100vh;
    display: block;
}

/* UI */
#ui {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 20;
    background: rgba(0,0,0,0.45);
    padding: 10px;
    border-radius: 8px;
    width: 220px;
}

#ui div {
    margin-bottom: 6px;
}

#levelName {
    font-size: 20px;
    font-weight: bold;
}

#message {
    font-size: 16px;
    color: #00ff88;
    min-height: 20px;
}

#modes button,
#controls button,
#viewToggle button {
    margin: 2px;
    padding: 4px 8px;
    border: none;
    border-radius: 6px;
    background: #444;
    color: #fff;
    cursor: pointer;
}

#modes button.active,
#viewToggle button.active {
    background: #00ff88;
    color: #000;
}

/* STATYSTYKI */
#statsPanel {
    margin-top: 10px;
    font-size: 12px;
    color: #ccc;
}

/* EDYTOR */
#editor {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 20;
    background: rgba(0,0,0,0.55);
    padding: 10px;
    border-radius: 8px;
    width: 260px;
}

#editor h3 {
    margin-top: 0;
}

#gridEditor {
    display: grid;
    gap: 2px;
    margin: 10px 0;
}

.grid-cell {
    width: 22px;
    height: 22px;
    background: #222;
    border: 1px solid #444;
    text-align: center;
    line-height: 22px;
    font-size: 12px;
    cursor: pointer;
}

.grid-cell.wall { background: #555; }
.grid-cell.player { background: #00ff88; color: #000; }
.grid-cell.box { background: #ffcc00; color: #000; }
.grid-cell.target { background: #3366ff; }

textarea {
    width: 100%;
    margin-top: 5px;
}

.row {
    margin-bottom: 6px;
}

/* STEROWANIE DOTYKOWE (MOBILE) */
#touchControls {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.touch-row {
    display: flex;
    gap: 50px;
}

.touch-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.touch-btn:active {
    background: rgba(0, 255, 136, 0.5);
    transform: scale(0.95);
}

/* RESPONSYWNOŚĆ MOBILE */
@media (max-width: 768px) {
    #touchControls {
        display: flex;
    }

    #ui {
        width: 180px;
        padding: 8px;
        font-size: 14px;
    }

    #levelName {
        font-size: 16px;
    }

    #message {
        font-size: 14px;
    }

    #modes button,
    #controls button,
    #viewToggle button {
        padding: 6px 10px;
        font-size: 12px;
    }

    #editor {
        display: none;
    }
}

@media (max-width: 480px) {
    #ui {
        width: 150px;
        padding: 6px;
        font-size: 12px;
    }

    #levelName {
        font-size: 14px;
    }

    #modes button,
    #controls button,
    #viewToggle button {
        padding: 4px 6px;
        font-size: 11px;
    }

    .touch-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .touch-row {
        gap: 40px;
    }
}

/* Pokaż kontrolki dotykowe na urządzeniach z ekranem dotykowym */
@media (pointer: coarse) {
    #touchControls {
        display: flex;
    }

    #editor {
        display: none;
    }
}
