:root {
  --cream: #fff8e9;
  --paper: #fffdf7;
  --ink: #49362f;
  --pink-dark: #c94e76;
  --gray: #6f7b86;
  --gray-dark: #4b5761;
  --yellow: #ffd76a;
  --green: #55a86b;
  --shadow: rgba(72, 43, 35, 0.2);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background:
    radial-gradient(circle at 8% 12%, rgba(173, 196, 214, .38), transparent 18rem),
    radial-gradient(circle at 90% 15%, rgba(255, 215, 106, .3), transparent 20rem),
    linear-gradient(180deg, #fbfdff, var(--cream));
}
button, a { -webkit-tap-highlight-color: transparent; }
.game { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.stage { width: min(100%, 760px); }

.game-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.back-link, .sound-toggle { min-height: 40px; display: inline-flex; align-items: center; padding: 8px 14px; border: 2px solid rgba(0,0,0,.12); border-radius: 999px; color: inherit; background: #fff; font: inherit; font-size: .9rem; font-weight: 800; text-decoration: none; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.sound-toggle[aria-pressed="true"] { background: #eee7e1; opacity: .85; }
a:focus-visible, button:focus-visible { outline: 3px solid #3d927d; outline-offset: 3px; }

.title { margin-bottom: 14px; text-align: center; }
.title p { margin: 0 0 4px; color: var(--gray-dark); font-size: clamp(.95rem, 2.4vw, 1.2rem); font-weight: 900; }
.title h1 { margin: 0; color: var(--pink-dark); font-size: clamp(1.9rem, 7.4vw, 3.8rem); line-height: 1.1; text-shadow: 0 4px 0 #ffd9a0; }

.play-layout { display: grid; gap: 12px; }
.message { min-height: 72px; display: grid; place-items: center; margin: 0; padding: 12px 14px; border: 4px solid #b9c6d0; border-radius: 18px; background: var(--paper); font-size: clamp(1rem, 2.8vw, 1.3rem); font-weight: 900; line-height: 1.4; text-align: center; }

/* 舞台 */
.scene { position: relative; width: 100%; aspect-ratio: 1; border: 6px solid #c9d5de; border-radius: 20px; background: #eef4f7; box-shadow: 0 18px 34px var(--shadow); overflow: hidden; }
.scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .35; }

.wolf, .house, .fireplace, .pig { position: absolute; border: 4px solid #fff; border-radius: 22px; background: #fff; box-shadow: 0 8px 16px rgba(57,36,31,.22); object-fit: cover; }
.wolf { left: 5%; bottom: 8%; width: 36%; aspect-ratio: 1; transform-origin: 30% 80%; transition: transform .25s ease, left .9s ease, bottom .9s ease, opacity .6s ease; z-index: 3; }
.wolf.is-puff { animation: puff .32s ease; }
.wolf.is-climb { left: 52%; bottom: 62%; transform: scale(.7) rotate(-8deg); }
.wolf.is-run { left: -60%; bottom: 20%; transform: scale(.8) rotate(-20deg); opacity: 0; }

.house { right: 6%; top: 10%; width: 46%; aspect-ratio: 1; padding: 0; overflow: hidden; cursor: pointer; z-index: 2; }
.house img { display: block; width: 100%; height: 100%; object-fit: cover; }
.house:disabled { cursor: default; }
.house.is-ready { outline: 5px solid var(--yellow); outline-offset: 2px; }
.house.is-shake { animation: shake .35s ease; }
.house.is-shake-small { animation: shakeSmall .3s ease; }
.house.is-fly { animation: fly 1.1s ease-in forwards; }
.house.is-enter { animation: popIn .45s cubic-bezier(.2,1.35,.35,1); }

.fireplace { right: 6%; top: 10%; width: 46%; aspect-ratio: 1; z-index: 2; animation: popIn .45s cubic-bezier(.2,1.35,.35,1); }

.pigs { position: absolute; right: 6%; bottom: 8%; display: flex; gap: 6px; z-index: 2; }
.pig { position: static; width: clamp(54px, 15vw, 96px); aspect-ratio: 1; border-width: 3px; border-radius: 16px; animation: popIn .4s cubic-bezier(.2,1.35,.35,1); }
.pigs.is-run .pig { animation: run .9s ease-in forwards; }
.pigs.is-scared .pig { animation: shakeSmall .3s ease 3; }

/* 風 */
.wind-gust { position: absolute; left: 0; top: 0; width: 34%; height: auto; pointer-events: none; z-index: 4; filter: drop-shadow(0 0 3px rgba(255,255,255,.95)) drop-shadow(0 2px 4px rgba(40,90,130,.35)); animation: gust .6s cubic-bezier(.3,.1,.5,1) forwards; }

.pop-text { position: absolute; left: 27%; top: 16%; margin: 0; padding: 8px 18px; border: 4px solid #fff; border-radius: 999px; color: #fff; background: var(--gray-dark); box-shadow: 0 8px 18px var(--shadow); font-size: clamp(1.1rem, 4.6vw, 2rem); font-weight: 900; white-space: nowrap; transform: translate(-50%, -50%); opacity: 0; pointer-events: none; z-index: 5; }
.pop-text.is-show { animation: popText .7s ease forwards; }
.pop-text.is-stay { left: 50%; top: 46%; opacity: 1; background: var(--pink-dark); animation: popIn .5s cubic-bezier(.2,1.4,.35,1); }

/* ここをタップ */
.tap-hint { position: absolute; z-index: 6; display: inline-flex; align-items: center; gap: 4px; margin: 0; padding: 6px 14px; border: 3px solid #fff; border-radius: 999px; color: #664416; background: var(--yellow); box-shadow: 0 6px 14px var(--shadow); font-size: clamp(.95rem, 3.6vw, 1.25rem); font-weight: 900; white-space: nowrap; pointer-events: none; animation: hintBounce 1s ease-in-out infinite; }
.tap-hand { font-size: 1.3em; line-height: 1; }
.tap-hint-house { right: 29%; top: 58%; translate: 50% 0; }
.tap-hint-button { left: 50%; bottom: calc(100% + 6px); translate: -50% 0; }
.blow-wrap { position: relative; display: grid; justify-items: center; margin-top: 38px; }

/* ゲージ */
.gauge { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 22px; }
.gauge i { width: 18px; height: 18px; border: 3px solid #b9c6d0; border-radius: 50%; background: #fff; transition: background .15s, transform .15s; }
.gauge i.is-on { border-color: #7fa4bd; background: #a9d4f0; transform: scale(1.15); }

.blow-button { animation: buttonPulse 1.2s ease-in-out infinite; min-width: min(100%, 320px); min-height: 72px; padding: 14px 28px; border: 0; border-radius: 999px; color: #fff; background: var(--gray); box-shadow: 0 8px 0 var(--gray-dark); font: inherit; font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 900; cursor: pointer; touch-action: manipulation; user-select: none; }
.blow-button:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 3px 0 var(--gray-dark); }
.blow-button:disabled { opacity: .5; cursor: default; animation: none; }

.complete-panel { width: 100%; padding: 16px; border: 5px solid #e9b867; border-radius: 18px; background: var(--paper); text-align: center; }
.complete-title { margin: 0 0 6px; color: var(--pink-dark); font-size: clamp(1.8rem, 6vw, 3rem); font-weight: 900; line-height: 1.1; }
.complete-copy { margin: 0 0 12px; font-weight: 800; line-height: 1.55; }
.product-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.product-button, .reset-button { min-height: 52px; display: inline-grid; place-items: center; margin: 5px; padding: 12px 16px; border: 0; border-radius: 15px; font: inherit; font-weight: 900; text-decoration: none; cursor: pointer; }
.product-button { color: #3d2c22; background: var(--yellow); box-shadow: 0 7px 0 #c98d1b; }
.product-button-minne { background: #d9f2f8; box-shadow: 0 7px 0 #8fc6d7; }
.reset-button { color: #fff; background: #3d927d; box-shadow: 0 7px 0 #236653; }
[hidden] { display: none !important; }

@keyframes puff { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.12) rotate(4deg); } }
@keyframes shake { 0%, 100% { translate: 0; rotate: 0deg; } 25% { translate: 6% 0; rotate: 5deg; } 50% { translate: -3% 0; rotate: -3deg; } 75% { translate: 4% 0; rotate: 3deg; } }
@keyframes shakeSmall { 0%, 100% { translate: 0; } 33% { translate: 2% 0; } 66% { translate: -1% 0; } }
@keyframes fly { 0% { transform: none; opacity: 1; } 30% { transform: translate(10%, -10%) rotate(20deg); } 100% { transform: translate(140%, -140%) rotate(220deg) scale(.4); opacity: 0; } }
@keyframes run { to { transform: translateX(160%); opacity: 0; } }
@keyframes gust {
  0% { left: 26%; top: calc(56% + var(--lift)); opacity: 0; transform: rotate(-12deg) scale(calc(var(--size) * .5)); }
  20% { opacity: 1; }
  65% { left: 46%; top: calc(34% + var(--lift)); opacity: 1; transform: rotate(-8deg) scale(var(--size)); }
  100% { left: 56%; top: calc(28% + var(--lift)); opacity: 0; transform: rotate(-4deg) scale(calc(var(--size) * 1.15)); }
}
@keyframes popText { 0% { opacity: 0; scale: .5; } 25% { opacity: 1; scale: 1.1; } 70% { opacity: 1; scale: 1; } 100% { opacity: 0; scale: 1; } }
@keyframes hintBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes buttonPulse { 0%, 100% { scale: 1; } 50% { scale: 1.04; } }
@keyframes popIn { from { opacity: 0; scale: .55; } to { opacity: 1; scale: 1; } }

@media (max-width: 520px) {
  .game { padding: 10px; }
  .message { min-height: 58px; padding: 8px 10px; border-width: 3px; font-size: .95rem; }
  .scene { border-width: 3px; border-radius: 14px; }
  .wolf, .house, .fireplace { border-width: 3px; border-radius: 14px; }
  .pig { border-radius: 12px; }
  .product-links { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
