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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
    "Apple SD Gothic Neo", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: #4E342E;
}

#game-root {
  position: relative;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #87CEEB 0%, #FFF9C4 100%);
}

#hud {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

#hud-combo {
  color: #FF8F00;
}

#hud-mission {
  color: #2E7D32;
}

#hud-lang-btn,
#hud-sound-btn {
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  border: none;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

#field {
  position: relative;
  flex: 1;
  margin: 0 12px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.entity {
  position: absolute;
  /* --motion-dx: 돌풍(사인파)·벌(직선 이동) 등 좌우 이동 오프셋. 평소엔 0px. */
  transform: translate(calc(-50% + var(--motion-dx, 0px)), -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
  animation: pop-in 0.15s ease-out;
}

/* 파워업 버프 중에는 탭 판정 영역이 넓어진다 (padding으로 클릭 가능 범위만 확장, 시각적 크기는 유지) */
#field.field-buffed .entity {
  padding: var(--powerup-hit-padding, 0px);
}

.entity.powerup {
  animation: pop-in 0.15s ease-out, powerup-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes powerup-pulse {
  from { filter: drop-shadow(0 0 4px rgba(255, 235, 59, 0.6)); }
  to { filter: drop-shadow(0 0 14px rgba(255, 235, 59, 1)); }
}

/* 황금 해바라기: 강렬한 골드 글로우 + 다급한 맥동 (수명이 짧다는 신호) */
.entity.golden {
  font-size: 3.1rem;
  animation: pop-in 0.1s ease-out, golden-pulse 0.2s ease-in-out infinite alternate;
}

@keyframes golden-pulse {
  from {
    filter: drop-shadow(0 0 6px rgba(255, 193, 7, 0.9)) drop-shadow(0 0 16px rgba(255, 152, 0, 0.7)) brightness(1.25);
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    filter: drop-shadow(0 0 14px rgba(255, 193, 7, 1)) drop-shadow(0 0 30px rgba(255, 152, 0, 0.9)) brightness(1.5);
    transform: translate(-50%, -50%) scale(1.12);
  }
}

/* 벌: 가로지르는 동안 살짝 좌우로 진동하는 날갯짓 느낌 */
.entity.bee {
  animation: pop-in 0.1s ease-out, bee-buzz 0.15s ease-in-out infinite alternate;
}

@keyframes bee-buzz {
  from { transform: translate(calc(-50% + var(--motion-dx, 0px)), -50%) rotate(-6deg); }
  to { transform: translate(calc(-50% + var(--motion-dx, 0px)), -50%) rotate(6deg); }
}

/* 씨앗 주머니: 곧 터질 듯한 들썩임 */
.entity.seedbag {
  animation: pop-in 0.15s ease-out, seedbag-wiggle 0.4s ease-in-out infinite;
}

@keyframes seedbag-wiggle {
  0%, 100% { transform: translate(calc(-50% + var(--motion-dx, 0px)), -50%) rotate(0deg); }
  50% { transform: translate(calc(-50% + var(--motion-dx, 0px)), -50%) rotate(-8deg); }
}

/* 위험도 임계 초과: 심장박동에 맞춘 붉은 비네트 맥동 */
#game-root.danger-critical::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  box-shadow: inset 0 0 80px 30px rgba(180, 20, 20, 0.55);
  animation: vignette-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes vignette-pulse {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

@keyframes pop-in {
  from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.entity.harvest-pop {
  animation: harvest-pop 0.15s ease-out forwards;
}

@keyframes harvest-pop {
  0% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.4); }
  100% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
}

.entity.flip-pop {
  animation: flip-pop 0.25s ease-out;
}

@keyframes flip-pop {
  0% { transform: translate(-50%, -50%) scale(1) rotateY(0deg); }
  50% { transform: translate(-50%, -50%) scale(1.3) rotateY(90deg); }
  100% { transform: translate(-50%, -50%) scale(1) rotateY(0deg); }
}

.floating-text {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 1.3rem;
  pointer-events: none;
  animation: float-up 0.7s ease-out forwards;
}

.floating-text.gain {
  color: #FFC107;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.floating-text.loss {
  color: #7B6B8A;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

@keyframes float-up {
  from { transform: translate(-50%, -50%) translateY(0); opacity: 1; }
  to { transform: translate(-50%, -50%) translateY(-40px); opacity: 0; }
}

#danger-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 5, 15, 0);
  pointer-events: none;
  transition: background 0.4s ease-out;
}

#event-tint {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  transition: background 0.5s ease-out;
  z-index: 2;
}

