/* Robo Maze only — the fit-to-screen layout, the compass, the typing bar and
   the program strip. Everything else on this page comes from
   assets/css/game-shell.css. */

/* ---------- fit the whole game on one screen ----------
   On a wide screen the maze and the program sit side by side and the maze is
   sized from the screen height, so nothing needs a scroll. The how-to-play
   panels move below the game. */
@media (min-width: 981px) {
    .game {
        grid-template-columns: 1fr;
    }
    .play {
        display: flex;
        gap: 16px;
        align-items: stretch;
        justify-content: center;
    }
    .play .stage {
        flex: 0 1 auto;
        margin: 0;
    }
    .play .type-bar {
        flex: 0 0 300px;
        width: auto;
        margin: 0;
        align-content: start;
        grid-template-rows: auto auto auto minmax(0, 1fr) auto;
        /* the maze alone sets the row's height, so a long program scrolls
           inside its box instead of stretching the page */
        contain: size;
    }
    .play .program-box {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .play .program {
        flex: 1;
        overflow-y: auto;
        align-content: flex-start;
    }
    .play .program-actions {
        margin-top: auto;
    }
    .side {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

.hud .stat b.stars {
    color: #e0a100;
    letter-spacing: 0.08em;
}

/* ---------- compass (page head, top right) ---------- */
.head-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.compass {
    margin: 0;
    width: 38px;
    height: 38px;
    flex: none;
}
.compass svg {
    width: 100%;
    height: 100%;
    display: block;
}
.compass .rim {
    fill: var(--surface);
    stroke: var(--line);
    stroke-width: 2;
}
.compass .face {
    fill: var(--tint);
}
.compass .pt-ns,
.compass .pt-ew {
    fill: #b8c0e0;
}
.compass .pt-n {
    fill: var(--coral);
}
.compass .hub {
    fill: var(--ink);
}
.compass text {
    font: 800 13px "Bricolage Grotesque", sans-serif;
    fill: var(--ink-soft);
    text-anchor: middle;
}
.compass text.n {
    fill: var(--coral);
}

/* ---------- typing bar ---------- */
.type-bar {
    /* lines up with the stage above when the two are stacked */
    width: min(100%, max(420px, calc((100vh - var(--above)) * 4 / 3)));
    width: min(100%, max(420px, calc((100dvh - var(--above)) * 4 / 3)));
    margin: 14px auto 0;
    display: grid;
    gap: 10px;
}
.type-bar label {
    font-family: "Bricolage Grotesque";
    font-weight: 700;
    font-size: 17px;
}
.type-row {
    display: flex;
    gap: 10px;
}
.type-row input {
    flex: 1;
    width: 0; /* otherwise the box's built-in width pushes past a phone screen */
    min-width: 0;
    font: 600 22px/1.2 "DM Mono", monospace;
    padding: 13px 16px;
    border: 2px solid var(--line);
    border-radius: var(--r-md);
    background: var(--paper);
    color: var(--ink);
    transition: border-color 0.15s;
}
.type-row input:focus {
    outline: none;
    border-color: var(--blue);
    background: var(--surface);
}
.type-row input::placeholder {
    color: #b9bdd0;
}
.add-btn {
    border: 2px solid var(--blue);
    border-radius: var(--r-md);
    padding: 0 22px;
    background: var(--surface);
    color: var(--blue-deep);
    font-weight: 700;
    font-size: 17px;
}
.add-btn:hover:not(:disabled) {
    background: var(--tint);
}
.type-bar button:disabled {
    opacity: 0.5;
    cursor: default;
}

.word-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.word-keys button {
    border: 1.5px solid var(--line);
    background: var(--surface);
    border-radius: 999px;
    padding: 7px 14px;
    font: 500 14px "DM Mono", monospace;
    color: var(--ink);
}
.word-keys button:hover:not(:disabled) {
    background: var(--tint);
    border-color: var(--blue);
}

/* ---------- the program ---------- */
.program-box {
    background: var(--tint);
    border-radius: var(--r-md);
    padding: 12px;
    display: grid;
    gap: 10px;
}
.program-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.program-head span {
    font-family: "DM Mono", monospace;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.program-head p {
    margin: 0;
    font-size: 14px;
    color: var(--ink-soft);
}
.program {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    counter-reset: step;
}
.program:empty {
    display: none;
}
.program .chip {
    counter-increment: step;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 999px;
    padding: 4px 4px 4px 10px;
    font: 500 14px "DM Mono", monospace;
    color: var(--blue-deep);
    transition:
        background 0.15s,
        border-color 0.15s;
}
.program .chip::before {
    content: counter(step);
    font-size: 11px;
    color: var(--ink-soft);
}
.program .x {
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--tint);
    color: var(--ink-soft);
    font-size: 11px;
    line-height: 1;
}
.program .x:hover:not(:disabled) {
    background: #ffe0d9;
    color: #d8452c;
}
.program .chip.done {
    background: #e2f6f1;
    border-color: #bfe9df;
    color: #0e8f80;
}
.program .chip.now {
    background: #fff3cf;
    border-color: var(--yellow);
    color: #8a5d00;
}
.program .chip.hit {
    background: #ffe9e4;
    border-color: var(--coral);
    color: #d8452c;
}
.program .chip.hit span::after {
    content: " 💥";
}

.program-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.run-btn {
    margin-left: auto;
    border: none;
    border-radius: var(--r-md);
    padding: 11px 26px;
    background: var(--blue);
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 4px 0 var(--blue-deep);
    transition:
        transform 0.1s,
        box-shadow 0.1s;
}
.run-btn:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--blue-deep);
}

.say {
    min-height: 1.5em;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink-soft);
}
.say[data-tone="warn"] {
    color: #d8452c;
}
.say[data-tone="good"] {
    color: #0e8f80;
}

@media (max-width: 560px) {
    .type-row input {
        font-size: 18px;
    }
    .compass {
        width: 36px;
        height: 36px;
    }
}
