/* ねこの おみせやさん — 見た目。ライト=クリーム・ダーク=夜。外部フォントは使わない(何も送らないため) */
:root {
  --bg: #fff6e9;
  --ink: #2b2433;
  --sub: #6b6177;
  --card: #ffffff;
  --card-sh: #ecd9b8;
  --gold: #ffb800;
  --focus: #2f7cf6;
  --tab-on: #fff1c2;
  --wall: #ffe4ec;
  --aw1: #ff8fa6;
  --aw2: #fffdf8;
  --counter: #e0a868;
  --counter-sh: #b9783f;
  --table: #fbe7cc;
}
#app[data-shop="onigiri"] { --wall: #e0f2d6; --aw1: #5fbf7f; }
#app[data-shop="juice"] { --wall: #fff0c0; --aw1: #ffa53d; }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a27;
    --ink: #f3eefc;
    --sub: #b4abc4;
    --card: #2c2840;
    --card-sh: #14121c;
    --focus: #ffb800;
    --tab-on: #4a4166;
    --wall: #3b2b3d;
    --aw1: #b9566f;
    --aw2: #e9e2f2;
    --counter: #8a5a33;
    --counter-sh: #5e3a1f;
    --table: #2a2537;
  }
  #app[data-shop="onigiri"] { --wall: #253a2c; --aw1: #3f8f5a; }
  #app[data-shop="juice"] { --wall: #3d3420; --aw1: #c27a22; }
}

