/* Circus Dash - the ring page. The kit draws the cards, claim form and leaderboards (kit.css,
   "verified leaderboards"); this file is the stage: a "screen" (the heads-up display over a 16:10
   canvas), the panels over it, the jump pad under it on touch screens and the side column. Sizes
   only from the kit scale; the field's own palette lives in render.js. */

.cd { max-width: 1180px; margin: 0 auto; padding: 16px var(--gutter) 24px; display: grid; gap: 16px; }
.cd__stage {
    position: relative;
    display: grid;
    padding: 10px;
    border-radius: 18px;
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.cd__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; }
/* the screen keeps the engine's 256 x 160 view and fits the screen height on desktops */
.cd__screen { position: relative; display: grid; gap: 8px; align-content: start; width: min(100%, calc((100svh - var(--header-h) - 150px) * 1.6), 960px); margin: 0 auto; }
.cd__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(--accent); letter-spacing: .1em; }
.cd__pause { position: absolute; z-index: 1; 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; }
.cd__pause:hover { background: var(--surface-2); }
.cd__field { position: relative; width: 100%; aspect-ratio: 256 / 160; border-radius: 12px; overflow: hidden; background: #241019; box-shadow: inset 0 0 0 2px #14070d; touch-action: none; }
.cd__canvas { display: block; width: 100%; height: 100%; }
.cd[data-phase="play"] .cd__field { cursor: pointer; }
.cd__field.is-shaking { animation: cd-shake .32s linear; }
@keyframes cd-shake {
    20% { transform: translate(-3px, 2px); }
    40% { transform: translate(3px, -2px); }
    60% { transform: translate(-2px, -1px); }
    80% { transform: translate(2px, 1px); }
}

/* cards over the field */
.cd__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(36 16 25 / .45); touch-action: pan-y; }
.end-badge[data-reason="fall"] { 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 jump pad: touch screens only, while a run is on - one big button under the field */
.pad { display: none; width: min(100%, 960px); margin: -4px auto 0; }
.pad__jump {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
    width: 100%;
    min-height: 64px;
    padding: 8px 18px;
    border: 0;
    border-radius: 16px;
    background: var(--primary-bg);
    color: var(--primary-ink);
    box-shadow: var(--shadow-1);
    font: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.pad__jump .icon { grid-row: 1 / span 2; width: 28px; height: 28px; }
.pad__label { font-size: var(--fs-m); font-weight: 600; line-height: 1.25; }
.pad__hint { font-size: var(--fs-xs); line-height: 1.3; opacity: .85; }
.pad__jump.is-down { transform: translateY(2px); box-shadow: none; }
@media (pointer: coarse) {
    .cd[data-phase="play"] .pad, .cd[data-phase="countdown"] .pad, .cd[data-phase="pause"] .pad { display: block; }
}

/* beside the field */
.cd__side { display: grid; gap: 16px; align-content: start; }

@media (min-width: 1024px) {
    .cd { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; padding-top: 24px; }
    .pad { grid-column: 1; }
    .cd__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 jump pad right under it, all on screen while playing */
@media (max-width: 639px) {
    .cd { padding: 0 0 16px; gap: 10px; }
    /* room for the menu / result cards over the field */
    .cd__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); }
    .cd[data-phase="play"] .cd__stage, .cd[data-phase="countdown"] .cd__stage, .cd[data-phase="pause"] .cd__stage { min-height: 0; }
    .cd__screen { width: 100%; }
    .cd__field { border-radius: 8px; }
    .cd__hud { gap: 4px; }
    .hud-chip { min-width: 0; padding: 3px 8px; }
    .cd__pause { right: 8px; top: 8px; }
    .cd__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); }
    .cd__side { padding: 0 var(--gutter); }
    .pad { width: calc(100% - 2 * var(--gutter)); }
    .pad__jump { min-height: 72px; }
}
/* the smallest phones keep the heads-up display on one row: the round shows in the act banner */
@media (max-width: 359px) {
    .hud-chip--loop { display: none; }
}

/* phones on their side: the field fits the height (the heads-up display floats over its top
   corner, where only the tent is), the jump pad beside it */
@media (orientation: landscape) and (max-height: 500px) {
    .cd { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding-top: 8px; }
    .cd__stage { grid-column: 1; grid-row: 1; min-height: 0; padding: 6px; }
    .cd__screen { width: min(100%, calc((100svh - var(--header-h) - 28px) * 1.6)); }
    .cd__hud { position: absolute; z-index: 1; top: 6px; left: 6px; right: 6px; min-height: 0; padding: 0; gap: 4px; pointer-events: none; }
    .cd__hud .hud-chip { flex-direction: row; align-items: baseline; gap: 6px; min-width: 0; padding: 2px 8px; background: color-mix(in srgb, var(--surface) 88%, transparent); }
    .cd .pad { grid-column: 2; grid-row: 1; width: 112px; margin: 0; }
    .cd .pad__jump { grid-template-columns: minmax(0, 1fr); justify-items: center; row-gap: 4px; min-height: min(220px, calc(100svh - var(--header-h) - 40px)); padding: 8px; text-align: center; }
    .cd .pad__jump .icon { grid-row: auto; }
    .cd__side { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    .cd__field.is-shaking { animation: none; }
}
