:root {
  --ink: #4A3428;
  --accent: #FF8A5B;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --spring-dur: 520ms;
  --spring-ease: cubic-bezier(.34, 1.56, .64, 1);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "M PLUS Rounded 1c", "Noto Sans JP", system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #FFF6E8;
}

body {
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

#app { position: fixed; inset: 0; overflow: hidden; }

#sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--sky-top, #FFF6E8), var(--sky-bottom, #FFE2D1));
}

#pager { position: absolute; inset: 0; touch-action: none; cursor: grab; }
#pager.grabbing { cursor: grabbing; }

.page { position: absolute; inset: 0; will-change: transform; }
.layer { position: absolute; inset: 0; pointer-events: none; will-change: transform, opacity; }

.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-top) + 28px) 16px calc(var(--safe-bottom) + 70px);
  color: var(--page-ink);
}
.content :is(button, .buddy) { pointer-events: auto; }

#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------- ページインジケーター ---------- */

#indicator {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 20px);
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
#indicator .dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  opacity: .25;
}
#indicator .dot::after { content: ""; position: absolute; inset: -12px -6px; }
#indicator .pill {
  position: absolute;
  top: 10px;
  left: 14px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 60%, transparent);
  will-change: transform, width;
  pointer-events: none;
}

/* ---------- ぷにっと押せるボタン ---------- */

[data-squish] { transition: transform var(--spring-dur) var(--spring-ease), box-shadow 120ms; }
[data-squish].pressed { transform: scale(.94) translateY(3px); transition: transform 90ms ease-out, box-shadow 90ms; }

/* ---------- なかま ---------- */

.stage { flex: 1; display: grid; width: 100%; }
.stage.center { place-items: center; }
.stage.ground { place-items: end center; padding-bottom: 5vh; }

.buddy {
  position: relative;
  width: 148px;
  height: 148px;
  touch-action: none;
  cursor: pointer;
}
.buddy-wrap {
  position: absolute;
  inset: 0;
  transform-origin: 50% 100%;
  will-change: transform;
}
.buddy-body {
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 46% 46% / 56% 56% 44% 44%;
  background:
    radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--buddy) 45%, white) 0 14%, transparent 34%),
    radial-gradient(circle at 50% 40%, var(--buddy) 55%, color-mix(in srgb, var(--buddy) 82%, #3a2050));
  box-shadow: 0 6px 0 color-mix(in srgb, var(--buddy) 70%, #3a2050);
  transform-origin: 50% 100%;
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.035, .965); }
}

.buddy-face {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 78px;
  height: 46px;
  transform: translate(-50%, -50%);
}
.eye {
  position: absolute;
  top: 0;
  width: 16px;
  height: 21px;
  border-radius: 50%;
  background: #2B1E2E;
  overflow: hidden;
  transition: height 80ms, top 80ms;
}
.eye.l { left: 12px; }
.eye.r { right: 12px; }
.pupil {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease-out;
}
.buddy.blink .eye { height: 3px; top: 10px; }

.cheek {
  position: absolute;
  top: 24px;
  width: 17px;
  height: 9px;
  border-radius: 50%;
  background: #FF6F96;
  opacity: .42;
}
.cheek.l { left: -2px; }
.cheek.r { right: -2px; }

.mouth {
  position: absolute;
  left: 50%;
  top: 25px;
  width: 14px;
  height: 8px;
  transform: translateX(-50%);
  border: 3px solid #2B1E2E;
  border-top: 0;
  border-radius: 0 0 12px 12px;
  transition: all 120ms;
}

