/* もぐもぐ ぱくぱく — 見た目。ライト=キッチン・ダーク=よるの キッチン。外部フォントは使わない */
:root {
  --bg: #fff4e0;
  --wall: #fffaf2;
  --tile: #f6e7cf;
  --ink: #2b2433;
  --sub: #6b6177;
  --card: #ffffff;
  --card-sh: #e2cba5;
  --gold: #ffc53d;
  --focus: #2f7cf6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #211c1a;
    --wall: #3a322d;
    --tile: #332b27;
    --ink: #f3eefc;
    --sub: #c4b8ab;
    --card: #3a302b;
    --card-sh: #120f0d;
    --focus: #ffc53d;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  overflow: hidden;
}
#app {
  position: fixed; inset: 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  /* 画面の下 15% には押すものを置かない(手首が当たる) */
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 10px) 15vh calc(env(safe-area-inset-left) + 10px);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
svg { display: block; width: 100%; height: 100%; overflow: visible; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.logo { display: flex; align-items: center; gap: 8px; margin: 0; min-width: 0; font-size: clamp(17px, 4.6vw, 24px); font-weight: 900; white-space: nowrap; }
.logo img { width: 40px; height: 40px; flex-shrink: 0; }
@media (max-width: 440px) { .logo span { display: none; } }
.pals { display: flex; gap: 6px; }
.pbtn { width: 56px; height: 56px; padding: 4px; border-radius: 14px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); }
.pbtn[aria-pressed="true"] { box-shadow: 0 4px 0 var(--card-sh), 0 0 0 4px var(--gold); }
.snd { flex-shrink: 0; width: 52px; height: 56px; border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); display: grid; place-items: center; }
.snd svg { width: 32px; height: 32px; }
.spk { fill: var(--ink); }
.wave, .slash { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.snd.off .wave, .snd:not(.off) .slash { display: none; }
.pbtn:active, .snd:active { transform: translateY(3px); }

/* ---- キッチン ---- */
.stage {
  position: relative; min-height: 0; border: 3px solid var(--ink); border-radius: 22px; overflow: hidden;
  background: linear-gradient(var(--wall) 0 62%, var(--tile) 62%);
}
.stage::before { content: ""; position: absolute; left: 0; right: 0; top: 62%; height: 4px; background: rgba(43, 36, 51, .25); }
.pal { position: absolute; right: 4%; top: 6%; height: 70%; aspect-ratio: 1; max-width: 66%; }
.pv { display: block; width: 100%; height: 100%; transform-origin: 50% 90%; }
.pv.s-idle { animation: breathe 2.4s ease-in-out infinite; }
.pv.s-cold { animation: shiver .16s linear infinite; }
.pv.s-love, .pv.s-yum { animation: dance .5s ease-in-out infinite; }
.pv.s-hot { animation: jump .4s ease-out 3; }
@keyframes breathe { 50% { transform: scale(1.02, .98); } }
@keyframes shiver { 25% { transform: translateX(-2%); } 75% { transform: translateX(2%); } }
@keyframes dance { 50% { transform: translateY(-4%) rotate(-4deg); } }
@keyframes jump { 50% { transform: translateY(-10%); } }
.breath { transform-box: fill-box; transform-origin: 100% 50%; animation: breath .3s ease-in-out infinite alternate; }
@keyframes breath { to { transform: scaleX(1.15); } }

.plate { position: absolute; left: 5%; bottom: 8%; width: 40%; max-width: 220px; aspect-ratio: 1.4; display: grid; place-items: end center; }
.plate::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 34%; border-radius: 50%; background: #fff; border: 3px solid #2b2433; box-shadow: inset 0 -6px 0 #dee2e6; }
.food { position: relative; width: 72%; aspect-ratio: 1; margin-bottom: 10%; }
.ck1 { filter: sepia(.5) saturate(1.3) brightness(.92); }
.ck2 { filter: brightness(.35) saturate(.4); }
.say {
  position: absolute; left: 4%; top: 6%; max-width: 54%; margin: 0; padding: 10px 14px; border-radius: 18px;
  background: #fff; color: #2b2433; border: 3px solid #2b2433; font-size: clamp(16px, 4.6vw, 24px); font-weight: 900; z-index: 3;
}
.say::after { content: ""; position: absolute; right: -14px; top: 40%; border: 8px solid transparent; border-left: 12px solid #2b2433; }

.hand { position: absolute; right: 22%; top: 46%; width: 48px; height: 58px; pointer-events: none; opacity: 0; z-index: 4; }
.hand.on { opacity: 1; animation: poke 1s ease-in-out infinite; }
@keyframes poke { 50% { transform: translate(-6px, -10px); } }

/* えんしゅつ(DOM の かずは すくなく) */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.fx i { position: absolute; display: block; }
.t-kiru i { left: calc(12% + var(--i) * 9%); bottom: 18%; width: 4px; height: 26%; background: #fff; border: 2px solid #2b2433; border-radius: 2px; animation: chop .3s ease-in calc(var(--i) * .14s) both; }
.t-yaku i { left: calc(8% + var(--i) * 7%); bottom: 4%; width: 18px; height: 28px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(circle at 50% 70%, #ffe066 0 30%, #ff922b 32%); animation: rise .6s ease-out calc(var(--i) * .06s) both; }
.t-hiyasu i { left: calc(10% + var(--i) * 6%); top: 30%; width: 10px; height: 10px; background: #fff; border: 2px solid #4dabf7; border-radius: 2px; animation: snow .6s ease-in calc(var(--i) * .05s) both; }
.t-karai i { left: calc(14% + var(--i) * 4%); top: 34%; width: 7px; height: 7px; background: #fa5252; border-radius: 2px; animation: snow .5s ease-in calc(var(--i) * .04s) both; }
.t-amaku i { left: calc(18% + var(--i) * 8%); top: 30%; width: 8px; height: 30px; background: #f59f00; border-radius: 4px; animation: drip .6s ease-in calc(var(--i) * .1s) both; }
.r-love i, .r-yum i { right: calc(10% + var(--i) * 10%); top: 22%; width: 26px; height: 24px; background: #ff6b9a; clip-path: path("M13 24C-6 10 2-4 13 6C24-4 32 10 13 24Z"); animation: float 1.4s ease-out calc(var(--i) * .15s) both; }
.r-yum i { background: #ffd43b; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.r-cough i, .r-puzzled i { right: calc(28% + var(--i) * 6%); top: 40%; width: 30px; height: 30px; border-radius: 50%; background: #868e96; opacity: .8; animation: float 1.2s ease-out calc(var(--i) * .15s) both; }
.r-puzzled i { background: #fff; border: 3px solid #adb5bd; }
.r-cold i { right: calc(20% + var(--i) * 12%); top: 16%; width: 12px; height: 12px; background: #fff; border: 2px solid #4dabf7; transform: rotate(45deg); animation: snow 1s ease-in calc(var(--i) * .12s) both; }
@keyframes chop { from { transform: translateY(-80%); opacity: 0; } 60% { opacity: 1; } to { transform: none; opacity: 0; } }
@keyframes rise { from { transform: translateY(30%) scale(.6); opacity: 1; } to { transform: translateY(-160%) scale(1.1); opacity: 0; } }
@keyframes snow { from { transform: translateY(-40px); opacity: 1; } to { transform: translateY(60px) rotate(180deg); opacity: 0; } }
@keyframes drip { from { transform: scaleY(0); transform-origin: top; } 60% { transform: scaleY(1); } to { transform: scaleY(1) translateY(20px); opacity: 0; } }
@keyframes float { from { transform: translateY(20px) scale(.5); opacity: 0; } 30% { opacity: 1; } to { transform: translateY(-90px) scale(1.1); opacity: 0; } }

/* ---- えらぶ ---- */
.tray { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; width: min(100%, 620px); }
.fbtn, .tbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 70px; padding: 4px 2px; border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh);
}
.tbtn .fi { background: var(--c); border-radius: 10px; border: 2.5px solid #2b2433; }
.fbtn:active, .tbtn:active { transform: translateY(3px); }
.fi { width: 42px; height: 42px; padding: 3px; }
.fn { font-size: clamp(11px, 3.1vw, 15px); font-weight: 900; white-space: nowrap; }

/* スマホを横にしたとき: えらぶ ところを みぎに */
@media (orientation: landscape) and (max-height: 600px) {
  #app { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); column-gap: 10px; }
  .top { grid-column: 1 / -1; }
  .logo img { width: 32px; height: 32px; }
  .pbtn, .snd { height: 48px; width: 48px; }
  .tray { grid-column: 2; grid-row: 2; justify-content: center; }
  .row { width: auto; grid-auto-flow: row; grid-template-columns: repeat(6, 50px); grid-auto-columns: auto; gap: 4px; }
  .fbtn, .tbtn { min-height: 0; height: min(calc((100svh - 15vh - 90px) / 2), 72px); padding: 2px; }
  .fi { width: 30px; height: 30px; }
  .fn { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
