/* One unit (--u) is 1% of the height of a 16:9 box fitted to the window, so
   every screen scales the same on any monitor. */
@property --angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 360deg;
}

:root {
  --ground: #eef2f8;
  --ink: #18223f;
  --orange: #f59e0b;
  --blue: #2a62d8;
  --sun: #ffd45c;
  --slate: #2b3454;
  --muted: #3a4466;
  --line: #c5cee0;
  --u: min(1vh, 0.5625vw);
  --emoji: 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ground);
  color: var(--ink);
  font-family: 'Andika', system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.scene {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.emoji,
.notes,
.song-note {
  font-family: var(--emoji);
  line-height: 1;
}

/* ---- Meet a letter ---- */
.row {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(7 * var(--u));
}

.card {
  width: calc(56 * var(--u));
  height: calc(56 * var(--u));
  border-radius: calc(7 * var(--u));
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(40 * var(--u));
  font-weight: 700;
  line-height: 1;
}

.bubble {
  position: relative;
  width: calc(56 * var(--u));
  height: calc(56 * var(--u));
  border-radius: 50%;
  background: var(--sun);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bubble .emoji {
  font-size: calc(32 * var(--u));
}

.notes {
  position: absolute;
  top: -2%;
  right: -6%;
  font-size: calc(12 * var(--u));
  animation: bob 1s ease-in-out infinite;
}

.pads {
  display: flex;
  gap: calc(4 * var(--u));
  margin-bottom: calc(6 * var(--u));
  visibility: hidden;
}

.pads.on {
  visibility: visible;
}

.pad {
  width: calc(36 * var(--u));
  height: calc(11 * var(--u));
  border-radius: calc(3 * var(--u));
  animation: pulse 1.4s ease-in-out infinite;
}

.pad-left {
  background: var(--orange);
}

.pad-right {
  background: var(--blue);
}

.pad.tapped,
.half.tapped {
  animation: squish 0.25s ease-out;
}

/* ---- Countdown before a video or song ---- */
.countdown {
  position: absolute;
  top: calc(4 * var(--u));
  right: calc(4 * var(--u));
  width: calc(17 * var(--u));
  height: calc(17 * var(--u));
  display: grid;
  place-items: center;
}

.countdown-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--ink) var(--angle), var(--line) 0);
  animation: drain var(--countdown-ms, 3000ms) linear forwards;
}

.countdown-number {
  position: relative;
  width: 76%;
  height: 76%;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  font-size: calc(8 * var(--u));
}

/* ---- Find a letter ---- */
.scene-find {
  flex-direction: row;
  align-items: stretch;
  gap: calc(2.5 * var(--u));
  padding: calc(3.5 * var(--u));
  box-sizing: border-box;
}

.half {
  position: relative;
  overflow: hidden;
  flex: 1;
  border-radius: calc(6 * var(--u));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}

/* Once a press counts, the cards pulse gently. */
.scene-find.ready .half:not(.faded):not(.found) .card {
  animation: pulse 1.4s ease-in-out infinite;
}

.half-left {
  background: var(--orange);
}

.half-right {
  background: var(--blue);
}

.half .card {
  width: calc(48 * var(--u));
  height: calc(48 * var(--u));
  font-size: calc(35 * var(--u));
}

.scene-find .half.faded {
  opacity: 0.22;
}

.half.found .card {
  animation: hop 0.5s ease-out 2;
}

/* ---- Video and song ---- */
.scene-media {
  padding: calc(3 * var(--u));
  box-sizing: border-box;
}

.media {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: calc(5 * var(--u));
  overflow: hidden;
  background: var(--slate);
}

.media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.badge {
  position: absolute;
  top: calc(3 * var(--u));
  right: calc(3 * var(--u));
  width: calc(17 * var(--u));
  height: calc(17 * var(--u));
  border-radius: calc(4 * var(--u));
  background: #fff;
  display: grid;
  place-items: center;
  font-size: calc(12 * var(--u));
  font-weight: 700;
  line-height: 1;
}

.dance {
  animation: dance 0.72s ease-in-out infinite;
}

.song-notes {
  display: flex;
  gap: calc(6 * var(--u));
  margin-bottom: calc(6 * var(--u));
  font-size: calc(9 * var(--u));
}

.song-note {
  animation: bob 1s ease-in-out infinite;
}

.song-note:nth-child(even) {
  animation-delay: 0.5s;
}

.song-notes.jump {
  animation: hop 0.4s ease-out;
}

