/* Clown Showdown: game CSS. Tokens from /design/garden.css. The canvas draws the big top; the DOM holds HUD,
   controls and cards (HUD stays level while the stage tilts). */
html, body { height: 100%; }
body { overflow: hidden; overscroll-behavior: none; background: var(--gg-cream); }
.cs-appbar { position: relative; z-index: 5; }
.cs-namechip { min-height: 30px; }
@media (max-width: 560px) { .cs-namechip { display: none; } }
/* short landscape phones: a slimmer bar so the tent gets the height (buttons stay 44 px) */
@media (orientation: landscape) and (max-height: 500px) {
  .cs-appbar .gg-appbar__in { min-height: 50px; }
  .cs-appbar .gg-wordmark { font-size: 19px; }
  .cs-appbar .gg-wordmark svg { width: 30px; height: 30px; }
}

/* --gg-pt-h: the playtest strip under the app bar (platform/playtest.js sets it; 0 when there is none) */
.cs-main { position: relative; height: calc(100svh - 66px - var(--gg-pt-h, 0px)); width: 100%; }
@media (orientation: landscape) and (max-height: 500px) { .cs-main { height: calc(100svh - 52px - var(--gg-pt-h, 0px)); } }
.cs-stage {
  position: absolute; inset: 0; overflow: hidden; background: #3B2147;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.cs-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cs-stage.is-idle .cs-hud, .cs-stage.is-idle .cs-jump, .cs-stage.is-idle .cs-pad, .cs-stage.is-idle .cs-hint { visibility: hidden; }

/* ---------- HUD (level, never tilts) ---------- */
.cs-hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3; pointer-events: none;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
}
.cs-hud .gg-pill { min-height: 32px; box-shadow: var(--gg-shadow-sm); }
.cs-level { background: var(--gg-butter); font-family: var(--gg-font-display); font-weight: 800; }
.cs-time { font-family: var(--gg-font-display); font-variant-numeric: tabular-nums; min-width: 78px; justify-content: center; }
.cs-hoops { background: var(--gg-paper); gap: 6px; font-variant-numeric: tabular-nums; }
.cs-hoops svg { width: 18px; height: 18px; }
.cs-hoops.is-full { background: var(--gg-lime); }
.cs-hoops[hidden] { display: none; }
.cs-gauge { margin-left: auto; width: 104px; height: 30px; }
.cs-gauge svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(2px 2px 0 #111); }

/* ---------- hints ---------- */
.cs-hint {
  position: absolute; left: 50%; top: 56px; z-index: 3; transform: translateX(-50%);
  width: max-content; max-width: min(92%, 440px); margin: 0; padding: 9px 16px; text-align: center;
  background: var(--gg-paper); border: var(--gg-border); border-radius: var(--gg-r-md); box-shadow: var(--gg-shadow);
  font-weight: 700; font-size: var(--gg-text-sm); line-height: 1.3; pointer-events: none;
  animation: cs-in .3s var(--gg-ease-spring);
}
.cs-hint[hidden] { display: none; }
.cs-hint b { background: var(--gg-butter); padding: 0 5px; border-radius: 6px; border: 2px solid var(--gg-ink); }
@keyframes cs-in { from { opacity: 0; transform: translate(-50%, -6px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* ---------- controls ---------- */
.cs-jump {
  position: absolute; z-index: 4; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: 84px; height: 84px; border-radius: 50%; border: 3px solid var(--gg-ink); padding: 0;
  background: var(--gg-pink); box-shadow: 0 5px 0 var(--gg-ink); color: var(--gg-paper);
  display: grid; place-items: center; align-content: center; gap: 0; cursor: pointer;
  touch-action: none; -webkit-tap-highlight-color: transparent;
  font-family: var(--gg-font-display); font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
  transition: transform .06s, box-shadow .06s;
}
.cs-jump svg { width: 36px; height: 36px; margin-bottom: -2px; }
.cs-jump span { -webkit-text-stroke: 3px var(--gg-ink); paint-order: stroke fill; }
.cs-jump.is-down { transform: translateY(4px); box-shadow: 0 1px 0 var(--gg-ink); }
.cs-jump:focus-visible { outline: 3px dashed var(--gg-lime); outline-offset: 3px; }
.cs-left .cs-jump { right: auto; left: max(16px, env(safe-area-inset-left)); }

.cs-pad {
  position: absolute; z-index: 2; left: max(14px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom));
  display: grid; justify-items: center; gap: 2px; pointer-events: none; opacity: .92;
  padding: 6px 10px 6px; border: var(--gg-border); border-radius: var(--gg-r-md); background: color-mix(in srgb, var(--gg-paper) 88%, transparent); box-shadow: var(--gg-shadow-sm);
  font-size: var(--gg-text-xs); font-weight: 800; letter-spacing: .04em;
  transition: opacity .4s;
}
.cs-pad svg { width: 72px; height: 38px; }
@media (orientation: landscape) and (max-height: 500px) { .cs-pad svg { width: 92px; height: 48px; } }
.cs-pad.is-quiet { opacity: 0; }
.cs-left .cs-pad { left: auto; right: max(14px, env(safe-area-inset-right)); }

/* the thumb ring: where your thumb went down, the dot shows the tilt */
.cs-thumb {
  position: absolute; z-index: 2; width: 120px; height: 44px; margin: -22px 0 0 -60px; pointer-events: none;
  border: 3px solid rgba(17, 17, 17, .75); border-radius: 22px; background: rgba(255, 254, 246, .35);
}
.cs-thumb[hidden] { display: none; }
.cs-thumb i { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: var(--gg-butter); border: 3px solid var(--gg-ink); }

.cs-flash { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: #FFFEF6; opacity: 0; }
.cs-flash.is-on { animation: cs-flash .45s ease-out; }
@keyframes cs-flash { 0% { opacity: .55; } 100% { opacity: 0; } }

/* landscape phones: the shaft sits in the middle, the pad hint in the left gutter, Jump in the right one */
@media (orientation: landscape) and (max-height: 500px) {
  .cs-hud { padding-top: 8px; }
  .cs-hint { top: 48px; font-size: var(--gg-text-xs); max-width: min(46%, 360px); }
  .cs-jump { width: 92px; height: 92px; right: max(28px, env(safe-area-inset-right)); bottom: max(26px, env(safe-area-inset-bottom)); }
  .cs-left .cs-jump { left: max(28px, env(safe-area-inset-left)); }
  .cs-pad { left: max(24px, env(safe-area-inset-left)); bottom: max(28px, env(safe-area-inset-bottom)); }
}
/* desktop: keyboard first, the pad hint shows the keys */
@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .cs-jump { width: 76px; height: 76px; }
}

/* ---------- modals ---------- */
.cs-modal { z-index: 60; }
.cs-title { font-family: var(--gg-font-display); font-weight: 800; font-size: clamp(38px, 10.5vw, 54px); line-height: 1; margin: 6px 0 10px; }
.cs-lede { color: var(--gg-ink-2); margin: 0 0 18px; }
.cs-titlebtns, .cs-resbtns { display: grid; gap: 10px; margin-top: 4px; }
.cs-status { margin: 14px 0 0; font-size: var(--gg-text-sm); color: var(--gg-ink-2); }
.cs-status b { color: var(--gg-ink); }
.cs-h2 { font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-2xl); margin: 4px 0 8px; }
.cs-line { margin: 4px 0 10px; color: var(--gg-ink-2); font-size: var(--gg-text-sm); }
/* the playtest board line (platform/playtest.js renders it: "Saved to the board: #3 this week" + Board) */
.cs-ptline { margin: 0 0 12px; }
.cs-ptline[hidden] { display: none; }
.cs-howlist { text-align: left; margin: 0 0 18px; padding-left: 20px; display: grid; gap: 8px; font-size: var(--gg-text-sm); }
.cs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 10px; margin: 6px 0 16px; max-height: 46vh; overflow: auto; padding: 4px; }
.cs-lv {
  min-height: 58px; border: var(--gg-border); border-radius: var(--gg-r-md); background: var(--gg-paper); box-shadow: var(--gg-shadow-sm);
  display: grid; place-items: center; gap: 0; padding: 4px 2px; cursor: pointer; font-family: var(--gg-font-display); font-weight: 800; font-size: 20px; color: var(--gg-ink);
}
.cs-lv small { display: flex; gap: 1px; }
.cs-lv small svg { width: 12px; height: 12px; }
.cs-lv.is-next { background: var(--gg-butter); }
.cs-lv:disabled { opacity: .45; cursor: default; box-shadow: none; }
.cs-lv:focus-visible { outline: 3px dashed var(--gg-lime); outline-offset: 2px; }
.cs-stars { display: flex; justify-content: center; gap: 8px; margin: 4px 0 10px; }
.cs-stars svg { width: 40px; height: 40px; }
.cs-stars .is-pop { animation: cs-star .45s var(--gg-ease-spring) both; }
@keyframes cs-star { from { transform: scale(.2) rotate(-30deg); opacity: 0; } to { transform: none; opacity: 1; } }
.cs-rows { display: grid; gap: 6px; margin: 0 0 8px; }
.cs-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; border: 2px solid var(--gg-ink); border-radius: var(--gg-r-md); background: var(--gg-cream); font-size: var(--gg-text-sm); text-align: left; }
.cs-row b { font-family: var(--gg-font-display); font-size: 18px; font-variant-numeric: tabular-nums; }
.cs-row small { color: var(--gg-ink-3); font-weight: 600; margin-left: 4px; }
.cs-row.is-good { background: var(--gg-lime-100); }
.cs-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 0; font-weight: 700; }
.cs-toggle[hidden] { display: none; }
.cs-pausecard > .gg-btn--ghost { margin-top: 14px; width: 100%; }

