/* ---------------------------------------------
 * テーマ変数
 * ------------------------------------------- */
:root {
  --bg-gradient:
    radial-gradient(circle at 18% 22%, rgba(124, 104, 201, 0.55), transparent 52%),
    radial-gradient(circle at 78% 18%, rgba(86, 116, 209, 0.4), transparent 58%),
    linear-gradient(180deg, #33295f 0%, #2a2150 52%, #201945 100%);
  --text-color: #fdf9ff;
  --muted-text: rgba(253, 249, 255, 0.8);
  --status-color: #ffffff;
  --hero-surface: rgba(39, 28, 78, 0.58);
  --hero-outline: rgba(255, 255, 255, 0.12);
  --puzzle-surface: rgba(27, 20, 60, 0.66);
  --puzzle-outline: rgba(161, 160, 214, 0.22);
  --btn-bg: rgba(255, 255, 255, 0.18);
  --btn-text: #fff6ff;
  --btn-shadow: rgba(21, 14, 54, 0.35);
  --btn-shadow-active: rgba(21, 14, 54, 0.28);

  --clock-glow: rgba(142, 161, 233, 0.28);
  --clock-face: rgba(33, 25, 69, 0.92);
  --clock-rim: rgba(255, 255, 255, 0.6);
  --clock-tick: rgba(255, 255, 255, 0.55);
  --clock-hand: #ffd6f9;
  --cup-body: rgba(28, 19, 60, 0.75);
  --cup-rim: rgba(255, 255, 255, 0.78);
  --cup-outline: rgba(255, 255, 255, 0.42);
  --drink-color: #ffe6a6;
  --drink-opacity: 0;

  --wave-glow: rgba(207, 195, 255, 0.35);
  --wave-layer-1: rgba(255, 231, 208, 0.35);
  --wave-layer-2: rgba(255, 240, 224, 0.65);

  --font-display: "Zen Maru Gothic", "Noto Sans JP", system-ui, sans-serif;
}

body.body--flooded {
  --bg-gradient:
    radial-gradient(circle at 82% 16%, rgba(255, 219, 166, 0.48), transparent 56%),
    radial-gradient(circle at 12% 24%, rgba(255, 209, 222, 0.4), transparent 60%),
    linear-gradient(180deg, #fff1f0 0%, #ffe9d8 54%, #fff7e5 100%);
  --text-color: #fdf9ff;
  --muted-text: rgba(93, 61, 77, 0.78);
  --status-color: #ffbc5c;
  --hero-surface: rgba(255, 255, 255, 0.72);
  --hero-outline: rgba(255, 197, 207, 0.55);
  --puzzle-surface: rgba(255, 255, 255, 0.78);
  --puzzle-outline: rgba(255, 212, 226, 0.46);
  --btn-bg: rgba(255, 255, 255, 0.9);
  --btn-text: #865770;
  --btn-shadow: rgba(255, 176, 196, 0.46);
  --btn-shadow-active: rgba(255, 176, 196, 0.34);

  --clock-glow: rgba(255, 202, 158, 0.35);
  --clock-face: rgba(255, 255, 255, 0.92);
  --clock-rim: rgba(255, 186, 207, 0.9);
  --clock-tick: rgba(255, 178, 211, 0.8);
  --clock-hand: #ff9c9f;
  --cup-body: rgba(255, 255, 255, 0.92);
  --cup-rim: rgba(255, 208, 214, 0.95);
  --cup-outline: rgba(255, 168, 192, 0.58);
  --drink-color: #ffe28f;
  --drink-opacity: 1;

  --wave-glow: rgba(255, 222, 191, 0.45);
  --wave-layer-1: rgba(255, 226, 143, 0.42);
  --wave-layer-2: rgba(255, 226, 143, 0.72);
}

/* ---------------------------------------------
 * リセット
 * ------------------------------------------- */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-display);
  line-height: 1.6;
  color: var(--text-color);
  background: var(--bg-gradient);
  transition: background 1.6s ease, color 0.9s ease;
}

