/* ===== RESET & BASE ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* no iOS long-press menu on food images */
  touch-action: manipulation;  /* no double-tap zoom / 300ms tap delay */
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh; /* accounts for mobile browser chrome */
  overflow: hidden;
  overscroll-behavior: none; /* no pull-to-refresh / bounce while smashing */
  font-family: 'Fredoka', 'Nunito', system-ui, sans-serif;
  background: #1a0a2e;
  color: #fff;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ===== BACKGROUNDS ===== */
.bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: opacity 0.8s ease;
  z-index: 0;
}

#bg-princess {
  background-image: url('images/bg-princess.jpg');
  opacity: 1;
}

#bg-dino {
  background-image: url('images/bg-dino.jpg');
  opacity: 0;
}

#bg-dino.visible {
  opacity: 1;
}

#bg-princess.hidden {
  opacity: 0;
}

/* ===== SCREENS ===== */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  background: rgba(0,0,0,0.25);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  display: flex;
}

/* ===== TITLE SCREEN ===== */
.title-content {
  text-align: center;
  max-width: 700px;
}

.title-princess {
  width: 220px;
  height: auto;
  border-radius: 30px;
  box-shadow: 0 15px 40px rgba(255, 105, 180, 0.5);
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

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

.title-content h1 {
  font-size: clamp(2.2rem, 6vw, 3.8rem);
  font-weight: 700;
  line-height: 1.15;
  background: linear-gradient(90deg, #ff9ecd, #ff6bcb, #c77dff, #7b2ff7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 4px 20px rgba(255, 105, 180, 0.4);
  margin-bottom: 10px;
}

.subtitle {
  font-size: 1.3rem;
  color: #ffe6f7;
  margin-bottom: 40px;
  opacity: 0.95;
}

.smash-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pulse-circle {
  font-size: 3rem;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

.smash-hint p {
  font-size: 1.4rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 105, 180, 0.35);
  padding: 12px 28px;
  border-radius: 50px;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

/* ===== SHARED TOP BAR ===== */
.top-bar {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 20px;
}

.phase-label {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  font-weight: 700;
  background: linear-gradient(90deg, #ff6bcb, #c77dff);
  padding: 12px 28px;
  border-radius: 50px;
  box-shadow: 0 8px 25px rgba(255, 105, 180, 0.4);
  border: 3px solid rgba(255,255,255,0.5);
}

.character-side {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.character-side img {
  height: 140px;
  width: auto;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  object-fit: cover;
}

.unicorn-float {
  height: 110px !important;
  animation: float 2.8s ease-in-out infinite;
  animation-delay: 0.4s;
}

.character-side.dino-mode img {
  height: 160px;
  border-radius: 16px;
}

/* ===== WHEEL ===== */
.wheel-area {
  position: relative;
  margin: 10px 0;
}

#meal-canvas, #day-canvas {
  border-radius: 50%;
  box-shadow: 0 0 0 10px rgba(255,255,255,0.7),
              0 0 0 18px rgba(255, 105, 180, 0.5),
              0 20px 50px rgba(0,0,0,0.4);
  background: #fff;
}

.wheel-pointer {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.8rem;
  color: #ff2d95;
  text-shadow: 0 4px 10px rgba(0,0,0,0.4);
  z-index: 20;
  filter: drop-shadow(0 0 8px #ff6bcb);
}

/* ===== POWER BAR ===== */
.power-section {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 15px;
  width: 100%;
  max-width: 420px;
}

.power-label {
  font-size: 1.2rem;
  font-weight: 600;
  color: #ffe6f7;
}

.power-bar-outer {
  width: 100%;
  height: 28px;
  background: rgba(0,0,0,0.4);
  border-radius: 20px;
  border: 3px solid rgba(255,255,255,0.5);
  overflow: hidden;
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.3);
}

.power-bar-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff9ecd, #ff2d95, #c77dff);
  border-radius: 16px;
  transition: width 0.08s linear;
  box-shadow: 0 0 15px #ff6bcb;
}

.power-bar-inner.dino-power {
  background: linear-gradient(90deg, #7dce82, #2ecc71, #27ae60);
  box-shadow: 0 0 15px #2ecc71;
}

.power-bar-inner.full {
  background: linear-gradient(90deg, #ff9f1c, #ff6b00, #ff2d00) !important;
  box-shadow: 0 0 25px #ff6b00, 0 0 40px #ff2d00 !important;
  animation: fullPulse 0.4s ease-in-out infinite alternate;
}

@keyframes fullPulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.3); }
}

/* ===== ROCKET BLAST OFF ===== */
.rocket {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  pointer-events: none;
}

.rocket img {
  width: 90px;
  height: auto;
  filter: drop-shadow(0 0 12px #ff6b00);
}

.rocket.launch {
  animation: rocketLaunch 1.4s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

@keyframes rocketLaunch {
  0% {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(-70vh) scale(0.6);
    opacity: 0;
  }
}

/* ===== RESULT BANNER ===== */
.result-banner {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ff6bcb, #c77dff);
  color: white;
  font-size: 1.8rem;
  font-weight: 700;
  padding: 18px 40px;
  border-radius: 60px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.35);
  border: 4px solid white;
  text-align: center;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 30;
  max-width: 90%;
}

.result-banner.dino-result {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
}

@keyframes popIn {
  0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

.hidden {
  display: none !important;
}

/* ===== FINAL SCREEN ===== */
.final-content {
  text-align: center;
  max-width: 850px;
  width: 100%;
}

.final-content h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin-bottom: 24px;
  text-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.fridge-poster {
  background: linear-gradient(180deg, #fff5fb 0%, #ffe6f7 100%);
  color: #5a1a4a;
  border-radius: 24px;
  padding: 28px 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35),
              0 0 0 8px #ff9ecd,
              0 0 0 14px #c77dff;
  margin-bottom: 30px;
  text-align: left;
}

.poster-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
  border-bottom: 3px dashed #ff9ecd;
  padding-bottom: 16px;
}

.poster-princess, .poster-unicorn {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #ff6bcb;
  box-shadow: 0 6px 15px rgba(255,105,180,0.4);
}

.poster-header h2 {
  font-size: 1.7rem;
  color: #c77dff;
  margin-bottom: 2px;
}

.poster-header p {
  font-size: 1rem;
  color: #9b4d8a;
}

.poster-meals {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.poster-meal-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: white;
  border-radius: 18px;
  padding: 16px 22px;
  box-shadow: 0 6px 18px rgba(199, 125, 255, 0.25);
  border: 3px solid #ffcce8;
}

.poster-day {
  font-size: 1.5rem;
  font-weight: 800;
  color: #ff2d95;
  min-width: 130px;
}

.poster-meal-name {
  font-size: 1.6rem;
  font-weight: 700;
  color: #5a1a4a;
  flex: 1;
}

.poster-who {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 30px;
  background: #ffe6f7;
  color: #c77dff;
}

.poster-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 1.1rem;
  color: #9b4d8a;
  font-weight: 600;
}

.final-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* ===== PRINT STYLES ===== */
@media print {
  body * {
    visibility: hidden;
  }
  #fridge-poster, #fridge-poster * {
    visibility: visible;
  }
  #fridge-poster {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    box-shadow: none;
    border: 4px solid #ff9ecd;
  }
  .final-actions {
    display: none !important;
  }
}