/* 連打中：にこにこ顔 */
.buddy.happy .eye {
  height: 11px;
  top: 6px;
  background: none;
  border: 3.5px solid #2B1E2E;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
}
.buddy.happy .pupil { display: none; }
.buddy.happy .mouth { width: 20px; height: 12px; background: #2B1E2E; border-radius: 3px 3px 12px 12px; }

/* 長押し中：ほっぺをふくらませる */
.buddy.charging .mouth { width: 10px; height: 10px; border: 3px solid #2B1E2E; border-radius: 50%; top: 24px; }
.buddy.charging .cheek { opacity: .75; transform: scale(1.25); }

.buddy-shadow {
  position: absolute;
  left: 50%;
  bottom: -12px;
  width: 112px;
  height: 16px;
  border-radius: 50%;
  background: rgba(30, 10, 40, .16);
  transform: translateX(-50%);
  filter: blur(2px);
}
.page-night .buddy-shadow { background: rgba(0, 0, 0, .35); }

.combo {
  position: absolute;
  left: 50%;
  top: -46px;
  transform: translateX(-50%) scale(0);
  font-size: 30px;
  font-weight: 800;
  white-space: nowrap;
  color: var(--page-ink);
  text-shadow: 0 3px 0 color-mix(in srgb, var(--page-ink) 18%, transparent);
  pointer-events: none;
}
.combo.hot { color: var(--page-accent); }

/* 画面ごとの小物 */
.buddy[data-variant="morning"] .buddy-body::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -18px;
  width: 22px;
  height: 26px;
  background: #6DBE6A;
  border-radius: 100% 0 100% 0;
  transform: translateX(-20%) rotate(-12deg);
}
.buddy[data-variant="noon"] .buddy-body::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -14px;
  width: 4px;
  height: 18px;
  background: #E0A92A;
  border-radius: 4px;
  transform: translateX(-50%);
  box-shadow: 0 -8px 0 4px #FFEA8A;
}
.buddy[data-variant="night"] .buddy-body::before {
  content: "";
  position: absolute;
  left: 26%;
  top: -30px;
  width: 0;
  height: 0;
  border-left: 34px solid transparent;
  border-right: 34px solid transparent;
  border-bottom: 52px solid #4B3FB8;
  transform: rotate(14deg);
  transform-origin: 50% 100%;
}
.buddy[data-variant="night"] .buddy-body::after {
  content: "";
  position: absolute;
  left: 77px;
  top: -37px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #FFF6C8;
  box-shadow: 0 0 12px #FFF6C8;
}

/* ---------- ホーム ---------- */