/* ---- Hello, goodbye, rest ---- */
.wave .emoji {
  animation: wave 1s ease-in-out infinite;
  transform-origin: 70% 80%;
}

.scene-rest {
  background: #101832;
}

.rest-moon {
  font-size: calc(30 * var(--u));
}

.pop {
  animation: pop 0.4s ease-out;
}

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -4%;
  width: calc(1.6 * var(--u));
  height: calc(2.6 * var(--u));
  border-radius: calc(0.4 * var(--u));
  animation: fall 2s cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}

@keyframes fall {
  to { transform: translate(var(--drift, 0), 110vh) rotate(var(--spin, 720deg)); }
}

@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-12%) rotate(6deg); }
}
@keyframes squish {
  0% { transform: scale(1); }
  40% { transform: scale(0.92); }
  100% { transform: scale(1); }
}
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8%); }
}
@keyframes dance {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg) translateY(-3%); }
}
@keyframes wave {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(14deg); }
}
@keyframes drain {
  to { --angle: 0deg; }
}

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

/* ---- Grown-up screen and review page ---- */
#grownups {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: auto;
  background: var(--ground);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  user-select: text;
  -webkit-user-select: text;
}

#grownups,
#grownups *,
.review,
.review * {
  cursor: auto;
}

#grownups button,
#grownups a,
.review button,
.review a {
  cursor: pointer;
}

.gu {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.gu h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 600;
}

.gu h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
}

.gu p {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
  color: var(--muted);
}

.gu-letters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.gu-letter {
  box-sizing: border-box;
  min-height: 150px;
  padding: 14px 10px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.gu-letter.gu-later,
.gu-letter.gu-next {
  background: transparent;
  border: 2px dashed #8a96b4;
}

button.gu-letter[aria-pressed='true'] {
  border: 2px solid var(--ink);
}

.gu-glyph {
  font-family: 'Andika', system-ui, sans-serif;
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
}

.gu-status {
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--muted);
}

.gu-known .gu-status {
  background: var(--ink);
  color: #fff;
}

.gu-learning .gu-status {
  background: var(--sun);
  color: var(--ink);
}

.gu-dots {
  display: grid;
  grid-template-columns: repeat(5, 12px);
  gap: 6px;
}

.gu-dot {
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.gu-dot.right {
  background: var(--ink);
}

.gu-dot.miss {
  border: 2px solid #5f6b8c;
}

.gu-dot.empty {
  border: 2px dotted var(--line);
}

.gu-settings {
  display: grid;
  grid-template-columns: minmax(120px, 170px) minmax(0, 1fr);
  gap: 12px 20px;
  align-items: center;
  font-size: 16px;
}

.gu-label {
  font-weight: 500;
}

.gu-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.gu-option,
.gu-action,
.gu-link {
  box-sizing: border-box;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.gu-option[aria-pressed='true'],
.gu-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.gu-option:focus-visible,
.gu-action:focus-visible,
.gu-link:focus-visible,
button.gu-letter:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.gu-note {
  color: var(--muted);
  font-size: 15px;
}

.gu-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

@media (max-width: 560px) {
  .gu-settings {
    grid-template-columns: minmax(0, 1fr);
  }
}

.review {
  position: static;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 60px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  user-select: text;
  -webkit-user-select: text;
}

body.review-page {
  overflow: auto;
  height: auto;
}

.review h1 { font-size: 26px; font-weight: 600; margin: 0 0 8px; }
.review h2 { font-size: 18px; font-weight: 600; margin: 32px 0 12px; }
.review p { font-size: 16px; line-height: 1.45; color: var(--muted); margin: 0 0 12px; }
.review-lines { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.review-line { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 8px 12px; font-size: 15px; }
.review-line button { min-width: 44px; min-height: 44px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-size: 16px; }
.review-line .missing { color: #8a3b12; font-size: 13px; }
.review-clips { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.review-clip { background: #fff; border-radius: 14px; padding: 12px; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.review-clip video { width: 100%; border-radius: 10px; background: var(--slate); display: block; margin-bottom: 8px; }
.review-clip strong { font-size: 16px; }

/* Small corner button for grown-ups: the only thing in the game the mouse can click. */
#grownup-button {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 5;
  width: 64px;
  height: 64px;
  margin: 6px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: 0; /* invisible until the mouse is over the corner */
  transition: opacity 0.15s;
}

#grownup-button:hover,
#grownup-button:focus-visible {
  opacity: 1;
}
