/*
 * Star Trek: Away Team - the chrome around the canvas.
 *
 * The canvas is the game and fills the window; everything else is a thin LCARS
 * layer over it - a bar across the top, a dossier at the foot of the map, the
 * touch pad at the bottom, and three panels that slide over the lot. Colours are
 * amber for the player's things and periwinkle for the systems.
 */

:root {
    --ink: #05060b;
    --panel: #14111b;
    --panel-2: #1b1726;
    --line: #2b2438;
    --text: #f4e9dc;
    --dim: #a2948a;
    --amber: #ff9f45;
    --amber-dim: #b86a2c;
    --ice: #9fe8ff;
    --peri: #8f9bff;
    --alert: #ff5a52;
    --gold: #f2b53a;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--ink);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overscroll-behavior: none;
}

.app {
    position: fixed;
    /* The site bar holds the top of the window; the canvas and the layer over it
       start below it, so the top of a level is never behind the bar.
       `--jn-nav-height` comes from navbar.css's :root, 44px as a fallback. */
    inset: var(--jn-nav-height, 44px) 0 0 0;
    overflow: hidden;
    background: var(--ink);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#stage {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.screen {
    position: absolute;
    inset: 0;
    display: none;
    pointer-events: none;
}

.app[data-screen="title"] .screen--title {
    display: flex;
    pointer-events: auto;
}

.app[data-screen="map"] .screen--map {
    display: block;
}

.app[data-screen="play"] .screen--play {
    display: block;
}

/* ---------------------------------------------------------------------- title */

.screen--title {
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 32px 20px;
    background:
        radial-gradient(900px 520px at 78% 14%, rgba(143, 155, 255, 0.18), transparent 62%),
        radial-gradient(760px 420px at 12% 88%, rgba(255, 159, 69, 0.12), transparent 60%),
        linear-gradient(160deg, #04050c 0%, #0a0a1a 52%, #1a1424 100%);
}

.title__inner {
    width: min(640px, 100%);
    padding: 30px 28px;
    border: 1px solid var(--line);
    border-left: 6px solid var(--amber);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(20, 17, 27, 0.92), rgba(12, 11, 18, 0.94));
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.title__kicker {
    margin: 0 0 10px;
    color: var(--amber);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.title__name {
    margin: 0;
    font-size: clamp(2rem, 7vw, 3.2rem);
    line-height: 1;
    letter-spacing: -0.02em;
}

.title__name span {
    color: #cbb9a6;
    font-weight: 400;
}

.title__tag {
    margin: 8px 0 16px;
    color: var(--ice);
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.title__lede {
    margin: 0 0 20px;
    color: var(--dim);
    font-size: 0.95rem;
    max-width: 46ch;
}

.title__modes,
.menu__modes {
    display: flex;
    gap: 8px;
    margin: 0 0 16px;
}

.title__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 22px;
}

.title__keys {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 6px 18px;
    margin: 0;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--dim);
    font-size: 0.8rem;
}

.title__keys div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.title__keys dt {
    margin: 0;
}

.title__keys dd {
    margin: 0;
    color: var(--text);
}

kbd {
    display: inline-block;
    min-width: 1.5em;
    padding: 1px 5px;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: #0d0c14;
    color: var(--text);
    font: inherit;
    font-size: 0.78em;
    text-align: center;
}

/* ------------------------------------------------------------------------ bar */

.bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
    background: linear-gradient(180deg, rgba(5, 6, 11, 0.92), rgba(5, 6, 11, 0.55) 70%, transparent);
    pointer-events: auto;
}

.bar__title {
    margin: 0;
    color: var(--amber);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 34vw;
}

.bar__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    margin: 0;
    font-size: 0.72rem;
}

