/* game-core.css — shared look for the byondthewords hand-tracking games.
 * Matches Scoop Shop: same page background, header, 1480:880 game screen, buttons and HUD.
 */
:root {
  --ink: #221B3F;
  --paper: #FAF6F0;
  --indigo-deep: #201838;
  --coral: #FF6F5E;
  --yellow: #FFC93C;
  --mint: #22B8A0;
  --sky: #EAF3FF;
  /* 1 unit = 1px of the 1480-wide design. Only use inside .game-container (it is the size container). */
  --u: calc(100cqw / 1480);
}
* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 50% 30%, #FFFDF9 0%, #F5ECE0 100%);
  color: var(--ink);
  font-family: 'Nunito', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 10px;
  position: relative;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Top-right controls (pause + sound) */
.top-controls {
  display: flex;
  gap: 8px;
}
.sound-btn {
  font-family: 'Baloo 2', sans-serif;
  font-size: clamp(12px, 2.4vw, 16px);
  font-weight: 800;
  background: #FFF;
  border: 2px solid var(--indigo-deep);
  color: var(--indigo-deep);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(34, 27, 63, 0.1);
  transition: transform 0.15s ease, background 0.15s ease;
}
.sound-btn:hover { transform: translateY(-2px); background: var(--paper); }

.bg-decor {
  position: absolute;
  border-radius: 50%;
  opacity: 0.35;
  filter: blur(2px);
  z-index: 0;
  pointer-events: none;
}
.bg-1 { width: 140px; height: 140px; background: #FF8DA1; top: 2%; left: 2%; }
.bg-2 { width: 180px; height: 180px; background: #72EFDD; bottom: 2%; right: 2%; }
.bg-3 { width: 110px; height: 110px; background: #FFC93C; bottom: 4%; left: 3%; }
.bg-4 { width: 130px; height: 130px; background: #B79CFF; top: 3%; right: 2%; }
@media (max-width: 700px) { .bg-decor { display: none; } }

.header-bar {
  width: min(96vw, calc(88vh * 1.6818), 1480px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  z-index: 1;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--indigo-deep);
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: clamp(13px, 2.2vw, 18px);
  background: #FFF;
  padding: 6px 16px;
  border-radius: 999px;
  border: 2px solid var(--indigo-deep);
  box-shadow: 0 4px 12px rgba(34, 27, 63, 0.08);
  transition: transform .15s ease, box-shadow .15s ease;
}
.back-link:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(34, 27, 63, 0.15); }
.header-bar h2 {
  font-family: 'Baloo 2', sans-serif;
  color: var(--indigo-deep);
  margin: 0;
  font-size: clamp(18px, 3vw, 28px);
}

/* The game screen: always 1480:880, scales to any window */
.game-container {
  position: relative;
  width: min(96vw, calc(88vh * 1.6818), 1480px);
  aspect-ratio: 1480 / 880;
  container-type: inline-size;
  background: var(--indigo-deep);
  border-radius: clamp(14px, 2.5vw, 32px);
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(34, 27, 63, 0.28);
  border: 5px solid #FFF;
  z-index: 1;
  touch-action: none;
}
#webcam { display: none; }
#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
}

/* HUD: same dark rounded boxes Scoop Shop draws on its canvas */
.hud-bar {
  position: absolute;
  top: calc(var(--u) * 24);
  left: calc(var(--u) * 24);
  right: calc(var(--u) * 24);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(var(--u) * 12);
  z-index: 20;
  pointer-events: none;
}
.hud-badge {
  background: rgba(32, 24, 56, 0.85);
  border-radius: calc(var(--u) * 16);
  padding: calc(var(--u) * 10) calc(var(--u) * 20);
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: calc(var(--u) * 26);
  line-height: 1.2;
  color: #72EFDD;
  white-space: nowrap;
}
.hud-badge span { color: var(--yellow); }

.progress {
  position: absolute;
  top: calc(var(--u) * 100);
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(var(--u) * 560), 70%);
  height: calc(var(--u) * 16);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.18);
  border: calc(var(--u) * 3) solid #FFF;
  overflow: hidden;
  z-index: 20;
  pointer-events: none;
}
.progress > div { height: 100%; width: 0; background: var(--yellow); transition: width 0.3s ease; }

