body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #111;
    color: white;
}

.game-container {
    display: flex;
    height: 100vh;
}

.panel {
    padding: 15px;
    box-sizing: border-box;
}

.left-panel, .right-panel {
    width: 25%;
    background: #1b1b1b;
    overflow-y: auto;
}

.center-panel {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #222;
}

button {
    display: block;
    margin: 5px 0;
    padding: 8px;
    width: 100%;
    cursor: pointer;
}

.run-history {
    margin-top: 14px;
}

.run-history h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

#runHistoryList {
    margin: 0;
    padding-left: 20px;
}

#runHistoryList li {
    margin-bottom: 6px;
    font-size: 14px;
}

#codeInput {
    width: 100%;
    min-height: 260px;
    box-sizing: border-box;
    border: 1px solid #444;
    border-radius: 8px;
    background: #101010;
    color: #f2f2f2;
    padding: 10px;
    font-family: "Courier New", Courier, monospace;
    font-size: 14px;
    line-height: 1.45;
    resize: vertical;
}

.code-help {
    margin-top: 10px;
    color: #d5d5d5;
}

.code-help p {
    margin: 0 0 6px;
}

.code-help pre {
    margin: 0;
    padding: 8px;
    border-radius: 8px;
    background: #151515;
    border: 1px solid #353535;
    white-space: pre-wrap;
    font-family: "Courier New", Courier, monospace;
    font-size: 13px;
}

#result {
    margin-top: 12px;
    min-height: 22px;
}

#grid {
    display: grid;
    gap: 2px;
    position: relative;
}

.tile {
    width: 50px;
    height: 50px;
    background: #333;
}

.wall { background: #7a5228; }
.hole { background: black; }
.goal { background: green; }
.start { background: #333; }

.player-marker {
    --arrow-rotation: 0deg;
    width: 50px;
    height: 50px;
    position: absolute;
    background: orange;
    border-radius: 8px;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.2) inset;
    transition: transform 0.32s ease-in-out, box-shadow 0.32s ease-in-out;
}

.player-arrow {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    transform: rotate(var(--arrow-rotation));
    transition: transform 0.32s ease-in-out;
}

.player-arrow::before {
    content: "▲";
}

.player-marker.no-transition {
    transition: none;
}

.player-marker.no-transition .player-arrow {
    transition: none;
}

#grid.running .player-marker {
    animation: runningPulse 0.6s ease-in-out infinite;
}

@keyframes runningPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255,255,255,0.2) inset; }
    50% { box-shadow: 0 0 0 4px rgba(255,255,255,0.35) inset; }
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: min(90vw, 380px);
    background: #1b1b1b;
    border: 1px solid #3a3a3a;
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    transform: scale(1);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 8px;
}

.modal-content p {
    margin-top: 0;
    margin-bottom: 14px;
}

.modal-actions {
    display: grid;
    gap: 10px;
}

.modal-content.pop {
    animation: modalBlowIn 360ms cubic-bezier(.2,.9,.2,1) both;
}

@keyframes modalBlowIn {
    0% { transform: scale(0); opacity: 0; }
    75% { transform: scale(1.06); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@media(max-width: 900px) {
    .game-container {
        flex-direction: column;
    }
    .left-panel, .right-panel {
        width: 100%;
        height: auto;
    }
}
