/* ---------------------------------------------------------------------------
   Gridbreak - Tron: black grid, cyan light trails, green orbs.
   The canvas palette lives in assets/js/config.js; these are the page colours.
   --------------------------------------------------------------------------- */

:root {
    --bg: #04060c;
    --bg-soft: #071018;
    --panel: rgba(8, 22, 32, 0.82);
    --line: rgba(37, 233, 255, 0.22);
    --line-strong: rgba(37, 233, 255, 0.55);
    --cyan: #25e9ff;
    --cyan-soft: #9fe9ff;
    --green: #39ff8a;
    --magenta: #ff2d95;
    --text: #c9f7ff;
    --muted: #5c8a99;
    --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    color: var(--text);
    font-family: var(--mono);
    letter-spacing: 0.02em;
    background:
        radial-gradient(ellipse at 50% -10%, rgba(37, 233, 255, 0.10), transparent 55%),
        radial-gradient(ellipse at 50% 120%, rgba(57, 255, 138, 0.06), transparent 55%),
        var(--bg);
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(37, 233, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 233, 255, 0.035) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at 50% 30%, black, transparent 80%);
    pointer-events: none;
}

[hidden] {
    display: none !important;
}

a {
    color: var(--cyan);
}

h1,
h2,
p,
ol {
    margin: 0;
}

.app {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
}

.screen {
    width: 100%;
}

.screen--menu,
.screen--over {
    overflow-y: auto;
    padding: clamp(18px, 4vw, 48px) clamp(12px, 4vw, 40px) 48px;
}

.screen--play {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 10px clamp(8px, 2vw, 20px) 12px;
    gap: 8px;
}

.hero {
    width: 100%;
    max-width: 780px;
    margin: 0 auto;
}

.eyebrow {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.42em;
    text-transform: uppercase;
}

.title {
    margin: 6px 0 12px;
    font-size: clamp(38px, 9vw, 86px);
    line-height: 0.95;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--cyan);
    text-shadow: 0 0 18px rgba(37, 233, 255, 0.65), 0 0 60px rgba(37, 233, 255, 0.25);
}

.title span {
    color: var(--green);
    text-shadow: 0 0 18px rgba(57, 255, 138, 0.6), 0 0 60px rgba(57, 255, 138, 0.22);
}

.lede {
    max-width: 62ch;
    color: #9dc8d6;
    font-size: 13px;
    line-height: 1.65;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 2px;
    box-shadow: inset 0 0 24px rgba(37, 233, 255, 0.05), 0 0 0 1px rgba(4, 6, 12, 0.6);
}

.start {
    display: grid;
    gap: 14px;
    margin: 22px 0 18px;
    padding: 18px;
}

.field {
    display: grid;
    gap: 6px;
}

.field__label {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.field__label .badge {
    margin-left: 4px;
}

.field input {
    width: 100%;
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
    font-size: 15px;
    background: #061119;
    border: 1px solid var(--line);
    border-radius: 2px;
    outline: none;
}

.field input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 1px rgba(37, 233, 255, 0.35), 0 0 18px rgba(37, 233, 255, 0.18);
}

.field input[readonly] {
    color: var(--cyan-soft);
    border-style: dashed;
}

.badge {
    display: inline-grid;
    place-items: center;
    width: 15px;
    height: 15px;
    color: #04121a;
    font-size: 11px;
    font-weight: 700;
    background: var(--cyan);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--cyan);
    vertical-align: -2px;
}

