/* ---------- #1 メニュー（ビーチの背景に、物の位置へ文字を重ねる） ----------
   文字の大きさは背景の実描画の高さ --fh（js/ui/menu.js が入れる）に比例させ、画面サイズが変わってもずれないようにする */
.menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  background: #0b0d10;
  --fh: 100vh;
  animation: menu-in 0.5s ease both;
}
.menu[hidden] { display: none; }
.menu:focus { outline: none; }
@keyframes menu-in { from { opacity: 0; } to { opacity: 1; } }

.scene { position: absolute; inset: 0; }
.scene-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
/* 位置と大きさは scene1.js が背景の実描画の矩形を入れる（入った後は object-fit は効かない） */
.scene-media[style*="width"] { inset: auto; max-width: none; object-fit: fill; }

/* 入口（位置と大きさは JS が背景に合わせて入れる） */
.spot {
  position: absolute;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.spot:focus-visible { outline: 2px solid var(--zeal-mustard); outline-offset: 4px; border-radius: 6px; }

/* ---- ヤシの幹の焼き印: 焦げ茶の字、輪郭が炭に息を吹きかけたように赤くジワジワ光る ---- */
.burn {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", "Noto Serif CJK JP", serif;
  font-weight: 900;
  font-size: clamp(18px, calc(var(--fh) * 0.03), 42px);
  letter-spacing: 0.18em;
  line-height: 1;
  color: #1f0f06;
  -webkit-text-stroke: 0.6px rgba(255, 96, 32, 0.55);
  text-shadow:
    0 0 1px rgba(255, 110, 40, 0.9),
    0 0 4px rgba(255, 70, 20, 0.55),
    0 0 10px rgba(200, 40, 0, 0.35);
  animation: ember 3.6s ease-in-out infinite;
  transition: transform 0.25s ease;
}
.burn-late { animation-delay: -1.7s; animation-duration: 4.3s; }
.spot-burn:hover .burn, .spot-burn:focus-visible .burn { transform: scale(1.06); animation-duration: 1.4s; }

/* 一定でない呼吸: 弱く→急に赤く→ゆっくり冷める→小さく再燃 */
@keyframes ember {
  0%, 100% {
    -webkit-text-stroke-color: rgba(255, 96, 32, 0.35);
    text-shadow: 0 0 1px rgba(255, 110, 40, 0.6), 0 0 3px rgba(255, 70, 20, 0.35), 0 0 8px rgba(200, 40, 0, 0.2);
  }
  14% {
    -webkit-text-stroke-color: rgba(255, 150, 60, 0.95);
    text-shadow: 0 0 1px #ffb15a, 0 0 5px rgba(255, 90, 20, 0.95), 0 0 14px rgba(255, 50, 0, 0.7), 0 0 26px rgba(255, 30, 0, 0.35);
  }
  22% {
    -webkit-text-stroke-color: rgba(255, 120, 40, 0.75);
    text-shadow: 0 0 1px rgba(255, 140, 60, 0.9), 0 0 4px rgba(255, 80, 20, 0.75), 0 0 11px rgba(230, 40, 0, 0.5);
  }
  48% {
    -webkit-text-stroke-color: rgba(255, 96, 32, 0.4);
    text-shadow: 0 0 1px rgba(255, 110, 40, 0.65), 0 0 3px rgba(255, 70, 20, 0.4), 0 0 8px rgba(200, 40, 0, 0.22);
  }
  61% {
    -webkit-text-stroke-color: rgba(255, 130, 50, 0.8);
    text-shadow: 0 0 1px #ff9a4a, 0 0 4px rgba(255, 85, 20, 0.8), 0 0 12px rgba(240, 45, 0, 0.55);
  }
  78% {
    -webkit-text-stroke-color: rgba(255, 96, 32, 0.45);
    text-shadow: 0 0 1px rgba(255, 110, 40, 0.7), 0 0 3px rgba(255, 70, 20, 0.45), 0 0 9px rgba(200, 40, 0, 0.25);
  }
}

/* ---- 砂浜の落書き: 指でなぞった溝（暗い影と明るい縁） ---- */
.sand {
  font-family: "Yomogi", "UD Digi Kyokasho N-R", "Yu Kyokasho", "Klee One", cursive, var(--sans);
  font-size: clamp(30px, calc(var(--fh) * 0.068), 76px);
  line-height: 1;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: rgba(122, 96, 70, 0.62);
  text-shadow:
    1px 1px 0 rgba(255, 252, 244, 0.85),
    -1px -1px 1px rgba(92, 70, 46, 0.45),
    0 0 1px rgba(92, 70, 46, 0.3);
  transform: rotate(-5deg) skewX(-6deg);
  transition: color 0.25s ease;
}
.spot-sand:hover .sand, .spot-sand:focus-visible .sand { color: rgba(96, 70, 44, 0.8); }
/* PC で溝の画像が読めたら、文字は出さない（二重に出さない） */
.frame > .sand-img { position: absolute; display: none; pointer-events: none; opacity: 0; }
.menu[data-variant="pc"][data-news-img="on"] .frame > .sand-img:not([hidden]) { display: block; }
.menu[data-variant="pc"][data-news-img="on"] .sand { visibility: hidden; }

/* ---- テレビ: ブラウン管に「代表挨拶」。ランダムにチカチカ（data-flicker は JS） ---- */
.tv {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 44px;
  border-radius: 14% / 18%;
  background: radial-gradient(ellipse at 50% 45%, rgba(170, 220, 205, 0.55), rgba(40, 70, 64, 0.5) 70%, rgba(10, 20, 18, 0.6));
  box-shadow: 0 0 calc(var(--fh) * 0.012) rgba(160, 255, 225, 0.45);
  overflow: hidden;
}
.tv::after {
  /* 走査線 */
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.tv-text {
  font-weight: 800;
  font-size: clamp(11px, calc(var(--fh) * 0.0145), 22px);
  letter-spacing: 0.06em;
  line-height: 1.05;
  white-space: nowrap;
  color: #f2fff9;
  text-shadow: 0 0 4px rgba(170, 255, 225, 0.95), 0 0 10px rgba(120, 255, 210, 0.6);
}
.tv[data-flicker="dim"] { filter: brightness(0.55); }
.tv[data-flicker="off"] { filter: brightness(0.12) contrast(1.4); }
.tv[data-flicker="roll"] .tv-text { transform: translate(2px, -3px) skewX(-8deg); opacity: 0.75; }
.tv[data-flicker="roll"]::after { transform: translateY(2px); }
.spot-tv:hover .tv { box-shadow: 0 0 calc(var(--fh) * 0.02) rgba(160, 255, 225, 0.75); }

/* ---- #0 へ戻る ---- */
.menu-back {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--zeal-mustard);
  border-radius: 999px;
  background: rgba(47, 46, 41, 0.62);
  color: var(--zeal-cream);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
/* #1 に切り替わってから 0.3 秒遅らせて、0.3 秒でふわっと出す（menu.js の show() が data-shown を入れる） */
.menu[data-shown] .menu-back { animation: back-in 0.3s ease 0.3s both; }
@keyframes back-in { from { opacity: 0; } to { opacity: 1; } }
.menu-back:hover { background: rgba(47, 46, 41, 0.8); }
.menu-back:focus-visible { outline: 2px solid var(--zeal-mustard); outline-offset: 3px; }

/* ---- #0 → #1 のつなぎの動画（js/ui/intro.js）。流れている間は #1 の中身を隠し、待っている間は #0 が透けて見える ---- */
.frame > .intro { position: absolute; display: none; pointer-events: none; }
.frame > .intro video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill; /* 入れ物は動画と同じ縦横比（scene1.js の intro.rect） */
  opacity: 0;
}
.frame > .intro video.is-on { opacity: 1; }
.menu[data-intro] { background: transparent; animation: none; cursor: pointer; }
/* 動画のあとは、#1 をフェードで出し直さない（B の最後のコマ＝背景なので、そのまま切り替える） */
.menu[data-after-intro] { animation: none; }
.menu[data-intro] .frame > .intro { display: block; }
.menu[data-intro] .scene,
.menu[data-intro] .frame > :not(.intro),
.menu[data-intro] .menu-back { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .menu { animation: none; }
  .menu[data-shown] .menu-back { animation: none; }
  .burn { animation: none; }
}

/* スマホ縦: テレビの画面が小さいので「代表／挨拶」の 2 行に */
.menu[data-variant="sp"] .tv-text span { display: block; text-align: center; }

/* ---- PC のメニューの画: 刻印が燃える演出（js/ui/ember.js）・テレビ（js/ui/tv-fx.js） ---- */
.spot[hidden] { display: none; }
.frame > canvas.ember,
.frame > canvas.tv-fx {
  position: absolute;
  display: none;
  pointer-events: none;
}
.frame > canvas.ember { inset: 0; width: 100%; height: 100%; }
.menu[data-variant="pc"][data-ember="on"] .frame > canvas.ember { display: block; }
/* テレビは画面の形の画像で切り抜いたキャンバスに映す（位置は menu.js が TV_SCREEN から入れる） */
.menu[data-variant="pc"] .frame > canvas.tv-fx { display: block; }
.menu[data-variant="pc"] .spot-tv .tv { display: none; }
/* 刻印を WebGL で描いているときは、文字の焼き印は隠す（読み上げは aria-label） */
.menu[data-ember="on"] .burn { opacity: 0; animation: none; }
/* 刻印は背景と同じ矩形で描き、両方のヤシが画面に入る範囲だけ PC の画にする（scene1.js の keepX・minAspect）ので、
   焼き印の文字を画面の端に寄せる代わりの表示は PC では使わない */
