/* What the whole-body games share. The cards, buttons and panel come from core/base.css. */

/* ---------- which pieces each screen shows ---------- */
.choose,
.coach,
.tally,
.body-check { display: none; }

body[data-screen='choose'] #screen-choose { display: grid; }

body[data-screen='bodycheck'] .camera-frame,
body[data-screen='bodycheck'] .body-check { display: block; }

/* ---------- choosing a fighter ---------- */
.choose {
  position: fixed;
  inset: 0;
  grid-template-columns: minmax(200px, 1fr) minmax(0, 1.05fr) minmax(220px, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "head head head"
    "chosen . side"
    "grid grid grid";
  gap: 8px clamp(10px, 2vw, 24px);
  padding: clamp(10px, 2vh, 22px) clamp(12px, 2.4vw, 32px) clamp(10px, 2vh, 20px);
  pointer-events: none;
}

.choose > * { pointer-events: auto; }

.choose-head {
  grid-area: head;
  position: relative;
  text-align: center;
  pointer-events: none;
}

.choose-head h2 {
  color: #fff;
  text-shadow: 0 3px 0 rgba(18, 48, 77, 0.55);
}

.choose-head .all-games {
  position: absolute;
  left: 0;
  top: 8px;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 6px 16px;
}

.chosen {
  grid-area: chosen;
  align-self: center;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: clamp(12px, 1.8vw, 22px);
  display: grid;
  gap: 8px;
}

.chosen-name {
  font-size: clamp(30px, 4vw, 52px);
  font-weight: 700;
  line-height: 1;
}

.chosen-title {
  font-size: clamp(16px, 1.7vw, 22px);
  font-weight: 500;
  color: var(--ink-soft);
}

.chosen-move { font-size: clamp(17px, 1.7vw, 22px); font-weight: 600; }

.chosen-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
}

.choose-side {
  grid-area: side;
  align-self: center;
  display: grid;
  gap: 10px;
  justify-items: stretch;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: clamp(12px, 1.8vw, 20px);
}

.choose-side .big-button { padding: 10px 24px 12px; }

.fighter-grid {
  grid-area: grid;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: clamp(4px, 0.8vw, 10px);
}

.fighter-card {
  border: 4px solid transparent;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  padding: 2px 2px 5px;
  display: grid;
  justify-items: center;
  font-size: clamp(12px, 1.25vw, 17px);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(18, 48, 77, 0.2);
}

.fighter-card img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  min-height: 0;
}

.fighter-card:hover { background: #fff; transform: translateY(-2px); }

.fighter-card[aria-checked='true'] {
  border-color: var(--sun-deep);
  background: #fff5cc;
}

@media (max-width: 820px), (max-height: 520px) {
  .choose {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto minmax(100px, 1fr) auto;
    grid-template-areas:
      "head head"
      "chosen side"
      ". ."
      "grid grid";
    overflow: auto;
  }
  .fighter-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .fighter-card img { max-height: 15vh; }
  .chosen-label { font-size: 12px; }
}

/* ---------- camera ---------- */
.body-frame {
  --camera-small: clamp(150px, 19vw, 270px);
  top: auto;
  bottom: 12px;
  left: 12px;
  transform: none;
}

.body-frame canvas,
.body-guide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.body-guide { display: none; }

body[data-screen='bodycheck'] .body-frame {
  --body-view: min(92vw, calc((100vh - 170px) * var(--camera-aspect)));
  top: 60px;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  width: var(--body-view);
}

body[data-screen='bodycheck'] .body-guide { display: block; }

.body-guide circle,
.body-guide path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.72);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 5 4;
}

