/*
 * Scorched Earth.
 *
 * The page has exactly one fixed thing: the site bar above it. Everything below
 * that is a stage filling the rest of the viewport, and the battlefield is a
 * canvas painted edge to edge inside it, so the game is full-screen without ever
 * covering the site navigation.
 */

:root {
    --bg: #0a0812;
    --ink: #f4f1fb;
    --muted: #a9a2c2;
    --line: rgba(255, 255, 255, 0.1);
    --panel: rgba(14, 11, 24, 0.66);
    --panel-solid: #15111f;
    --accent: #ff9f6e;
    --radius: 16px;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

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

body {
    background: var(--bg);
    color: var(--ink);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

button {
    font: inherit;
    color: inherit;
}

.app {
    display: flex;
    flex-direction: column;
    /* The site bar holds the top of the window; the stage takes what is left, so
       the battlefield never sits under it. `--jn-nav-height` comes from
       navbar.css's :root; 44px is the bar's own height as a fallback. */
    height: calc(100dvh - var(--jn-nav-height, 44px));
}

/* ---------- play-screen tools ---------- */

/* Sound and the way back to the menu: the two controls the page header used to
   carry. They hang under the wind pill on the battlefield's right edge. */
.playtools {
    display: flex;
    gap: 8px;
    position: absolute;
    right: clamp(10px, 2vw, 20px);
    top: calc(clamp(10px, 2vw, 18px) + 46px);
    z-index: 4;
}

.playtools .iconbtn {
    backdrop-filter: blur(10px);
    background: var(--panel);
}

.iconbtn {
    align-items: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    font-size: 13px;
    height: 34px;
    justify-content: center;
    min-width: 38px;
    padding: 0 10px;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.iconbtn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.24);
}

.iconbtn[aria-pressed="false"] {
    color: var(--muted);
}

/* ---------- stage and screens ---------- */

.stage {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
}

.screen {
    align-items: center;
    display: flex;
    inset: 0;
    justify-content: center;
    overflow-y: auto;
    padding: clamp(20px, 5vw, 60px);
    position: absolute;
}

.screen[hidden] {
    display: none;
}

.screen--play {
    display: block;
    overflow: hidden;
    padding: 0;
}

/* ---------- menu ---------- */

.screen--menu {
    background:
        radial-gradient(1100px 620px at 76% 8%, rgba(255, 159, 110, 0.16), transparent 62%),
        radial-gradient(900px 520px at 12% 90%, rgba(126, 105, 220, 0.2), transparent 60%),
        linear-gradient(180deg, #120c1d, #0a0812);
}

.menu {
    max-width: 640px;
    text-align: left;
    width: 100%;
}

.menu__kicker {
    color: var(--accent);
    font-size: 12px;
    letter-spacing: 0.22em;
    margin: 0 0 10px;
    text-transform: uppercase;
}

.menu__title {
    background: linear-gradient(96deg, #fff4e6, #ffb27a 46%, #c99cf0);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: clamp(38px, 8vw, 68px);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 0.98;
    margin: 0 0 14px;
}

.menu__lede {
    color: var(--muted);
    font-size: clamp(15px, 1.8vw, 17px);
    line-height: 1.55;
    margin: 0 0 26px;
    max-width: 46ch;
}

.menu__levels {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 26px;
}

.level {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 128px;
    padding: 13px 18px;
    text-align: left;
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.level:hover {
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.level--primary {
    background: linear-gradient(140deg, rgba(255, 159, 110, 0.24), rgba(201, 156, 240, 0.18));
    border-color: rgba(255, 159, 110, 0.55);
}

.level__name {
    font-size: 15px;
    font-weight: 650;
}

.level__meta {
    color: var(--muted);
    font-size: 12px;
}

.keys {
    color: var(--muted);
    display: grid;
    font-size: 13px;
    gap: 7px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.keys kbd {
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    display: inline-block;
    font-family: inherit;
    font-size: 11px;
    min-width: 20px;
    padding: 2px 5px;
    text-align: center;
}

/* ---------- battlefield ---------- */

.field {
    display: block;
    height: 100%;
    touch-action: none;
    width: 100%;
}

.screen--play::after {
    background: radial-gradient(120% 90% at 50% 50%, transparent 62%, rgba(3, 2, 8, 0.55));
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
}

.hud {
    align-items: center;
    background: var(--panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: flex;
    font-size: 13px;
    gap: 8px;
    padding: 8px 14px;
    pointer-events: none;
    position: absolute;
    z-index: 3;
}

.hud--turn {
    left: clamp(10px, 2vw, 20px);
    top: clamp(10px, 2vw, 18px);
}

.hud--wind {
    right: clamp(10px, 2vw, 20px);
    top: clamp(10px, 2vw, 18px);
    font-variant-numeric: tabular-nums;
}

.hud--aim {
    bottom: calc(96px + env(safe-area-inset-bottom));
    left: clamp(10px, 2vw, 20px);
    gap: 14px;
    font-variant-numeric: tabular-nums;
}

.hud__windarrow {
    color: var(--accent);
    display: inline-block;
    font-size: 16px;
    line-height: 1;
    transition: transform 0.25s ease;
}

.dot {
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 12px -1px var(--accent);
    height: 9px;
    width: 9px;
}

.hud--turn.is-ai .dot {
    background: #8b8fb7;
    box-shadow: none;
}

/* ---------- weapon dock and fire ---------- */

.controls {
    align-items: flex-end;
    bottom: 0;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    left: 0;
    padding: 0 clamp(10px, 2vw, 20px) calc(10px + env(safe-area-inset-bottom));
    pointer-events: none;
    position: absolute;
    right: 0;
    z-index: 4;
}

.dock {
    display: flex;
    gap: 7px;
    margin: 0 auto;
    overflow-x: auto;
    padding: 4px 2px;
    pointer-events: auto;
    scrollbar-width: none;
}

.dock::-webkit-scrollbar {
    display: none;
}

.wpn {
    --wpn-color: #9fb4c9;
    align-items: center;
    background: var(--panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 3px;
    min-width: 62px;
    padding: 8px 10px;
    transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

.wpn:hover:not([data-empty="true"]) {
    transform: translateY(-2px);
}

.wpn[aria-pressed="true"] {
    border-color: var(--wpn-color);
    box-shadow: inset 0 0 0 1px var(--wpn-color), 0 6px 22px -10px var(--wpn-color);
}

.wpn[data-empty="true"] {
    cursor: not-allowed;
    opacity: 0.36;
}

.wpn__glyph {
    color: var(--wpn-color);
    font-size: 17px;
    line-height: 1;
}

.wpn__name {
    font-size: 10px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.wpn__ammo {
    color: var(--muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

/* ---------- the shield: held to raise, spent while up ---------- */

.shield {
    align-items: center;
    background: var(--panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 18px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 5px;
    height: 74px;
    justify-content: center;
    padding: 0;
    pointer-events: auto;
    touch-action: none;
    transition: border-color 0.14s ease, box-shadow 0.14s ease, opacity 0.2s ease;
    user-select: none;
    width: 74px;
}

.shield:hover:not(:disabled) {
    border-color: rgba(125, 211, 252, 0.55);
}

.shield[aria-pressed="true"] {
    border-color: #7dd3fc;
    box-shadow: inset 0 0 0 1px #7dd3fc, 0 6px 22px -10px #7dd3fc;
}

.shield:disabled {
    cursor: default;
    opacity: 0.34;
}

.shield__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.shield__meter {
    background: rgba(255, 255, 255, 0.13);
    border-radius: 999px;
    height: 5px;
    overflow: hidden;
    width: 44px;
}

.shield__fill {
    background: #7dd3fc;
    border-radius: 999px;
    display: block;
    height: 100%;
    transition: width 0.1s linear;
    width: 100%;
}

.shield__read {
    color: var(--muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.fire {
    background: radial-gradient(circle at 32% 28%, #ffd7b0, #ff7a4d 58%, #d1472a);
    border: 0;
    border-radius: 50%;
    box-shadow: 0 12px 32px -12px #ff7a4d, inset 0 1px 0 rgba(255, 255, 255, 0.5);
    color: #2a0c04;
    cursor: pointer;
    flex: 0 0 auto;
    font-size: 14px;
    font-weight: 800;
    height: 74px;
    letter-spacing: 0.02em;
    pointer-events: auto;
    transition: transform 0.12s ease, filter 0.12s ease;
    width: 74px;
}

.fire:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-2px);
}

.fire:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
}

.fire:disabled {
    cursor: default;
    filter: grayscale(0.6) brightness(0.7);
    opacity: 0.6;
}

/* ---------- online: menu, lobby, clock ---------- */

.menu__divider {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: 11px;
    gap: 12px;
    letter-spacing: 0.2em;
    margin: 0 0 14px;
    text-transform: uppercase;
}

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

.menu__join {
    margin: 0 0 22px;
}

.menu__joinlabel {
    color: var(--muted);
    display: block;
    font-size: 11px;
    letter-spacing: 0.16em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.menu__joinrow {
    display: flex;
    gap: 8px;
}

.menu__joincode {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
    font-family: inherit;
    font-size: 20px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: 0.32em;
    max-width: 160px;
    padding: 10px 4px 10px 16px;
    text-transform: uppercase;
    width: 40%;
}

.menu__joincode:focus-visible {
    border-color: rgba(255, 159, 110, 0.7);
    outline: none;
}

.menu__error {
    color: #ff9d9d;
    font-size: 13px;
    margin: 10px 0 0;
}

.menu__error[hidden] {
    display: none;
}

.level--online {
    align-items: center;
    flex-direction: row;
    gap: 14px;
    justify-content: space-between;
    margin-bottom: 22px;
    width: 100%;
}

.level--online .level__name::after {
    color: var(--accent);
    content: " \25b8";
}

.level--slim {
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: 10px 20px;
}

.level:disabled,
.level[disabled] {
    cursor: default;
    opacity: 0.45;
    transform: none;
}

.screen--lobby {
    background:
        radial-gradient(1000px 560px at 22% 4%, rgba(126, 105, 220, 0.22), transparent 62%),
        linear-gradient(180deg, #120c1d, #0a0812);
}

.lobby {
    max-width: 480px;
    text-align: center;
    width: 100%;
}

.lobby__kicker {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.24em;
    margin: 0 0 6px;
    text-transform: uppercase;
}

.lobby__code {
    font-size: clamp(46px, 12vw, 74px);
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    letter-spacing: 0.16em;
    line-height: 1;
    margin: 0 0 12px;
}

.lobby__lede {
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 22px;
}

.seats {
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
}

.seat {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    padding: 12px 16px;
    text-align: left;
}

.seat[data-you="true"] {
    border-color: rgba(255, 159, 110, 0.5);
}

.seat[data-away="true"] {
    opacity: 0.5;
}

.seat__name {
    font-size: 15px;
    font-weight: 650;
}

.seat__meta {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.04em;
}

.lobby__ai {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 18px;
}

.lobby__ai[hidden] {
    display: none;
}

.lobby__ailabel {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.lobby__aiselect {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    padding: 8px 10px;
}

.lobby__actions {
    flex-wrap: wrap;
}

.hud--clock {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    left: 50%;
    top: clamp(10px, 2vw, 18px);
    transform: translateX(-50%);
}

.hud[hidden] {
    display: none;
}

/* ---------- result ---------- */

.screen--result {
    background:
        radial-gradient(900px 520px at 50% 0%, rgba(255, 159, 110, 0.12), transparent 60%),
        rgba(6, 4, 12, 0.55);
    backdrop-filter: blur(4px);
    z-index: 6;
}

.result {
    background: var(--panel-solid);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 30px 80px -40px #000;
    max-width: 460px;
    padding: clamp(24px, 4vw, 40px);
    text-align: center;
    width: 100%;
}

.result__kicker {
    color: var(--accent);
    font-size: 12px;
    letter-spacing: 0.2em;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.result__title {
    font-size: clamp(30px, 6vw, 44px);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 24px;
}

.result__title.is-loss {
    color: var(--muted);
}

.result__stats {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, 1fr);
    margin: 0 0 26px;
}

.result__stats div {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 8px;
}

.result__stats dt {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.result__stats dd {
    font-size: 22px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    margin: 4px 0 0;
}

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

@media (max-width: 620px) {
    .brand__tag {
        display: none;
    }

    .hud--aim {
        display: none;
    }

    .fire {
        height: 64px;
        width: 64px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
    }
}

