:root {
  --ink: #10243a;
  --muted: #607189;
  --blue: #2f86df;
  --cyan: #45d8ff;
  --gold: #ffd45c;
  --orange: #f4a35f;
  --green: #5cc285;
  --cream: #fff7e3;
  --panel: rgba(255, 251, 238, 0.94);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 9%, rgba(255, 255, 255, 0.9), transparent 18%),
    radial-gradient(circle at 86% 13%, rgba(255, 255, 255, 0.82), transparent 16%),
    linear-gradient(145deg, #7fd5ff 0%, #2f92e7 46%, #d8f9ff 100%);
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.bridge-app {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 118px;
  gap: 8px;
  width: 100vw;
  height: 100vh;
  padding: 8px 12px 10px;
}

.bridge-app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 17% 74%, rgba(37, 139, 93, 0.28), transparent 16%),
    radial-gradient(circle at 82% 73%, rgba(44, 119, 161, 0.28), transparent 18%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));
}

.topbar {
  z-index: 3;
  display: grid;
  grid-template-columns: 1.12fr 1fr 1.05fr 0.9fr auto auto;
  gap: 8px;
}

.status-card {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 2px solid rgba(255, 219, 128, 0.34);
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(28, 82, 91, 0.94), rgba(19, 65, 76, 0.96));
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.14), 0 10px 24px rgba(20, 61, 84, 0.2);
}

.status-card.compact {
  min-width: 136px;
  justify-content: center;
}

.status-card small {
  display: block;
  color: rgba(255, 239, 190, 0.72);
  font-size: 12px;
  font-weight: 900;
}

.status-card strong {
  display: block;
  color: #fff4ca;
  font-size: clamp(19px, 1.9vw, 30px);
  line-height: 1.05;
  font-weight: 1000;
}

.status-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #10364b;
  background: linear-gradient(180deg, #ffd36a, #f79c36);
  box-shadow: inset 0 -5px 0 rgba(150, 75, 20, 0.22), 0 7px 15px rgba(117, 69, 20, 0.22);
  font-size: 24px;
  font-weight: 1000;
}

.note-icon {
  border-radius: 999px;
}

#cameraButton,
#playButton,
#startButton,
#skipCameraButton,
#replayButton {
  border-radius: 16px;
  color: #082a36;
  background: linear-gradient(180deg, #52f0f0, #12a7b8);
  font-weight: 1000;
  box-shadow: 0 12px 24px rgba(18, 128, 155, 0.22);
}

#cameraButton {
  min-height: 50px;
  padding: 0 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions a {
  display: grid;
  min-height: 54px;
  padding: 0 14px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.46);
  border-radius: 15px;
  color: #fff4ca;
  background: linear-gradient(180deg, rgba(35, 82, 96, 0.94), rgba(22, 65, 78, 0.96));
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12), 0 10px 22px rgba(20, 61, 84, 0.18);
  font-size: 16px;
  font-weight: 1000;
  text-decoration: none;
  white-space: nowrap;
}

.game-shell {
  z-index: 2;
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 10px;
}

.guide-card {
  position: absolute;
  z-index: 6;
  left: 14px;
  top: 14px;
  width: min(246px, 19vw);
  min-width: 206px;
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 232, 174, 0.96), rgba(255, 203, 116, 0.94));
  border: 2px solid rgba(242, 185, 91, 0.5);
  box-shadow: 0 16px 36px rgba(86, 55, 17, 0.22);
}

.guide-icon {
  display: none;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  color: white;
  background: linear-gradient(180deg, #6fb0ff, #2d74d6);
  font-size: 32px;
}

.guide-card h1 {
  margin: 0 0 8px;
  font-size: clamp(18px, 1.35vw, 23px);
  line-height: 1.08;
}

.cue-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.cue-list article {
  padding: 7px 8px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.58);
}

.cue-list article:nth-child(3) {
  grid-column: 1 / -1;
}

.cue-list strong,
.cue-list span {
  display: block;
  font-weight: 950;
}

.cue-list strong {
  color: #8a5a0d;
  font-size: 13px;
}

.cue-list span {
  margin-top: 4px;
  color: rgba(48, 34, 16, 0.82);
  font-size: 12px;
  line-height: 1.22;
}

.fallback-note {
  margin: 7px 0 0;
  color: rgba(57, 42, 20, 0.68);
  font-weight: 850;
  font-size: 11px;
  line-height: 1.25;
}

