@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&display=swap');

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Fredoka', 'Comic Sans MS', sans-serif;
  background: linear-gradient(160deg, #fdf6e3 0%, #ffe9f0 100%);
  color: #3a2e4f;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
}

h1 {
  font-size: clamp(2rem, 7vw, 3.4rem);
  margin: 0.4em 0 0.1em;
  text-align: center;
}

.subtitle { font-size: 1.2rem; opacity: 0.7; margin: 0 0 1em; text-align: center; }

/* ── Home page cards ───────────────────────────────── */
.menu {
  display: grid;
  gap: 22px;
  width: min(94vw, 560px);
  padding: 10px 0 40px;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 26px;
  border-radius: 28px;
  text-decoration: none;
  color: white;
  box-shadow: 0 8px 0 rgba(0,0,0,0.18);
  transition: transform 0.1s;
}
.game-card:active { transform: translateY(5px); box-shadow: 0 3px 0 rgba(0,0,0,0.18); }
.game-card .emoji { font-size: 3.4rem; }
.game-card .label { display: flex; flex-direction: column; }
.game-card .title { font-size: 1.7rem; font-weight: 700; }
.game-card .desc { font-size: 1rem; opacity: 0.92; }

.card-blocks  { background: linear-gradient(135deg, #ff5757, #ffb302); }
.card-ocean   { background: linear-gradient(135deg, #00b4d8, #0353a4); }
.card-woods   { background: linear-gradient(135deg, #6a994e, #386641); }

/* ── Game pages ────────────────────────────────────── */
.topbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
}
.home-btn {
  font-family: inherit;
  font-size: 1.3rem;
  text-decoration: none;
  background: white;
  border: none;
  border-radius: 999px;
  padding: 8px 20px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
  color: #3a2e4f;
  cursor: pointer;
}
.stars { font-size: 1.6rem; letter-spacing: 3px; min-height: 1.6em; }

.question {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 600;
  text-align: center;
  margin: 8px 16px;
  min-height: 1.4em;
}

.stage {
  width: min(94vw, 640px);
  min-height: 270px;
  border-radius: 28px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 18px;
  margin-bottom: 18px;
}

.answers {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  padding-bottom: 40px;
}
.answer-btn {
  font-family: inherit;
  font-size: 2.4rem;
  font-weight: 700;
  width: 92px;
  height: 92px;
  border: none;
  border-radius: 26px;
  background: white;
  color: #3a2e4f;
  box-shadow: 0 7px 0 rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.1s;
}
.answer-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(0,0,0,0.15); }
.answer-btn.correct { background: #80ed99; }
.answer-btn.wrong   { background: #ffadad; animation: shake 0.4s; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ── Numberblocks ──────────────────────────────────── */
.numberblock {
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  animation: bounce-in 0.5s;
}
.block {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  border: 3px solid rgba(0,0,0,0.25);
  position: relative;
}
.block.face::before {
  content: '';
  position: absolute;
  top: 16px; left: 12px;
  width: 10px; height: 14px;
  background: #222;
  border-radius: 50%;
  box-shadow: 28px 0 0 #222;
}
.block.face::after {
  content: '';
  position: absolute;
  bottom: 12px; left: 50%;
  transform: translateX(-50%);
  width: 22px; height: 10px;
  border-bottom: 4px solid #222;
  border-radius: 0 0 22px 22px;
}

/* ── Octonauts ocean ───────────────────────────────── */
.stage.ocean {
  width: min(96vw, 920px);
  height: clamp(340px, 58vh, 560px);
  background: linear-gradient(180deg, #90e0ef 0%, #00a6d6 35%, #0077b6 75%, #02507a 100%);
  overflow: hidden;
  position: relative;
}
/* Sunlight rays from the surface. */
.stage.ocean::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    105deg,
    transparent 0 60px,
    rgba(255, 255, 255, 0.09) 60px 90px,
    transparent 90px 170px
  );
  pointer-events: none;
}
/* Sandy floor. */
.stage.ocean::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 13%;
  background: linear-gradient(180deg, #e9d8a6 0%, #d4b483 100%);
  border-radius: 50% 50% 0 0 / 30px 30px 0 0;
  pointer-events: none;
}
.creature {
  position: absolute;
  font-size: 3.8rem;
  animation: floaty 3s ease-in-out infinite;
  cursor: pointer;
  z-index: 5;
}
.creature img {
  width: clamp(80px, 12vw, 116px);
  height: clamp(80px, 12vw, 116px);
}
.creature.counted { filter: drop-shadow(0 0 10px gold); }
@keyframes floaty {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.bubble {
  position: absolute;
  bottom: -20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.55);
  animation: rise linear infinite;
}
@keyframes rise {
  to { transform: translateY(-620px); opacity: 0; }
}
.seaweed {
  position: absolute;
  bottom: 4%;
  width: 12px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #57cc99 0%, #2d6a4f 100%);
  transform-origin: bottom center;
  animation: sway ease-in-out infinite alternate;
  z-index: 2;
}
@keyframes sway {
  from { transform: rotate(-9deg); }
  to   { transform: rotate(9deg); }
}
.scenery {
  position: absolute;
  bottom: 2%;
  font-size: 2.2rem;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25));
}

/* ── Gruffalo spelling ─────────────────────────────── */
.stage.woods {
  background: linear-gradient(180deg, #d8f3dc 0%, #95d5b2 100%);
  flex-direction: column;
  gap: 20px;
}
.word-emoji { font-size: 4.6rem; animation: bounce-in 0.5s; }
.slots, .letter-bank {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.slot {
  width: 58px; height: 58px;
  border-radius: 14px;
  background: rgba(255,255,255,0.55);
  border: 3px dashed #386641;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #1b4332;
}
.slot.filled { border-style: solid; background: white; animation: bounce-in 0.3s; }
.letter-tile {
  font-family: inherit;
  width: 62px; height: 62px;
  font-size: 2rem;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  background: #ffb703;
  color: #5a3e00;
  box-shadow: 0 6px 0 rgba(0,0,0,0.18);
  cursor: pointer;
  transition: transform 0.1s;
}
.letter-tile:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.18); }
.letter-tile.used { opacity: 0; pointer-events: none; }
.letter-tile.wrong { background: #ffadad; animation: shake 0.4s; }

@keyframes bounce-in {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Celebration ───────────────────────────────────── */
.confetti-bit {
  position: fixed;
  top: -20px;
  font-size: 1.6rem;
  animation: fall 2.4s linear forwards;
  pointer-events: none;
  z-index: 50;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}
.big-cheer {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(3rem, 12vw, 6rem);
  font-weight: 700;
  color: #ff6b35;
  text-shadow: 0 4px 0 rgba(0,0,0,0.12);
  pointer-events: none;
  z-index: 60;
  animation: bounce-in 0.5s;
}

/* ── Real character pictures ───────────────────────── */
.nb-char {
  max-height: 360px;
  max-width: 80%;
  object-fit: contain;
  animation: bounce-in 0.5s;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.2));
}
.creature img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}
.word-img {
  max-height: 150px;
  max-width: 260px;
  object-fit: contain;
  animation: bounce-in 0.5s;
  filter: drop-shadow(0 5px 8px rgba(0,0,0,0.2));
}

/* ── Upload page ───────────────────────────────────── */
.upload-box {
  background: white;
  border-radius: 24px;
  padding: 26px;
  width: min(92vw, 440px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 40px;
}
.upload-box label { font-weight: 600; }
.upload-box select, .upload-box input {
  font-family: inherit;
  font-size: 1.05rem;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid #e8ddcc;
  width: 100%;
}
.upload-box button {
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 13px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff5757, #ffb302);
  color: white;
  cursor: pointer;
}
.msg-ok  { color: #1d8a4e; font-weight: 700; margin: 0; }
.msg-err { color: #d62246; font-weight: 700; margin: 0; }