p {
  margin: 0;
}

/* ---------------------------------------------
 * セクションレイアウト
 * ------------------------------------------- */

/* 夜→朝画面を重ね、アクティブ状態だけ表示するための土台 */
.screen-stack {
  position: relative;
  min-height: 100dvh;
}

.screen {
  display: none;
  /* 互いに重ねておき、.screen--active だけを前面に表示 */
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 100%;
  padding: clamp(32px, 8vw, 56px) clamp(20px, 6vw, 56px);
  z-index: 1;
  gap: clamp(32px, 6vw, 48px);
  align-content: center;
  overflow-y: auto;
}

.screen--active {
  display: grid;
}

/* ---------------------------------------------
 * ヒーローブロック
 * ------------------------------------------- */
.hero {
  max-width: 460px;
  margin: 0 auto;
  padding: clamp(28px, 7vw, 36px) clamp(24px, 6vw, 36px);
  border-radius: 32px;
  background: var(--hero-surface);
  border: 1px solid var(--hero-outline);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(6, 2, 32, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 4vw, 20px);
  text-align: center;
}

.hero--day {
  box-shadow: 0 28px 60px rgba(255, 180, 194, 0.32);
}

.hero__status {
  font-size: clamp(36px, 10vw, 70px);
  font-weight: 700;
  letter-spacing: 0.4rem;
  text-transform: uppercase;
  color: var(--status-color);
}

.hero__clock {
  width: clamp(220px, 58vw, 320px);
  margin: 0 auto;
}

.hero__clock-graphic {
  width: 100%;
  height: auto;
  display: block;
}

.clock__glow {
  fill: var(--clock-glow);
}

.clock__rim {
  fill: none;
  stroke: var(--clock-rim);
  stroke-width: 8;
}

.clock__face {
  fill: var(--clock-face);
}

.clock__ticks {
  stroke: var(--clock-tick);
}

.clock__hand {
  stroke: var(--clock-hand);
  stroke-linecap: round;
  transition: stroke 0.6s ease;
}

.clock__hand--hour {
  stroke-width: 8;
}

.clock__hand--minute {
  stroke-width: 6;
}

.cup__body {
  fill: var(--cup-body);
  stroke: var(--cup-outline);
  stroke-width: 3;
  stroke-linejoin: round;
}

.cup__rim {
  fill: var(--cup-rim);
  stroke: var(--cup-outline);
  stroke-width: 3;
  stroke-linecap: round;
}

.cup__drink {
  fill: var(--drink-color);
  opacity: var(--drink-opacity);
  transition: opacity 1.4s ease;
}

.cup__smile {
  stroke: var(--clock-hand);
  transition: stroke 0.6s ease;
}

.hero__emoji {
  font-size: 28px;
  display: inline-block;
  margin-bottom: 4px;
}

.hero__lead {
  font-size: clamp(16px, 4.5vw, 18px);
  color: var(--text-color);
}

/* ===== スマホサイズ対応 ===== */
@media (max-width: 480px) {
  .hero__lead {
    font-size: 0.9rem;           /* 少し小さめに */
    line-height: 1.6;
    padding: 0.8em 1em;
  }
}

.hero__question {
  font-size: clamp(18px, 5vw, 22px);
  font-weight: 600;
  color: var(--muted-text);
}

.hero__list {
  display: grid;
  gap: 12px;
  color: var(--muted-text);
  font-size: clamp(15px, 4.2vw, 18px);
}

.hero__list-item span:first-child {
  margin-right: 6px;
}

/* ---------------------------------------------
 * スワイプ領域
 * ------------------------------------------- */
.clock-pad {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  touch-action: none;
}

/* デバッグ表示用のレイヤー。クリック・タッチを透過させる */
#debugLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

