/* ============================================================
   Peekaboo Camera — big, warm, and wobbly for tiny humans
   ============================================================ */
:root {
  color-scheme: light;
  --sun-1: #ffe29a;
  --sun-2: #ffb703;
  --sky: #fff7e6;
  --ink: #4a3319;
  --ink-soft: #8a6b45;
  --card: #ffffff;
  --coral: #ef476f;
  --teal: #06d6a0;
  --blue: #219ebc;
  --radius: 28px;
  /* Native emoji fonts first; Noto Color Emoji web font guarantees the
     hands & animal friends render even where no system emoji font exists. */
  font-family: "Fredoka", "Comic Sans MS", system-ui,
    "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* CRITICAL: our .screen/.tap-pad/.reveal-overlay display rules must never
   defeat the hidden attribute — this is what makes screen switching work. */
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--sun-1), transparent 70%),
    var(--sky);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom));
  position: relative;
}

/* ---------- start screen ---------- */
.start-screen { justify-content: center; text-align: center; gap: 1.4rem; }

.floaties { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floaties span {
  position: absolute;
  left: var(--x);
  bottom: -3rem;
  font-size: 2.2rem;
  opacity: 0.85;
  animation: floatUp 11s linear infinite;
  animation-delay: var(--d);
  filter: drop-shadow(0 4px 6px rgba(74, 51, 25, 0.12));
}
@keyframes floatUp {
  0%   { transform: translateY(0) rotate(-8deg); opacity: 0; }
  8%   { opacity: 0.85; }
  92%  { opacity: 0.85; }
  100% { transform: translateY(-115dvh) rotate(10deg); opacity: 0; }
}

.logo {
  margin: 0;
  font-size: clamp(2.6rem, 11vw, 4.2rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-shadow: 0 3px 0 #fff, 0 8px 24px rgba(255, 183, 3, 0.45);
}
.logo-hands {
  display: block;
  font-size: 0.9em;
  text-shadow: none;
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-10px) rotate(4deg); }
}

.tagline {
  margin: 0;
  max-width: 26rem;
  font-size: 1.15rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.tagline strong { color: var(--coral); }

.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, var(--coral), #d63a60);
  border-radius: 999px;
  box-shadow: 0 6px 0 #b02a4c, 0 14px 28px rgba(239, 71, 111, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b02a4c, 0 8px 16px rgba(239, 71, 111, 0.3); }
.btn:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

.btn-play {
  font-size: 1.6rem;
  padding: 1rem 2.6rem;
  animation: heartbeat 2.8s ease-in-out infinite;
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  6%       { transform: scale(1.06); }
  12%      { transform: scale(1); }
}
.btn-small { font-size: 1.1rem; padding: 0.65rem 1.8rem; }

.how {
  list-style: none;
  display: flex;
  gap: 0.75rem;
  padding: 0;
  margin: 0.4rem 0 0;
  flex-wrap: wrap;
  justify-content: center;
}
.how li {
  background: var(--card);
  border-radius: 20px;
  padding: 0.8rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(74, 51, 25, 0.08), 0 10px 24px rgba(74, 51, 25, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 8.2rem;
}
.how li span { font-size: 1.7rem; }

.privacy {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  max-width: 24rem;
}

/* ---------- game screen ---------- */
.game-screen { justify-content: flex-start; gap: 1.1rem; }

.topbar {
  width: 100%;
  max-width: 30rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rounds {
  background: var(--card);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: 0 4px 0 rgba(74, 51, 25, 0.08);
}
#roundCount { display: inline-block; min-width: 1ch; }
#roundCount.pop { animation: pop 0.45s ease; }
@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.6) rotate(8deg); color: var(--coral); }
  100% { transform: scale(1); }
}

.topbar-btns { display: flex; gap: 0.5rem; }
.chip-btn {
  font: inherit;
  font-size: 1.25rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--card);
  box-shadow: 0 4px 0 rgba(74, 51, 25, 0.08);
  transition: transform 0.12s ease;
}
.chip-btn:active { transform: scale(0.92); }
.chip-btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.status-bubble {
  background: var(--card);
  border-radius: var(--radius);
  border-bottom-right-radius: 6px;
  padding: 0.9rem 1.4rem;
  font-size: clamp(1.2rem, 4.5vw, 1.5rem);
  font-weight: 700;
  text-align: center;
  max-width: 26rem;
  box-shadow: 0 6px 0 rgba(74, 51, 25, 0.08), 0 14px 30px rgba(74, 51, 25, 0.1);
}
.status-bubble.wiggle { animation: wiggle 0.7s ease; }
@keyframes wiggle {
  0%   { transform: rotate(0); }
  20%  { transform: rotate(-3deg) scale(1.04); }
  45%  { transform: rotate(3deg) scale(1.04); }
  70%  { transform: rotate(-2deg); }
  100% { transform: rotate(0); }
}