.stage-card {
  position: relative;
  overflow: hidden;
  min-height: 0;
  border-radius: 22px;
  border: 3px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 24px 55px rgba(31, 82, 136, 0.24);
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 255, 255, 0.6), transparent 18%),
    linear-gradient(180deg, rgba(145, 216, 255, 0.7), rgba(72, 166, 226, 0.78));
}

#camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0.18;
  filter: saturate(1.02) contrast(1.04);
}

#camera.is-live {
  opacity: 0.82;
}

#gameCanvas {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

.feedback-pill {
  position: absolute;
  left: 50%;
  bottom: 72px;
  transform: translateX(-50%);
  min-width: min(430px, 72%);
  padding: 14px 18px;
  border-radius: 18px;
  text-align: center;
  color: #fff7d6;
  background: rgba(19, 65, 84, 0.86);
  box-shadow: 0 14px 30px rgba(11, 42, 58, 0.28);
  border: 2px solid rgba(255, 238, 155, 0.28);
}

.action-cue {
  position: absolute;
  left: 50%;
  top: 18px;
  z-index: 4;
  transform: translateX(-50%);
  min-width: min(460px, 64%);
  padding: 12px 18px;
  border-radius: 20px;
  text-align: center;
  color: #fff7d6;
  background: rgba(18, 63, 84, 0.88);
  border: 2px solid rgba(255, 226, 117, 0.46);
  box-shadow: 0 12px 28px rgba(11, 42, 58, 0.24);
}

.action-cue strong,
.action-cue span {
  display: block;
}

.action-cue strong {
  font-size: clamp(22px, 2.1vw, 34px);
  line-height: 1.1;
}

.action-cue span {
  margin-top: 4px;
  color: rgba(255, 247, 214, 0.84);
  font-weight: 850;
}

.feedback-pill strong,
.feedback-pill span {
  display: block;
}

.feedback-pill strong {
  font-size: clamp(22px, 2.1vw, 34px);
  line-height: 1.05;
}

.feedback-pill span {
  margin-top: 5px;
  color: rgba(255, 247, 214, 0.86);
  font-weight: 850;
}

.feedback-pill.is-good {
  background: linear-gradient(180deg, rgba(52, 186, 102, 0.95), rgba(24, 113, 79, 0.94));
  box-shadow: 0 0 0 4px rgba(112, 255, 149, 0.16), 0 18px 34px rgba(25, 95, 61, 0.34);
}

.feedback-pill.is-warn {
  background: rgba(158, 91, 22, 0.9);
}

.feedback-pill.is-danger {
  background: rgba(154, 58, 58, 0.9);
}

.play-panel {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px 10px 10px;
  border-radius: 20px;
  color: #fff8db;
  background: rgba(18, 63, 84, 0.88);
}

#playButton {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  font-size: 24px;
}

.play-panel small,
.play-panel strong {
  display: block;
}

.play-panel small {
  color: rgba(255, 248, 219, 0.68);
  font-weight: 850;
}

.play-panel strong {
  font-size: 20px;
}

.side-meter {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  justify-items: center;
  gap: 8px;
  padding: 12px 8px;
  border-radius: 22px;
  background: rgba(14, 68, 91, 0.86);
  color: #fdf1be;
  font-weight: 1000;
  box-shadow: 0 18px 36px rgba(14, 55, 78, 0.22);
}

.meter-title {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 14px;
  border: 2px solid rgba(93, 230, 255, 0.48);
  color: #80f0ff;
  font-size: 25px;
}

.side-label {
  color: #ffe5a1;
  font-size: 18px;
}

.meter-track {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 170px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.meter-track::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
}

.side-zone {
  position: absolute;
  top: 24%;
  bottom: 24%;
  width: 34%;
  border-radius: 999px;
  border: 3px solid rgba(255, 224, 98, 0.64);
  background: rgba(255, 211, 92, 0.2);
  box-shadow: 0 0 20px rgba(255, 211, 92, 0.3);
}

.left-zone {
  left: 10%;
}

.right-zone {
  right: 10%;
}

.hand-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  border: 5px solid #eaffd1;
  background: #6ee89a;
  box-shadow: 0 0 18px rgba(110, 232, 154, 0.76);
}

#sideStateLabel {
  min-height: 30px;
  color: #82f0ff;
  font-size: 18px;
}

.meter-help {
  color: rgba(255, 246, 202, 0.72);
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
}

