:root {
  --bg: #fdf8f5;
  --fg: #2a1d1a;
  --muted: #7a6a65;
  --card: #ffffff;
  --accent: #b23a2b;
  --fat: #f3d9c9;
  --border: #ecdcd4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1413;
    --fg: #f3ebe8;
    --muted: #a8988f;
    --card: #261e1c;
    --accent: #e0604d;
    --fat: #5a3e35;
    --border: #3a2e2b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
}
main {
  max-width: 480px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
/* ホーム画面起動時、ステータスバーの裏に暗い帯を敷いて白文字を読めるようにする */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: env(safe-area-inset-top); background: #1a0e0c;
}
header { text-align: center; margin: 8px 0 16px; }
h1 { font-size: 1.5rem; margin: 0; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: .9rem; }
.notice {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; font-size: .85rem; margin-bottom: 12px;
}
.notice a { color: var(--accent); font-weight: bold; }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: block; text-align: center; padding: 14px 8px; border-radius: 12px;
  border: 2px solid var(--accent); color: var(--accent); font-weight: bold; cursor: pointer;
  background: var(--card);
}
.btn.primary { background: var(--accent); color: #fff; }
#preview { width: 100%; border-radius: 12px; margin-top: 16px; display: block; }
#preview[hidden] { display: none; }
.status { text-align: center; margin: 16px 0; color: var(--muted); }
.status.error { color: var(--accent); }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; margin-top: 16px;
}
.big { text-align: center; font-size: 3.5rem; font-weight: 800; color: var(--accent); line-height: 1; }
.big small { font-size: 1.5rem; margin-left: 2px; }
.error { text-align: center; font-size: 1.1rem; font-weight: 700; color: var(--accent); margin-top: 8px; }
.range { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 2px; }
.bar { height: 10px; background: var(--fat); border-radius: 5px; margin: 14px 0; overflow: hidden; }
#bar-fill { height: 100%; background: var(--accent); width: 0; transition: width .6s; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 600; }
.comment { margin: 14px 0 0; }
footer { color: var(--muted); font-size: .75rem; text-align: center; margin-top: 24px; }

/* ---------- スプラッシュ ---------- */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 42%, #4a2420 0%, #1a0e0c 75%);
  color: #fff4ec;
  transition: opacity .45s ease, visibility .45s;
}
#splash.hide { opacity: 0; visibility: hidden; }
.splash-steak {
  width: min(56vw, 240px); height: auto; overflow: visible;
  animation: sp-pop .6s cubic-bezier(.2, .9, .3, 1.2) both;
}
.splash-steak .sashi {
  stroke-dasharray: 1; stroke-dashoffset: 1; opacity: .9;
  animation: sp-draw .5s ease-out var(--d, .4s) forwards;
}
.splash-steak .scan {
  transform-box: view-box;
  animation: sp-scan .9s ease-in-out .9s both;
}
.splash-title {
  margin-top: 22px; font-size: 1.6rem; font-weight: 800; letter-spacing: .06em;
  animation: sp-rise .5s ease-out .5s both;
}
.splash-sub {
  margin-top: 6px; font-size: .9rem; color: #e9b9a8; letter-spacing: .1em;
  animation: sp-rise .5s ease-out .7s both;
}
#splash.launched .splash-steak { animation: none; }
@keyframes sp-pop { from { opacity: 0; transform: scale(.8) rotate(-6deg); } to { opacity: 1; transform: none; } }
@keyframes sp-draw { to { stroke-dashoffset: 0; } }
@keyframes sp-scan {
  0% { transform: translateY(0); opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(380px); opacity: 0; }
}
@keyframes sp-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .splash-steak, .splash-title, .splash-sub { animation: none; }
  .splash-steak .sashi { animation: none; stroke-dashoffset: 0; }
  .splash-steak .scan { display: none; }
}

