/* Colors — bright, high contrast, and built for fingers on a tablet.
   Fourth in the set after ABC, 123 and Shapes, and shares their look. Here the
   colour itself is the content, so choices are big colour swatches. */

:root {
  --bg: #f2fbf6;
  --ink: #2b2b45;
  --muted: #6b6b8a;
  --card: #ffffff;
  --shadow: 0 10px 0 rgba(43, 43, 69, 0.16);
  --tile-shadow: 0 7px 0 rgba(43, 43, 69, 0.14);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Baloo 2", "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, #f8fffb, var(--bg) 60%);
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* --- Top bar --- */
#bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(12px, 3vw, 28px);
}

#stars {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 800;
  min-width: 4.5ch;
}

#tabs {
  display: flex;
  gap: 8px;
  margin-left: auto;
  background: rgba(43, 43, 69, 0.08);
  padding: 5px;
  border-radius: 999px;
}

.tab {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  padding: 10px 22px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  min-height: 48px;
}

.tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(43, 43, 69, 0.15);
}

.icon-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(43, 43, 69, 0.08);
  color: var(--ink);
  display: grid;
  place-items: center;
}

.icon-btn:active {
  transform: scale(0.92);
}

.pill {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  padding: 16px 30px;
  border-radius: 999px;
  background: #7ed957;
  color: var(--ink);
  box-shadow: 0 6px 0 #55b436;
  min-height: 60px;
}

.pill:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #55b436;
}

.pill.big {
  font-size: clamp(1.3rem, 5vw, 2rem);
  padding: 22px 60px;
}

#screen {
  padding: clamp(8px, 2vw, 20px) clamp(12px, 3vw, 28px) 48px;
}

/* --- Learn mode: the colour grid --- */
#grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(96px, 17vw, 150px), 1fr));
  gap: clamp(10px, 2vw, 18px);
  max-width: 1100px;
  margin: 0 auto;
}

.tile {
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  aspect-ratio: 1;
  border-radius: 22px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--card);
  box-shadow: var(--tile-shadow);
  transition: transform 120ms ease;
}

.tile:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 rgba(43, 43, 69, 0.14);
}

/* The colour itself fills most of the tile; the name sits on a white strip. */
.tile .swatch {
  width: 100%;
  height: 100%;
}

.tile .name {
  padding: 8px 4px;
  font-size: clamp(0.85rem, 2.2vw, 1.05rem);
  color: var(--ink);
  text-align: center;
}

/* --- Play mode --- */
#play {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

#prompt {
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 800;
  margin: clamp(8px, 3vh, 28px) 0 6px;
}

/* The object whose colour is being asked about, in an "object" round. */
#prompt-pic {
  font-size: clamp(4rem, 20vw, 9rem);
  line-height: 1.1;
  margin: 4px 0;
}

#replay {
  margin-bottom: clamp(10px, 3vh, 26px);
}

#choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(96px, 24vw, 190px), 1fr));
  gap: clamp(12px, 3vw, 24px);
  max-width: 760px;
  margin: 0 auto;
}

/* A choice IS a colour: the whole button is painted in it. */
.choice {
  border: 0;
  cursor: pointer;
  aspect-ratio: 1;
  border-radius: 28px;
  box-shadow: 0 9px 0 rgba(43, 43, 69, 0.2);
}

.choice:active {
  transform: translateY(6px);
  box-shadow: 0 3px 0 rgba(43, 43, 69, 0.2);
}

.choice.right {
  animation: pop 520ms ease;
}

.choice.wrong {
  animation: shake 420ms ease;
}

.choice[disabled] {
  cursor: default;
  opacity: 0.4;
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px); }
  45% { transform: translateX(12px); }
  70% { transform: translateX(-7px); }
}

/* --- Colour card --- */
#card {
  position: fixed;
  inset: 0;
  background: rgba(43, 43, 69, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

#card-inner {
  position: relative;
  background: var(--card);
  border-radius: 32px;
  padding: clamp(20px, 5vw, 40px);
  text-align: center;
  width: min(460px, 100%);
  box-shadow: var(--shadow);
  animation: pop 320ms ease;
}

#card-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
}

#card-swatch {
  width: clamp(140px, 45vw, 220px);
  height: clamp(140px, 45vw, 220px);
  border-radius: 28px;
  margin: 8px auto 14px;
  box-shadow: inset 0 0 0 1px rgba(43, 43, 69, 0.06);
}

#card-word {
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 800;
  margin-bottom: 18px;
}

#card-nav {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
}

/* --- Title screen --- */
#start {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 20%, #f8fffb, #c7f0d7 70%);
  text-align: center;
  padding: 20px;
}

#start h1 {
  font-size: clamp(4rem, 24vw, 10rem);
  margin: 0;
  line-height: 1;
  letter-spacing: 0.06em;
}

#start h1 span {
  display: inline-block;
  animation: bob 2.4s ease-in-out infinite;
}

#start h1 span:nth-child(2) { animation-delay: 0.2s; }
#start h1 span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-16px) rotate(3deg); }
}

#start p {
  font-size: clamp(1.1rem, 4vw, 1.6rem);
  color: var(--muted);
  margin: 10px 0 32px;
}

/* --- Confetti --- */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}

#confetti span {
  position: absolute;
  font-size: 1.8rem;
  animation: fall 1.5s linear forwards;
}

@keyframes fall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