.button {
    padding: 10px 18px;
    color: var(--cyan-soft);
    font: inherit;
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    background: rgba(37, 233, 255, 0.04);
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.button:hover,
.button:focus-visible {
    color: #eaffff;
    background: rgba(37, 233, 255, 0.12);
    box-shadow: 0 0 20px rgba(37, 233, 255, 0.28);
    outline: none;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    box-shadow: none;
}

.button--primary {
    color: #eaffff;
    background: linear-gradient(180deg, rgba(37, 233, 255, 0.22), rgba(37, 233, 255, 0.05));
    border-color: var(--cyan);
    box-shadow: 0 0 22px rgba(37, 233, 255, 0.22), inset 0 0 18px rgba(37, 233, 255, 0.10);
}

.button--primary:hover,
.button--primary:focus-visible {
    background: linear-gradient(180deg, rgba(37, 233, 255, 0.34), rgba(37, 233, 255, 0.10));
    box-shadow: 0 0 30px rgba(37, 233, 255, 0.38), inset 0 0 22px rgba(37, 233, 255, 0.14);
}

.button--small {
    padding: 6px 10px;
    font-size: 10px;
    letter-spacing: 0.12em;
}

.note {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
}

.note strong {
    color: var(--cyan-soft);
    font-weight: 600;
}

/* The mode switch and the board tabs: one pill shape, two jobs. */

.mode-switch,
.board-tabs {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 2px;
    overflow: hidden;
}

.mode-switch {
    width: 100%;
    margin-bottom: 10px;
}

.mode-switch__button,
.board-tabs__button {
    flex: 1;
    padding: 8px 12px;
    color: var(--muted);
    font: inherit;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.mode-switch__button + .mode-switch__button,
.board-tabs__button + .board-tabs__button {
    border-left: 1px solid var(--line);
}

.mode-switch__button:hover,
.mode-switch__button:focus-visible,
.board-tabs__button:hover,
.board-tabs__button:focus-visible {
    color: var(--cyan-soft);
    outline: none;
}

.mode-switch__button.is-active,
.board-tabs__button.is-active {
    color: #eaffff;
    background: rgba(37, 233, 255, 0.14);
    box-shadow: inset 0 0 16px rgba(37, 233, 255, 0.18);
}

.mode-note {
    margin: 0 0 12px;
}

/* The competitive switch sits under the mode switch: a state of the next run,
   not a third mode. */

.competitive {
    display: grid;
    gap: 6px;
    margin: 0 0 12px;
}

.competitive__button {
    justify-self: start;
    letter-spacing: 0.14em;
}

.competitive__button.is-active {
    color: #04121a;
    background: var(--cyan);
    border-color: var(--cyan);
    box-shadow: 0 0 18px rgba(37, 233, 255, 0.45);
}

.competitive__button.is-active:hover,
.competitive__button.is-active:focus-visible {
    color: #04121a;
    background: #8ff6ff;
    box-shadow: 0 0 24px rgba(37, 233, 255, 0.55);
}

.competitive__note {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.55;
}

/* The jump button and the list it opens. The list runs from level 1 to the
   furthest level the player has reached, so it is a grid of numbers
   rather than a row, and it sits above the shared bar and its menu. */

.start-level__button {
    justify-self: start;
    letter-spacing: 0.14em;
}

.level-picker {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: none;
    place-items: center;
    padding: 18px;
    background: rgba(3, 5, 10, 0.82);
    backdrop-filter: blur(2px);
}

.level-picker.is-visible {
    display: grid;
}

.level-picker__panel {
    display: grid;
    gap: 12px;
    width: min(480px, 100%);
    max-height: 80vh;
    padding: 20px;
    text-align: center;
}

.level-picker__title {
    color: var(--cyan-soft);
    font-size: 11px;
    letter-spacing: 0.3em;
}

.level-picker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 6px;
    overflow-y: auto;
}

.level-picker__button {
    padding: 8px 4px;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 2px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.level-picker__button:hover,
.level-picker__button:focus-visible {
    color: var(--cyan-soft);
    border-color: var(--line-strong);
    outline: none;
}

.level-picker__button.is-active {
    color: #eaffff;
    background: rgba(37, 233, 255, 0.14);
    border-color: var(--cyan);
    box-shadow: inset 0 0 16px rgba(37, 233, 255, 0.18);
}

/* The board panel's second switch: whole runs, or the best fill per level, and
   the level strip that only the coverage board needs. */

.board-views,
.board-levels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.board-views__button,
.board-levels__button {
    padding: 5px 9px;
    color: var(--muted);
    font: inherit;
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 2px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.board-levels__button {
    min-width: 27px;
    padding: 4px 6px;
    letter-spacing: 0.08em;
    text-align: center;
}

.board-views__button:hover,
.board-views__button:focus-visible,
.board-levels__button:hover,
.board-levels__button:focus-visible {
    color: var(--cyan-soft);
    border-color: var(--line-strong);
    outline: none;
}

.board-views__button.is-active,
.board-levels__button.is-active {
    color: #eaffff;
    background: rgba(37, 233, 255, 0.14);
    border-color: var(--line-strong);
}

.board-panel {
    padding: 14px 16px;
    margin-top: 8px;
}

.panel__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.panel__title {
    font-size: 11px;
    letter-spacing: 0.3em;
    color: var(--cyan-soft);
    font-weight: 600;
}

.panel__meta {
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.2em;
}

.board {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.board th {
    padding: 5px 8px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.22em;
    text-align: left;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
}

.board td {
    padding: 7px 8px;
    border-bottom: 1px solid rgba(37, 233, 255, 0.08);
    vertical-align: middle;
}

.board tr:last-child td {
    border-bottom: none;
}

.board__rank {
    width: 2.6em;
    color: var(--muted);
}

.board__name {
    color: var(--text);
}

.board__check {
    margin-left: 6px;
    color: var(--cyan);
    text-shadow: 0 0 8px var(--cyan);
}

.board__score {
    color: var(--green);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.board__level {
    width: 3.5em;
    color: var(--muted);
    text-align: right;
}

.board__percent {
    width: 4.5em;
    color: var(--green);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.board__empty {
    padding: 20px 8px;
    color: var(--muted);
    text-align: center;
}

.howto {
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.howto__title {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.3em;
    font-weight: 400;
}

.howto__list {
    display: grid;
    gap: 6px;
    padding-left: 18px;
    color: #9dc8d6;
    font-size: 12px;
    line-height: 1.6;
}

.howto__list strong {
    color: var(--cyan-soft);
    font-weight: 600;
}

/* --- play --------------------------------------------------------------- */

.hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    background: var(--panel);
}

.hud__stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 64px;
}

.hud__label {
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.22em;
}

.hud__stat strong {
    color: var(--cyan-soft);
    font-size: 18px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.hud__stat--wide {
    flex: 1 1 220px;
    min-width: 150px;
}

.hud__stat--wide .hud__label {
    color: var(--text);
}

.hud__small {
    color: var(--muted);
    font-size: 10px;
}

.hud__of {
    margin: 0 2px;
    color: var(--muted);
}

.meter {
    height: 6px;
    margin-top: 4px;
    background: rgba(37, 233, 255, 0.10);
    border: 1px solid var(--line);
    overflow: hidden;
}

#hud-clear-bar {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--green));
    box-shadow: 0 0 12px var(--cyan);
    transition: width 0.18s ease;
}

.lives {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 22px;
    font-size: 12px;
    color: var(--muted);
}

.life {
    display: inline-block;
    width: 12px;
    height: 12px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--green);
}

.hud__actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 220px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #03050a;
}

#gridbreak-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

/*
 * The pointer is the weapon: a double-bladed sabre - a hilt in the middle with
 * a glowing blade out of each end - laid across for a horizontal shot and stood
 * upright for a vertical one. There is deliberately no dot in the middle; the
 * hilt's centre is the hotspot, so the line splits exactly where the blades
 * point. The fallback keeps the direction even where an SVG cursor will not load.
 */
#gridbreak-canvas.axis-h {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30'%3E%3Cg%3E%3Cpath d='M10.6 12.7C6.4 13 2.8 14 0.7 15c2.1 1 5.7 2 9.9 2.3z' fill='%2325e9ff' fill-opacity='0.22'/%3E%3Cpath d='M19.4 12.7C23.6 13 27.2 14 29.3 15c-2.1 1-5.7 2-9.9 2.3z' fill='%2325e9ff' fill-opacity='0.22'/%3E%3Cpath d='M10.4 13.9C6.6 14.1 3.4 14.6 1.4 15 3.4 15.4 6.6 15.9 10.4 16.1z' fill='%23e8feff'/%3E%3Cpath d='M19.6 13.9C23.4 14.1 26.6 14.6 28.6 15 26.6 15.4 23.4 15.9 19.6 16.1z' fill='%23e8feff'/%3E%3Crect x='10.6' y='12.2' width='8.8' height='5.6' rx='1.7' fill='%2313242e' stroke='%2325e9ff' stroke-opacity='0.9' stroke-width='0.9'/%3E%3Crect x='12.2' y='13.4' width='1.1' height='3.2' rx='0.5' fill='%239fe9ff' fill-opacity='0.75'/%3E%3Crect x='14.45' y='13.4' width='1.1' height='3.2' rx='0.5' fill='%239fe9ff' fill-opacity='0.75'/%3E%3Crect x='16.7' y='13.4' width='1.1' height='3.2' rx='0.5' fill='%239fe9ff' fill-opacity='0.75'/%3E%3C/g%3E%3C/svg%3E") 15 15, ew-resize;
}

#gridbreak-canvas.axis-v {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30'%3E%3Cg transform='rotate(90 15 15)'%3E%3Cpath d='M10.6 12.7C6.4 13 2.8 14 0.7 15c2.1 1 5.7 2 9.9 2.3z' fill='%2325e9ff' fill-opacity='0.22'/%3E%3Cpath d='M19.4 12.7C23.6 13 27.2 14 29.3 15c-2.1 1-5.7 2-9.9 2.3z' fill='%2325e9ff' fill-opacity='0.22'/%3E%3Cpath d='M10.4 13.9C6.6 14.1 3.4 14.6 1.4 15 3.4 15.4 6.6 15.9 10.4 16.1z' fill='%23e8feff'/%3E%3Cpath d='M19.6 13.9C23.4 14.1 26.6 14.6 28.6 15 26.6 15.4 23.4 15.9 19.6 16.1z' fill='%23e8feff'/%3E%3Crect x='10.6' y='12.2' width='8.8' height='5.6' rx='1.7' fill='%2313242e' stroke='%2325e9ff' stroke-opacity='0.9' stroke-width='0.9'/%3E%3Crect x='12.2' y='13.4' width='1.1' height='3.2' rx='0.5' fill='%239fe9ff' fill-opacity='0.75'/%3E%3Crect x='14.45' y='13.4' width='1.1' height='3.2' rx='0.5' fill='%239fe9ff' fill-opacity='0.75'/%3E%3Crect x='16.7' y='13.4' width='1.1' height='3.2' rx='0.5' fill='%239fe9ff' fill-opacity='0.75'/%3E%3C/g%3E%3C/svg%3E") 15 15, ns-resize;
}

.banner {
    position: absolute;
    top: 13%;
    left: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 22px;
    text-align: center;
    background: rgba(4, 6, 12, 0.84);
    border: 1px solid var(--line-strong);
    box-shadow: 0 0 30px rgba(37, 233, 255, 0.25);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.banner.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.banner strong {
    color: var(--cyan-soft);
    font-size: clamp(16px, 3vw, 26px);
    letter-spacing: 0.24em;
    text-shadow: 0 0 18px var(--cyan);
}

.banner span {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.pause {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(3, 5, 10, 0.78);
    backdrop-filter: blur(2px);
}

.pause.is-visible {
    display: grid;
}

.pause__panel {
    display: grid;
    gap: 12px;
    max-width: 340px;
    padding: 24px;
    text-align: center;
}

.pause__title {
    color: var(--cyan-soft);
    letter-spacing: 0.3em;
}

/* --- game over ---------------------------------------------------------- */

.over {
    display: grid;
    gap: 16px;
    max-width: 720px;
    margin: 0 auto;
    padding: clamp(18px, 4vw, 34px);
}

.over__title {
    margin: 0;
    color: var(--magenta);
    font-size: clamp(28px, 6vw, 52px);
    letter-spacing: 0.16em;
    text-shadow: 0 0 24px rgba(255, 45, 149, 0.5);
}

.over__title.is-win {
    color: var(--green);
    text-shadow: 0 0 24px rgba(57, 255, 138, 0.5);
}

.over__summary {
    color: #9dc8d6;
    font-size: 12px;
    line-height: 1.7;
}

.score-form {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 12px;
}

.score-form .field {
    grid-column: 1;
}

.score-form .button {
    grid-column: 2;
}

.score-form .note {
    grid-column: 1 / -1;
    min-height: 1.3em;
    margin: 0;
}

.noscript {
    padding: 16px;
    color: var(--magenta);
    text-align: center;
}

/* --- smaller screens ---------------------------------------------------- */

@media (max-width: 760px) {
    .screen--play {
        padding: 6px 6px 8px;
        gap: 6px;
    }

    .hud {
        gap: 6px 12px;
        padding: 6px 8px;
    }

    .hud__stat {
        min-width: 52px;
    }

    .hud__stat strong {
        font-size: 15px;
    }

    .hud__stat--wide {
        flex-basis: 150px;
    }

    .hud__stat--name {
        display: none;
    }

    .hud__actions {
        gap: 4px;
    }

    .button--small {
        padding: 5px 7px;
        font-size: 9px;
    }
}

@media (max-width: 560px) {
    .title {
        letter-spacing: 0.03em;
    }

    .score-form {
        grid-template-columns: 1fr;
    }

    .score-form .field,
    .score-form .button,
    .score-form .note {
        grid-column: 1;
    }

    .score-form .button {
        width: 100%;
    }

    .board {
        font-size: 12px;
    }

    .board th,
    .board td {
        padding: 6px 5px;
    }

    .board__level {
        width: 2.6em;
    }

    .pause__panel {
        padding: 18px;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .screen--play {
        padding: 4px 4px 6px;
    }

    .hud {
        padding: 4px 6px;
        gap: 4px 10px;
    }

    .hud__stat strong {
        font-size: 13px;
    }

    .hud__label,
    .hud__small {
        font-size: 8px;
    }

    .meter {
        height: 4px;
    }

    .life {
        width: 9px;
        height: 9px;
    }

    .stage {
        min-height: 0;
    }
}
