:root {
  --bg: #fff4e6;
  --bg-dot: #ffe6c7;
  --ink: #3a2a1e;
  --ink-soft: #8a7564;
  --card: #ffffff;
  --line: #f0e2cf;
  --accent: #ff6b5a;
  --accent-dark: #e04e3e;
  --machine: #4fb3e8;
  --machine-dark: #2f8fc6;
  --radius: 20px;
  --shadow: 0 6px 0 rgba(58, 42, 30, .08), 0 12px 24px rgba(58, 42, 30, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 2px, transparent 2.5px);
  background-size: 22px 22px;
  min-height: 100vh;
}
button { font: inherit; color: inherit; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
}

/* ---------- ヘッダー ---------- */
.hero { text-align: center; margin: 8px 0 18px; }
.hero__eyebrow { margin: 0 0 4px; font-weight: 700; color: var(--ink-soft); font-size: 14px; }
.hero__title {
  margin: 0; font-size: clamp(36px, 11vw, 52px); font-weight: 800; letter-spacing: .02em; line-height: 1.1;
  color: var(--ink);
  text-shadow: 3px 3px 0 #fff, 5px 5px 0 var(--bg-dot);
}
.hero__title span { color: var(--accent); }

/* ---------- メンバー ---------- */
.members__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.sprite {
  background-image: url("assets/snowman-all.png");
  background-repeat: no-repeat;
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(0,0,0,.08);
}
.member-tile {
  overflow: hidden;
  animation: tile-in .5s both;
}
.member-tile .sprite { width: 100%; }
.members__grid.is-dim .member-tile { opacity: .35; transform: scale(.96); transition: .3s; }
.members__grid .member-tile.is-pick { opacity: 1; transform: scale(1.06); transition: .3s; box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--c); border-radius: 12px; }
@keyframes tile-in { from { opacity: 0; transform: translateY(8px) scale(.95); } }

/* ---------- マシン ---------- */
.machine-wrap { display: flex; flex-direction: column; align-items: center; margin: 22px 0 8px; }
.machine { width: min(250px, 66vw); height: auto; overflow: visible; }
.machine__label { font-weight: 800; font-size: 13px; fill: var(--machine-dark); letter-spacing: .2em; }
.machine__handle { transform-origin: 92px 248px; transform-box: view-box; }
.machine__capsules { transform-origin: 120px 120px; transform-box: view-box; }
.machine__drop { opacity: 0; }
.machine.is-spinning .machine__handle { animation: handle 1.3s cubic-bezier(.45,0,.3,1); }
.machine.is-spinning .machine__capsules { animation: shake 1.3s ease-in-out; }
.machine.is-dropping .machine__drop { animation: drop .6s cubic-bezier(.3,1.6,.5,1) forwards; }
@keyframes handle { to { transform: rotate(720deg); } }
@keyframes shake {
  0%,100% { transform: none; }
  15% { transform: rotate(-6deg) translateY(-3px); }
  30% { transform: rotate(5deg) translateY(2px); }
  45% { transform: rotate(-4deg) translateY(-2px); }
  60% { transform: rotate(4deg); }
  80% { transform: rotate(-2deg); }
}
@keyframes drop { from { opacity: 1; transform: translateY(-14px); } to { opacity: 1; transform: none; } }

.spin-btn {
  margin-top: 14px;
  border: 0;
  padding: 16px 40px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .05em;
  box-shadow: 0 6px 0 var(--accent-dark), 0 12px 20px rgba(224, 78, 62, .3);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  -webkit-tap-highlight-color: transparent;
}
.spin-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-dark); }
.spin-btn:disabled { opacity: .6; cursor: default; }
.spin-btn:not(:disabled) span { display: inline-block; animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 0%,100% { transform: none; } 50% { transform: translateY(-2px) scale(1.03); } }

/* ---------- パネル ---------- */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-top: 22px;
}
.panel__title { margin: 0 0 6px; font-size: 17px; font-weight: 800; }
.panel__hint { margin: 0 0 12px; font-size: 12px; color: var(--ink-soft); }

