/* こねこにごはん（index.html・トップのゲーム）
   画面: .fd-title（タイトル）/ .fd-play（プレイ: HUD・こねこの場・ごはんトレイ）/ .fd-pause-ov / .fd-over
   動きは transform と opacity だけ（安い Android でも軽く）。
   こねこの大きさ --cat は feed.js が場の広さから計算して .fd-field に入れる。 */

.fd-root { position: absolute; inset: 0; overflow: hidden; }
.fd-title, .fd-play { position: absolute; inset: 0; }

/* ================= タイトル ================= */
.fd-title { background: linear-gradient(180deg, #FFF7F0 0%, #FFEAF1 100%); }
.fd-title-in {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  gap: clamp(10px, calc(var(--app-h, 640px) * 0.03), 28px);
  padding: 12px 14px 16px;
  text-align: center;
}
.fd-logo {
  margin: 0;
  font-size: 30px;
  font-size: clamp(28px, calc(var(--app-h, 640px) * 0.045), 40px);
  font-weight: 900;
  line-height: 1.45;
  color: var(--accent-deep);
  text-shadow: 0 2px 0 #fff;
}
.fd-title-cats { display: flex; justify-content: center; align-items: flex-end; gap: 4px; }

/* タイトルの こねこ（ふきだし付き） */
/* 大きさは 縦の長さ と 横幅（3匹＋ふきだしが入る）の小さい方 */
.fd-title-cats { --mini: 92px; --mini: clamp(84px, min(calc(var(--app-h, 640px) * 0.15), calc((100vw - 40px) / 3.4)), 150px); }
.fd-mini { position: relative; width: var(--mini); height: var(--mini); flex-shrink: 0; }
.fd-mini:nth-child(2) { width: calc(var(--mini) * 1.15); height: calc(var(--mini) * 1.15); }
.fd-mini .fd-cat { width: 100%; height: 100%; }
.fd-mini .fd-bubble { width: 42%; height: 42%; top: -10%; right: -8%; font-size: calc(var(--mini) * 0.24); }
.fd-title-cats .fd-mini:nth-child(1) .fd-bubble { animation: fd-bob 2.2s ease-in-out infinite; }
.fd-title-cats .fd-mini:nth-child(2) .fd-bubble { animation: fd-bob 2.2s ease-in-out -0.7s infinite; }
.fd-title-cats .fd-mini:nth-child(3) .fd-bubble { animation: fd-bob 2.2s ease-in-out -1.4s infinite; }
@keyframes fd-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.fd-start-wrap { animation: fd-pulse 1.6s ease-in-out infinite; }
@keyframes fd-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.fd-start { min-width: 220px; min-height: 68px; font-size: 26px; padding: 6px 36px; }
.fd-start { min-height: clamp(64px, calc(var(--app-h, 640px) * 0.085), 80px); font-size: clamp(24px, calc(var(--app-h, 640px) * 0.034), 30px); }

.fd-best {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 16px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--line);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.45;
}
.fd-best .sg-emoji { font-size: 18px; }

/* あそびかた 3こま */
.fd-howto {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  width: 100%;
  max-width: 440px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.fd-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 4px 8px;
  border-radius: 16px;
  background: #fff;
  border: 2px solid var(--line);
}
.fd-step-no {              /* 番号はカードの上の辺のまんなかに */
  position: absolute;
  left: 50%;
  top: -11px;
  margin-left: -11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 22px;
}
/* 絵の大きさは 縦の長さ と 横幅（3こまに収まる）の小さい方 */
.fd-howto { --pic: 44px; --pic: clamp(38px, min(calc(var(--app-h, 640px) * 0.07), calc((100vw - 60px) / 6.4)), 60px); }
.fd-step-pic { height: var(--pic); display: flex; align-items: center; justify-content: center; gap: 2px; }
.fd-step-txt { font-size: 14px; font-weight: 800; line-height: 1.45; word-break: keep-all; overflow-wrap: anywhere; }
.fd-hp-food { width: calc(var(--pic) * 0.66); height: calc(var(--pic) * 0.66); font-size: calc(var(--pic) * 0.56); display: flex; align-items: center; justify-content: center; }
.fd-hp-arrow { font-size: 16px; font-weight: 900; color: var(--accent-deep); line-height: 1; }
.fd-hp-cat { width: var(--pic); height: var(--pic); }
.fd-hp-bar {
  width: 22px;
  height: 10px;
  border-radius: 99px;
  background: rgba(90, 70, 54, 0.14);
  overflow: hidden;
}
.fd-hp-bar i { display: block; width: 25%; height: 100%; background: var(--danger); border-radius: 99px; }
.fd-hp-hearts { display: flex; gap: 2px; }
.fd-hp-hearts .fd-heart { width: calc(var(--pic) * 0.46); height: calc(var(--pic) * 0.42); }

/* ================= プレイ ================= */
.fd-play {
  display: flex;
  flex-direction: column;
  background: #FFF3EC;
  touch-action: none;           /* ドラッグ中にページが動かない */
  overscroll-behavior: none;
}

/* ---- 上: お金・ハート・ポーズ ---- */
.fd-hud {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 6px 8px 6px 10px;
  background: #fff;
  border-bottom: 3px solid var(--line);
  z-index: 5;
}
.fd-money {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 29px;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
}
.fd-coin {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--yellow);
  border: 3px solid var(--yellow-deep);
  color: #8A5A00;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
}
.fd-money-num { display: inline-block; font-variant-numeric: tabular-nums; }
.fd-money.up .fd-money-num { animation: fd-up 0.35s ease-out; }
.fd-money.down .fd-money-num { animation: fd-down 0.45s ease-out; color: var(--danger); }
@keyframes fd-up { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes fd-down { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 60% { transform: translateX(5px); } }

.fd-lives { flex-shrink: 0; display: flex; gap: 3px; }
.fd-heart { display: inline-block; width: 30px; height: 28px; }
.fd-heart svg { display: block; width: 100%; height: 100%; }
.fd-heart path { fill: #FF6F91; stroke: #E5588A; stroke-width: 1.6; }
.fd-heart.lost path { fill: #F4E9E4; stroke: #D9C6BD; }
.fd-heart.lost.pop { animation: fd-heart-lost 0.5s ease-out; }
@keyframes fd-heart-lost { 0% { transform: scale(1.5); } 60% { transform: scale(0.85); } 100% { transform: scale(1); } }

.fd-pause-btn {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  touch-action: manipulation;
}
.fd-pause-btn i { display: block; width: 7px; height: 20px; border-radius: 3px; background: var(--ink); }
.fd-pause-btn:active { transform: scale(0.92); }

/* ---- まんなか: こねこが座る場所（2列×3段） ---- */
.fd-field {
  --cat: 110px;
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  padding: 6px 6px 2px;
  overflow: hidden;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.7) 0 3px, transparent 3.5px) 0 0 / 44px 44px,
    radial-gradient(circle, rgba(255, 196, 214, 0.35) 0 3px, transparent 3.5px) 22px 22px / 44px 44px,
    linear-gradient(180deg, #FFEFF5 0%, #FFE9DC 100%);
}
.fd-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* ざぶとん（こねこが座る所・空いていても見える） */
.fd-slot::before {
  content: '';
  position: absolute;
  left: 50%;
  top: calc(50% + var(--cat) * 0.32 - 9px);
  width: calc(var(--cat) * 0.96);
  height: calc(var(--cat) * 0.24);
  margin-left: calc(var(--cat) * -0.48);
  border-radius: 50%;
  background: rgba(255, 143, 177, 0.18);
  border: 2px dashed rgba(229, 88, 138, 0.18);
}

/* こねこ1匹: 絵 + ふきだし + がまんバー */
.fd-kit {
  position: relative;
  z-index: 0;
  width: var(--cat);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.fd-cat { position: relative; width: var(--cat); height: var(--cat); transition: transform 0.12s ease-out; }
.fd-bubble {
  position: absolute;
  top: calc(var(--cat) * -0.07);
  right: calc(var(--cat) * -0.15);
  width: calc(var(--cat) * 0.46);
  height: calc(var(--cat) * 0.46);
  border-radius: 50%;
  background: #fff;
  border: 3px solid #F6C4D4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cat) * 0.26);
  z-index: 2;
}
.fd-bubble::after {        /* ふきだしのしっぽ */
  content: '';
  position: absolute;
  left: -3%;
  bottom: -3%;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #F6C4D4;
}
.fd-bubble-food { display: flex; align-items: center; justify-content: center; width: 70%; height: 70%; line-height: 1; }
.fd-bar {
  width: calc(var(--cat) * 0.8);
  height: 12px;
  margin-top: 6px;
  border-radius: 99px;
  background: rgba(90, 70, 54, 0.13);
  overflow: hidden;
}
.fd-bar-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 99px;
  background: #4FCB9F;
  transform-origin: 0 50%;
}
.fd-kit.warn .fd-bar-fill { background: #FFC23D; }
.fd-kit.danger .fd-bar-fill { background: #FF5C6C; }
.fd-kit.danger .fd-bubble { animation: fd-wobble 0.42s ease-in-out infinite; border-color: #FF9AA6; }
@keyframes fd-wobble {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-10deg) scale(1.06); }
  75% { transform: rotate(10deg) scale(1.06); }
}

/* ねらっている子（ドラッグ中） */
.fd-kit::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 0;
  width: calc(var(--cat) * 1.16);
  height: calc(var(--cat) * 1.16);
  margin: calc(var(--cat) * -0.08) 0 0 calc(var(--cat) * -0.58);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 214, 107, 0.95), rgba(255, 214, 107, 0.45) 70%, rgba(255, 214, 107, 0));
  opacity: 0;
  transition: opacity 0.12s;
}
.fd-slot.target .fd-kit::before { opacity: 1; }
.fd-slot.target .fd-cat { transform: scale(1.08); }

