:root {
  --sky: #dff3ff;
  --sky-deep: #bfe6ff;
  --grass: #9ed98a;
  --grass-deep: #6fbf5c;
  --brown: #5b4636;
  --cream: #fffaf2;
  --pink: #ffb3bd;
  --yellow: #ffd45e;
  --text: #4a3a2e;
  --muted: #8a7666;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", sans-serif;
  color: var(--text);
  background: linear-gradient(var(--sky-deep), var(--sky) 40%, var(--cream) 75%);
  min-height: 100vh;
  line-height: 1.8;
  overflow-x: hidden;
}

/* ---------- 雲 ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.cloud {
  position: absolute;
  width: 120px; height: 40px;
  background: #fff;
  border-radius: 40px;
  opacity: .9;
  animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: ""; position: absolute; background: #fff; border-radius: 50%;
}
.cloud::before { width: 54px; height: 54px; top: -26px; left: 18px; }
.cloud::after  { width: 40px; height: 40px; top: -18px; left: 62px; }
.c1 { top: 10%; animation-duration: 60s; animation-delay: -10s; }
.c2 { top: 26%; transform: scale(.7); animation-duration: 80s; animation-delay: -45s; }
.c3 { top: 46%; transform: scale(.5); animation-duration: 70s; animation-delay: -25s; }
@keyframes drift {
  from { left: -160px; }
  to   { left: 110%; }
}

header, main, footer { position: relative; z-index: 1; }

/* ---------- ヒーロー ---------- */
.hero {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 40px 16px;
}

.goat-wrap { position: relative; }

.goat-btn {
  background: none; border: none; cursor: pointer;
  display: block;
  animation: bounce 3s ease-in-out infinite;
}
.goat-btn:focus-visible { outline: 3px dashed var(--brown); border-radius: 50%; }
.goat { width: min(220px, 55vw); height: auto; display: block; }
.goat-btn.wiggle { animation: wiggle .5s ease-in-out; }

.eyes { transform-origin: 100px 108px; animation: blink 4s infinite; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(.1); }
}

.bubble {
  position: absolute;
  top: -8px; right: -70px;
  background: #fff;
  border: 3px solid var(--brown);
  border-radius: 20px;
  padding: 4px 14px;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  transform: scale(.6) translateY(10px);
  transition: .25s cubic-bezier(.3, 1.6, .5, 1);
  pointer-events: none;
}
.bubble::after {
  content: ""; position: absolute;
  bottom: -10px; left: 14px;
  border: 8px solid transparent;
  border-top-color: var(--brown);
}
.bubble.show { opacity: 1; transform: scale(1) translateY(0); }

.hello { margin-top: 20px; font-weight: 700; color: var(--grass-deep); letter-spacing: .1em; }
.name {
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  font-weight: 800;
  color: var(--brown);
  line-height: 1.2;
  text-shadow: 4px 4px 0 #fff;
}
.tagline { margin-top: 10px; color: var(--muted); }

.friendship {
  margin-top: 24px;
  width: min(280px, 80vw);
}
.friendship-label {
  font-weight: 700;
  color: var(--brown);
  margin-bottom: 8px;
}
.friendship-label span {
  color: var(--grass-deep);
}
.gauge {
  width: 100%;
  height: 20px;
  background: var(--cream);
  border: 3px solid var(--brown);
  border-radius: 999px;
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--yellow), var(--pink));
  border-radius: 999px;
  transition: width .5s cubic-bezier(.3, 1.2, .4, 1), background .3s ease;
}
.friendship-count {
  margin-top: 6px;
  font-size: .85rem;
  color: var(--muted);
}

.cta {
  display: inline-block;
  margin-top: 28px;
  padding: 10px 26px;
  background: var(--yellow);
  color: var(--brown);
  font-weight: 800;
  text-decoration: none;
  border: 3px solid var(--brown);
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--brown);
  transition: transform .15s, box-shadow .15s;
}
.cta:hover  { transform: translateY(2px); box-shadow: 0 3px 0 var(--brown); }
.cta:active { transform: translateY(5px); box-shadow: 0 0 0 var(--brown); }

/* ---------- About ---------- */
.about {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 16px 80px;
}

.section-title {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--brown);
  margin-bottom: 32px;
}
.hoof { display: inline-block; transform: rotate(-15deg); }