.menu-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px;
}
.menu-item {
  width: 100%;
  border: 2px solid var(--line);
  background: #fffaf3;
  border-radius: 16px;
  padding: 6px 6px 10px;
  cursor: pointer;
  text-align: center;
  transition: opacity .2s, filter .2s, border-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.menu-item svg { width: 100%; height: auto; display: block; }
.menu-item__name { display: block; font-weight: 800; font-size: 14px; line-height: 1.3; }
.menu-item__state { display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: #e9f7ef; color: #2c8a55; }
.menu-item.is-off { opacity: .45; filter: grayscale(1); border-style: dashed; }
.menu-item.is-off .menu-item__state { background: #eee; color: #888; }

.food-img { width: 100%; aspect-ratio: 200 / 150; display: block; object-fit: contain; }

/* 追加したメニュー */
.menu-list li { position: relative; }
.menu-item__new { display: inline-block; margin-left: 4px; font-size: 10px; font-weight: 800; color: #fff; background: var(--accent); padding: 0 6px; border-radius: 99px; vertical-align: 2px; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.history li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 14px; background: #fffaf3; border: 2px solid var(--line);
  font-size: 14px;
}
.history__dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,.08); }
.history__name { font-weight: 800; flex: 1; }
.history__date { color: var(--ink-soft); font-size: 12px; }

.foot { text-align: center; color: var(--ink-soft); font-size: 12px; margin-top: 28px; }

/* ---------- オーバーレイ ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; }
.overlay[hidden] { display: none; }
.overlay__bg { position: absolute; inset: 0; background: rgba(40, 26, 16, .55); backdrop-filter: blur(3px); animation: fade .3s both; }
@keyframes fade { from { opacity: 0; } }

.stage {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  display: grid; place-items: center;
}

.big-capsule {
  --c: #ff6b5a;
  position: absolute;
  top: 50%; left: 50%; margin: -75px 0 0 -75px;
  width: 150px; height: 150px;
  animation: cap-in .5s cubic-bezier(.3,1.6,.5,1) both, cap-wobble .9s .5s ease-in-out;
}
.big-capsule__top, .big-capsule__bottom {
  position: absolute; left: 0; width: 150px; height: 75px;
  transition: transform .5s cubic-bezier(.5,-0.4,.5,1), opacity .5s;
}
.big-capsule__top {
  top: 0; border-radius: 75px 75px 0 0;
  background: linear-gradient(160deg, rgba(255,255,255,.95), rgba(235,240,245,.85));
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.06);
}
.big-capsule__top::after {
  content: ""; position: absolute; left: 26px; top: 18px; width: 34px; height: 14px; border-radius: 50%;
  background: #fff; transform: rotate(-30deg);
}
.big-capsule__bottom {
  bottom: 0; border-radius: 0 0 75px 75px;
  background: var(--c);
  box-shadow: inset 0 -10px 0 rgba(0,0,0,.12), inset 0 4px 0 rgba(255,255,255,.25);
}
.big-capsule.is-rainbow .big-capsule__bottom {
  background: linear-gradient(90deg, #f5d90a, #f39a1f, #e43d45, #f27cc0, #9b5bd4, #2e8de8, #18a589);
}
.big-capsule.is-open .big-capsule__top { transform: translate(-40px, -140px) rotate(-40deg); opacity: 0; }
.big-capsule.is-open .big-capsule__bottom { transform: translate(40px, 160px) rotate(30deg); opacity: 0; }
@keyframes cap-in { from { transform: translateY(-60vh) scale(.4); } }
@keyframes cap-wobble {
  0%,100% { transform: none; }
  20% { transform: rotate(-12deg); }
  40% { transform: rotate(10deg); }
  60% { transform: rotate(-8deg); }
  80% { transform: rotate(5deg); }
}

.flash {
  position: absolute; top: 50%; left: 50%; margin: -5px 0 0 -5px; width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(#fff 30%, rgba(255,255,255,0) 70%);
  opacity: 0; pointer-events: none;
}
.flash.is-on { animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(90); } }

.result {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: #fff;
  border-radius: 28px;
  padding: 18px 16px 16px;
  text-align: center;
  box-shadow: 0 10px 0 rgba(0,0,0,.08), 0 20px 50px rgba(0,0,0,.25);
  border: 4px solid var(--c, #ff6b5a);
  opacity: 0; transform: scale(.6);
  pointer-events: none;
}
.result.is-show { animation: pop .55s cubic-bezier(.3,1.6,.5,1) forwards; pointer-events: auto; }
@keyframes pop { to { opacity: 1; transform: none; } }

.result__rare {
  margin: 0 0 8px; font-weight: 800; font-size: 15px;
  background: linear-gradient(90deg, #f5d90a, #f39a1f, #e43d45, #f27cc0, #9b5bd4, #2e8de8, #18a589);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.result__member { width: min(300px, 100%); margin: 0 auto; }
.result__member .sprite { width: 100%; border-radius: 14px; }
.result.is-show .result__member { animation: member-in .6s .1s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes member-in { from { transform: translateY(20px) scale(.8); opacity: 0; } }

.bubble {
  position: relative; display: inline-block;
  margin: 14px auto 0; padding: 8px 16px; border-radius: 16px;
  background: color-mix(in srgb, var(--c, #ff6b5a) 16%, #fff);
  border: 2px solid var(--c, #ff6b5a);
  font-weight: 800; font-size: 15px;
}
.bubble::before {
  content: ""; position: absolute; left: 50%; top: -9px; width: 14px; height: 14px; margin-left: -7px;
  background: inherit; border-left: 2px solid var(--c, #ff6b5a); border-top: 2px solid var(--c, #ff6b5a);
  transform: rotate(45deg);
}
.result.is-show .bubble { animation: member-in .5s .35s both; }

.result__dish { margin-top: -6px; }
.result__illust { width: min(240px, 70%); margin: 0 auto; }
.result__illust svg { width: 100%; height: auto; display: block; }
.result.is-show .result__illust { animation: dish-in .7s .55s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes dish-in { from { transform: scale(.3) rotate(-20deg); opacity: 0; } }
.result__label { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.result__name { margin: 2px 0 0; font-size: clamp(28px, 9vw, 38px); font-weight: 800; line-height: 1.2; }
.result__note { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); min-height: 1em; }
.result.is-show .result__label, .result.is-show .result__name, .result.is-show .result__note { animation: member-in .5s .8s both; }

.result__actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.btn {
  border: 0; border-radius: 999px; padding: 12px 22px; font-weight: 800; font-size: 16px; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-dark);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-dark); }
.btn--ghost { background: #f3ece3; color: var(--ink); box-shadow: 0 4px 0 #e2d6c6; }

.confetti { position: absolute; inset: -40px; pointer-events: none; overflow: visible; }
.confetti i {
  position: absolute; top: 40%; left: 50%; width: 10px; height: 14px; border-radius: 3px;
  animation: confetti 1.6s cubic-bezier(.2,.7,.4,1) forwards;
}
@keyframes confetti {
  0% { transform: translate(0,0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; }
}

.steam path { animation: steam 2.4s ease-in-out infinite; }
.steam path:nth-child(2) { animation-delay: .4s; }
.steam path:nth-child(3) { animation-delay: .8s; }
@keyframes steam { 0%,100% { opacity: .2; transform: translateY(4px); } 50% { opacity: .9; transform: none; } }

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