/* Hundred Acre Friends — core styles */

:root {
  --honey: #f7c948;
  --honey-deep: #e8a020;
  --brown: #6b4a2f;
  --brown-deep: #5c4023;
  --cream: #fff8e7;
  --game-color: #f7c948;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--brown-deep);
  background: linear-gradient(#c9e8f5, #f4fae9);
  position: fixed;
  inset: 0;
  width: 100%;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---- background scene ---- */

#meadow-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#meadow-bg svg {
  width: 100%;
  height: 100%;
  display: block;
}

main {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---- screens ---- */

.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.screen.active {
  display: flex;
}

/* ---- home ---- */

.home-head {
  text-align: center;
  padding: clamp(10px, 3vh, 28px) 16px 4px;
}

.home-head h1 {
  font-size: clamp(30px, 6vw, 54px);
  font-weight: 900;
  color: var(--brown-deep);
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.8);
  letter-spacing: 0.5px;
}

.tagline {
  margin-top: 4px;
  font-size: clamp(14px, 2.2vw, 19px);
  font-weight: 600;
  color: #7a5a3a;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7);
}

#menu-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(40vw, 210px), 1fr));
  gap: clamp(12px, 2.2vw, 22px);
  padding: clamp(12px, 2.5vw, 26px);
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  align-content: start;
}

.tile {
  --tile-color: #fbe6a2;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, var(--tile-color) 130%);
  border-radius: 32px;
  border: 4px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 22px rgba(107, 74, 47, 0.2);
  padding: 16px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.14s ease;
}

.tile:active {
  transform: scale(0.93);
}

.tile-art {
  width: clamp(96px, 18vw, 142px);
  aspect-ratio: 1;
}

.tile-label {
  font-size: clamp(15px, 2.3vw, 21px);
  font-weight: 800;
  color: var(--brown-deep);
  text-align: center;
  line-height: 1.15;
}

.footnote {
  text-align: center;
  font-size: 11px;
  color: rgba(92, 64, 35, 0.65);
  padding: 4px 14px 10px;
}

/* ---- play screen ---- */

.play-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 4px;
}

#home-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: 4px solid rgba(255, 255, 255, 1);
  box-shadow: 0 6px 14px rgba(107, 74, 47, 0.22);
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: transform 0.12s ease;
}

#home-btn:active {
  transform: scale(0.9);
}

#game-title {
  font-size: clamp(20px, 3.6vw, 32px);
  font-weight: 900;
  color: var(--brown-deep);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.8);
}

#stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px;
}

/* ---- game utility layout ---- */

.stage-center {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vw, 30px);
}

.choice {
  background: rgba(255, 255, 255, 0.88);
  border: 5px solid #ffffff;
  border-radius: 30px;
  box-shadow: 0 8px 18px rgba(107, 74, 47, 0.2);
  min-width: 130px;
  min-height: 130px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease;
}

.choice:active {
  transform: scale(0.92);
}

.prompt-banner {
  background: var(--game-color);
  border: 4px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(107, 74, 47, 0.18);
  padding: 10px 30px;
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 3px rgba(92, 64, 35, 0.35);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- art holders ---- */

.art {
  line-height: 0;
}

.art svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* Drop-in real character images (js/image-art.js) render as <img>. */
.art-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.art-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  line-height: 1;
}

.art-sm { width: 80px; height: 80px; }
.art-md { width: 140px; height: 140px; }
.art-lg { width: 220px; height: 220px; }

/* ---- caption bubble ---- */

#caption {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) translateY(8px);
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  border: 3px solid rgba(247, 201, 72, 0.9);
  border-radius: 999px;
  padding: 9px 24px;
  font-size: clamp(15px, 2.4vw, 20px);
  font-weight: 800;
  color: var(--brown-deep);
  max-width: 92vw;
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#caption.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- confetti ---- */

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -48px;
  animation: confetti-fall 1.7s ease-in forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(115vh) rotate(340deg);
    opacity: 0.85;
  }
}

/* ---- animation utilities ---- */

.bob {
  animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* One-shot feedback animations use !important so they always win over the
 * .pop-in entry animation (later in cascade) AND inline bob-stagger
 * animation-delay/duration styles that games set on the same elements. */
.wiggle {
  animation: wiggle 0.5s ease !important;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-7deg); }
  50% { transform: rotate(6deg); }
  75% { transform: rotate(-4deg); }
}

.pop-in {
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

@keyframes pop-in {
  from {
    transform: scale(0.3);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.bounce-once {
  animation: bounce-once 0.6s ease !important;
}

@keyframes bounce-once {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-26px) scale(1.06); }
  55% { transform: translateY(0) scale(0.97); }
  75% { transform: translateY(-10px) scale(1.02); }
}

.rise-up {
  animation: rise-up 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

@keyframes rise-up {
  from {
    transform: translateY(70%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sink-down {
  animation: sink-down 0.5s ease forwards;
}

@keyframes sink-down {
  to {
    transform: translateY(80%);
    opacity: 0;
  }
}

.float-away {
  animation: float-away 1.2s ease-in forwards !important;
}

@keyframes float-away {
  to {
    transform: translateY(-90vh) rotate(8deg);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bob { animation: none; }
}

/* Small phones: shrink play elements so rounds fit without scrolling. */
@media (max-width: 640px), (max-height: 640px) {
  .stage-center { gap: 10px; }
  .choice-row { gap: 12px; }
  .choice {
    min-width: 110px;
    min-height: 110px;
    padding: 10px;
    border-radius: 24px;
  }
  .art-lg { width: 150px; height: 150px; }
  .art-md { width: 110px; height: 110px; }
  .prompt-banner { padding: 8px 20px; font-size: 20px; }
  .play-head { padding: 8px 10px 2px; }
  #home-btn { width: 54px; height: 54px; font-size: 24px; }
}
