/* =========================================================
   あそぶページ（/game「3回唱えろ」）

   読むページには要らないものなので、style.css とは分けている。
   背景の絵（img/play/*.webp）は JS が読めたときだけ敷く。
   ここに url() で書くと、絵がまだ無いときにビルドのリンク検査で落ちるため。
   ========================================================= */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.play-main { position: relative; z-index: 1; }

.nav a.is-current { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- このページについて（下の説明） ---------- */
.play-about {
  max-width: 620px;
  margin: clamp(28px, 6vw, 56px) auto;
  padding: 22px clamp(18px, 4vw, 30px);
  background: var(--daikon);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-size: 14.5px;
}
.play-about p { margin: 0 0 12px; }
.play-about-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: .04em;
}
.play-about-note { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 0 !important; }


/* =========================================================
   3回唱えろ
   ========================================================= */

/* 遊んでいるあいだは、ページが動かないようにする */
body.is-playing { overflow: hidden; overscroll-behavior: none; }

.game-stage {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: calc(100vh - 58px);
  height: calc(100svh - 58px);
  min-height: 460px;
  margin: 0 auto;
  overflow: hidden;
  /* 指の操作はすべてゲームが受け持つ（拡大・スクロール・選択・長押しメニューを止める） */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  /* 背景の絵が無いときの、コンビニの店内らしい色（壁・おでんケースの台・床） */
  background-color: #efe6d2;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, .55) 0 18%, transparent 18%),
    linear-gradient(180deg, transparent 0 24%, #c9b48d 24% 25%, #e9dcc0 25% 44%, #b99d6c 44% 46%, transparent 46%),
    repeating-linear-gradient(90deg, rgba(60, 42, 28, .05) 0 2px, transparent 2px 64px),
    linear-gradient(180deg, #f3ecdc 0%, #e8dcc3 60%, #ddcfb2 100%);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  border-left: 2px solid var(--line);
  border-right: 2px solid var(--line);
}
.game-stage.has-bg { background-color: #2a2420; }

/* 背景の絵が無いときだけ、サイトのおでんケースの絵を置く */
.game-stage::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 22%;
  width: min(62%, 320px);
  aspect-ratio: 880 / 561;
  transform: translateX(-50%);
  background: url("img/hero-oden.webp") center / contain no-repeat;
  opacity: .95;
  pointer-events: none;
}
.game-stage.has-bg::before { display: none; }

.game-field { position: absolute; inset: 0; }
/* 切り絵のモチキン（mochikin-rig.js）は、全員をこの1枚に描く */
.game-canvas { position: absolute; left: 0; top: 0; pointer-events: none; }

/* ここまで来られたら、こぼれる */
.game-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 86%;
  bottom: 0;
  border-top: 3px dashed rgba(210, 96, 63, .75);
  background: linear-gradient(180deg, rgba(255, 250, 240, .55), rgba(255, 250, 240, .85));
  pointer-events: none;
}

.game-voice { position: absolute; inset: 0; pointer-events: none; z-index: 2000; }

/* 唱えた声は、線の下（こちら側）から出る */
.game-bubble {
  translate: -50% 0;
  font-size: 13px;
}
.game-bubble::after { left: calc(50% - 8px); }

.tap-ring {
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 2px solid rgba(60, 42, 28, .35);
  border-radius: 50%;
  animation: tap-ring .38s ease-out forwards;
}
@keyframes tap-ring {
  from { transform: scale(.4); opacity: 1; }
  to { transform: scale(1.3); opacity: 0; }
}

/* ---------- モチキン ---------- */
.mob {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 50% 100%;
  pointer-events: none;
  will-change: transform;
}
.mob-body {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 100%;
}
.mob-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
  filter: drop-shadow(0 3px 0 rgba(60, 42, 28, .22));
  -webkit-user-drag: none;
}
.mob-img.is-alt { transform: scaleX(-1); }

/* 唱えられた瞬間に、びくっとする */
.mob.is-hit .mob-body { animation: mob-hit .22s ease-out; }
@keyframes mob-hit {
  0% { transform: scale(1.18, .84); }
  60% { transform: scale(.94, 1.08); }
  100% { transform: scale(1, 1); }
}
.mob.is-t1:not(.is-hit) .mob-body { animation: mob-wobble .42s ease-in-out infinite; }
.mob.is-t2:not(.is-hit) .mob-body { animation: mob-wobble .2s ease-in-out infinite; }
@keyframes mob-wobble {
  0%, 100% { transform: rotate(-3deg) scale(1.02, .98); }
  50% { transform: rotate(3deg) scale(.98, 1.02); }
}

/* あと何回でパンか（頭の上の3つの丸） */
.mob-pips {
  position: absolute;
  left: 50%;
  top: -16px;
  display: flex;
  gap: 4px;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity .12s;
}
.mob.is-t1 .mob-pips,
.mob.is-t2 .mob-pips { opacity: 1; }
.mob-pips i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: #fff;
}
.mob.is-t1 .mob-pips i:nth-child(1),
.mob.is-t2 .mob-pips i:nth-child(-n+2) { background: var(--accent); }

