:root{
  --green:#055e32;--green-d:#03472a;--yellow:#ffd400;--ink:#1b211e;--gray:#6a726d;--line:#e3e6e4;--paper:#f4f5f4;
  --safe-t:env(safe-area-inset-top);--safe-b:env(safe-area-inset-bottom);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#101412;color:#fff;
  font-family:"Zen Kaku Gothic New","Hiragino Sans","Yu Gothic",sans-serif;font-feature-settings:"palt";
  touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
button{font:inherit;color:inherit;cursor:pointer}
[hidden]{display:none!important}

#feed{position:fixed;inset:0;width:100%;height:100%;display:block}
.bg-photo{position:fixed;inset:0;width:100%;height:100%;object-fit:cover;display:block}

/* 左上の印 */
.mark{position:fixed;z-index:20;top:calc(var(--safe-t) + 14px);left:16px;width:58px;pointer-events:none;
  filter:drop-shadow(0 2px 8px rgba(0,0,0,.35))}
.mark img{display:block;width:100%}
.is-start .mark{filter:none}

/* はじめの画面 */
.start{position:fixed;inset:0;z-index:30;display:grid;grid-template-rows:1fr auto;background:#fff;color:var(--ink)}
.start-visual{position:relative;display:grid;place-items:center;padding:calc(var(--safe-t) + 64px) 28px 0;
  background:radial-gradient(90% 60% at 50% 58%,#fff 0,var(--tint,#eef1ef) 72%,var(--tint2,#e5eae7) 100%)}
[data-season="ch"]{--tint:#e6f0e9;--tint2:#d9e8de}
[data-season="year"]{--tint:#f6e9e6;--tint2:#f0dcd7}
[data-season="vd"]{--tint:#f8e9ee;--tint2:#f2dbe3}
[data-season="hl"]{--tint:#f6ecdf;--tint2:#efdfca}
.start-visual img{width:min(88vw,460px);max-height:56vh;object-fit:contain;filter:drop-shadow(0 18px 24px rgba(10,30,20,.12))}
.start-body{padding:22px 24px calc(var(--safe-b) + 22px);text-align:center}
.start-season{display:inline-block;margin:0 0 10px;padding:4px 12px;border-radius:99px;background:var(--yellow);color:var(--ink);font-size:12px;font-weight:900;letter-spacing:.08em}
.start-name,.pc-name{word-break:keep-all;overflow-wrap:anywhere}
.start-name{margin:0 0 20px;font-size:21px;line-height:1.45;font-weight:900;letter-spacing:.02em}
.btn-primary{display:flex;align-items:center;justify-content:center;gap:10px;width:100%;max-width:420px;min-height:58px;margin:0 auto;padding:0 20px;
  border:0;border-radius:16px;background:var(--green);color:#fff;font-size:17px;font-weight:900;letter-spacing:.04em}
.btn-primary:active{background:var(--green-d)}
.btn-primary svg{width:24px;height:24px}
.btn-primary:disabled{opacity:.5}
.start-note{margin:12px 0 0;color:var(--gray);font-size:12px;font-weight:700}
.start-steps{display:flex;justify-content:center;gap:8px;margin:0 auto 18px;padding:0;list-style:none;max-width:420px}
.start-steps li{flex:1;display:grid;justify-items:center;gap:6px;padding:10px 4px 9px;border-radius:12px;background:#f2f4f3;font-size:12px;font-weight:700;color:var(--ink);position:relative}
.start-steps li+li::before{content:"";position:absolute;left:-7px;top:50%;width:6px;height:6px;border-top:2px solid #b9c2bd;border-right:2px solid #b9c2bd;transform:translateY(-50%) rotate(45deg)}
.start-steps svg{width:22px;height:22px;fill:none;stroke:var(--green);stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.start-name{margin-bottom:16px}

/* 読み込み中 */
.loading{position:fixed;inset:0;z-index:40;display:grid;place-content:center;justify-items:center;gap:16px;background:rgba(255,255,255,.94);color:var(--ink);font-weight:700}
.loading p{margin:0;font-size:14px}
.spinner{width:42px;height:42px;border:3px solid #d9dfdb;border-top-color:var(--green);border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* 床さがしの案内 */
.guide{position:fixed;z-index:15;left:50%;bottom:calc(var(--safe-b) + 48px);transform:translateX(-50%);display:grid;justify-items:center;gap:14px;width:min(92vw,380px);pointer-events:none}
.guide p{margin:0;padding:10px 18px;border-radius:99px;background:rgba(16,20,18,.72);font-size:14px;font-weight:700;line-height:1.5;text-align:center;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
.guide-phone{position:relative;width:38px;height:64px;border:3px solid #fff;border-radius:9px;animation:sway 2.2s ease-in-out infinite;filter:drop-shadow(0 4px 12px rgba(0,0,0,.4))}
.guide-phone span{position:absolute;left:50%;bottom:4px;width:10px;height:3px;margin-left:-5px;border-radius:2px;background:#fff}
@keyframes sway{0%,100%{transform:translateX(-36px) rotate(-8deg)}50%{transform:translateX(36px) rotate(8deg)}}
.guide.is-ready .guide-phone{display:none}

/* 撮影のボタンまわり */
.controls{position:fixed;z-index:15;left:0;right:0;bottom:0;display:grid;justify-items:center;gap:12px;padding:70px 12px calc(var(--safe-b) + 14px);
  background:linear-gradient(to bottom,transparent,rgba(0,0,0,.45));pointer-events:none}
.controls>*{pointer-events:auto}
.tools{display:flex;gap:6px}
.tools button{display:grid;justify-items:center;gap:2px;min-width:64px;padding:7px 8px 6px;border:1px solid rgba(255,255,255,.28);border-radius:14px;
  background:rgba(16,20,18,.55);font-size:11px;font-weight:700;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
.tools button svg{width:20px;height:20px}
.tools button:active{background:rgba(16,20,18,.8)}
.shutter{position:relative;width:84px;height:84px;padding:0;border:0;border-radius:50%;background:transparent;touch-action:none}
.shutter-ring{position:absolute;inset:0;width:100%;height:100%;transform:rotate(-90deg)}
.shutter-ring circle{fill:none;stroke:#fff;stroke-width:6}
.shutter-ring .ring-progress{stroke:#ff3b30;stroke-dasharray:289;stroke-dashoffset:289;opacity:0}
.shutter-core{position:absolute;inset:11px;border-radius:50%;background:#fff;transition:transform .15s,background .15s,border-radius .15s}
.shutter:active .shutter-core{transform:scale(.92)}
.is-recording .shutter-core{inset:26px;border-radius:9px;background:#ff3b30}
.is-recording .ring-progress{opacity:1}
.is-recording .tools,.is-recording .shutter-hint{visibility:hidden}
.shutter-hint{margin:0;font-size:11px;font-weight:700;opacity:.9;text-shadow:0 1px 4px rgba(0,0,0,.5)}
.rec{position:fixed;z-index:16;top:calc(var(--safe-t) + 16px);left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:8px;padding:6px 14px;border-radius:99px;background:rgba(16,20,18,.7);font-size:14px;font-weight:900;font-variant-numeric:tabular-nums}
.rec-dot{width:9px;height:9px;border-radius:50%;background:#ff3b30;animation:blink 1s steps(1) infinite}
@keyframes blink{50%{opacity:.2}}
.flash{position:fixed;inset:0;z-index:50;background:#fff;opacity:0;pointer-events:none}
.flash.on{animation:flash .35s ease-out}
@keyframes flash{0%{opacity:.9}100%{opacity:0}}

/* 撮ったあと */
.result{position:fixed;inset:0;z-index:45;display:grid;grid-template-rows:1fr auto;gap:16px;padding:calc(var(--safe-t) + 18px) 16px calc(var(--safe-b) + 16px);background:#101412}
.result-media{position:relative;min-height:0}
.result-media img,.result-media video{position:absolute;inset:0;margin:auto;max-width:100%;max-height:100%;border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.45)}
.result-actions{display:grid;grid-template-columns:1fr 1.4fr;gap:10px;width:100%;max-width:440px;margin:0 auto}
.btn-ghost{min-height:58px;border:1px solid rgba(255,255,255,.35);border-radius:16px;background:transparent;font-size:15px;font-weight:700}

/* PCで開いたとき：左に写真と3D、右にQR */
.is-pc{background:#eef0ee}
.is-pc #feed,.is-pc .bg-photo{right:auto;width:calc(100% - 380px);cursor:grab}
.pc-panel{position:fixed;z-index:20;top:50%;right:40px;transform:translateY(-50%);width:300px;padding:28px 26px 24px;border-radius:22px;background:#fff;color:var(--ink);text-align:center;box-shadow:0 20px 60px rgba(20,30,25,.18)}
.pc-name{margin:0 0 18px;font-size:19px;line-height:1.5;font-weight:900}
.pc-qr{width:180px;height:180px;margin:0 auto 14px}
.pc-qr svg,.pc-qr img{display:block;width:100%;height:100%}
.pc-text{margin:0;color:var(--gray);font-size:13px;font-weight:700;line-height:1.6}

/* LP に埋め込んだ見本：縦のスクロールはページに渡す */
html.is-embed,html.is-embed body{touch-action:pan-y;background:#dfe3e0}
.is-embed .mark{display:none}
.is-embed #feed{cursor:grab}

/* うまくいかないとき */
.error{position:fixed;inset:0;z-index:60;display:grid;place-content:center;justify-items:center;gap:14px;padding:32px;background:#fff;color:var(--ink);text-align:center}
.error h2{margin:0;font-size:20px;font-weight:900}
.error p{margin:0 0 8px;max-width:340px;color:var(--gray);font-size:14px;line-height:1.8;font-weight:700}
.error .btn-primary{width:260px}

/* PC で幅が狭いとき：写真を上、QR を下に */
@media (max-width:860px){
  .is-pc{--sheet-h:calc(188px + var(--safe-b))}
  .is-pc #feed,.is-pc .bg-photo{width:100%;height:calc(100% - var(--sheet-h))}
  .pc-panel{top:auto;right:0;bottom:0;left:0;transform:none;width:auto;height:var(--sheet-h);
    display:grid;grid-template-columns:128px minmax(0,1fr);grid-template-rows:1fr auto auto auto 1fr;column-gap:22px;
    padding:20px max(24px,calc(50% - 260px)) calc(20px + var(--safe-b));border-radius:24px 24px 0 0;text-align:left;
    box-shadow:0 -10px 36px rgba(20,30,25,.10)}
  .pc-panel .start-season{grid-column:2;grid-row:2;justify-self:start;align-self:start;margin:0 0 8px}
  .pc-name{grid-column:2;grid-row:3;margin:0 0 4px;font-size:17px;line-height:1.45}
  .pc-qr{grid-column:1;grid-row:1/-1;align-self:center;width:128px;height:128px;margin:0}
  .pc-text{grid-column:2;grid-row:4;font-size:12px}
}
@media (max-width:400px){
  .pc-panel{grid-template-columns:104px minmax(0,1fr);column-gap:16px}
  .pc-qr{width:104px;height:104px}
  .pc-name{font-size:15px}
}

/* スマホで横にはみ出さないように（上の絵の幅＋余白が画面を超えていた。8th Wall の部品の CSS にも負けない） */
.start{grid-template-columns:minmax(0,1fr)}
.start-visual img{width:min(100%,460px)}
.btn-primary,.start-steps li,.result .btn-primary{box-sizing:border-box!important}
.start-steps li{min-width:0}
/* はじめの画面の地の色（行事ごと。ベージュにしない） */
[data-season="hl"]{--tint:#efeaf5;--tint2:#e4ddef}
[data-season="setsubun"]{--tint:#f3ebe6;--tint2:#ebdcd6}
[data-season="hina"],[data-season="sakura"]{--tint:#f9eaf0;--tint2:#f3dbe6}
[data-season="wd"]{--tint:#eaf1f7;--tint2:#dde8f2}
[data-season="school"]{--tint:#edf2ec;--tint2:#e0eadf}
[data-season="kodomo"],[data-season="summer"],[data-season="tanabata"]{--tint:#e8f1f7;--tint2:#d9e7f2}
[data-season="tsukimi"]{--tint:#f1eee6;--tint2:#e6e2d6}
[data-season="cele"]{--tint:#f4eef3;--tint2:#ebe1ea}