.timeline-card {
  z-index: 2;
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  min-height: 118px;
  padding: 8px;
  border-radius: 24px;
  background: rgba(255, 251, 238, 0.95);
  box-shadow: 0 14px 34px rgba(29, 77, 118, 0.18);
}

.meter-badge {
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: white;
  background: linear-gradient(180deg, #69a8f6, #286fcf);
  font-size: 19px;
  font-weight: 1000;
  text-align: center;
}

#timelineCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 34, 58, 0.54);
}

.overlay.is-hidden {
  display: none;
}

.overlay-card {
  width: min(930px, 94vw);
  padding: 24px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 251, 238, 0.98), rgba(255, 238, 197, 0.96));
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 30px 70px rgba(0, 35, 72, 0.34);
  text-align: center;
}

.overlay-kicker {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  color: #287384;
  background: rgba(52, 213, 230, 0.14);
  font-weight: 1000;
}

.overlay-card h2 {
  margin: 14px 0 18px;
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1.05;
}

.sync-guide-card {
  width: min(960px, 94vw);
  max-height: min(88dvh, 760px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.sync-guide-card h2 {
  margin-bottom: 14px;
  font-size: clamp(30px, 3.5vw, 46px);
}

.sync-guide {
  position: relative;
  min-height: 0;
  height: min(54dvh, 500px);
  overflow: hidden;
  border-radius: 22px;
  border: 2px solid rgba(62, 154, 214, 0.28);
  background: #e8f8ff;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.72),
    0 18px 50px rgba(24, 88, 150, 0.24);
}

.sync-guide video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: linear-gradient(180deg, #e9fbff, #bceeff);
}

.sync-guide audio {
  display: none;
}

.sync-dim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(20, 112, 180, 0.16)),
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.42), transparent 34%);
}

.sync-status {
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 3;
  padding: 8px 14px;
  border-radius: 999px;
  color: #fff8dc;
  background: rgba(16, 68, 87, 0.84);
  font-weight: 1000;
  box-shadow: 0 12px 24px rgba(10, 48, 74, 0.22);
}

.sync-caption {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 18px;
  width: min(82%, 720px);
  transform: translateX(-50%);
  padding: 14px 18px;
  border-radius: 18px;
  color: #fff8dc;
  background: rgba(12, 67, 92, 0.88);
  box-shadow: 0 18px 42px rgba(7, 42, 66, 0.28);
}

.sync-caption strong,
.sync-caption span {
  display: block;
}

.sync-caption strong {
  font-size: clamp(22px, 2.6vw, 34px);
  line-height: 1.12;
}

.sync-caption span {
  margin-top: 6px;
  color: rgba(255, 248, 220, 0.88);
  font-size: clamp(15px, 1.45vw, 20px);
  font-weight: 850;
  line-height: 1.35;
}

.sync-guide-card .overlay-actions {
  position: relative;
  z-index: 6;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(40, 115, 132, 0.16);
}

.demo-strip {
  position: relative;
  height: 252px;
  overflow: hidden;
  border-radius: 24px;
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 255, 255, 0.78), transparent 14%),
    radial-gradient(circle at 86% 16%, rgba(255, 255, 255, 0.68), transparent 14%),
    linear-gradient(180deg, #7ed8ff, #54afea);
}

.demo-strip::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 82px;
  background: linear-gradient(180deg, rgba(22, 110, 188, 0), rgba(21, 117, 172, 0.58));
}

.demo-cloud {
  position: absolute;
  width: 210px;
  height: 64px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  filter: blur(0.2px);
}

.cloud-a {
  left: 6%;
  top: 30px;
}

.cloud-b {
  right: 8%;
  top: 54px;
  width: 260px;
}