/* 実際のタッチを受ける透明レイヤー */
#touchLayer {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  z-index: 2;
  /* デバッグ時に枠が見たい場合は以下をON
  outline: 1px dashed #bbb;
  */
}

/* ---------------------------------------------
 * 背景の波
 * ------------------------------------------- */
#waveBg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none; /* 触れない */
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, var(--wave-glow) 0%, transparent 60%);
  transition: filter 1.2s ease, opacity 1.2s ease;
}

body.body--flooded #waveBg {
  filter: brightness(1.05) saturate(1.15);
}

/* 夜明け演出用の太陽・月 */
.sky-object {
  position: fixed;
  top: clamp(20px, 7vh, 72px);
  right: clamp(20px, 8vw, 80px);
  width: clamp(120px, 24vw, 180px);
  height: auto;
  z-index: 3;
  opacity: 0;
  transform: translateY(12px) scale(0.94);
  transition: opacity 1.4s ease, transform 1.2s ease;
  pointer-events: none;
  filter: drop-shadow(0 18px 38px rgba(28, 18, 68, 0.42));
}

.sky-object svg {
  width: 100%;
  height: auto;
  display: block;
}

.sky-object--moon {
  opacity: 1;
}

body.body--flooded .sky-object--moon {
  opacity: 0;
  transform: translateY(-12px) scale(0.92);
}

body.body--flooded .sky-object--sun {
  opacity: 1;
  transform: translateY(-6px) scale(1.06);
  filter: drop-shadow(0 22px 42px rgba(255, 189, 170, 0.52));
}

/* 朝画面の背景に空と地面を重ねる */
.hero--day {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(148, 208, 255, 0.88) 0%, rgba(178, 228, 161, 0.95) 70%, rgba(118, 198, 129, 0.95) 100%);
}

.hero--day::before,
.hero--day::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 柔らかな雲を浮かべる */
.hero--day::before {
  background:
    radial-gradient(circle at 20% 32%, rgba(255, 255, 255, 0.7) 0%, transparent 55%),
    radial-gradient(circle at 72% 26%, rgba(255, 255, 255, 0.6) 0%, transparent 60%);
  opacity: 0.75;
  mix-blend-mode: screen;
}

/* 地面に緩やかな丘のラインを加える */
.hero--day::after {
  top: 75%;
  height: 80%;
  background:
    radial-gradient(120% 120% at 20% 20%, rgba(102, 183, 121, 0.85) 0%, transparent 72%),
    radial-gradient(100% 110% at 80% 10%, rgba(91, 173, 110, 0.8) 0%, transparent 70%);
  opacity: 0.9;
  mix-blend-mode: multiply;
}

.hero--day > * {
  position: relative;
  z-index: 1;
}


/* ---------------------------------------------
 * デバッグ用：チェックポイントのドット表示
 * ------------------------------------------- */
/* チェックポイントの可視化（DEBUG 用、通常公開では非表示） */
.cp-dot {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.65);
  background: rgba(255, 205, 232, 0.9);
  box-shadow: 0 10px 24px rgba(51, 34, 104, 0.25);
}

.cp-dot--next {
  background: rgba(198, 213, 255, 0.9);
}

.cp-dot--passed {
  background: rgba(187, 247, 208, 0.9);
}

/* ---------------------------------------------
 * ボタン
 * ------------------------------------------- */
.btn {
  justify-self: center;
  padding: 14px 26px;
  font-size: 16px;
  font-weight: 600;
  color: var(--btn-text);
  background: var(--btn-bg);
  border: none;
  border-radius: 999px;
  box-shadow: 0 16px 34px var(--btn-shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, color 0.3s ease;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 10px 20px var(--btn-shadow-active);
}

body.body--flooded .btn {
  color: var(--btn-text);
}

@media (min-width: 768px) {
  .screen {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
  }

  #screenB.screen {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .hero,
  .puzzle {
    max-width: none;
  }

  .puzzle {
    justify-self: end;
  }

  .hero {
    justify-self: start;
  }
}