/* ガラガラ抽選 合成プレビュー — スマホ最優先（320/390px）。UI_PROFILE.md の役割別トークン。
   色は役割で使い分ける: main=案内・遷移 / accent=抽選CTA / confirm=店頭の確定 / line=LINE風の合成画面 / stamp=使用済み */
:root {
  --paper: #fbf9f4;
  --surface: #ffffff;
  --ink: #1f2937;
  --muted: #566170;
  --rule: #e8e4db;
  --gold: #b39960;
  --main: #173f61;      /* 案内・遷移CTA（三角くじ来店者CTAの青系を継承） */
  --accent: #b83a0c;    /* 抽選CTA・ガラガラ本体の暖色 */
  --confirm: #71313d;   /* スタッフ確定（三角くじの深いワイン系を継承） */
  --stamp: #982e39;     /* 使用済み印 */
  --line: #087a3f;      /* LINE風・合成画面（実LINEではない） */
  --go: #007537;        /* 抽選の主CTA（三角くじ来店者CTAの緑系 #00843d→#007537 を継承） */
  --ok: #0f766e;
  --danger: #b3261e;
  --t-special: #c9972b;
  --t-first: #b3261e;
  --t-second: #1f6f8b;
  --t-third: #2a7f62;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  overscroll-behavior-y: none;
}
button { font: inherit; }
h1, h2, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.screen {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  padding: 0 16px calc(16px + var(--safe-b));
  max-width: 480px; margin: 0 auto; width: 100%;
}
/* 来場者共通ヘッダー（開発/本番で同一）。アイコン＋サービス名。画面端いっぱいに敷く */
.site-head {
  display: flex; align-items: center; gap: 12px; min-height: 68px; margin: 0 -16px; padding: calc(10px + var(--safe-t)) 16px 10px;
  background: #fff; border-bottom: 1px solid var(--rule);
}
.brand-icon { height: 46px; width: auto; flex: none; display: block; }
.brand-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--go); flex: none; }
.brand-name { font-size: 14.5px; font-weight: 700; letter-spacing: .02em; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.demo-tag {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .04em; color: #7a4b00;
  background: #fff1cc; border: 1px solid #e6c36b; border-radius: 999px; padding: 1px 10px; white-space: nowrap;
}
.steps { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; flex: 1; justify-content: flex-end; }
.steps li { font-size: 12px; color: var(--muted); padding: 2px 7px; border-radius: 999px; white-space: nowrap; min-width: 24px; text-align: center; }
.steps li[aria-current="step"] { background: var(--main); color: #fff; font-weight: 700; }
.steps li.done { color: var(--ok); font-weight: 600; }

.body { flex: 1; display: flex; flex-direction: column; gap: 14px; padding-top: 14px; min-height: 0; }
h1 { font-size: 22px; line-height: 1.35; font-weight: 800; }
.nb { display: inline-block; }
.lead { color: var(--muted); font-size: 15px; }
.small { font-size: 13px; color: var(--muted); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 52px; padding: 12px 18px; border: 0; border-radius: 12px; cursor: pointer;
  font-size: 17px; font-weight: 700; color: #fff; background: var(--main);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: translateY(1px); filter: brightness(.95); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.accent { background: var(--accent); }
.btn.go { position: relative; overflow: hidden; background: linear-gradient(110deg, #00843d, #007537); border: 1px solid #006f35; box-shadow: 0 4px 13px #006f3525; }
.btn.line { background: var(--line); }
.btn.ghost { background: transparent; color: var(--main); border: 1.5px solid var(--main); }
.btn.text { background: transparent; color: var(--main); min-height: 44px; font-size: 15px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn:focus-visible, .link:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
.actions { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
/* 主CTAは常に初期viewport内（縦に短い画面でも押せる）。背景を敷いて下の文字と重ならないようにする */
.actions.sticky { position: sticky; bottom: 0; margin-top: 0; padding: 4px 0 calc(6px + var(--safe-b)); background: linear-gradient(to bottom, rgba(251,249,244,0), var(--paper) 14px); z-index: 2; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255,255,255,.45); border-top-color: #fff;
  animation: spin .8s linear infinite; flex: none;
}
.btn.ghost .spinner, .btn.text .spinner { border-color: rgba(23,63,97,.3); border-top-color: var(--main); }
@keyframes spin { to { transform: rotate(360deg); } }

.notice { border-radius: 10px; padding: 12px 14px; font-size: 15px; line-height: 1.6; }
.notice.error { background: #fdecea; color: #7a1a13; border: 1px solid #f3b6b0; }
.notice.info { background: #eef4f8; color: #17384f; border: 1px solid #c9dbe7; }
.notice.warn { background: #fff6e0; color: #6b4300; border: 1px solid #ecd08a; }
.notice.ok { background: #e8f5f1; color: #0b4f49; border: 1px solid #b7ddd5; }

/* ---- ① 入口 ---- */
.entry-art { display: grid; place-items: center; padding: 2px 0; }
.entry-art svg { width: min(46vw, 150px); height: auto; }
.flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: s; }
.flow li {
  counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 10px 12px; font-size: 15px;
}
.flow li::before {
  content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--main); color: #fff; font-weight: 800; font-size: 14px;
}
.flow b { display: block; font-size: 15px; }
.flow span { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---- ② LINE（合成） ---- */
.line-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.line-card .cover { background: linear-gradient(135deg, #0a8f4a, #2fb36d); height: 72px; }
.line-card .who { display: grid; justify-items: center; gap: 4px; padding: 0 16px 16px; margin-top: -34px; text-align: center; }
.avatar { width: 68px; height: 68px; border-radius: 50%; background: #fff; border: 3px solid #fff; display: grid; place-items: center; font-size: 34px; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.line-card h2 { font-size: 18px; }
.perks { list-style: none; margin: 8px 0 12px; padding: 0; display: grid; gap: 6px; text-align: left; width: 100%; }
.perks li { font-size: 14px; padding-left: 22px; position: relative; }
.perks li::before { content: "✓"; position: absolute; left: 2px; color: var(--ok); font-weight: 800; }

/* ---- ③ ガラガラ ---- */
.draw-title { text-align: center; font-size: 18px; font-weight: 800; min-height: 28px; line-height: 1.4; }
.stage-wrap { flex: 0 1 auto; height: clamp(250px, 42dvh, 340px); min-height: 190px; position: relative; display: grid; place-items: center; overflow: hidden; border-radius: var(--radius); background: radial-gradient(120% 90% at 50% 20%, #fff 0%, #f3ecdc 100%); border: 1px solid var(--rule); }
.stage-zoom { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
.stage-zoom svg { width: 100%; height: 100%; display: block; overflow: visible; }
.machine { transition: opacity .35s; }
.stage-wrap[data-focus="1"] .machine { opacity: 0; } /* 玉アップ中は筐体の残像を出さない（V2：スマホで薄い四角が残って見えた） */
.floor { transition: opacity .35s; }
.stage-wrap[data-focus="1"] .floor { opacity: 0; }
.spot { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: radial-gradient(circle at 50% 50%, rgba(255,244,200,.95), rgba(255,244,200,0) 60%); transition: opacity .4s; }
.stage-wrap[data-focus="1"] .spot { opacity: 1; }
.caps circle { transform-box: fill-box; transform-origin: center; }
.stage-wrap.spinning .caps circle { animation: jig .28s ease-in-out infinite alternate; }
.stage-wrap.spinning .caps circle:nth-child(2n) { animation-duration: .21s; animation-direction: alternate-reverse; }
.stage-wrap.spinning .caps circle:nth-child(3n) { animation-duration: .34s; }
@keyframes jig { from { transform: translate(-3px, 2px) rotate(-8deg); } to { transform: translate(3px, -3px) rotate(8deg); } }
.handle { transform-box: fill-box; transform-origin: center; }
.stage-wrap.spinning .handle { animation: turn 1s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
.burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.burst i { position: absolute; left: 50%; top: 50%; width: 8px; height: 14px; border-radius: 2px; opacity: 0; }
.ribbon {
  position: absolute; left: 50%; bottom: 10px; transform: translate(-50%, 8px); opacity: 0; transition: opacity .3s, transform .3s;
  background: var(--tier, var(--main)); color: var(--on-tier, #fff); font-weight: 800; font-size: 22px; padding: 6px 22px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,.2);
}
.ribbon.show { opacity: 1; transform: translate(-50%, 0); }
/* 通信待ちなどの短い状態文。抽選機の下に独立した行を取らず、ステージ内の下端に重ねる（抽選機とボタンの縦余白を詰める） */
.stage-status { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 1; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.4; pointer-events: none; }
.stage-status:not(:empty) { background: rgba(255,255,255,.85); border-radius: 8px; padding: 3px 8px; }
.result-card { text-align: center; display: grid; gap: 6px; }
.tier-chip { display: inline-block; background: var(--tier, var(--main)); color: #fff; font-weight: 800; padding: 3px 14px; border-radius: 999px; font-size: 15px; }
.result-card h2 { font-size: 24px; line-height: 1.3; }
[data-tier="special"] { --tier: var(--t-special); --on-tier: #2b1d00; } /* 金地は濃色文字でコントラスト確保 */
[data-tier="first"] { --tier: var(--t-first); }
[data-tier="second"] { --tier: var(--t-second); }
[data-tier="third"] { --tier: var(--t-third); }

.draw .actions { min-height: 150px; justify-content: flex-start; }

/* ---- ⑤ 券 ---- */
.ticket { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; box-shadow: 0 2px 10px rgba(80,60,20,.08); }
.ticket-head { background: var(--tier, var(--main)); color: var(--on-tier, #fff); display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }
.ticket-head strong { font-size: 20px; }
.ticket-head .demo-tag { background: rgba(255,255,255,.92); }
.ticket-body { padding: 14px; display: grid; gap: 10px; }
.prize { font-size: 19px; font-weight: 800; line-height: 1.4; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; word-break: break-all; }
.tear { border-top: 2px dashed var(--rule); margin: 0 -14px; position: relative; }
.tear::before, .tear::after { content: ""; position: absolute; top: -9px; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); border: 1px solid var(--rule); }
.tear::before { left: -9px; } .tear::after { right: -9px; }
.save { background: #f7f3e8; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.save b { display: block; margin-bottom: 2px; }
.hold-use {
  position: relative; display: grid; gap: 2px; width: 100%; min-height: 64px; padding: 10px 14px; border: 0; border-radius: 12px;
  background: var(--confirm); color: #fff; text-align: center; font-weight: 700; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.hold-use small { font-size: 13px; font-weight: 500; opacity: .9; }
.hold-use progress { width: 100%; height: 6px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 3px; overflow: hidden; background: rgba(255,255,255,.3); }
.hold-use progress::-webkit-progress-bar { background: rgba(255,255,255,.3); }
.hold-use progress::-webkit-progress-value { background: #fff; }
.hold-use progress::-moz-progress-bar { background: #fff; }
.hold-use:disabled { opacity: .55; }
.stamp {
  display: block; width: max-content; margin: 4px auto 6px; transform: rotate(-6deg); color: var(--stamp); border: 4px solid var(--stamp);
  border-radius: 10px; padding: 2px 18px; font-weight: 900; font-size: 30px; letter-spacing: .08em; background: rgba(255,255,255,.7); pointer-events: none;
}
.used-at { text-align: center; }
.ticket.used .ticket-body > :not(.keep) { opacity: .55; }

/* ---- ⑥ LINE トーク（合成） ---- */
.chat { background: #cfdde9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--rule); }
.chat-head { background: var(--line); color: #fff; padding: 10px 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.chat-log { padding: 14px 12px; display: grid; gap: 10px; }
.msg { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: start; }
.msg .avatar { width: 34px; height: 34px; font-size: 18px; border-width: 2px; box-shadow: none; }
.bubble { background: #fff; border-radius: 4px 14px 14px 14px; padding: 10px 12px; font-size: 15px; line-height: 1.55; max-width: 100%; }
.bubble b { font-weight: 800; }
.bubble .btn { margin-top: 8px; min-height: 46px; font-size: 15px; }
.sheet-back { position: fixed; inset: 0; background: rgba(17,24,39,.5); display: grid; align-items: end; z-index: 20; }
.sheet { background: #fff; border-radius: 18px 18px 0 0; padding: 18px 16px calc(16px + var(--safe-b)); max-width: 480px; width: 100%; margin: 0 auto; display: grid; gap: 12px; }
.sheet h2 { font-size: 18px; }
.reset-link { text-align: center; padding-top: 4px; }

/* ---- V2 追加 ---- */
a.btn { text-decoration: none; }
.prize { text-wrap: balance; }
.btn.sub { min-height: 46px; font-size: 15px; font-weight: 600; } /* 補助導線：主ボタン（クーポンを開く）より目立たせない */
.note-lines { display: grid; gap: 4px; margin-top: 4px; text-align: center; }
.note-lines p { font-size: 13px; line-height: 1.55; color: var(--muted); text-wrap: balance; }
.note-lines .note-gap { margin-top: 1.55em; } /* 2文目の次に1行分の余白 */
/* 緑ボタンの光：約3.6秒ごとに1回、短く流れる（点滅なし・押下を妨げない） */
.btn.go::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 38%; pointer-events: none; background: linear-gradient(105deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.5) 50%, rgba(255,255,255,0) 100%); transform: translateX(-130%) skewX(-18deg); animation: shine 3.6s ease-in-out 1s infinite; }
.btn.go:disabled::after { animation: none; opacity: 0; }
@keyframes shine { 0%, 72% { transform: translateX(-130%) skewX(-18deg); } 100% { transform: translateX(380%) skewX(-18deg); } }
@media (prefers-reduced-motion: reduce) { .btn.go::after { display: none; } }
.draw .stage-wrap { margin-bottom: 8px; }
.draw .actions { padding-top: 12px; }

/* クーポン案内：カードをゆったり。主ボタンは画面中央より少し下（小さい画面では無理に固定せず自然に流す） */
.ticket-screen .body { gap: 16px; }
.ticket.roomy .ticket-head { padding: 9px 20px; justify-content: center; text-align: center; }
.ticket.roomy .ticket-head strong { font-size: 24px; }
.ticket.roomy .ticket-body { padding: 28px 22px 32px; gap: 20px; }
.ticket.roomy .prize { font-size: 21px; }
.ticket.roomy .meta { font-size: 15px; gap: 10px 14px; }
.meta dd.soft { font-weight: 500; color: var(--muted); font-size: 14px; }
/* 特典イメージ：幅に追従・縦横比2:1・最大高さを抑えてボタンまで極端に長くしない */
.prize-img { display: block; width: auto; height: auto; max-width: 100%; max-height: 170px; aspect-ratio: 2 / 1; margin: 0 auto; border-radius: 10px; background: #fff; }
@media (max-height: 720px) { .prize-img { max-height: 128px; } }
@media (max-height: 640px) { .prize-img { max-height: 96px; } }
.ticket-actions { margin-top: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* LINEのご案内：緑のヘッダー＋アイコン付き3ブロック（静的ページ） */
.info-hero { background: linear-gradient(120deg, #00843d, #007537); color: #fff; border-radius: var(--radius); padding: 20px 18px; }
.info-hero h1 { font-size: 21px; }
.info-blocks { display: grid; gap: 12px; }
.info-block { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px; }
.info-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #e6f3ec; color: #007537; }
.info-block h2 { font-size: 16px; line-height: 1.4; margin-bottom: 2px; }
.info-block p { font-size: 14px; line-height: 1.65; color: var(--muted); }

.loading { display: grid; place-items: center; flex: 1; color: var(--muted); gap: 10px; }
.loading .spinner { border-color: rgba(23,63,97,.25); border-top-color: var(--main); width: 28px; height: 28px; }

@media (max-width: 340px) {
  h1 { font-size: 20px; }
  .steps li { padding: 2px 4px; font-size: 11px; }
  .screen { padding-left: 12px; padding-right: 12px; }
  .site-head { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
}
/* 縦が低めの画面（iPhone SE等）：筐体を少し小さくして主ボタンを押しやすく保つ */
@media (max-height: 640px) {
  .stage-wrap { height: clamp(190px, 33dvh, 250px); }
}
/* 縦に短い画面（ブラウザバー表示中のiPhone SE・横向き等） */
@media (max-height: 560px) {
  .body { gap: 10px; padding-top: 8px; }
  .entry-art svg { width: 84px; }
  h1 { font-size: 19px; }
  .btn { min-height: 48px; }
  .flow li { padding: 7px 10px; }
  .stage-wrap { height: clamp(170px, 36dvh, 250px); min-height: 150px; }
  .result-card h2 { font-size: 20px; }
  .lead { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