.instruction-banner {
  position: absolute;
  top: calc(var(--u) * 100);
  left: 50%;
  transform: translateX(-50%);
  max-width: 94%;
  text-align: center;
  z-index: 20;
  background: rgba(32, 24, 56, 0.85);
  color: #FFF;
  padding: calc(var(--u) * 8) calc(var(--u) * 24);
  border-radius: 999px;
  font-family: 'Baloo 2', sans-serif;
  font-size: calc(var(--u) * 24);
  font-weight: 700;
  pointer-events: none;
}

/* Message such as "Camera not available" */
.camera-banner {
  position: absolute;
  bottom: calc(var(--u) * 24);
  left: 50%;
  transform: translateX(-50%);
  max-width: 90%;
  text-align: center;
  z-index: 60;
  background: #FFF;
  color: var(--indigo-deep);
  border: 2px solid var(--indigo-deep);
  padding: calc(var(--u) * 10) calc(var(--u) * 24);
  border-radius: calc(var(--u) * 20);
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: max(12px, calc(var(--u) * 22));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  display: none;
}
.camera-banner.show { display: block; }

/* Start / paused / fallback overlays (same look as Scoop Shop's start overlay) */
.card-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(32, 24, 56, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  color: #FFF;
  overflow-y: auto;
  touch-action: pan-y;
}
#pauseScreen { z-index: 40; }
.card-overlay h1 {
  font-family: 'Baloo 2', sans-serif;
  font-size: clamp(26px, calc(var(--u) * 60), 60px);
  font-weight: 800;
  color: #FFF;
  margin: 0 0 10px 0;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.card-overlay p {
  font-size: clamp(14px, calc(var(--u) * 20), 20px);
  color: #D1CBEE;
  margin: 0 0 20px 0;
  max-width: 520px;
  line-height: 1.5;
}
.instructions-box {
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  padding: 12px 20px;
  margin-bottom: 18px;
  max-width: 580px;
  text-align: left;
}
.instructions-box h3 {
  font-family: 'Baloo 2', sans-serif;
  font-size: clamp(15px, calc(var(--u) * 22), 22px);
  color: var(--yellow);
  margin: 0 0 6px 0;
}
.instructions-box ul { list-style: none; margin: 0; padding: 0; font-size: clamp(12px, calc(var(--u) * 17), 17px); line-height: 1.5; color: #E8E4FA; }
.instructions-box li { margin-bottom: 5px; display: flex; align-items: flex-start; gap: 8px; }
.stars { font-size: clamp(28px, calc(var(--u) * 44), 44px); letter-spacing: 6px; margin-bottom: 10px; }
.best-line {
  color: var(--yellow);
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: clamp(14px, calc(var(--u) * 20), 20px);
  min-height: 1.4em;
  margin-bottom: 8px;
}
.privacy-note { font-size: clamp(11px, calc(var(--u) * 14), 14px) !important; opacity: 0.75; max-width: 460px; margin: 14px 0 0 0 !important; line-height: 1.4; }
.hint-line { font-size: clamp(11px, calc(var(--u) * 14), 14px) !important; opacity: 0.65; margin: 8px 0 0 0 !important; }
.modal-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.btn-action {
  font-family: 'Baloo 2', sans-serif;
  font-size: clamp(16px, calc(var(--u) * 26), 26px);
  font-weight: 800;
  color: #FFF;
  background: var(--coral);
  border: none;
  padding: clamp(10px, calc(var(--u) * 18), 18px) clamp(24px, calc(var(--u) * 48), 48px);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(255, 111, 94, 0.5);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.btn-action:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 14px 30px rgba(255, 111, 94, 0.7); background: #FF5845; }
.btn-action.secondary { background: #FFF; color: var(--indigo-deep); box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25); }
.btn-action.secondary:hover { background: var(--paper); }
.btn-action:focus-visible, .sound-btn:focus-visible, .back-link:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 3px;
}

/* Hand / pointer cursor */
.hand-pointer {
  position: absolute;
  width: calc(var(--u) * 42);
  height: calc(var(--u) * 42);
  border-radius: 50%;
  border: 3px solid #FFF;
  background: rgba(255, 201, 60, 0.85);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 0 18px rgba(255, 201, 60, 0.9);
  display: none;
}
.hand-pointer.pinched {
  background: rgba(34, 184, 160, 0.95);
  border-color: #FFC93C;
  transform: translate(-50%, -50%) scale(1.3);
}

@media (max-width: 480px) {
  body { padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
