/* Snake - the field 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 arrows under it and the side column. Sizes only from the kit scale. */

.snk { max-width: 1180px; margin: 0 auto; padding: 16px var(--gutter) 24px; display: grid; gap: 16px; }
.snk__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;
}
.snk__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; }
.snk__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; }
.snk__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; }
.snk__pause:hover { background: var(--surface-2); }
/* the field keeps the engine's 20 × 20 proportions and fits the screen height on desktops */
.snk__field { position: relative; width: min(100%, calc(100svh - var(--header-h) - 150px), 640px); aspect-ratio: 1; margin: 0 auto; border-radius: 12px; overflow: hidden; background: #1b2a22; box-shadow: inset 0 0 0 2px #0f1a15; }
.snk__canvas { display: block; width: 100%; height: 100%; }
.snk[data-phase="play"] .snk__field { cursor: none; }

/* cards over the field */
.snk__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(27 42 34 / .35); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); touch-action: pan-y; }
.end-badge[data-reason="full"] { background: rgb(201 165 90 / .22); color: var(--gold-ink); }
.end-badge[data-reason="crash"] { background: rgb(155 50 38 / .12); color: var(--accent); }

/* touch arrows: on coarse pointers only */
.dpad { display: none; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 56px); gap: 6px; justify-content: center; margin: -4px auto 0; }
.dpad__btn { display: grid; place-items: center; min-width: 44px; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); cursor: pointer; touch-action: manipulation; }
.dpad__btn:active { background: var(--surface-2); transform: translateY(1px); }
.dpad__btn--up { grid-column: 2; grid-row: 1; }
.dpad__btn--left { grid-column: 1; grid-row: 2; }
.dpad__btn--right { grid-column: 3; grid-row: 2; }
.dpad__btn--down { grid-column: 2; grid-row: 2; }
@media (pointer: coarse) {
    .snk[data-phase="play"] .dpad, .snk[data-phase="countdown"] .dpad, .snk[data-phase="pause"] .dpad { display: grid; }
}

/* beside the field */
.snk__side { display: grid; gap: 16px; align-content: start; }

@media (min-width: 1024px) {
    .snk { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; padding-top: 24px; }
    .dpad { grid-column: 1; }
    .snk__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; arrows right under it */
@media (max-width: 639px) {
    .snk { padding: 0 0 16px; gap: 10px; }
    /* room for the menu / result cards over the field (the field itself stays square at the top) */
    .snk__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); }
    /* while playing the stage is only as tall as the field, so the arrows sit right under it, on screen */
    .snk[data-phase="play"] .snk__stage, .snk[data-phase="countdown"] .snk__stage, .snk[data-phase="pause"] .snk__stage { min-height: 0; }
    .snk__field { width: min(100%, calc(100svh - var(--header-h) - 216px)); border-radius: 8px; }
    .snk__hud { gap: 4px; }
    .hud-chip { min-width: 0; padding: 3px 8px; }
    .snk__pause { right: 8px; top: 8px; }
    .snk__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); }
    .snk__side { padding: 0 var(--gutter); }
    .dpad { grid-template-columns: repeat(3, 72px); grid-template-rows: repeat(2, 60px); }
}

/* phones on their side: the field fits the height, the arrows beside it */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
    .snk { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding-top: 8px; }
    .snk__stage { grid-column: 1; grid-row: 1; min-height: 0; }
    .snk__field { width: min(100%, calc(100svh - var(--header-h) - 84px)); }
    .snk .dpad { grid-column: 2; grid-row: 1; margin: 0; }
    .snk__side { grid-column: 1 / -1; }
}
