:root {
  color: #273047;
  background: #fff7df;
  font-family: Inter, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { margin: 0; }

.app-shell { max-width: 1180px; margin: 0 auto; padding: 24px; }

.hero {
  align-items: center;
  background: linear-gradient(135deg, #ffe88a, #ffb7d5 48%, #9de7ff);
  border: 5px solid #273047;
  border-radius: 28px;
  box-shadow: 8px 8px 0 #273047;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 18px 26px;
}

.eyebrow { font-weight: 800; letter-spacing: 0.08em; margin: 0 0 4px; text-transform: uppercase; }

h1 { font-size: clamp(1.8rem, 4.5vw, 3.2rem); line-height: 0.95; margin: 0; }

.hero-buttons { display: flex; flex-wrap: wrap; gap: 10px; }

.primary,
.avatar-choice,
.side-button {
  border: 3px solid #273047;
  border-radius: 999px;
  box-shadow: 4px 4px 0 #273047;
  cursor: pointer;
  font-weight: 800;
  padding: 12px 18px;
}

.primary { background: #7cffb2; font-size: 1.1rem; }
.primary.play { background: #ffd166; }
.primary:disabled, .side-button:disabled { cursor: not-allowed; opacity: 0.6; }

.play-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 230px;
  margin-top: 18px;
}

.panel {
  background: #fffdf6;
  border: 4px solid #273047;
  border-radius: 24px;
  box-shadow: 7px 7px 0 #273047;
  padding: 18px;
}

/* Big camera play area, kid-drawn layout. */
.camera-stage { overflow: hidden; padding: 0; position: relative; }
.camera-stage video { display: none; }
#motion-canvas { background: #dff6ff; display: block; height: auto; min-height: 320px; width: 100%; }

.overlay-status {
  background: rgba(255, 253, 246, 0.92);
  border-radius: 14px;
  bottom: 10px;
  left: 12px;
  margin: 0;
  max-width: 70%;
  padding: 8px 14px;
  position: absolute;
}

/* The robot coach floats over the camera view. */
.coach-card {
  background: linear-gradient(180deg, #dff6ff 0%, #f2e6ff 62%, #ffe9c0 100%);
  border: 4px solid #273047;
  border-radius: 20px;
  box-shadow: 5px 5px 0 rgba(39, 48, 71, 0.5);
  height: 220px;
  left: 12px;
  overflow: hidden;
  position: absolute;
  top: 12px;
  width: 190px;
  z-index: 3;
}

.avatar-stage canvas { display: block; height: 100%; width: 100%; }

/* Game HUD */
.hud { pointer-events: none; }
.hidden { display: none !important; }

.hud-chip {
  background: #ffd166;
  border: 3px solid #273047;
  border-radius: 999px;
  font-weight: 800;
  padding: 6px 14px;
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 3;
}

.hud-timer {
  background: #fffdf6;
  border: 4px solid #273047;
  border-radius: 999px;
  font-size: 2rem;
  font-weight: 900;
  height: 64px;
  line-height: 58px;
  position: absolute;
  right: 12px;
  text-align: center;
  top: 58px;
  width: 64px;
  z-index: 3;
}

.hud-timer.urgent { background: #ff8fa5; }

.hud-pose {
  background: rgba(39, 48, 71, 0.85);
  border-radius: 999px;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  left: 50%;
  padding: 8px 22px;
  position: absolute;
  top: 12px;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 2;
}

.hud-meter {
  background: rgba(255, 253, 246, 0.9);
  border: 3px solid #273047;
  border-radius: 999px;
  bottom: 52px;
  height: 20px;
  left: 12%;
  overflow: hidden;
  position: absolute;
  width: 76%;
  z-index: 2;
}

.match-fill {
  background: linear-gradient(90deg, #ffd166, #7cffb2);
  height: 100%;
  transition: width 120ms linear;
  width: 0%;
}

.game-message {
  background: rgba(255, 253, 246, 0.95);
  border: 4px solid #273047;
  border-radius: 22px;
  box-shadow: 6px 6px 0 rgba(39, 48, 71, 0.4);
  font-size: 1.6rem;
  font-weight: 900;
  left: 50%;
  padding: 18px 30px;
  position: absolute;
  text-align: center;
  top: 45%;
  transform: translate(-50%, -50%);
  z-index: 4;
}

.confetti { inset: 0; overflow: hidden; pointer-events: none; position: absolute; z-index: 5; }
.confetti span {
  animation: confetti-fall 1.4s ease-in forwards;
  font-size: 1.6rem;
  position: absolute;
  top: -10%;
}

@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translateY(420px) rotate(300deg) scale(1.4); }
}

/* Sidebar, kid-drawn: back / how to play / points / coins / versions. */
.sidebar { display: flex; flex-direction: column; gap: 12px; }
.sidebar h2 { font-size: 1.05rem; margin: 6px 0 0; }
.sidebar-row { display: flex; gap: 8px; }

.side-button { background: #9de7ff; flex: 1; font-size: 0.85rem; padding: 8px 10px; }

.score-cards { display: flex; gap: 8px; }
.score-card {
  background: #fff;
  border: 3px solid #273047;
  border-radius: 16px;
  box-shadow: 3px 3px 0 #273047;
  display: flex;
  flex: 1;
  flex-direction: column;
  font-size: 1.2rem;
  font-weight: 900;
  gap: 2px;
  padding: 8px 10px;
}
.score-label { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.06em; opacity: 0.7; text-transform: uppercase; }

.avatar-picker { display: flex; flex-direction: column; gap: 8px; }
.avatar-choice { background: white; box-shadow: 3px 3px 0 #273047; font-size: 0.9rem; padding: 8px 12px; text-align: left; }
.avatar-choice.selected { background: #9de7ff; }

.status { font-weight: 700; }

.robot-panel { margin-top: 18px; }
.robot-panel h2 { margin-top: 0; }
pre { background: #1e293b; border-radius: 18px; color: #b7ffcc; overflow: auto; padding: 16px; }

/* How to play dialog */
.howto {
  align-items: center;
  background: rgba(39, 48, 71, 0.55);
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 20;
}
.howto-box {
  background: #fffdf6;
  border: 5px solid #273047;
  border-radius: 26px;
  box-shadow: 8px 8px 0 #273047;
  max-width: 420px;
  padding: 22px 28px;
}
.howto-box ol { font-size: 1.05rem; font-weight: 600; line-height: 1.5; padding-left: 22px; }

/* Small screens (portrait phones): sidebar drops below the camera. */
@media (max-width: 700px) {
  .app-shell { padding: 12px; }
  .hero { flex-direction: column; padding: 16px; text-align: center; }
  .play-grid { gap: 12px; grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .sidebar-row, .score-cards { flex: 1 1 100%; }
  .avatar-picker { flex-direction: row; flex-wrap: wrap; }
  .coach-card { height: 150px; width: 130px; }
}

/* Phones held sideways: camera stays big, sidebar narrow on the right. */
@media (orientation: landscape) and (max-height: 560px) {
  .app-shell { padding: 10px; }
  .hero { border-width: 3px; box-shadow: 5px 5px 0 #273047; gap: 12px; padding: 10px 16px; }
  h1 { font-size: 1.4rem; }
  .primary { font-size: 0.9rem; padding: 8px 14px; }
  .play-grid { gap: 10px; grid-template-columns: minmax(0, 1fr) 180px; margin-top: 10px; }
  .panel { border-width: 3px; box-shadow: 5px 5px 0 #273047; }
  .sidebar { gap: 8px; padding: 12px; }
  .coach-card { height: 150px; width: 130px; }
  .hud-timer { font-size: 1.5rem; height: 52px; line-height: 46px; width: 52px; }
  .avatar-choice { font-size: 0.78rem; padding: 6px 10px; }
}