/* short landscape: cards fit without scrolling */
@media (orientation: landscape) and (max-height: 500px) {
  .cs-modal .gg-modal__card { width: min(620px, 100%); padding: 14px 20px 16px; max-height: calc(100svh - 24px); overflow: auto; }
  .cs-title { font-size: 38px; margin: 2px 0 6px; }
  .cs-lede { margin: 0 0 10px; font-size: var(--gg-text-sm); }
  .cs-titlebtns { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cs-titlebtns .gg-btn--lg { grid-column: 1 / -1; min-height: 48px; }
  .cs-status { margin-top: 8px; font-size: var(--gg-text-xs); }
  .cs-resultcard { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; align-items: start; }
  .cs-resultcard > .gg-eyebrow, .cs-resultcard > .cs-h2, .cs-resultcard > .cs-stars { grid-column: 1; }
  .cs-resultcard > .cs-rows, .cs-resultcard > .cs-line { grid-column: 2; }
  /* the board line: one row across the card (its text, then its buttons), so the card stays one screen tall */
  .cs-resultcard > .cs-ptline { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px 12px; margin: 4px 0 8px; padding: 6px 12px; text-align: left; }
  .cs-ptline .ggp-moment__line { flex: 1 1 auto; font-size: var(--gg-text-xs); }
  .cs-ptline .ggp-moment__row { flex: none; flex-wrap: nowrap; }
  .cs-resultcard > .cs-rows { grid-row: 1 / span 3; margin-top: 6px; }
  .cs-resultcard > .cs-resbtns { grid-column: 1 / -1; grid-template-columns: 1.4fr 1fr 1fr; }
  .cs-resultcard .gg-btn--lg { min-height: 48px; }
  .cs-stars { justify-content: flex-start; }
  .cs-stars svg { width: 34px; height: 34px; }
  .cs-pausecard { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
  .cs-pausecard > .cs-h2 { grid-column: 1 / -1; }
  .cs-pausecard > .cs-resbtns { grid-row: 2 / span 4; }
  .cs-pausecard > .cs-toggle { grid-column: 2; margin-top: 4px; }
  .cs-pausecard > .gg-btn--ghost { grid-column: 2; margin-top: 8px; }
  .cs-howlist { gap: 4px; margin-bottom: 10px; }
  .cs-grid { max-height: 40vh; }
}

@media (prefers-reduced-motion: reduce) {
  .cs-hint, .cs-stars .is-pop { animation: none; }
  .cs-flash.is-on { animation: none; }
}