.demo-board {
  position: absolute;
  bottom: 50px;
  display: grid;
  place-items: center;
  width: 164px;
  height: 90px;
  border-radius: 18px;
  border: 3px solid rgba(161, 111, 42, 0.24);
  color: #3e2a12;
  background: linear-gradient(180deg, #ffe7a6, #f1b85f);
  font-size: 42px;
  font-weight: 1000;
  box-shadow: 0 18px 0 rgba(130, 74, 24, 0.38);
}

.demo-board em {
  display: block;
  font-style: normal;
  font-size: 18px;
}

.board-quarter {
  left: 8%;
  animation: boardQuarterOnePulse 12s linear infinite;
}

.board-quarter-two {
  left: 28%;
  animation: boardQuarterTwoPulse 12s linear infinite;
}

.board-half {
  left: 48%;
  width: 240px;
  background: linear-gradient(180deg, #dff1c8, #9fd497);
  animation: boardHalfPulse 12s linear infinite;
}

.board-rest {
  right: 6%;
  width: 126px;
  background: linear-gradient(180deg, #f9ead2, #d1b48a);
  animation: boardRestPulse 12s linear infinite;
}

.demo-forward-label {
  position: absolute;
  left: 12%;
  top: 92px;
  padding: 7px 14px;
  border-radius: 999px;
  color: #fff7d7;
  background: rgba(16, 68, 87, 0.74);
  font-weight: 1000;
  box-shadow: 0 0 20px rgba(70, 216, 255, 0.28);
}

.demo-gesture-card {
  position: absolute;
  right: 5%;
  top: 28px;
  width: 220px;
  height: 112px;
  border-radius: 22px;
  border: 3px solid rgba(255, 255, 255, 0.62);
  background: rgba(16, 68, 87, 0.78);
  box-shadow: 0 16px 30px rgba(24, 74, 94, 0.28);
}

.demo-gesture-card strong {
  position: absolute;
  left: 16px;
  top: 12px;
  color: #fff7d7;
  font-size: 18px;
}

.demo-side {
  position: absolute;
  top: 56px;
  color: #c8fbff;
  font-size: 18px;
  font-weight: 1000;
}

.side-left { left: 20px; }
.side-right { right: 20px; }

.demo-guide-dot {
  position: absolute;
  left: 54px;
  top: 56px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #75ff9a;
  box-shadow: 0 0 0 7px rgba(117, 255, 154, 0.22), 0 0 20px rgba(117, 255, 154, 0.7);
  animation: demoHandSideSwing 12s ease-in-out infinite;
}

.demo-hand {
  position: absolute;
  left: 46px;
  top: 44px;
  width: 64px;
  height: 62px;
  transform-origin: 50% 100%;
  animation: demoHandSideSwing 12s ease-in-out infinite;
}

.demo-wrist,
.demo-palm,
.demo-finger,
.demo-thumb {
  position: absolute;
  background: linear-gradient(180deg, #ffe7b6, #ffb45d);
  box-shadow: 0 0 0 1px rgba(128, 70, 24, 0.08), 0 4px 9px rgba(70, 38, 15, 0.13);
}

.demo-wrist {
  left: 28px;
  top: 44px;
  width: 16px;
  height: 26px;
  border-radius: 10px;
}

.demo-palm {
  left: 16px;
  top: 22px;
  width: 38px;
  height: 36px;
  border-radius: 19px 19px 15px 15px;
}

.demo-finger {
  bottom: 30px;
  width: 10px;
  height: 35px;
  border-radius: 10px;
  transform-origin: 50% 100%;
}

.demo-finger-one {
  left: 17px;
  transform: rotate(-16deg);
}

.demo-finger-two {
  left: 30px;
  height: 40px;
}

.demo-finger-three {
  left: 43px;
  height: 34px;
  transform: rotate(14deg);
}

.demo-thumb {
  left: 4px;
  top: 34px;
  width: 27px;
  height: 11px;
  border-radius: 999px;
  transform: rotate(-33deg);
}

.demo-glow {
  position: absolute;
  left: 8%;
  bottom: 48px;
  width: 164px;
  height: 90px;
  border-radius: 18px;
  border: 4px solid rgba(255, 243, 140, 0.96);
  box-shadow: 0 0 30px rgba(255, 228, 82, 0.86);
  animation: demoGlow 12s linear infinite;
}

.demo-kid {
  position: absolute;
  left: 12%;
  bottom: 92px;
  width: 62px;
  height: 92px;
  border-radius: 36px 36px 24px 24px;
  background:
    radial-gradient(circle at 50% 18%, #f6c58a 0 17px, transparent 18px),
    linear-gradient(180deg, #2e82d8, #1f5da8);
  box-shadow: 0 10px 0 rgba(64, 72, 90, 0.25);
  animation: demoKidStepHold 12s ease-in-out infinite;
}

.overlay-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.overlay-points article {
  min-height: 104px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  text-align: left;
}

.overlay-points strong,
.overlay-points span {
  display: block;
  font-weight: 950;
}

.overlay-points strong {
  color: #257785;
  font-size: 20px;
}

.overlay-points span {
  margin-top: 8px;
  color: #4a5c6d;
  line-height: 1.45;
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

#startButton,
#skipCameraButton,
#replayButton {
  min-height: 58px;
  padding: 0 28px;
  font-size: 20px;
}

#skipCameraButton {
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid rgba(40, 115, 132, 0.2);
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.result-actions a {
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 28px;
  border-radius: 16px;
  color: #082a36;
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid rgba(40, 115, 132, 0.2);
  font-size: 20px;
  font-weight: 1000;
  text-decoration: none;
}

.countdown {
  display: grid;
  place-items: center;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  color: white;
  background: rgba(18, 104, 183, 0.88);
  font-size: 86px;
  font-weight: 1000;
  box-shadow: 0 0 0 18px rgba(255, 255, 255, 0.24);
  animation: countdownPop 0.78s ease both;
}

.result-card {
  max-width: 720px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.result-grid article {
  padding: 16px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.result-grid strong,
.result-grid span {
  display: block;
}

.result-grid strong {
  color: #187f8e;
  font-size: 30px;
}

.result-grid span {
  color: var(--muted);
  font-weight: 900;
}

@keyframes countdownPop {
  from { transform: scale(0.72); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes boardQuarterOnePulse {
  0%, 12% { filter: brightness(1.32) drop-shadow(0 0 18px rgba(255, 226, 92, 0.72)); transform: translateY(-3px); }
  20%, 100% { filter: brightness(0.92); transform: translateY(0); }
}

@keyframes boardQuarterTwoPulse {
  0%, 18% { filter: brightness(0.92); transform: translateY(0); }
  21%, 34% { filter: brightness(1.32) drop-shadow(0 0 18px rgba(255, 226, 92, 0.72)); transform: translateY(-3px); }
  42%, 100% { filter: brightness(0.92); transform: translateY(0); }
}

@keyframes boardHalfPulse {
  0%, 58% { filter: brightness(0.92); transform: translateY(0); }
  64%, 78% { filter: brightness(1.32) drop-shadow(0 0 18px rgba(255, 226, 92, 0.72)); transform: translateY(-3px); }
  86%, 100% { filter: brightness(0.92); transform: translateY(0); }
}

@keyframes boardRestPulse {
  0%, 82% { filter: brightness(0.92); transform: translateY(0); }
  88%, 100% { filter: brightness(1.22) drop-shadow(0 0 14px rgba(255, 255, 255, 0.58)); transform: translateY(-2px); }
}

@keyframes demoHandStepHold {
  0%, 10% { transform: translateX(0) rotate(-7deg); opacity: 0.9; }
  21%, 28% { transform: translateX(92px) rotate(7deg); opacity: 1; }
  64%, 68% { transform: translateX(0) rotate(-7deg); opacity: 1; }
  100% { transform: translateX(0) rotate(-7deg); opacity: 0.9; }
}

@keyframes demoHandSideSwing {
  0%, 10% { transform: translateX(0) rotate(-7deg); }
  21%, 28% { transform: translateX(92px) rotate(7deg); }
  64%, 68% { transform: translateX(0) rotate(-7deg); }
  100% { transform: translateX(0) rotate(-7deg); }
}

@keyframes demoArrow {
  0%, 20% { opacity: 0.2; transform: translateX(-60px) scaleX(0.35); }
  24%, 40% { opacity: 1; transform: translateX(0) scaleX(0.7); }
  46% { opacity: 0.35; transform: translateX(20px) scaleX(0.3); }
  82% { opacity: 0.72; transform: translateX(250px) scaleX(0.18); }
  100% { opacity: 0.12; transform: translateX(250px) scaleX(0.18); }
}

@keyframes demoGlow {
  0%, 12% { opacity: 1; transform: translateX(0) scaleX(1); }
  21%, 28% { opacity: 1; transform: translateX(160px) scaleX(1); }
  64%, 68% { opacity: 1; transform: translateX(510px) scaleX(1.46); }
  88%, 100% { opacity: 0.78; transform: translateX(640px) scaleX(0.76); }
}

@keyframes demoKidStepHold {
  0%, 10% { transform: translateX(0) translateY(0); }
  21%, 28% { transform: translateX(160px) translateY(-4px); }
  64%, 68% { transform: translateX(510px) translateY(-4px); }
  100% { transform: translateX(640px) translateY(-4px); }
}

@media (max-width: 980px) {
  .bridge-app {
    padding: 12px;
    gap: 10px;
  }

  .topbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-shell {
    grid-template-columns: minmax(0, 1fr) 76px;
  }

  .guide-card {
    position: absolute;
    z-index: 4;
    left: 18px;
    top: 108px;
    width: min(260px, 36vw);
    padding: 12px;
  }

  .guide-card h1 {
    font-size: 22px;
  }

  .cue-list article:nth-child(3),
  .fallback-note {
    display: none;
  }

  .overlay-points {
    grid-template-columns: 1fr;
  }

  .sync-guide-card {
    max-height: calc(100dvh - 28px);
    overflow: auto;
  }

  .sync-guide {
    height: min(48dvh, 390px);
  }

  .sync-caption {
    width: calc(100% - 24px);
    bottom: 12px;
    padding: 12px 14px;
  }
}

/* v88: mobile and in-app browser fit layer for small landscape viewports. */
html,
body {
  height: var(--pml-app-height, 100dvh);
  min-height: var(--pml-app-height, 100dvh);
}

.bridge-app {
  height: var(--pml-app-height, 100dvh);
  min-height: var(--pml-app-height, 100dvh);
  padding-right: max(10px, env(safe-area-inset-right));
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  padding-left: max(10px, env(safe-area-inset-left));
}

body.pml-mobile-game .overlay {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

body.pml-mobile-game .overlay-card,
body.pml-mobile-game .sync-guide-card,
body.pml-mobile-game .result-card {
  max-height: calc(var(--pml-app-height, 100dvh) - 20px);
  overflow: auto;
}

body.pml-mobile-game .overlay-actions,
body.pml-mobile-game .result-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding-top: 10px;
  padding-bottom: max(0px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255, 251, 238, 0), rgba(255, 251, 238, 0.94) 34%);
}

body.pml-compact-game .bridge-app {
  grid-template-rows: auto minmax(0, 1fr) 58px;
  gap: 5px;
  padding-top: max(6px, env(safe-area-inset-top));
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}

body.pml-compact-game .topbar {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 5px;
}

body.pml-compact-game .status-card {
  min-height: 36px;
  padding: 4px 6px;
  border-width: 1px;
  border-radius: 10px;
  gap: 5px;
}

body.pml-compact-game .status-card.compact {
  min-width: 0;
}

body.pml-compact-game .status-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 14px;
}

body.pml-compact-game .status-card small {
  font-size: 9px;
}

body.pml-compact-game .status-card strong {
  font-size: 12px;
  line-height: 1.05;
}

body.pml-compact-game .topbar-actions {
  display: none;
}

body.pml-compact-game #cameraButton {
  min-height: 30px;
  padding: 0 8px;
  border-radius: 9px;
  font-size: 11px;
}

body.pml-compact-game .game-shell {
  grid-template-columns: minmax(0, 1fr) 56px;
  gap: 6px;
}

body.pml-compact-game .guide-card {
  display: none;
}

body.pml-compact-game .motion-panel {
  padding: 6px 5px;
  border-radius: 12px;
}

body.pml-compact-game .motion-slider {
  min-height: 124px;
}

body.pml-compact-game .timeline-card {
  padding: 5px 8px;
  border-radius: 12px;
}

body.pml-compact-game .timeline-head {
  display: none;
}

body.pml-compact-game #timelineCanvas {
  height: 42px;
}

body.pml-compact-game .sync-guide-card {
  width: min(760px, calc(100vw - 20px));
  padding: 12px;
  border-radius: 16px;
}

body.pml-compact-game .sync-guide-card h2,
body.pml-compact-game .overlay-card h2 {
  font-size: clamp(22px, 5.2vw, 30px);
}

body.pml-compact-game .sync-guide {
  height: clamp(150px, 44dvh, 250px);
}

body.pml-compact-game .sync-caption {
  right: 10px;
  bottom: 10px;
  left: 10px;
  max-width: none;
  padding: 9px 11px;
}

body.pml-compact-game .overlay-actions button,
body.pml-compact-game .result-actions button,
body.pml-compact-game .result-actions a {
  min-height: 42px;
  padding: 0 16px;
  font-size: 15px;
}

/* v89: immersive play mode for phone browsers and in-app browsers */
body.pml-game-immersive .bridge-app {
  grid-template-rows: minmax(0, 1fr) 44px;
  gap: 6px;
  height: var(--pml-app-height, 100dvh);
  min-height: var(--pml-app-height, 100dvh);
  padding:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
}

body.pml-game-immersive .topbar {
  position: fixed;
  z-index: 20;
  top: max(6px, env(safe-area-inset-top));
  right: max(6px, env(safe-area-inset-right));
  left: max(6px, env(safe-area-inset-left));
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  pointer-events: none;
}

body.pml-game-immersive .topbar-actions {
  display: none;
}

body.pml-game-immersive .status-card {
  min-height: 38px;
  max-width: 25vw;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 12px;
  pointer-events: auto;
}

body.pml-game-immersive .status-card.mode-card,
body.pml-game-immersive .status-card.compact {
  display: none;
}

body.pml-game-immersive .status-icon {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 14px;
}

body.pml-game-immersive .status-card small {
  font-size: 9px;
}

body.pml-game-immersive .status-card strong {
  font-size: clamp(12px, 2.1vw, 17px);
}

body.pml-game-immersive .game-shell {
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 6px;
  min-height: 0;
}

body.pml-game-immersive .guide-card {
  display: none;
}

body.pml-game-immersive .stage-card {
  border-radius: 18px;
}

body.pml-game-immersive .side-meter {
  gap: 4px;
  padding: 6px 5px;
  border-radius: 12px;
}

body.pml-game-immersive .meter-title,
body.pml-game-immersive .side-label,
body.pml-game-immersive .meter-help {
  display: none;
}

body.pml-game-immersive .motion-slider,
body.pml-game-immersive .meter-track {
  min-height: 120px;
}

body.pml-game-immersive .action-cue {
  top: 50px;
  min-width: min(360px, 54%);
  padding: 8px 12px;
  border-radius: 14px;
}

body.pml-game-immersive .action-cue strong {
  font-size: clamp(17px, 2.7vw, 24px);
}

body.pml-game-immersive .action-cue span {
  font-size: clamp(11px, 1.7vw, 14px);
}

body.pml-game-immersive .feedback-pill {
  bottom: 56px;
  min-width: min(330px, 46%);
  padding: 8px 12px;
  border-radius: 14px;
}

body.pml-game-immersive .feedback-pill strong {
  font-size: clamp(14px, 2.4vw, 19px);
}

body.pml-game-immersive .feedback-pill span {
  font-size: clamp(11px, 1.7vw, 14px);
}

body.pml-game-immersive .play-panel {
  right: max(10px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  padding: 6px 10px;
  border-radius: 14px;
}

body.pml-game-immersive .play-panel button {
  width: 34px;
  height: 34px;
}

body.pml-game-immersive .timeline-card {
  padding: 4px 8px;
  border-radius: 12px;
}

body.pml-game-immersive .timeline-card .meter-badge {
  display: none;
}

body.pml-game-immersive #timelineCanvas {
  height: 34px;
}

body.pml-game-immersive .overlay {
  padding:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
}

body.pml-game-immersive .result-card {
  max-height: calc(var(--pml-app-height, 100dvh) - 20px);
  overflow: auto;
}

@media (max-height: 430px) and (orientation: landscape) {
  body.pml-game-immersive .status-card:nth-child(3) {
    display: none;
  }

  body.pml-game-immersive .action-cue {
    top: 44px;
    max-width: 46vw;
  }

  body.pml-game-immersive .feedback-pill {
    display: none;
  }

  body.pml-game-immersive .timeline-card {
    display: none;
  }
}

/* v90: proportional stage scaling during active play */
:root {
  --pml-game-design-width: 1366px;
  --pml-game-design-height: 768px;
}

body.pml-game-proportional {
  width: 100%;
  height: var(--pml-app-height, 100dvh);
  min-height: var(--pml-app-height, 100dvh);
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 9%, rgba(255, 255, 255, 0.9), transparent 18%),
    radial-gradient(circle at 86% 13%, rgba(255, 255, 255, 0.82), transparent 16%),
    linear-gradient(145deg, #7fd5ff 0%, #2f92e7 46%, #d8f9ff 100%);
}

body.pml-game-proportional .bridge-app {
  position: fixed;
  top: 50%;
  left: 50%;
  width: var(--pml-game-design-width);
  height: var(--pml-game-design-height);
  min-height: 0;
  padding: 8px 12px 10px;
  transform: translate(-50%, -50%) scale(var(--pml-game-scale, 1));
  transform-origin: center center;
}