.camera-frame[data-ready='open'] .body-guide circle,
.camera-frame[data-ready='open'] .body-guide path { stroke: #7dff9f; stroke-dasharray: none; }

.body-check {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: 12px;
  width: min(560px, 90vw);
  transform: translateX(-50%);
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  padding: 8px 18px;
}

.body-check .check-progress {
  position: static;
  display: block;
  transform: none;
  width: 100%;
  margin: 0 0 4px;
}

body[data-screen='bodycheck'] .prompt {
  top: 8px;
  bottom: auto;
}

/* ---------- the coach, and the running count ---------- */
.coach {
  position: fixed;
  z-index: 3;
  right: 12px;
  bottom: 12px;
  width: min(26vw, 52vh);
  min-width: 170px;
  background: #fff;
  border: 5px solid var(--sun);
  border-radius: 26px;
  box-shadow: var(--shadow);
  overflow: hidden;
  flex-direction: column;
  align-items: stretch;
}

/* The character showing what to do, as big as it can be without covering the fight. */
.coach-demo {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(#cfeeff, #f4fbff);
}

.coach-text {
  font-size: clamp(22px, 2.9vw, 42px);
  font-weight: 700;
  line-height: 1.08;
  text-align: center;
  padding: 4px 10px 6px;
}

.coach-effort {
  height: clamp(12px, 1.5vw, 20px);
  margin: 0 14px 12px;
  background: var(--surface-soft);
  border: 2px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.coach-effort-fill {
  width: 0;
  height: 100%;
  background: var(--good);
  border-radius: 999px;
  transition: width 0.08s linear;
}

/* The child did something when something else is wanted. */
.coach.is-nudged { animation: nudge 0.5s ease-in-out; }

@keyframes nudge {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .coach.is-nudged { animation: none; }
}

.person {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.person .head { fill: var(--ink); stroke: none; }
.person .floor { stroke: var(--line); }

.tally {
  position: fixed;
  z-index: 3;
  right: 12px;
  bottom: 12px;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 34vw;
}

.tally-item {
  position: relative;
  width: clamp(38px, 4.2vw, 54px);
  height: clamp(38px, 4.2vw, 54px);
  background: rgba(255, 255, 255, 0.88);
  border-radius: 12px;
  opacity: 0.72;
}

.tally-item.has-some { opacity: 1; background: #fff; }

.tally-item svg { width: 100%; height: 100%; display: block; }

.tally-count {
  position: absolute;
  right: -2px;
  bottom: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--sun);
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

/* ---------- words that fly up when something happens ---------- */
.callouts {
  position: fixed;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.callout {
  position: absolute;
  transform: translate(-50%, -50%);
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 3px 0 rgba(18, 48, 77, 0.9), 0 0 10px rgba(18, 48, 77, 0.45);
  font-size: clamp(20px, 2.6vw, 34px);
  animation: rise 0.85s ease-out forwards;
}

.callout.is-number { color: var(--sun); font-size: clamp(22px, 3vw, 40px); }
.callout.is-open { color: #9dffbd; }

.callout.is-big {
  font-size: clamp(32px, 5.4vw, 72px);
  color: var(--sun);
  animation: big-word 1.3s ease-out forwards;
}

.callout.is-combo {
  font-size: clamp(26px, 4vw, 54px);
  color: #9de6ff;
  animation: big-word 1.3s ease-out forwards;
}

@keyframes rise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.72); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

@keyframes big-word {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  24% { transform: translate(-50%, -50%) scale(1); }
  76% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -66%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .callout, .callout.is-big, .callout.is-combo { animation-name: fade-word; }
  @keyframes fade-word {
    0%, 80% { opacity: 1; }
    100% { opacity: 0; }
  }
}

/* ---------- the camera saw that ---------- */
.body-frame.has-seen {
  border-color: var(--good);
  box-shadow: 0 0 0 6px var(--good), var(--shadow);
}

.callout.is-seen {
  font-size: clamp(28px, 4.4vw, 58px);
  color: #9dffbd;
  animation: big-word 1.3s ease-out forwards;
}

.live-reading {
  font-size: 15px;
  line-height: 1.35;
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 8px 12px;
  margin: 0 0 10px;
}

/* ---------- a count, and cards of what's been done ---------- */
.body-count {
  z-index: 4;
  color: #fff;
  text-shadow: 0 5px 0 rgba(18, 48, 77, 0.8);
}

.break-tally,
.finish-tally {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.tally-card {
  display: grid;
  justify-items: center;
  width: 86px;
  padding: 4px 4px 7px;
  background: var(--surface-soft);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
}

.tally-card svg { width: 46px; height: 46px; display: block; }

.tally-card strong { font-size: 26px; line-height: 1.1; }

.finish-card { width: min(680px, 100%); display: grid; gap: 10px; justify-items: center; }

.finish-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

/* ---------- on a small screen ---------- */
@media (max-width: 620px) {
  .tally { display: none !important; }
  #open-panel { top: auto; bottom: 8px; right: 8px; }
}