/* ---------- 色解析 ---------- */
.color-box { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.color-box h2 { font-size: .95rem; margin: 0 0 8px; }
#overlay { width: 100%; border-radius: 10px; display: block; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin: 8px 0 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.excluded { font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
.breakdown { text-align: center; color: var(--muted); font-size: .75rem; margin-top: 4px; }

/* ---------- 脂質の内訳 ---------- */
.fat-split { margin: 4px 0 16px; }
.fat-split h2 { font-size: .95rem; margin: 0 0 8px; }
.split-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--border); }
.sb { display: block; height: 100%; transition: width .6s; }
.marbling { background: #ffcd3c; }
.cap { background: #3fa9e0; }
.lean { background: #d23228; }
.split-legend { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; font-size: .9rem; }
.split-legend li { display: flex; align-items: center; }
.split-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; }
.split-legend b { margin-left: auto; }

/* ---------- 計測中 ---------- */
.loading { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 20px 0; }
.loading[hidden] { display: none; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
.loading-text { font-weight: 700; color: var(--accent); letter-spacing: .1em; }
.progress { width: 70%; max-width: 260px; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.progress span { display: block; width: 40%; height: 100%; background: var(--accent); border-radius: 2px; animation: slide 1.4s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
.pick.busy { opacity: .5; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .progress span { animation-duration: 3s; }
}
.breakdown.note { margin-top: 2px; font-size: .7rem; }

/* ---------- 牛とバーベキューのイラスト ---------- */
.cow { display: block; width: min(100%, 380px); height: auto; margin: 20px auto 0; overflow: visible; }
.cow-tail, .cow-eye, .cow-ear, .bbq-flames path, .bbq-smoke path { transform-box: fill-box; }
.cow-tail { transform-origin: 20% 0%; animation: cow-tail 2.6s ease-in-out infinite; }
.cow-eye { transform-origin: 50% 50%; animation: cow-blink 5s infinite; }
.cow-ear { transform-origin: 0% 50%; animation: cow-ear 7s ease-in-out infinite; }
.bbq-flames path { transform-origin: 50% 100%; animation: flame .5s ease-in-out infinite alternate; }
.bbq-flames path:nth-child(2) { animation-delay: .15s; }
.bbq-flames path:nth-child(3) { animation-delay: .3s; }
.bbq-flames path:nth-child(4) { animation-delay: .07s; }
.bbq-drip { transform-box: fill-box; animation: drip 1.8s ease-in infinite; }
.bbq-ember { animation: ember 1.6s ease-in-out infinite alternate; }
.bbq-smoke path { animation: smoke 3.2s ease-out infinite; }
.bbq-smoke .s2 { animation-delay: 1.6s; }
@keyframes cow-tail { 0%, 100% { transform: rotate(4deg); } 50% { transform: rotate(-8deg); } }
@keyframes cow-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes cow-ear { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-12deg); } 90% { transform: rotate(4deg); } }
@keyframes flame { from { transform: scaleY(.8) skewX(-4deg); } to { transform: scaleY(1.15) skewX(4deg); } }
@keyframes drip { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(9px); opacity: 0; } }
@keyframes ember { from { opacity: .6; } to { opacity: 1; } }
@keyframes smoke { 0% { transform: translateY(8px); opacity: 0; } 30% { opacity: .6; } 100% { transform: translateY(-14px); opacity: 0; } }
/* よだれを垂らしてキョロキョロする人: 牛（右上）とグリル（右下）を交互に見る */
.person-head, .person-pupils, .person-drool, .person-drop, .person-sfx { transform-box: fill-box; }
.person-head { transform-origin: 50% 100%; animation: look-head 3.6s ease-in-out infinite; }
.person-pupils { animation: look-eyes 3.6s ease-in-out infinite; }
.person-drool { transform-origin: 50% 0%; animation: drool 1.8s ease-in-out infinite; }
.person-drop { animation: drool-drop 1.8s ease-in infinite; }
.person-sfx { animation: sfx 3.6s ease-in-out infinite; }
@keyframes look-head {
  0%, 10% { transform: rotate(0); }
  18%, 42% { transform: rotate(-6deg); }   /* 牛を見る */
  52%, 80% { transform: rotate(5deg); }    /* グリルを見る */
  90%, 100% { transform: rotate(0); }
}
@keyframes look-eyes {
  0%, 10% { transform: translate(0, 0); }
  18%, 42% { transform: translate(2.2px, -1.6px); }
  52%, 80% { transform: translate(2.4px, 1.6px); }
  90%, 100% { transform: translate(0, 0); }
}
@keyframes drool { 0%, 100% { transform: scaleY(.75); } 50% { transform: scaleY(1.15); } }
@keyframes drool-drop { 0%, 40% { transform: translateY(0); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(12px); opacity: 0; } }
@keyframes sfx { 0%, 100% { opacity: .35; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-color-scheme: dark) {
  .cow { filter: drop-shadow(0 0 1.5px rgba(255, 240, 230, .45)); }
}
@media (prefers-reduced-motion: reduce) {
  .cow-tail, .cow-eye, .cow-ear, .bbq-flames path, .bbq-ember, .bbq-smoke path, .bbq-drip,
  .person-head, .person-pupils, .person-drool, .person-drop, .person-sfx { animation: none; }
}

/* ---------- 広告 ---------- */
.ad { margin: 16px 0; }
.ad-label { font-size: .7rem; color: var(--muted); margin-bottom: 4px; }
#ad-slot { min-height: 100px; }
.ad-placeholder {
  height: 250px; border: 2px dashed var(--border); border-radius: 12px;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem;
}

.footer-link { color: var(--muted); text-decoration: underline; }