/* 出てくる・帰る */
.fd-kit.pop { animation: fd-pop 0.32s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
@keyframes fd-pop { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.fd-kit.bye { animation: fd-bye 0.3s ease-in forwards; }
@keyframes fd-bye { to { transform: translateY(-14px) scale(0.75); opacity: 0; } }
.fd-kit.cry.bye { animation-name: fd-fade; }
@keyframes fd-fade { to { transform: translateY(10px) scale(0.85); opacity: 0; } }

/* いやいや（ちがうごはん） */
.fd-kit.refuse .fd-cat { animation: fd-no 0.6s ease-in-out; }
@keyframes fd-no {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  15% { transform: translateX(-8%) rotate(-5deg); }
  35% { transform: translateX(7%) rotate(5deg); }
  55% { transform: translateX(-5%) rotate(-3deg); }
  75% { transform: translateX(3%) rotate(2deg); }
}
/* いやいや の ✕（絵の表情が変わらなくても伝わるように） */
.fd-no {
  position: absolute;
  z-index: 3;
  top: calc(var(--cat) * 0.02);
  left: calc(var(--cat) * -0.04);
  width: calc(var(--cat) * 0.3);
  height: calc(var(--cat) * 0.3);
  border-radius: 50%;
  background: #FF5C6C;
  border: 3px solid #fff;
  opacity: 0;
  transform: scale(0.3);
  pointer-events: none;
}
.fd-no::before, .fd-no::after {
  content: '';
  position: absolute;
  left: 22%;
  top: 43%;
  width: 56%;
  height: 14%;
  border-radius: 99px;
  background: #fff;
  transform: rotate(45deg);
}
.fd-no::after { transform: rotate(-45deg); }
.fd-kit.refuse .fd-no { animation: fd-nope 0.6s ease-out; }
@keyframes fd-nope {
  0% { opacity: 0; transform: scale(0.3); }
  20% { opacity: 1; transform: scale(1.15); }
  75% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.9); }
}
/* よろこぶ */
.fd-kit.happy .fd-cat { animation: fd-hop 0.5s ease-out; }
@keyframes fd-hop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-14%) scale(1.06); }
  70% { transform: translateY(0) scale(0.97, 1.03); }
  100% { transform: translateY(0) scale(1); }
}
/* なく */
.fd-kit.cry .fd-cat { animation: fd-sob 0.5s ease-in-out 2; }
@keyframes fd-sob { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(3%) scale(1.03, 0.96); } }
.fd-kit.happy .fd-bubble, .fd-kit.happy .fd-bar,
.fd-kit.cry .fd-bubble, .fd-kit.cry .fd-bar { opacity: 0; transition: opacity 0.15s; }

