/* Tank 2026 - the battlefield page. The kit draws the cards, claim form and leaderboards (kit.css,
   "verified leaderboards"); this file is the stage: a square canvas with a heads-up display, the
   panels over it, the touch pad (arrows left, trigger right) under it - beside it on a phone held
   sideways - and the side column. Sizes only from the kit scale. */

.tk { max-width: 1180px; margin: 0 auto; padding: 16px var(--gutter) 24px; display: grid; gap: 16px; }
.tk__stage {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
    border-radius: 18px;
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.tk__stage[aria-busy="true"] { min-height: 420px; background: linear-gradient(110deg, var(--surface-2) 35%, var(--surface) 50%, var(--surface-2) 65%) 0 0 / 300% 100%; animation: skeleton 1.4s ease-in-out infinite; }
.tk__hud { display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px; padding-right: 52px; }
.hud-chip { display: inline-flex; flex-direction: column; min-width: 64px; padding: 4px 10px; border-radius: 10px; background: var(--surface-2); color: var(--ink); line-height: 1.25; }
.hud-chip__label { font-size: var(--fs-xs); color: var(--ink-2); white-space: nowrap; }
.hud-chip strong { font-size: var(--fs-m); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-chip strong[data-hud="lives"] { color: var(--gold-ink); }
.tk__pause { position: absolute; right: 10px; top: 10px; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); cursor: pointer; }
.tk__pause:hover { background: var(--surface-2); }
/* the field is square and fits the screen height on desktops */
.tk__field { position: relative; width: min(100%, calc(100svh - var(--header-h) - 140px), 620px); aspect-ratio: 1; margin: 0 auto; border-radius: 12px; overflow: hidden; background: #0d0f0a; box-shadow: inset 0 0 0 2px #070806; }
.tk__canvas { display: block; width: 100%; height: 100%; }

/* cards over the field */
.tk__panel { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 16px; overflow-y: auto; overscroll-behavior: contain; border-radius: 18px; background: rgb(13 15 10 / .45); touch-action: pan-y; }
.end-badge[data-reason="base"], .end-badge[data-reason="lives"] { background: rgb(155 50 38 / .12); color: var(--accent); }
.end-badge[data-reason="timeout"] { background: rgb(201 165 90 / .22); color: var(--gold-ink); }

/* the touch pad: on coarse pointers only - four arrows on the left (slide a thumb across them), the trigger on the right */
.pad {
    display: none;
    grid-template-columns: auto minmax(0, 1fr) minmax(112px, 150px);
    align-items: stretch;
    gap: 8px;
    width: min(100%, 620px);
    margin: 0 auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.pad__dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 5px; grid-column: 1; touch-action: none; }
.pad__btn { display: grid; place-items: center; min-width: 56px; min-height: 56px; padding: 0; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); cursor: pointer; touch-action: none; }
.pad__btn .icon { width: 24px; height: 24px; }
.pad__btn--left { grid-column: 1; grid-row: 1 / span 2; }
.pad__btn--up { grid-column: 2; grid-row: 1; }
.pad__btn--down { grid-column: 2; grid-row: 2; }
.pad__btn--right { grid-column: 3; grid-row: 1 / span 2; }
.pad__btn.is-down { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--gold); }
.pad__fire { grid-column: 3; min-width: 112px; min-height: 117px; padding: 0; border: 0; border-radius: 28px; background: var(--primary-bg); color: var(--primary-ink); box-shadow: var(--shadow-1); font-size: var(--fs-l); font-weight: 600; cursor: pointer; touch-action: none; }
.pad__fire.is-down { box-shadow: inset 0 0 0 3px var(--gold); transform: translateY(1px); }
@media (pointer: coarse) {
    .tk[data-phase="play"] .pad, .tk[data-phase="countdown"] .pad, .tk[data-phase="pause"] .pad { display: grid; }
    /* the pad is under the field: leave room for it */
    .tk__field { width: min(100%, calc(100svh - var(--header-h) - 290px), 620px); }
}

/* beside the field */
.tk__side { display: grid; gap: 16px; align-content: start; }

@media (min-width: 1024px) {
    .tk { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; padding-top: 24px; }
    .pad { grid-column: 1; }
    .tk__side { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: calc(var(--header-h) + 24px); }
}

/* phones: the field as wide as the screen; the pad right under it, on screen while playing */
@media (max-width: 639px) {
    .tk { padding: 0 0 16px; gap: 6px; }
    /* room for the menu / result cards over the field */
    .tk__stage { min-height: min(560px, calc(100svh - var(--header-h) - 24px)); padding: 8px; border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--line); }
    .tk[data-phase="play"] .tk__stage, .tk[data-phase="countdown"] .tk__stage, .tk[data-phase="pause"] .tk__stage { min-height: 0; }
    .tk__field, .tk[data-phase] .tk__field { width: min(100%, calc(100svh - var(--header-h) - 196px)); border-radius: 8px; }
    .tk__hud { gap: 4px; }
    .hud-chip { min-width: 0; padding: 3px 8px; }
    .tk__pause { right: 8px; top: 8px; }
    .tk__panel { padding: 12px; place-items: start center; border-radius: 0; }
    .panel-card { padding: 18px 16px; }
    .end-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 10px 0; }
    .end-stats div { padding: 4px 6px; }
    .end-stats dt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .end-stats dd { font-size: var(--fs-s); }
    .tk__side { padding: 10px var(--gutter) 0; }
    /* the pad lines up with the field (8 px from the screen edges): it fits a 320 px screen */
    .pad { width: calc(100% - 16px); gap: 6px; margin-bottom: 4px; }
}

/* phones on their side: the field fits the height, the arrows left of it and the trigger right */
@media (orientation: landscape) and (max-height: 500px) {
    .tk { padding-top: 4px; }
    .tk__stage, .tk[data-phase] .tk__stage { min-height: 0; padding: 6px; gap: 6px; }
    .tk__pause { top: 6px; right: 6px; }
    .tk__field, .tk[data-phase] .tk__field { width: min(100%, calc(100svh - var(--header-h) - 70px)); }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
    /* the notch of a phone on its side: keep the arrows and the trigger clear of it */
    .tk { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 10px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
    .tk__stage { grid-column: 2; grid-row: 1; }
    .tk[data-phase="play"] .pad, .tk[data-phase="countdown"] .pad, .tk[data-phase="pause"] .pad { display: contents; }
    .pad__dpad { grid-column: 1; grid-row: 1; }
    .pad__fire { grid-column: 3; grid-row: 1; width: 96px; min-width: 96px; min-height: 112px; }
    .tk__side { grid-column: 1 / -1; grid-row: 2; padding: 0; }
}