.card {
  display: flex; gap: 24px; align-items: flex-start;
  background: #fff;
  border: 3px solid var(--brown);
  border-radius: 28px;
  padding: 28px;
  box-shadow: 8px 8px 0 var(--grass);
}
.card-avatar {
  flex-shrink: 0;
  width: 88px; height: 88px;
  display: grid; place-items: center;
  background: var(--sky);
  border: 3px solid var(--brown);
  border-radius: 50%;
  overflow: hidden;
}
.card-avatar .goat { width: 100%; height: 100%; }
.card-body h3 { font-size: 1.5rem; color: var(--brown); }
.role {
  display: inline-block;
  margin: 4px 0 12px;
  padding: 0 12px;
  font-size: .85rem;
  font-weight: 700;
  background: var(--pink);
  border-radius: 999px;
}

.facts {
  list-style: none;
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.facts li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
  background: var(--cream);
  border: 3px dashed #d9c7b2;
  border-radius: 20px;
  padding: 14px 18px;
}
.fact-icon { grid-row: span 2; font-size: 1.8rem; }
.fact-label { font-size: .8rem; color: var(--muted); font-weight: 700; }

/* スクロールでふわっと表示 */
.reveal { opacity: 0; transform: translateY(24px); transition: .7s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* ---------- フッター（草原） ---------- */
.field {
  background: var(--grass);
  text-align: center;
  padding: 24px 16px 28px;
  color: #2f5a24;
  font-weight: 700;
  font-size: .9rem;
}
.grass {
  position: absolute;
  top: -22px; left: 0; right: 0;
  height: 24px;
  background:
    radial-gradient(circle at 12px 24px, var(--grass) 12px, transparent 13px) repeat-x;
  background-size: 24px 24px;
}

@media (max-width: 560px) {
  .facts { grid-template-columns: 1fr; }
  .card { flex-direction: column; align-items: center; text-align: center; padding: 22px; }
  .bubble { right: -20px; top: -24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- ひみつの小屋（隠し要素） ---------- */
.secret-hut {
  max-width: 560px;
  margin: 0 auto 60px;
  padding: 28px;
  background: #241c2e;
  color: #f1e9ff;
  border: 3px solid #ffd45e;
  border-radius: 24px;
  box-shadow: 0 0 24px rgba(255, 212, 94, .5), 8px 8px 0 #120e18;
  animation: hutAppear .6s ease;
}
.secret-hut .section-title { color: #ffd45e; }
.secret-sub { text-align: center; color: #c9bce0; margin-bottom: 16px; }

@keyframes hutAppear {
  from { opacity: 0; transform: scale(.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.cipher-box { text-align: center; }
.cipher-label { font-size: .8rem; letter-spacing: .15em; color: #ffd45e; margin-bottom: 6px; }
.cipher-text {
  font-family: "Courier New", monospace;
  font-size: 1.1rem;
  letter-spacing: .05em;
  background: #120e18;
  padding: 10px 16px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 16px;
}
#cipherForm { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.cipher-input-label { display: block; font-size: .75rem; color: #c9bce0; margin-bottom: 6px; width: 100%; }
#cipherAnswer {
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid #ffd45e;
  background: #fff;
  color: #241c2e;
  font-family: inherit;
}
#cipherForm button {
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid #ffd45e;
  background: #ffd45e;
  color: #241c2e;
  font-weight: 800;
  cursor: pointer;
}
#cipherForm button:hover { filter: brightness(1.05); }
.cipher-result { margin-top: 14px; font-weight: 700; min-height: 1.4em; }
.cipher-result.success { color: #9ed98a; }
.cipher-result.fail { color: #ff9b9b; }

/* ---------- びっくり演出（脅かし要素） ---------- */
.boo-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(10, 0, 10, .85);
  opacity: 0;
  pointer-events: none;
}
.boo-overlay.show {
  opacity: 1;
  animation: booFlash .5s ease forwards;
}
.boo-eyes { font-size: 6rem; animation: booPop .5s ease; }
.boo-text { color: #ff5a5a; font-weight: 800; font-size: 1.6rem; text-shadow: 0 0 12px #ff5a5a; }

@keyframes booFlash {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes booPop {
  0%   { transform: scale(.3); }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
body.shake { animation: screenShake .4s ease; }
@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 4px); }
  40% { transform: translate(6px, -4px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(4px, 2px); }
}

/* ---------- 隠れ羊ピーカー ---------- */
.peeker {
  position: fixed;
  bottom: -60px;
  right: 24px;
  font-size: 2.6rem;
  z-index: 50;
  transition: transform .6s cubic-bezier(.3, 1.4, .5, 1);
  transform: translateY(0);
}
.peeker.peek { transform: translateY(-70px); }

@media (prefers-reduced-motion: reduce) {
  .boo-overlay, .boo-eyes, body.shake, .secret-hut { animation: none !important; }
}