/* よろこんだ時のハート */
.fd-luv {
  position: absolute;
  z-index: 3;
  top: 8%;
  width: 22%;
  height: 20%;
  pointer-events: none;
  opacity: 0;
  animation: fd-luv 0.9s ease-out forwards;
}
.fd-luv svg { display: block; width: 100%; height: 100%; }
.fd-luv path { fill: #FF6F91; stroke: #fff; stroke-width: 1.5; }
@keyframes fd-luv {
  0% { transform: translateY(0) scale(0.4); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-90%) scale(1); opacity: 0; }
}

/* ---- 下: ごはんトレイ ---- */
.fd-tray {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px 10px 13px;
  background: #fff;
  border-top: 3px solid var(--line);
  z-index: 5;
}
.fd-food {
  flex: 1 1 0;
  min-width: 84px;
  max-width: 124px;
  min-height: 96px;
  padding: 6px 4px 5px;
  border-radius: 22px;
  border: 3px solid var(--line);
  background: var(--fc, #fff);
  box-shadow: 0 5px 0 var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: grab;
  touch-action: none;
}
.fd-food-ico { width: 54px; height: 54px; font-size: 44px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.fd-food-name { font-size: 15px; font-weight: 800; line-height: 1.45; white-space: nowrap; pointer-events: none; }
.fd-food.held { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); opacity: 0.6; }

/* 指についてくる ごはん（指より上に描く） */
.fd-ghost {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 45;
  width: 92px;
  height: 92px;
  margin: -46px 0 0 -46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  border: 3px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 58px;
  pointer-events: none;
  will-change: transform;
}
.fd-ghost-in { width: 70px; height: 70px; display: flex; align-items: center; justify-content: center; line-height: 1; }
.fd-ghost.back { transition: transform 0.22s ease-in, opacity 0.22s ease-in; }
.fd-ghost.eat { transition: transform 0.18s ease-in, opacity 0.18s ease-in; }

/* ポーズ中は飾りの動きも止める */
.fd-play.frozen, .fd-play.frozen * { animation-play-state: paused !important; }

/* ================= ひとやすみ・おしまい ================= */
.fd-ov-title, .fd-over-title {
  font-size: 30px;
  font-weight: 900;
  line-height: 1.45;
  color: var(--accent-deep);
}
.fd-ov-cat { width: 150px; height: 150px; }
.fd-big { min-width: 220px; min-height: 66px; font-size: 24px; }
.fd-pause-ov .sg-btn.sub { min-width: 160px; }

.fd-over {
  background: linear-gradient(180deg, #FFF7F0 0%, #FFEAF1 100%);
  gap: 8px;
  overflow-y: auto;
  justify-content: center;
  justify-content: safe center;   /* 入りきらない小さい画面では上から並べてスクロール */
}
.fd-over-cat { width: 110px; height: 110px; flex-shrink: 0; }
.fd-over-kip { font-size: 40px; font-weight: 900; line-height: 1.3; }
.fd-over-fed {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.45;
}
.fd-over-fed-ico { width: 38px; height: 38px; }
.fd-over-best {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.45;
  color: var(--ink-soft);
}
.fd-newrec {
  padding: 4px 18px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 19px;
  font-weight: 900;
  line-height: 1.45;
  box-shadow: 0 3px 0 var(--yellow-deep);
  animation: fd-pulse 1s ease-in-out infinite;
}
.fd-over .fd-big { margin-top: 6px; flex-shrink: 0; }