* { 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: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
[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; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; }
svg { overflow: visible; }

/* ---- お客さん(ねこは まるばつと同じ色と線) ---- */
.an { display: block; width: 100%; height: 100%; }
.fh { fill: #ffb35c; stroke: #2b2433; stroke-width: 4; stroke-linejoin: round; }
.an-dog .fh { fill: #f2c58e; }
.an-usagi .fh { fill: #fbf7fb; }
.an-kuma .fh { fill: #c08a58; }
.fe { fill: #ff9aa9; }
.ff { fill: #2b2433; }
.fl { fill: none; stroke: #2b2433; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.fn { fill: #ff6b81; }
.fw { stroke: #2b2433; stroke-width: 2.5; stroke-linecap: round; opacity: .65; }
.sp { fill: #dba268; }
.ea { fill: #a8693a; stroke: #2b2433; stroke-width: 4; stroke-linejoin: round; }
.mz { fill: #fff3df; }
.an-kuma .mz { fill: #f0d2a8; }
.ki { fill: #e8b98a; }
.bel { fill: #fff3df; opacity: .85; }
.an-usagi .bel { fill: #ffe3ec; }
.bl { fill: #ff9aa9; opacity: .75; }
.om { fill: #7a2a3a; stroke: #2b2433; stroke-width: 3; stroke-linejoin: round; }
.tg { fill: #ff7d8f; stroke: #2b2433; stroke-width: 2.5; }
.ew { fill: #fff; stroke: #2b2433; stroke-width: 3; }
.hl { fill: #fff; }
.ht { fill: #ff4f6d; stroke: #2b2433; stroke-width: 2.5; stroke-linejoin: round; }
.st { fill: #ffd23f; stroke: #2b2433; stroke-width: 2.5; stroke-linejoin: round; }
.mch { transform-box: fill-box; transform-origin: 50% 50%; animation: chew .28s ease-in-out infinite alternate; }
@keyframes chew { to { transform: scale(1.3, .4); } }
.chk { animation: cheekdrop 1.3s ease-in-out both; }
@keyframes cheekdrop { 40%, 70% { transform: translateY(7px); } }

/* ---- 食べもの ---- */
.k3 { stroke: #2b2433; stroke-width: 3; stroke-linejoin: round; }
.k2 { stroke: #2b2433; stroke-width: 2.5; stroke-linejoin: round; }
.ol { fill: none; stroke: #2b2433; stroke-width: 4; stroke-linejoin: round; }
.plate { fill: #ffffff; stroke: #2b2433; stroke-width: 4; }
.plate-in { fill: none; stroke: #e6e0ef; stroke-width: 3; }
.dl { transform-box: fill-box; transform-origin: 50% 100%; }
.lq { transition: transform .45s cubic-bezier(.3, .7, .4, 1); }
.lq-c.tr { transition: fill .6s ease; }

/* ---- 大きいボタン(カード) ---- */
.big {
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--card-sh);
  transition: transform .06s;
}
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--card-sh); }
.back {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 56px; min-width: 56px; padding: 0 14px 0 10px;
  border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh);
  font-weight: 800; font-size: 18px; white-space: nowrap;
}
.back span { font-size: 32px; line-height: 1; margin-top: -5px; }
.back:active, .snd:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--card-sh); }

/* ---- はじめの画面 ---- */
.menu { padding: 3vh 16px 15vh; gap: 3vh; overflow-y: auto; }
.menu > .logo { margin-top: auto !important; }
.menu > .link { margin-bottom: auto; }
.logo { display: flex; align-items: center; gap: 10px; margin: 2vh 0 0; font-weight: 900; line-height: 1.08; }
.logo-face { width: clamp(64px, 19vw, 108px); height: clamp(64px, 19vw, 108px); flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; }
.logo-s { font-size: clamp(18px, 5.2vw, 30px); color: var(--sub); }
.logo-b { font-size: clamp(30px, 9.4vw, 60px); letter-spacing: .02em; white-space: nowrap; }
.shops { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: min(100%, 660px); }
.shop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 12px 4px 14px; min-height: 168px; }
.shop-pic { width: min(124px, 25vw); height: min(124px, 25vw); }
.shop-pic svg { width: 100%; height: 100%; display: block; }
.shop-name { display: flex; flex-direction: column; align-items: center; font-size: clamp(16px, 4.6vw, 24px); font-weight: 900; line-height: 1.15; white-space: nowrap; }
.shop-name small { font-size: .72em; color: var(--sub); font-weight: 800; }
.link { min-height: 48px; padding: 0 14px; font-size: 16px; color: var(--sub); text-decoration: underline; text-underline-offset: 3px; }

/* ---- おみせ(縦の画面: 上から お客さん・作る台・道具) ---- */
.game {
  position: relative;
  display: grid; width: 100%; max-width: 640px; margin: 0 auto; align-items: stretch;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1.05fr) minmax(0, 1fr) auto;
  grid-template-areas: "top" "scene" "work" "tools";
  /* 画面の下 15% には押すものを置かない(手首が当たる) */
  padding: 8px 12px 15vh; gap: 8px;
}
.top { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top .back, .snd { flex-shrink: 0; }
.line { display: flex; align-items: center; gap: 4px; min-width: 0; }
.dot { width: clamp(20px, 6.4vw, 32px); height: clamp(20px, 6.4vw, 32px); border-radius: 50%; background: var(--card); box-shadow: inset 0 0 0 3px var(--card-sh); flex-shrink: 0; }
.dot.now { box-shadow: inset 0 0 0 3px var(--gold); }
.dot.done { background: none; box-shadow: none; }
.dot .an { width: 100%; height: 100%; }
.snd { width: 56px; height: 56px; border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); display: grid; place-items: center; }
.snd svg { width: 34px; height: 34px; }
.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; }

/* お店の中(かべ・のき・カウンター) */
.scene {
  grid-area: scene; position: relative; overflow: hidden; isolation: isolate; z-index: 1;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--wall); border-radius: 20px 20px 6px 6px;
}
.awning { position: relative; z-index: 2; flex: 0 0 20px; height: 20px; background: repeating-linear-gradient(90deg, var(--aw1) 0 26px, var(--aw2) 26px 52px); }
.awning::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 12px;
  background:
    radial-gradient(circle at 13px 0, var(--aw1) 12px, transparent 12.5px) 0 0 / 52px 12px repeat-x,
    radial-gradient(circle at 13px 0, var(--aw2) 12px, transparent 12.5px) 26px 0 / 52px 12px repeat-x;
}
.stage { position: relative; flex: 1; min-height: 0; }
.counter { position: relative; z-index: 3; flex: 0 0 16px; background: var(--counter); box-shadow: inset 0 4px 0 rgba(255, 255, 255, .22), inset 0 -4px 0 var(--counter-sh); }
.cust { position: absolute; left: 3.5%; bottom: 0; width: var(--cw, 110px); height: var(--ch, 160px); z-index: 1; display: block; }
.cust-in { display: block; width: 100%; height: 100%; transform-origin: 50% 100%; }
.bubble {
  position: absolute; left: calc(3.5% + var(--cw, 110px) + 10px); top: 5%; z-index: 4;
  width: var(--bw, 120px); height: var(--bh, 120px);
  background: #fff; border: 4px solid #2b2433; border-radius: 24px; padding: 4%;
}
.bubble svg { display: block; width: 100%; height: 100%; }
.bubble::before { content: ""; position: absolute; left: -17px; top: 46%; border: 10px solid transparent; border-right: 15px solid #2b2433; border-left: 0; }
.bubble::after { content: ""; position: absolute; left: -10px; top: calc(46% + 5px); border: 5px solid transparent; border-right: 9px solid #fff; border-left: 0; }
.register { position: absolute; right: 3%; bottom: 0; width: var(--rw, 80px); height: var(--rh, 72px); z-index: 2; }
.reg-body, .drawer { position: absolute; display: block; }
.reg-body { inset: 0; }
.drawer { left: 8%; right: 8%; bottom: 2%; height: 24%; }
.reg-body svg, .drawer svg { display: block; width: 100%; height: 100%; }
.coins {
  position: absolute; inset: 0; margin: auto; z-index: 5;
  width: fit-content; height: fit-content; min-width: 120px; min-height: 96px; padding: 12px 16px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 26px; background: rgba(255, 255, 255, .6); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: dark) { .coins { background: rgba(255, 255, 255, .08); } }
.coin { display: block; width: var(--kc, 56px); height: var(--kc, 56px); }
.coin:nth-child(2) { margin-top: -18px; }
.coin svg { display: block; width: 100%; height: 100%; }

/* 作る台(子どもの がわ) */
.work {
  grid-area: work; position: relative; z-index: 2; min-height: 0; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--table); border-radius: 6px 6px 20px 20px;
}
.food { position: relative; flex: none; display: block; width: 160px; height: 160px; }
.stack { position: absolute; inset: 0; display: block; transform-origin: 50% 70%; }
.ly { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.ly-base, .ly-rice { transform-origin: 50% 84%; }
.ly-nori { transform-origin: 50% 80%; }
.ly-whip { transform-origin: 50% 22%; }

/* 道具: タブ・どうぞ・えらぶもの */
.tools {
  grid-area: tools; display: grid; align-items: center;
  grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "tabs serve" "tray tray";
  gap: 10px;
  transition: opacity .2s;
}
.game:not([data-phase="make"]) .tools { opacity: .4; pointer-events: none; }
.tabs { grid-area: tabs; display: flex; align-items: center; gap: 8px; }
.tab {
  flex: none; width: 64px; height: 64px; padding: 7px; border-radius: 18px;
  background: var(--card); box-shadow: 0 4px 0 var(--card-sh); display: grid; place-items: center;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}
.tab svg { display: block; width: 100%; height: 100%; }
.tab[aria-pressed="true"] { background: var(--tab-on); box-shadow: 0 4px 0 var(--card-sh), 0 0 0 4px var(--gold); }
.tab:disabled { opacity: .3; box-shadow: none; cursor: default; }
.serve {
  grid-area: serve; visibility: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 64px; min-width: 112px; padding: 0 16px 0 10px; border-radius: 22px;
  background: var(--gold); color: #3a2a00; box-shadow: 0 6px 0 #c98a00;
  font-size: clamp(22px, 6vw, 28px); font-weight: 900; white-space: nowrap;
}
.serve svg { width: 40px; height: 40px; flex-shrink: 0; }
.serve.show { visibility: visible; }
.serve:active { transform: translateY(4px); box-shadow: 0 2px 0 #c98a00; }
.tray { grid-area: tray; display: grid; grid-template-columns: repeat(var(--n, 4), minmax(64px, 1fr)); gap: 8px; }
.item {
  height: 76px; min-width: 64px; padding: 6px; border-radius: 18px;
  background: var(--card); box-shadow: 0 5px 0 var(--card-sh); display: grid; place-items: center;
  /* 絵の大きさを ボタンの中に固定する(幅に合わせて ふくらまない) */
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}
.item svg { display: block; width: 100%; height: 100%; }
.item.on { box-shadow: 0 5px 0 var(--card-sh), 0 0 0 4px var(--gold); }
.item:active, .tab:active { transform: translateY(3px); }

/* しばらく さわらないとき: 次に押すところが ゆっくり ふくらむ */
.serve.hint, .coins.hint, .tray.hint .item { animation: hint 1.5s ease-in-out 3; }
@keyframes hint { 50% { transform: scale(1.08); } }

/* おしまい */
.closed {
  grid-area: 2 / 1 / -1 / -1; position: relative; z-index: 6; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3vh;
  padding: 36px 16px 16px; background: var(--wall); border-radius: 20px;
}
.closed .awning { position: absolute; top: 0; left: 0; right: 0; }
.sign {
  margin: 0; padding: 10px 28px; border-radius: 16px;
  background: var(--counter); color: #fffaf0; box-shadow: 0 5px 0 var(--counter-sh);
  font-size: clamp(28px, 8vw, 44px); font-weight: 900; letter-spacing: .08em;
}
.friends { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 100%; }
.fr { display: block; width: clamp(48px, 14vw, 88px); height: clamp(48px, 14vw, 88px); animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.again {
  min-height: 70px; min-width: min(80vw, 300px); padding: 0 24px;
  font-size: clamp(22px, 6vw, 28px); font-weight: 900;
  background: var(--gold); color: #3a2a00; box-shadow: 0 6px 0 #c98a00;
}
.again:active { box-shadow: 0 2px 0 #c98a00; }
.again:disabled { opacity: .55; }

/* とびだす かざり・紙ふぶき(transform と opacity だけ) */
.fx, .confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.fx i { position: absolute; display: block; animation-name: fxfly; animation-timing-function: ease-out; animation-fill-mode: both; }
.fx i svg { display: block; width: 100%; height: 100%; }
@keyframes fxfly {
  0% { transform: translate(0, 0) scale(.3); opacity: 0; }
  18% { transform: translate(calc(var(--dx) * .15), calc(var(--dy) * .15)) scale(1); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px;
  animation-name: fall; animation-timing-function: cubic-bezier(.3, .6, .6, 1); animation-fill-mode: forwards;
}
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }

/* スマホを横にしたとき: 左に お客さん・まんなかに作る台・右に道具 */
@media (orientation: landscape) and (max-height: 600px) {
  .game {
    max-width: none;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "top top top" "scene work tools";
  }
  .scene { border-radius: 20px 6px 6px 20px; }
  .work { border-radius: 6px 20px 20px 6px; }
  .tools {
    grid-template-columns: 64px auto; grid-template-rows: auto auto;
    grid-template-areas: "tabs tray" "tabs serve"; align-content: center;
  }
  .tabs { flex-direction: column; justify-content: center; }
  .tray { grid-template-columns: repeat(2, 72px); }
  .item { height: 68px; }
  .serve { min-width: 0; }
  .menu {
    display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-content: center;
    row-gap: 2vh; padding-top: 2vh;
  }
  .menu > .logo, .menu > .link { margin: 0 !important; }
  .logo-face { width: 64px; height: 64px; }
  .logo-b { font-size: 34px; }
  .logo-s { font-size: 18px; }
  .shop { min-height: 0; padding: 8px 4px 10px; }
  .shop-pic { width: min(96px, 16vh + 20px); height: min(96px, 16vh + 20px); }
  .closed { gap: 2vh; padding-top: 30px; }
  .fr { width: 56px; height: 56px; }
}

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