.event-banner {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 85%;
  text-align: center;
  background: #FFC107;
  color: #4E342E;
  font-weight: 800;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  animation: toast-pop 0.2s ease-out;
  z-index: 6;
}

/* 순간 미션 배너는 필드 이벤트와 구분되게 초록 계열로 (§7-2f) */
.event-banner.mission-banner {
  background: #66BB6A;
  color: #FFFFFF;
}

#flash-overlay {
  position: absolute;
  inset: 0;
  background: rgba(220, 50, 50, 0);
  pointer-events: none;
  transition: background 0.1s ease-out;
}

#flash-overlay.flash-active {
  background: rgba(220, 50, 50, 0.35);
}

#game-root.shake {
  animation: shake 0.2s ease-in-out;
}

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

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(78, 52, 46, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 16px;
  animation: overlay-fade 0.2s ease-out;
}

@keyframes overlay-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel {
  background: #FFF9C4;
  border-radius: 20px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: panel-pop 0.25s ease-out;
}

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

.modal-title {
  margin: 0 0 16px;
  font-size: 1.2rem;
  text-align: center;
}

.choice-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice-card {
  font: inherit;
  font-weight: 700;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  background: #FFC107;
  color: #4E342E;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease-out;
}

.choice-card:active {
  transform: scale(0.96);
}

#debug-cheat-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  font: inherit;
  font-weight: 700;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: #4E342E;
  color: #FFF9C4;
  opacity: 0.7;
  cursor: pointer;
}

#debug-simulate-btn {
  position: absolute;
  right: 12px;
  bottom: 56px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: #4E342E;
  color: #FFF9C4;
  opacity: 0.7;
  cursor: pointer;
}

.evolution-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #FFC107;
  color: #4E342E;
  font-weight: 800;
  font-size: 1.4rem;
  text-align: center;
  padding: 14px 28px;
  border-radius: 16px;
  animation: toast-pop 0.3s ease-out, evolution-glow 1s ease-in-out 0.3s 2 alternate;
}

@keyframes evolution-glow {
  from { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); }
  to { box-shadow: 0 4px 28px rgba(255, 193, 7, 0.7); }
}

.evolution-toast-flavor {
  margin-top: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.8;
}

.monologue-banner {
  position: absolute;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  max-width: 85%;
  text-align: center;
  background: rgba(78, 52, 46, 0.8);
  color: #FFF9C4;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 999px;
  animation: banner-pop 0.25s ease-out;
  z-index: 4;
}

@keyframes banner-pop {
  from { transform: translateX(-50%) scale(0.8); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

.start-panel {
  text-align: center;
}

.start-title {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.start-tagline {
  margin: 0 0 20px;
  opacity: 0.75;
  font-weight: 600;
}

.choice-card-active {
  outline: 3px solid #4E342E;
  outline-offset: 2px;
}

@keyframes toast-pop {
  from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#final-stage-btn {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  font: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 14px 28px;
  border: none;
  border-radius: 999px;
  background: #FFC107;
  color: #4E342E;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  z-index: 5;
}

#boss-hud {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(80%, 360px);
  z-index: 6;
  text-align: center;
}

.boss-hud-label {
  font-weight: 700;
  font-size: 0.9rem;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

.boss-hp-track {
  margin-top: 4px;
  height: 14px;
  border-radius: 999px;
  background: rgba(78, 52, 46, 0.25);
  overflow: hidden;
}

.boss-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #FF8F00, #FFC107);
  transition: width 0.15s ease-out;
}

.boss-intro-toast {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 80%;
  text-align: center;
  background: rgba(78, 52, 46, 0.85);
  color: #FFF9C4;
  font-weight: 700;
  padding: 14px 20px;
  border-radius: 16px;
  animation: toast-pop 0.3s ease-out;
  z-index: 6;
}

.boss-enter-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 235, 150, 0.9), rgba(255, 193, 7, 0) 70%);
  animation: boss-flash 0.7s ease-out forwards;
  pointer-events: none;
  z-index: 7;
}

@keyframes boss-flash {
  from { opacity: 1; }
  to { opacity: 0; }
}

.dialogue-box {
  background: #FFF9C4;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 480px;
  width: 100%;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.dialogue-text {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.5;
}

.dialogue-hint {
  margin-top: 16px;
  align-self: flex-end;
  font-size: 0.85rem;
  opacity: 0.6;
}

.ending-panel {
  max-width: 420px;
}

.ending-stats {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 16px;
  margin: 0 0 16px;
}

.ending-stats dt {
  font-weight: 700;
  opacity: 0.75;
}

.ending-stats dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.ending-teaser {
  text-align: center;
  opacity: 0.7;
  font-size: 0.9rem;
  margin: 0 0 16px;
}