/* ===== RESPONSIVE TWEAKS ===== */
@media (max-width: 700px) {
  .title-princess {
    width: 160px;
  }
  .character-side img {
    height: 100px;
  }
  .character-side.dino-mode img {
    height: 120px;
  }
  #meal-canvas, #day-canvas {
    width: 300px !important;
    height: 300px !important;
  }
  .phase-label {
    font-size: 1.2rem;
    padding: 10px 18px;
  }
  .result-banner {
    font-size: 1.3rem;
    padding: 14px 24px;
  }
}

/* Small phones (e.g. iPhone SE / small Android, 360-380px wide) */
@media (max-width: 380px) {
  .screen {
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .title-princess {
    width: 120px;
    margin-bottom: 12px;
  }
  .title-content h1 {
    margin-bottom: 6px;
  }
  .subtitle {
    margin-bottom: 20px;
  }
  .character-side img {
    height: 76px;
  }
  .character-side.dino-mode img {
    height: 90px;
  }
  #meal-canvas, #day-canvas {
    width: 240px !important;
    height: 240px !important;
  }
  .power-section {
    margin-top: 10px;
  }
  .capture-zone {
    width: 200px;
    height: 140px;
  }
  .capture-character {
    width: 90px;
  }
}

/* Short viewports (landscape phones) — shrink vertical footprint */
@media (max-height: 600px) {
  .title-princess {
    width: 110px;
    margin-bottom: 10px;
  }
  .character-side img {
    height: 70px;
  }
  .character-side.dino-mode img {
    height: 84px;
  }
  #meal-canvas, #day-canvas {
    width: 220px !important;
    height: 220px !important;
  }
  .power-section {
    margin-top: 8px;
    gap: 8px;
  }
}

/* ===== RESULT FOOD IMAGE ===== */
#meal-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  bottom: 25px;
}

.result-food-img {
  width: 130px;
  height: 130px;
  object-fit: contain;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 25px rgba(0,0,0,0.35);
  border: 4px solid #fff;
  margin-top: 4px;
}

/* ===== CAPTURE MINI-GAME ===== */
.capture-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.capture-prompt {
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1.25rem, 3.2vw, 1.8rem);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ff6bcb, #c77dff);
  padding: 14px 26px;
  border-radius: 50px;
  border: 3px solid white;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  text-align: center;
  white-space: nowrap;
  z-index: 45;
}

.capture-zone {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  height: 170px;
  border: 5px dashed rgba(255,255,255,0.9);
  border-radius: 28px;
  background: rgba(255, 182, 255, 0.18);
  box-shadow: 0 0 40px rgba(255, 150, 255, 0.45);
  z-index: 41;
}

.capture-character {
  position: absolute;
  top: 43%;
  width: 120px;
  height: auto;
  border-radius: 50%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  z-index: 42;
  pointer-events: none;
}

.capture-feedback {
  position: absolute;
  top: 70%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.6rem;
  font-weight: 800;
  color: white;
  text-shadow: 0 4px 15px rgba(0,0,0,0.5);
  z-index: 46;
  animation: popIn 0.35s ease;
}

.capture-feedback.success {
  color: #7dffa0;
}

.capture-feedback.fail {
  color: #ff8a8a;
}
