/* Viv's Games — shared look & feel.
   Built for small fingers: nothing tappable is under ~72px, nothing depends
   on reading, and the whole page is locked against zoom/scroll/selection. */

:root {
  --red:    #ff4d6d;
  --orange: #ff8c42;
  --yellow: #ffc233;
  --green:  #5ac35a;
  --teal:   #2ec4b6;
  --blue:   #4cc9f0;
  --purple: #7c5cff;
  --pink:   #e163c9;

  --ink:      #2b2350;
  --ink-soft: #6b628f;
  --card:     #ffffff;
  --shadow:   0 8px 0 rgba(43,35,80,.16), 0 14px 30px rgba(43,35,80,.14);
  --shadow-sm:0 5px 0 rgba(43,35,80,.14), 0 8px 18px rgba(43,35,80,.12);

  --pad: max(12px, env(safe-area-inset-left));
  --font: ui-rounded, "SF Pro Rounded", "Baloo 2", system-ui, -apple-system,
          "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font);
  color: var(--ink);
}

body {
  background: linear-gradient(170deg, #b8ecff 0%, #d9f0ff 42%, #fff3d6 100%);
  background-attachment: fixed;
}

/* Soft floating blobs so the background never feels flat. */
body::before, body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(4px);
  opacity: .5;
  pointer-events: none;
  z-index: 0;
}
body::before { width: 46vmin; height: 46vmin; background: #ffe6a7; top: -14vmin; right: -12vmin; }
body::after  { width: 38vmin; height: 38vmin; background: #cdf5ee; bottom: -14vmin; left: -10vmin; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* ------------------------------------------------------------ layout --- */
.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 8px) var(--pad)
           calc(env(safe-area-inset-bottom) + 8px) var(--pad);
}
@supports (height: 100dvh) { .app { height: 100dvh; } }

/* ------------------------------------------------------------ topbar --- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
}
.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: clamp(16px, 4.2vmin, 34px);
  font-weight: 800;
  letter-spacing: .3px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255,255,255,.85);
}

.round-btn {
  width: 64px; height: 64px;
  flex: 0 0 64px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
  font-size: 30px; line-height: 1;
  transition: transform .12s ease;
}
.round-btn:active { transform: translateY(4px) scale(.95); box-shadow: 0 2px 0 rgba(43,35,80,.14); }
.round-btn[hidden] { display: none; }

.star-count {
  flex: 0 0 auto;
  min-width: 64px; height: 64px;
  padding: 0 16px;
  border-radius: 32px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: clamp(18px, 3.4vmin, 26px);
  font-weight: 800;
}
.star-count .pulse { animation: pop-in .45s ease; }

/* -------------------------------------------------------------- stage --- */
.stage {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.4vmin, 24px);
}

/* The spoken instruction, echoed visually as a picture/letter, never as
   text a pre-reader would have to decode. */
.prompt {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.5vmin, 20px);
  padding: clamp(8px, 1.8vmin, 16px) clamp(16px, 3.4vmin, 30px);
  background: rgba(255,255,255,.82);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-size: clamp(20px, 4vmin, 32px);
  font-weight: 800;
}
.prompt .big {
  font-size: clamp(38px, 9vmin, 84px);
  line-height: 1;
  font-weight: 900;
}

/* ------------------------------------------------------------- tiles --- */
.tile {
  position: relative;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  transition: transform .14s cubic-bezier(.34,1.56,.64,1), box-shadow .14s ease;
  min-width: 76px; min-height: 76px;
}
.tile:active { transform: translateY(5px) scale(.96); box-shadow: 0 3px 0 rgba(43,35,80,.16); }
.tile.letter { font-size: clamp(38px, 11vmin, 92px); }

/* ---------------------------------------------------------- feedback --- */
@keyframes wobble {
  0%,100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-9px) rotate(-5deg); }
  40% { transform: translateX(9px) rotate(5deg); }
  60% { transform: translateX(-6px) rotate(-3deg); }
  80% { transform: translateX(6px) rotate(3deg); }
}
.wobble { animation: wobble .5s ease; }

@keyframes pop-in {
  0% { transform: scale(.3); opacity: 0; }
  70% { transform: scale(1.14); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.pop-in { animation: pop-in .4s cubic-bezier(.34,1.56,.64,1) both; }

@keyframes cheer {
  0% { transform: scale(1); }
  35% { transform: scale(1.35) rotate(-6deg); }
  70% { transform: scale(1.15) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}
.cheer { animation: cheer .6s ease; }

@keyframes glow-pulse {
  0%,100% { box-shadow: var(--shadow), 0 0 0 0 rgba(255,194,51,.85); }
  50%     { box-shadow: var(--shadow), 0 0 0 16px rgba(255,194,51,0); }
}
.hint { animation: glow-pulse 1.3s ease infinite; }

@keyframes float-up {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-90px) scale(1.7); opacity: 0; }
}
.floater {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  font-size: 54px;
  animation: float-up .9s ease-out forwards;
}

.viv-confetti {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

/* ------------------------------------------------------------ overlay --- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3.5vmin, 34px);
  padding: 24px;
  text-align: center;
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(6px);
  animation: pop-in .35s ease both;
}
.overlay[hidden] { display: none; }
.overlay .title {
  font-size: clamp(30px, 7.5vmin, 66px);
  font-weight: 900;
  color: var(--ink);
}
.overlay .subtitle {
  font-size: clamp(18px, 3.6vmin, 28px);
  color: var(--ink-soft);
  font-weight: 700;
}
.overlay .art { font-size: clamp(70px, 18vmin, 170px); line-height: 1; }

.big-btn {
  padding: clamp(16px, 3vmin, 26px) clamp(30px, 6vmin, 56px);
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: clamp(22px, 4.4vmin, 36px);
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(0,0,0,.18), 0 12px 24px rgba(43,35,80,.2);
  display: inline-flex; align-items: center; gap: 12px;
  transition: transform .12s ease;
  min-height: 76px;
}
.big-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.big-btn.alt { background: var(--purple); }
.big-btn.ghost { background: var(--card); color: var(--ink); }

.btn-row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }

/* Row of stars earned, drawn big for the reward screen. */
.star-row { display: flex; gap: 10px; font-size: clamp(34px, 8vmin, 66px); }
.star-row span { animation: pop-in .45s cubic-bezier(.34,1.56,.64,1) both; }

/* ------------------------------------------------------ parent panel --- */
.parent-panel {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(43,35,80,.55);
  padding: 20px;
}
.parent-panel[hidden] { display: none; }
.parent-card {
  background: #fff;
  border-radius: 26px;
  padding: 26px;
  width: min(440px, 100%);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.parent-card h2 { margin: 0; font-size: 24px; }
.parent-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; font-size: 18px; font-weight: 700;
}
.parent-row button {
  padding: 12px 20px; border-radius: 14px; background: #eef0ff;
  font-weight: 800; font-size: 17px; min-height: 52px;
}
.parent-row button.on  { background: var(--green); color: #fff; }
.parent-row button.danger { background: #ffe0e6; color: #c1123c; }
.parent-note { font-size: 14px; color: var(--ink-soft); line-height: 1.5; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
