/*
  One stylesheet, no framework. The palette below is the only place colours are named; the
  canvas renderer keeps its own copy of the few it draws with, in js/sprites.js.
*/

:root {
    --bg: #0b0f1a;
    --bg-panel: #141b2b;
    --bg-panel-soft: #1b2334;
    --line: #26314a;
    --text: #e8edf7;
    --text-dim: #97a3bd;
    --accent: #f2c14e;
    --accent-soft: #6b5418;
    --player2: #46b7c4;
    --danger: #e0553f;
    --ok: #58c07a;
    --radius: 4px;
    --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "SF Mono", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background:
        radial-gradient(circle at 50% 0%, #16203a 0%, var(--bg) 60%),
        var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.shell {
    max-width: 1080px;
    margin: 0 auto;
    padding: 16px 20px 24px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    gap: 14px;
}

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

.shell__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.logo {
    margin: 0;
    font-size: 22px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent);
    text-shadow: 2px 2px 0 #7a5a10, 4px 4px 0 rgba(0, 0, 0, .45);
}

.logo span {
    color: var(--player2);
    text-shadow: 2px 2px 0 #124f57, 4px 4px 0 rgba(0, 0, 0, .45);
}

.shell__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chip {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 5px 10px;
    color: var(--text-dim);
    font-size: 13px;
}

.chip b {
    color: var(--accent);
    letter-spacing: 2px;
}

.shell__foot {
    color: var(--text-dim);
    font-size: 12px;
    text-align: center;
    margin-top: auto;
    padding-top: 8px;
}

/* ------------------------------------------------------------------- banner */

.banner {
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    background: var(--bg-panel);
    border-radius: var(--radius);
    padding: 9px 14px;
    font-size: 14px;
}

.banner--error {
    border-left-color: var(--danger);
}

.banner--ok {
    border-left-color: var(--ok);
}

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

.shell__body {
    flex: 1;
}

.screen {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.screen[hidden] {
    display: none;
}

.screen--game {
    grid-template-columns: minmax(0, 1fr) 220px;
    grid-template-areas:
        "hud   players"
        "arena players";
    align-items: start;
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}

.panel--muted {
    background: var(--bg-panel-soft);
}

.panel--center {
    grid-column: 1 / -1;
    max-width: 520px;
    margin: 0 auto;
    text-align: center;
}

.panel__title {
    margin: 0 0 6px;
    font-size: 17px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.panel__title--small {
    font-size: 13px;
    color: var(--accent);
    margin-top: 16px;
}

.panel__title--small:first-child {
    margin-top: 0;
}

.panel__lead {
    margin: 0 0 18px;
    color: var(--text-dim);
    font-size: 14px;
}

.panel__hint {
    color: var(--text-dim);
    font-size: 13px;
    margin: 10px 0 0;
    min-height: 1.4em;
}

.panel__row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-top: 14px;
}

.panel__row--center {
    justify-content: center;
}

.panel__row--join {
    align-items: flex-end;
}

.panel__divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 4px;
    color: var(--text-dim);
    font-size: 12px;
}

.panel__divider::before,
.panel__divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* -------------------------------------------------------------------- forms */

.field {
    display: block;
}

.field--inline {
    flex: 1;
}

.field__label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 5px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.field__input {
    width: 100%;
    background: #0d1421;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    padding: 9px 11px;
}

.field__input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.field__input--code {
    text-transform: uppercase;
    letter-spacing: 6px;
    font-size: 19px;
    text-align: center;
}

.btn {
    background: var(--bg-panel-soft);
    color: var(--text);
    border: 1px solid var(--line);
    border-bottom-width: 3px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    letter-spacing: 1px;
    padding: 9px 16px;
    cursor: pointer;
    text-transform: uppercase;
}

.btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
    border-bottom-width: 2px;
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--accent);
    border-color: #9c7c1c;
    color: #1a1405;
    font-weight: 700;
}

.btn--primary:hover:not(:disabled) {
    background: #ffd76b;
    color: #1a1405;
    border-color: #9c7c1c;
}

.btn--ghost {
    background: transparent;
}

.error {
    color: var(--danger);
    font-size: 13px;
    margin: 12px 0 0;
}

.keys,
.rules {
    margin: 0;
    padding-left: 18px;
    color: var(--text-dim);
    font-size: 13px;
}

.keys {
    list-style: none;
    padding-left: 0;
}

.keys li {
    margin-bottom: 6px;
}

.rules li {
    margin-bottom: 4px;
}

kbd {
    display: inline-block;
    background: #0d1421;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 3px;
    padding: 1px 6px;
    font-family: inherit;
    font-size: 12px;
    color: var(--text);
    margin-right: 2px;
}

/* -------------------------------------------------------------------- lobby */

.code-display {
    font-size: 46px;
    letter-spacing: 14px;
    text-indent: 14px;
    color: var(--accent);
    margin: 10px 0 4px;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, .5);
}

.players {
    list-style: none;
    margin: 18px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.players--side {
    grid-area: players;
    margin: 0;
}

.player {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-panel-soft);
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 8px 11px;
    text-align: left;
}

.player--slot1 {
    border-left-color: var(--player2);
}

.player--empty {
    border-left-color: var(--line);
    color: var(--text-dim);
    font-style: italic;
}

.player--offline {
    opacity: .55;
}

.player__name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player__tag {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.player__stat {
    font-size: 13px;
    color: var(--text-dim);
    white-space: nowrap;
}

.player__stat b {
    color: var(--text);
}

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

.hud {
    grid-area: hud;
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.hud__cell {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px 12px;
    min-width: 84px;
}

.hud__cell--wide {
    flex: 1;
}

.hud__label {
    display: block;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
}

.hud__value {
    font-size: 19px;
    color: var(--accent);
}

.arena {
    grid-area: arena;
    position: relative;
    background: #070a12;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/*
  The size is set in pixels by js/main.js, to an exact whole multiple of the 208-unit arena.
  A fractional scale makes some pixels a row taller than their neighbours, which on art this
  chunky is the difference between deliberate and broken. These rules are the fallback for the
  moment before the first measurement.
*/
#arena-canvas {
    display: block;
    width: min(60vh, 100%);
    height: auto;
    aspect-ratio: 1 / 1;
    image-rendering: pixelated;
    background: #0a1020;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 10, 18, .82);
    border-radius: var(--radius);
}

.overlay[hidden] {
    display: none;
}

.overlay__box {
    text-align: center;
    padding: 22px 26px;
    border: 1px solid var(--line);
    background: var(--bg-panel);
    border-radius: var(--radius);
    max-width: 90%;
}

.overlay__title {
    margin: 0 0 8px;
    font-size: 24px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent);
}

.overlay__title--lost {
    color: var(--danger);
}

.overlay__text {
    margin: 0 0 16px;
    color: var(--text-dim);
    font-size: 14px;
}

.overlay__actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 860px) {
    .screen,
    .screen--game {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "hud"
            "arena"
            "players";
    }

    .players--side {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .players--side .player {
        flex: 1 1 160px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn:active:not(:disabled) {
        transform: none;
    }
}