.home-head { text-align: center; margin-top: 2vh; }
.greet { font-size: 15px; font-weight: 600; opacity: .7; }
.clock { font-size: clamp(56px, 17vw, 76px); font-weight: 800; letter-spacing: .02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.date { font-size: 14px; opacity: .6; }

.cards { display: flex; gap: 12px; width: 100%; max-width: 420px; }
.card {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 12px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 5px 0 rgba(74, 52, 40, .14), 0 12px 24px rgba(74, 52, 40, .08);
  font-weight: 700;
  font-size: 15px;
}
.card.pressed { box-shadow: 0 1px 0 rgba(74, 52, 40, .14), 0 4px 10px rgba(74, 52, 40, .06); }
.card-art { width: 46px; height: 46px; border-radius: 50%; }
.card-art.morning { background: radial-gradient(circle at 50% 70%, #FFE6A0 0 26%, transparent 27%), linear-gradient(#A9BFFF, #FFD6B5); }
.card-art.noon { background: radial-gradient(circle at 62% 36%, #FFE45C 0 24%, transparent 25%), linear-gradient(#3FA6F2, #BDEBFF); }
.card-art.night { background: radial-gradient(circle at 60% 38%, transparent 0 15%, #090E2C 16%) , radial-gradient(circle at 52% 42%, #FFF4C9 0 22%, transparent 23%), linear-gradient(#090E2C, #2D2A6E); }
.card.is-now::after {
  content: "いま";
  position: absolute;
  top: -8px;
  right: -4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--page-accent);
  color: #fff;
  font-size: 11px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .12);
}

.chips { display: flex; gap: 8px; margin-top: 14px; }
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .62);
  box-shadow: 0 3px 0 rgba(74, 52, 40, .1);
  font-size: 13px;
  font-weight: 700;
}
.chip[aria-pressed="false"] { opacity: .55; }

.blob { position: absolute; border-radius: 50%; filter: blur(34px); opacity: .55; animation: float 11s ease-in-out infinite; }
.blob.b1 { width: 220px; height: 220px; left: -60px; top: 8%; background: #FFC7A8; }
.blob.b2 { width: 180px; height: 180px; right: -50px; top: 40%; background: #FFE1A0; animation-delay: -4s; }
.blob.b3 { width: 200px; height: 200px; left: 20%; bottom: -60px; background: #FFB8C9; animation-delay: -7s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(18px, -22px); }
}

/* ---------- 朝昼夜の画面 ---------- */

.title { text-align: center; margin-top: 3vh; }
.title h1 { font-size: clamp(58px, 18vw, 88px); font-weight: 800; letter-spacing: .1em; line-height: 1.05; text-indent: .1em; }
.title p { margin-top: 10px; font-size: 15px; font-weight: 600; opacity: .78; }
.hint {
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, white 40%, transparent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
}
.page-night .hint { background: rgba(255, 255, 255, .1); }

.hills { position: absolute; left: 0; bottom: 0; width: 100%; height: 34%; }

.tuft { position: absolute; bottom: -2px; width: 80px; height: 54px; }
.tuft.left { left: -6px; }
.tuft.right { right: -6px; transform: scaleX(-1); }

.sun { position: absolute; border-radius: 50%; }
.sun-morning {
  width: min(48vw, 240px);
  aspect-ratio: 1;
  left: 10%;
  bottom: 24%;
  background: radial-gradient(circle, #FFF6C0 0 35%, #FFC27A 70%, #FFA36B);
  box-shadow: 0 0 90px 36px rgba(255, 196, 130, .55);
  animation: rise 7s ease-in-out infinite;
}
@keyframes rise {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}
.sun-noon {
  width: 96px;
  height: 96px;
  top: calc(var(--safe-top) + 24%);
  right: 10%;
  background: radial-gradient(circle, #FFF9C9 0 30%, #FFE45C 62%);
  box-shadow: 0 0 60px 20px rgba(255, 236, 120, .6);
}
.sun-noon::before {
  content: "";
  position: absolute;
  inset: -46px;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 245, 170, .55) 0 7deg, transparent 7deg 22.5deg);
  -webkit-mask: radial-gradient(circle, transparent 0 46%, #000 47% 66%, transparent 74%);
  mask: radial-gradient(circle, transparent 0 46%, #000 47% 66%, transparent 74%);
  animation: spin 28s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.moon {
  position: absolute;
  top: calc(var(--safe-top) + 25%);
  right: 9%;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  box-shadow: inset -24px 10px 0 0 #FFF4C9;
  filter: drop-shadow(0 0 20px rgba(255, 244, 201, .55));
  transform: rotate(-8deg);
}
.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, .8);
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: .25; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.15); }
}
.shooting {
  position: absolute;
  top: 18%;
  left: 10%;
  width: 120px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, #fff);
  opacity: 0;
  transform: rotate(-18deg);
  animation: shoot 9s ease-in infinite 2s;
}
@keyframes shoot {
  0%, 88% { opacity: 0; transform: translate(0, 0) rotate(-18deg); }
  90% { opacity: 1; }
  100% { opacity: 0; transform: translate(220px, 70px) rotate(-18deg); }
}

.cloud {
  position: absolute;
  width: 130px;
  height: 40px;
  border-radius: 40px;
  background: #fff;
  opacity: .92;
  animation: drift 22s ease-in-out infinite alternate;
}
.cloud::before, .cloud::after { content: ""; position: absolute; border-radius: 50%; background: inherit; }
.cloud::before { width: 56px; height: 56px; left: 18px; top: -28px; }
.cloud::after { width: 44px; height: 44px; left: 62px; top: -18px; }
.cloud.pink { background: #FFE3EA; opacity: .85; }
.cloud.c1 { top: calc(var(--safe-top) + 30%); left: 54%; }
.cloud.c2 { top: calc(var(--safe-top) + 44%); left: 4%; transform: scale(.75); animation-delay: -9s; }
.cloud.c3 { top: calc(var(--safe-top) + 20%); left: 8%; transform: scale(.6); animation-delay: -15s; }
@keyframes drift {
  from { translate: -26px 0; }
  to { translate: 26px 0; }
}

.flower {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #FFD23F;
  box-shadow: 0 -8px 0 #fff, 0 8px 0 #fff, -8px 0 0 #fff, 8px 0 0 #fff;
  animation: sway 3.4s ease-in-out infinite;
}
@keyframes sway {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg); }
}

.firefly {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FFF6A8;
  box-shadow: 0 0 10px 4px rgba(255, 246, 168, .65);
  animation: firefly 6s ease-in-out infinite;
}
@keyframes firefly {
  0%, 100% { transform: translate(0, 0); opacity: .2; }
  30% { opacity: 1; }
  50% { transform: translate(14px, -26px); opacity: .9; }
  80% { transform: translate(-10px, -12px); opacity: .3; }
}

/* 動きを減らす設定の人には、待機中の動きを止める */
@media (prefers-reduced-motion: reduce) {
  .buddy-body, .blob, .sun, .sun-noon::before, .star, .shooting, .cloud, .flower, .firefly { animation: none; }
}