.mob.is-big .mob-img { filter: drop-shadow(0 3px 0 rgba(60, 42, 28, .22)) saturate(1.15); }

/* 線まで来てしまった（やさしく消える） */
.mob.is-spill .mob-body { animation: mob-spill .5s ease-in forwards; }
@keyframes mob-spill {
  to { transform: translateY(30%) scale(1.1, .6); opacity: 0; }
}
/* 時間切れで、鍋に戻っていく */
.mob.is-home .mob-body { animation: mob-home .6s ease-in forwards; }
@keyframes mob-home {
  to { transform: translateY(-20%) scale(.3); opacity: 0; }
}

/* ---------- はじける ---------- */
.pop {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}
.pop img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  translate: -50% -50%;
  animation: pop-burst .6s ease-out forwards;
}
@keyframes pop-burst {
  0% { transform: scale(.6); opacity: 1; }
  55% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1.25); opacity: 0; }
}
.pop-pan {
  position: absolute;
  left: 0;
  top: -30px;
  translate: -50% -50%;
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--accent);
  text-shadow: 2px 2px 0 #fff, -2px 2px 0 #fff, 2px -2px 0 #fff, -2px -2px 0 #fff;
  white-space: nowrap;
  animation: pop-pan .7s ease-out forwards;
}
@keyframes pop-pan {
  0% { transform: scale(.4); opacity: 0; }
  25% { transform: scale(1.3); opacity: 1; }
  100% { transform: translateY(-18px) scale(1); opacity: 0; }
}
.pop i {
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pouch-dark);
  border: 2px solid var(--tie);
  animation: pop-bit .6s ease-out forwards;
}
@keyframes pop-bit {
  to { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; }
}

/* こぼれたとき、画面がゆれる */
.game-stage.is-shake { animation: stage-shake .42s ease-in-out; }
@keyframes stage-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}

/* ---------- 画面の上の表示 ---------- */
.game-hud {
  position: absolute;
  z-index: 2100;
  left: 8px;
  right: 8px;
  top: 8px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.game-hud[hidden] { display: none; }
.game-hud p {
  margin: 0;
  padding: 2px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(253, 250, 243, .94);
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.4;
  white-space: nowrap;
}
.game-hud small { font-size: 11px; margin-left: 2px; }
.hud-time {
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(253, 250, 243, .94);
  overflow: hidden;
}
.hud-time i {
  display: block;
  height: 100%;
  background: var(--accent-2);
  transform-origin: 0 50%;
}
.hud-lives { display: flex; gap: 4px; padding: 5px 9px !important; }
.hud-lives i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--pouch-dark);
}
.hud-lives i.is-lost { background: transparent; border-style: dashed; opacity: .5; }

.game-narr {
  position: absolute;
  z-index: 2100;
  left: 50%;
  top: 52px;
  margin: 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(60, 42, 28, .82);
  color: var(--dashi);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  translate: -50% 0;
  opacity: 0;
  transition: opacity .25s;
}
.game-narr.is-on { opacity: 1; }

/* ---------- はじめ・結果・一時停止の画面 ---------- */
.game-screen {
  position: absolute;
  z-index: 2200;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 18px;
  text-align: center;
  background: rgba(246, 239, 224, .9);
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-user-select: text;
  user-select: text;
}
.game-screen[hidden] { display: none; }
.screen-art { width: clamp(90px, 28vw, 130px); height: auto; margin-bottom: 4px; }
.screen-kicker { margin: 0; font-size: 12.5px; color: var(--ink-soft); letter-spacing: .1em; }
.screen-title {
  margin: 2px 0 10px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(34px, 10vw, 46px);
  letter-spacing: .08em;
  line-height: 1.2;
  text-shadow: 3px 3px 0 var(--pouch);
}
.screen-rule { margin: 0 0 4px; font-size: 15px; }
.screen-sub { margin: 0 0 18px; font-size: 12.5px; color: var(--ink-soft); }
.screen-go { font-size: 18px; padding: 14px 44px; }
.screen-best { margin: 14px 0 0; font-size: 13px; color: var(--ink-soft); }

.game-result { justify-content: flex-start; padding-top: 28px; }
.result-score {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: .06em;
}
.result-score strong {
  font-weight: 400;
  font-size: clamp(54px, 16vw, 72px);
  color: var(--accent);
  text-shadow: 3px 3px 0 var(--pouch);
  margin-right: 4px;
}
.result-rank {
  margin: 8px 0 4px;
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: .04em;
}
.result-narr { margin: 0 0 6px; font-size: 13.5px; max-width: 26em; }
.result-best { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-soft); }
.result-card { margin: 0 0 12px; }
.result-card img {
  display: block;
  width: min(46vw, 190px);
  height: auto;
  margin: 0 auto;
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  -webkit-touch-callout: default;
}
.result-card figcaption { margin-top: 4px; font-size: 11px; color: var(--ink-soft); }
.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px 12px;
}
.result-actions .share-other { text-decoration: none; display: inline-block; }