/* ---------- viewfinder ---------- */
.viewfinder {
  position: relative;
  width: min(78vw, 20rem);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: #2b2118;
  box-shadow: 0 18px 40px rgba(74, 51, 25, 0.28);
  flex-shrink: 0;
}
.viewfinder video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror — like looking in a mirror */
}
.viewfinder-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 8px solid var(--sun-2);
  pointer-events: none;
  transition: border-color 0.3s ease;
}
.viewfinder.is-covered .viewfinder-ring { border-color: var(--coral); }

/* friendly "camera is waking up" shimmer while we wait for the stream */
.viewfinder-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: #ffe9c2;
  font-weight: 600;
  font-size: 1rem;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, #4a3a28, #2b2118);
  pointer-events: none;
}
.viewfinder-loading .cam { font-size: 3rem; animation: bob 1.6s ease-in-out infinite; }
.viewfinder.is-live .viewfinder-loading { display: none; }

.hands-curtain { position: absolute; inset: 0; pointer-events: none; }
.hand {
  position: absolute;
  top: 50%;
  font-size: 9rem;
  line-height: 1;
  transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25));
}
.hand-left  { left: 50%;  transform: translate(-215%, -50%) rotate(-14deg); }
.hand-right { right: 50%; transform: translate(215%, -50%) scaleX(-1) rotate(-14deg); }
.viewfinder.is-covered .hand-left  { transform: translate(-78%, -50%) rotate(-6deg); }
.viewfinder.is-covered .hand-right { transform: translate(78%, -50%) scaleX(-1) rotate(-6deg); }

/* live "can I see you?" badge — instant detection feedback */
.see-pill {
  position: absolute;
  left: 50%;
  bottom: 9%;
  transform: translateX(-50%);
  background: rgba(6, 214, 160, 0.92);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  pointer-events: none;
  display: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: background 0.25s ease;
  z-index: 2;
}
.viewfinder.is-live .see-pill { display: block; }
.see-pill.is-hiding { background: rgba(239, 71, 111, 0.92); }

/* ---------- tap-pad fallback ---------- */
.tap-pad {
  font: inherit;
  width: min(78vw, 20rem);
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #fff;
  background: radial-gradient(circle at 35% 30%, var(--sun-2), #e8871e);
  box-shadow: 0 10px 0 #c76d10, 0 20px 44px rgba(232, 135, 30, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tap-pad-emoji { font-size: 6rem; line-height: 1; }
.tap-pad small { font-size: 1.2rem; font-weight: 700; }
.tap-pad.holding {
  transform: scale(0.94) translateY(6px);
  box-shadow: 0 4px 0 #c76d10, 0 12px 24px rgba(232, 135, 30, 0.35);
  background: radial-gradient(circle at 35% 30%, #7b5ea7, #4a3573);
}
.tap-pad:focus-visible { outline: 4px solid var(--blue); outline-offset: 4px; }

.game-hint {
  margin: 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 1rem;
  max-width: 24rem;
}

/* ---------- reveal overlay ---------- */
.reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, var(--reveal-bg-1, var(--sun-1)), var(--reveal-bg-2, var(--sun-2)));
  animation: overlayIn 0.25s ease;
  cursor: pointer;
}
.reveal-overlay[hidden] { display: none; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.reveal-card {
  text-align: center;
  animation: cardPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 1rem;
}
@keyframes cardPop {
  0%   { transform: scale(0.3) rotate(-8deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.reveal-word {
  font-size: clamp(2.4rem, 10vw, 3.6rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
  letter-spacing: -0.01em;
}
.reveal-emoji {
  font-size: clamp(7rem, 38vw, 12rem);
  line-height: 1.15;
  animation: emojiBounce 1.1s ease-in-out infinite;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.22));
}
@keyframes emojiBounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-16px) rotate(3deg); }
}
.reveal-name {
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti {
  position: absolute;
  top: -5%;
  display: block;
  animation-name: confettiFall;
  animation-timing-function: ease-in;
  animation-fill-mode: both;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg);      opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.9; }
}

/* ---------- help dialog ---------- */
.help-dialog {
  border: none;
  border-radius: var(--radius);
  max-width: min(92vw, 26rem);
  padding: 1.6rem 1.6rem 1.4rem;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(74, 51, 25, 0.3);
  font-family: inherit;
}
.help-dialog::backdrop { background: rgba(74, 51, 25, 0.45); }
.help-dialog h2 { margin: 0 0 0.8rem; font-size: 1.5rem; }
.help-dialog ol { margin: 0 0 1.2rem; padding-left: 1.3rem; line-height: 1.55; }
.help-dialog li { margin-bottom: 0.45rem; }
.help-dialog form { text-align: center; margin: 0; }

/* ---------- calm mode ---------- */
@media (prefers-reduced-motion: reduce) {
  .floaties span, .logo-hands, .btn-play, .reveal-emoji { animation: none; }
  .confetti { animation-duration: 0.01s !important; }
  .hand { transition-duration: 0.01s; }
}

@media (min-width: 640px) {
  .game-screen { gap: 1.4rem; padding-top: 2rem; }
  .viewfinder, .tap-pad { width: 22rem; }
}