.bar__stats div {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.bar__stats dt {
    margin: 0;
    color: var(--dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.62rem;
}

.bar__stats dd {
    margin: 0;
    color: var(--text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.bar__actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

/* --------------------------------------------------------------------- dossier */

.dossier {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px max(16px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-right));
    background: linear-gradient(0deg, rgba(5, 6, 11, 0.94), rgba(5, 6, 11, 0.6) 70%, transparent);
    pointer-events: auto;
}

.dossier__hint {
    margin: 0;
    flex: 1;
    min-width: 0;
    color: var(--text);
    font-size: 0.86rem;
}

.dossier__actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

/* ------------------------------------------------------------------- touch pad */

.pad {
    position: absolute;
    left: 0;
    right: 0;
    bottom: max(10px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 14px;
    pointer-events: none;
}

.pad__side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
}

.pad__side--right {
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
}

.pad__row {
    display: flex;
    gap: 30px;
}

.key {
    min-width: 54px;
    height: 54px;
    padding: 0 14px;
    border: 1px solid rgba(159, 232, 255, 0.28);
    border-radius: 14px;
    background: rgba(12, 16, 28, 0.62);
    color: var(--ice);
    font: inherit;
    font-weight: 700;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

.key.is-down,
.key:active {
    background: rgba(159, 232, 255, 0.24);
    border-color: var(--ice);
}

.key--jump {
    background: rgba(255, 159, 69, 0.16);
    border-color: rgba(255, 159, 69, 0.5);
    color: var(--amber);
}

.key--fire {
    color: var(--peri);
    border-color: rgba(143, 155, 255, 0.4);
}

/* A keyboard and a mouse do not need a pad under the picture. */
@media (hover: hover) and (pointer: fine) {
    .pad {
        display: none;
    }
}

/* --------------------------------------------------------------------- buttons */

.button {
    padding: 10px 18px;
    border: 1px solid var(--amber);
    border-radius: 999px;
    background: var(--amber);
    color: #170d05;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
}

.button:hover {
    filter: brightness(1.08);
}

.button:disabled {
    cursor: default;
    opacity: 0.45;
    filter: none;
}

.button--ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}

.button--ghost:hover {
    border-color: var(--dim);
}

.chip {
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--dim);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.chip.is-on {
    border-color: var(--ice);
    background: rgba(159, 232, 255, 0.12);
    color: var(--ice);
}

.tool {
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(12, 11, 18, 0.7);
    color: var(--text);
    font: inherit;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}

.tool:hover {
    border-color: var(--amber);
    color: var(--amber);
}


/* -------------------------------------------------------------------- overlays */

.overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(3, 4, 9, 0.74);
    backdrop-filter: blur(3px);
}

.padd__sheet {
    width: min(680px, 100%);
    max-height: min(88vh, 760px);
    overflow-y: auto;
    padding: 20px;
    border: 1px solid var(--line);
    border-left: 6px solid var(--amber);
    border-radius: 16px;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.65);
}

.padd__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.padd__title {
    margin: 0;
    color: var(--amber);
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.padd__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px 18px;
    margin: 0 0 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(5, 6, 11, 0.45);
}

.padd__grid div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.padd__grid dt {
    margin: 0;
    color: var(--dim);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.padd__grid dd {
    margin: 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.padd__label {
    margin: 0 0 6px;
    color: var(--peri);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.padd__list {
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
    font-size: 0.86rem;
}

.padd__list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(43, 36, 56, 0.7);
    color: var(--dim);
}

.padd__list li b {
    color: var(--text);
    font-weight: 600;
    text-align: right;
}

.padd__list li.is-on b {
    color: var(--ice);
}

.padd__foot {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.photon {
    margin-top: 16px;
}

#photon {
    display: block;
    width: 100%;
    height: min(46vh, 300px);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #050912;
    touch-action: none;
}

.photon__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    color: var(--dim);
    font-size: 0.8rem;
}

.photon__foot p {
    margin: 0;
}

.menu__sheet {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(340px, 100%);
    padding: 22px;
    border: 1px solid var(--line);
    border-left: 6px solid var(--peri);
    border-radius: 16px;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.65);
}

.menu__title {
    margin: 0 0 8px;
    color: var(--peri);
    font-size: 0.8rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.menu__label {
    margin: 12px 0 0;
    color: var(--dim);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* ----------------------------------------------------------------- controls */

.controls__sheet {
    width: min(560px, 100%);
    max-height: min(88vh, 760px);
    overflow-y: auto;
    padding: 20px;
    border: 1px solid var(--line);
    border-left: 6px solid var(--ice);
    border-radius: 16px;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.65);
}

.controls__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.controls__title {
    margin: 0;
    color: var(--ice);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.controls__hint {
    margin: 0 0 14px;
    color: var(--dim);
    font-size: 0.82rem;
    line-height: 1.45;
}

.controls__list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.controls__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(9, 10, 17, 0.55);
}

.controls__action {
    color: var(--text);
    font-size: 0.9rem;
}

.controls__keys {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bind {
    min-width: 54px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(12, 11, 18, 0.8);
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.bind:hover {
    border-color: var(--ice);
    color: var(--ice);
}

.bind.is-listening {
    border-color: var(--amber);
    background: rgba(242, 176, 92, 0.16);
    color: var(--amber);
}

.controls__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
}

.controls__note {
    margin: 0;
    color: var(--dim);
    font-size: 0.76rem;
}

/* --------------------------------------------------------------- banner, toast */

.banner {
    position: absolute;
    z-index: 20;
    top: 14%;
    left: 50%;
    transform: translateX(-50%);
    width: min(460px, calc(100% - 32px));
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-top: 4px solid var(--ice);
    border-radius: 14px;
    background: rgba(10, 10, 18, 0.94);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    text-align: center;
    pointer-events: auto;
}

.banner__title {
    margin: 0 0 6px;
    color: var(--ice);
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.banner__line {
    margin: 0;
    color: var(--text);
    font-size: 0.92rem;
}

.banner .button {
    margin-top: 12px;
}

.toast {
    position: absolute;
    z-index: 22;
    left: 50%;
    bottom: 18%;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    margin: 0;
    padding: 9px 16px;
    border: 1px solid rgba(255, 159, 69, 0.5);
    border-radius: 999px;
    background: rgba(10, 10, 18, 0.92);
    color: var(--amber);
    font-size: 0.84rem;
    text-align: center;
}

@media (max-width: 560px) {
    .bar {
        gap: 10px;
        padding-top: max(8px, env(safe-area-inset-top));
    }

    /* On a phone the play bar is two rows: where you are, and how you are doing. */
    .bar--play {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            'title actions'
            'stats stats';
        row-gap: 2px;
    }

    .bar--play .bar__title {
        grid-area: title;
        max-width: none;
        font-size: 0.82rem;
    }

    .bar--play .bar__actions {
        grid-area: actions;
        margin-left: 0;
    }

    .bar--play .bar__stats {
        grid-area: stats;
        gap: 0 12px;
    }

    .bar__title {
        max-width: 40vw;
        font-size: 0.82rem;
    }

    .bar__stats {
        gap: 2px 10px;
        font-size: 0.66rem;
    }

    .bar__stats div:nth-child(n + 3) {
        display: none;
    }

    .banner {
        top: 12%;
        padding: 12px 14px;
    }

    .banner__line {
        font-size: 0.84rem;
    }

    .title__inner {
        padding: 22px 18px;
    }

    .title__keys {
        display: none;
    }

    .dossier {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .dossier__actions .button {
        flex: 1;
    }
}

