:root{
  --sky:#13aee8;
  --sky-light:#eaf9ff;
  --sky-deep:#1266d8;
  --cloth:#1e4387;
  --cloth-deep:#153052;
  --brass:#ffd56b;
  --brass-dim:#d99d3f;
  --coral:#ef5b5b;
  --orange:#ff9a4a;
  --green:#27b979;
  --paper:#fffaf0;
  --ink:#153052;
  --muted:#d6edff;
  --night:#071b3e;
  --mincho:"Zen Old Mincho","Hiragino Mincho ProN","Yu Mincho","MS PMincho","MS Mincho","Noto Serif JP",serif;
  --maru:"Zen Maru Gothic","Hiragino Maru Gothic ProN","Yu Gothic",sans-serif;
  --sw:80px;
  --fw:50px;
  --spread-gap:clamp(3px,1vw,15px);
  --ui-shadow:8px 8px 0 rgba(21,48,82,.9),0 24px 64px rgba(18,102,216,.2);
  --pointer-x:50%;
  --pointer-y:32%;
}
[hidden]{display:none!important}
*,*::before,*::after{box-sizing:border-box}

html,body{margin:0;padding:0;width:100%;height:100%;height:100dvh;overflow:hidden}
body{
  color:var(--paper);font-family:var(--maru);
  background:
    linear-gradient(90deg,rgba(234,249,255,.93),rgba(255,250,240,.78) 45%,rgba(255,213,107,.16)),
    url("/images/movie-key-visual-bg.png") center/cover no-repeat,
    linear-gradient(180deg,var(--sky-light) 0,var(--sky) 42%,var(--cloth) 100%);
  min-width:280px;
  -webkit-tap-highlight-color:transparent;user-select:none;
}
.movie-back-link{
  position:fixed;
  z-index:80;
  top:calc(14px + env(safe-area-inset-top));
  left:calc(14px + env(safe-area-inset-left));
  display:inline-flex;
  min-height:40px;
  align-items:center;
  justify-content:center;
  border:2px solid var(--ink);
  border-radius:999px;
  background:rgba(255,250,240,.92);
  box-shadow:4px 4px 0 rgba(21,48,82,.86),0 10px 24px rgba(21,48,82,.14);
  color:var(--ink);
  font:900 13px/1 var(--maru);
  letter-spacing:.04em;
  padding:.7em 1.1em;
  text-decoration:none;
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  transition:transform .15s ease,box-shadow .15s ease,background .15s ease;
}
.movie-back-link::before{
  content:"‹";
  margin-right:.45em;
  color:var(--coral);
  font-size:1.25em;
  line-height:.7;
}
.movie-back-link:hover{
  background:#fff6db;
  box-shadow:2px 2px 0 rgba(21,48,82,.86),0 8px 18px rgba(21,48,82,.12);
  transform:translate(2px,2px);
}
.movie-back-link:focus-visible{outline:3px solid #fff;outline-offset:3px}
body::before,body::after{
  content:"";position:fixed;left:-8vw;right:-8vw;pointer-events:none;z-index:0;
}
body::before{
  top:0;height:100%;opacity:.5;
  background:
    radial-gradient(circle at 15% 15%,rgba(255,213,107,.36),transparent 20rem),
    radial-gradient(circle at 82% 24%,rgba(239,91,91,.28),transparent 18rem),
    radial-gradient(circle at 62% 80%,rgba(39,185,121,.16),transparent 18rem);
  filter:none;
}
body::after{
  top:0;bottom:auto;height:100%;opacity:.42;
  background:
    radial-gradient(circle,rgba(255,255,255,.92) 0 1px,transparent 1.4px),
    radial-gradient(circle,rgba(255,213,107,.52) 0 1px,transparent 1.5px);
  background-size:34px 34px,74px 74px;
}
body:has(#setup:not([hidden])){
  background:
    radial-gradient(circle 260px at var(--pointer-x) var(--pointer-y),rgba(255,246,219,.45),transparent 72%),
    linear-gradient(90deg,rgba(255,250,240,.9),rgba(234,249,255,.7) 44%,rgba(255,213,107,.18)),
    url("../assets/ui/movie-choice-bg.png") center/cover no-repeat;
}

/* The app always owns exactly one viewport. Spread height is controlled by --sw. */
.app{
  position:relative;z-index:1;width:100%;height:100%;height:100dvh;
  display:grid;grid-template-rows:auto auto minmax(0,1fr);
  grid-template-areas:"hd" "sp" "tb";
  padding-top:env(safe-area-inset-top);
  padding-right:env(safe-area-inset-right);
  padding-bottom:env(safe-area-inset-bottom);
  padding-left:env(safe-area-inset-left);
}

header{
  grid-area:hd;position:relative;text-align:center;
  padding:clamp(10px,2.2dvh,22px) 16px clamp(8px,1.4dvh,14px);
  text-shadow:0 2px 12px rgba(21,48,82,.22);
}
header::after{
  content:"";position:absolute;left:calc(50% + min(24vw,260px));top:28%;
  width:clamp(56px,10vw,120px);aspect-ratio:1;border-radius:50%;
  background:url("../assets/ui/mascot-head.png") center/cover no-repeat;
  filter:drop-shadow(0 10px 18px rgba(21,48,82,.22));
  opacity:.92;transform:rotate(8deg);
}
.film{
  width:clamp(260px,42vw,540px);max-width:calc(100vw - 32px);margin:0 auto;
  line-height:0;filter:drop-shadow(0 4px 0 rgba(255,255,255,.9)) drop-shadow(0 9px 18px rgba(21,48,82,.18));
  animation:logo-enter .8s cubic-bezier(.2,.8,.2,1) both;
}
.film img{display:block;width:100%;height:auto}
h1{
  font-family:var(--mincho);font-weight:900;
  font-size:clamp(25px,3.7vw,46px);margin:.12em 0 0;
  letter-spacing:.09em;color:var(--ink);
  -webkit-text-stroke:.25px rgba(255,255,255,.72);
  text-shadow:3px 3px 0 rgba(255,213,107,.68),0 10px 30px rgba(18,102,216,.18);
  animation:title-enter .75s .12s cubic-bezier(.2,.8,.2,1) both;
}
.guide{
  display:inline-block;font-size:clamp(12px,1.55vw,16px);font-weight:700;
  margin:.68em 0 0;padding:.36em 1.1em;border-radius:999px;
  color:var(--ink);background:rgba(255,255,255,.86);
  border:1px solid rgba(21,48,82,.12);
  box-shadow:0 4px 14px rgba(18,102,216,.16),inset 0 1px 0 rgba(255,255,255,.9);
  transition:opacity .3s;
  animation:guide-enter .65s .28s ease-out both;
}
@keyframes logo-enter{from{opacity:0;transform:translateY(-18px) scale(.96)}to{opacity:1;transform:none}}
@keyframes title-enter{from{opacity:0;transform:translateY(13px);letter-spacing:.2em}to{opacity:1;transform:none;letter-spacing:.09em}}
@keyframes guide-enter{from{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}

/* Selected cards stay on one complete, centered row. */
.spread{
  grid-area:sp;display:flex;flex-wrap:nowrap;justify-content:center;align-items:flex-start;
  gap:var(--spread-gap);padding:4px clamp(8px,2vw,24px) 7px;
  min-width:0;overflow:visible;
}
.slot{display:flex;flex:0 0 var(--sw);flex-direction:column;align-items:center;gap:3px;width:var(--sw);min-width:0}
.slot-label{
  max-width:100%;overflow:hidden;text-overflow:ellipsis;
  font-family:var(--mincho);font-weight:900;font-size:clamp(10px,1.3vw,13px);
  letter-spacing:.05em;color:#fff6db;white-space:nowrap;text-shadow:0 2px 6px rgba(21,48,82,.78);
}
.slot.extra .slot-label{color:#ffe9a6}
.slot-frame{
  position:relative;width:100%;aspect-ratio:300/527;
  border:1.5px dashed rgba(255,213,107,.9);border-radius:7px;
  background:rgba(255,246,219,.14);box-shadow:inset 0 0 16px rgba(255,255,255,.12),0 0 18px rgba(255,154,74,.22);
  perspective:900px;
}
.slot-name{
  width:calc(var(--sw) + 12px);min-height:2.25em;text-align:center;
  font-family:var(--mincho);font-weight:700;font-size:clamp(10px,1.3vw,14px);
  line-height:1.22;color:#fff;opacity:0;transition:opacity .5s;
  text-shadow:0 2px 7px rgba(21,48,82,.9);
}
.slot-name small{display:block;font-family:var(--maru);font-size:clamp(9px,1.1vw,11px);color:#fff6db;letter-spacing:.03em}
.slot-name small.rev{color:#ffcf9f}
.slot-name rt{font-family:var(--maru);font-size:clamp(8px,.9vw,9px);color:#fff6db}
.slot-name.on{opacity:1;animation:name-enter .48s ease-out both}
@keyframes name-enter{from{opacity:0;transform:translateY(7px)}to{opacity:1;transform:none}}

/* Cards */
.card{position:absolute;inset:0;border-radius:7px;transform-style:preserve-3d;transition:transform .78s cubic-bezier(.2,.72,.2,1);cursor:pointer}
.card.flipped{transform:rotateY(180deg)}
.card.flipping{animation:tarot-flip .82s cubic-bezier(.22,.72,.2,1) both;z-index:2}
.card.front-visible .back{visibility:hidden}
.card.front-visible .front{backface-visibility:visible;-webkit-backface-visibility:visible}
@keyframes tarot-flip{
  0%{transform:rotateY(0) translateZ(0) translateY(0) scale(1);filter:brightness(1)}
  45%{transform:rotateY(90deg) translateZ(18px) translateY(-7px) scale(1.025);filter:brightness(1.08)}
  100%{transform:rotateY(180deg) translateZ(0) translateY(0) scale(1);filter:brightness(1)}
}
.card.flipping .front::after{content:"";position:absolute;inset:-20%;background:linear-gradient(105deg,transparent 42%,rgba(255,255,255,.36) 50%,transparent 58%);transform:translateX(-75%) rotate(5deg);animation:card-sheen .52s .14s ease-out both;pointer-events:none}
@keyframes card-sheen{to{transform:translateX(75%) rotate(5deg)}}
.face{position:absolute;inset:0;border-radius:6px;backface-visibility:hidden;-webkit-backface-visibility:hidden;overflow:hidden;box-shadow:0 5px 16px rgba(7,29,65,.38)}
.face.front{transform:rotateY(180deg);background:#fff}
.face.front img{width:100%;height:100%;object-fit:cover;display:block}
.face.front.rev img{transform:rotate(180deg)}
.back{
  background:
    linear-gradient(180deg,rgba(255,255,255,.16),rgba(255,255,255,0)),
    url("../assets/ui/mascot-head.png") center/74% auto no-repeat,
    radial-gradient(circle at 50% 50%,transparent 0 24%,rgba(255,213,107,.88) 24.5% 26%,transparent 26.5%),
    radial-gradient(circle at 50% 50%,rgba(255,246,219,.95) 0 5%,transparent 5.8%),
    repeating-linear-gradient(45deg,rgba(255,255,255,.22) 0 2px,transparent 2px 10px),
    linear-gradient(145deg,var(--coral),var(--orange) 48%,var(--cloth) 100%);
  border:2px solid var(--ink);outline:1.5px solid rgba(255,246,219,.95);outline-offset:-6px;
}
.fan.shuffling .fcard{transition:transform .2s cubic-bezier(.45,0,.55,1);filter:drop-shadow(0 8px 12px rgba(91,14,63,.28))}
body.is-shuffling .table::after{
  content:"シャッフル中…";position:absolute;z-index:20;left:50%;top:11%;transform:translateX(-50%);
  padding:.5em 1.25em;border-radius:999px;color:#fff6db;background:rgba(21,48,82,.86);
  border:2px solid rgba(255,213,107,.82);font:900 clamp(13px,1.6vw,17px) var(--maru);
  letter-spacing:.08em;box-shadow:4px 4px 0 rgba(239,91,91,.82),0 10px 24px rgba(21,48,82,.24);
  animation:shuffle-status .72s ease-in-out infinite alternate;pointer-events:none;
}
@keyframes shuffle-status{to{transform:translateX(-50%) translateY(-3px);box-shadow:0 10px 28px rgba(255,83,160,.36)}}
.slot .card.ready{animation:glow 1.6s ease-in-out infinite}
@keyframes glow{50%{filter:drop-shadow(0 0 9px rgba(255,231,139,.95));transform:translateY(-2px)}}

/* Fan and panels share the remaining, strictly bounded area. */
.table{grid-area:tb;position:relative;min-height:0;overflow:hidden}
.table::before{
  content:"";position:absolute;left:50%;top:48%;width:min(72vw,760px);aspect-ratio:1;
  transform:translate(-50%,-50%);pointer-events:none;opacity:.28;
  background:
    radial-gradient(circle,transparent 0 35%,rgba(255,213,107,.46) 35.4% 36%,transparent 36.5% 100%),
    conic-gradient(from 18deg,transparent 0 8deg,rgba(255,255,255,.46) 8deg 10deg,transparent 10deg 45deg);
  border-radius:50%;filter:drop-shadow(0 0 18px rgba(255,213,107,.32));
}
.fan{position:absolute;inset:4px clamp(5px,1vw,14px) 8px;overflow:hidden}
.fcard{
  position:absolute;left:0;top:0;width:var(--fw);aspect-ratio:300/527;
  transform-origin:50% 100%;will-change:transform;
  transition:transform .68s cubic-bezier(.24,.76,.2,1),opacity .3s,filter .2s;cursor:pointer;
}
.fcard .face{box-shadow:-2px 3px 8px rgba(6,26,59,.42)}
.fcard:hover{filter:brightness(1.12)}
.fcard:hover .card:not(.flipped):not(.flipping),.fcard:focus-visible .card:not(.flipped):not(.flipping){transform:translateY(-7px) scale(1.035)}
.fcard:hover .card.flipped,.fcard:focus-visible .card.flipped{transform:translateY(-7px) scale(1.035) rotateY(180deg)}
.fcard:focus-visible{outline:none;filter:drop-shadow(0 0 6px #fff)}
.fcard:focus-visible .back{outline-color:#fff}
.fan.locked .fcard{pointer-events:none}
.fcard.gone{opacity:0;pointer-events:none}

/* Welcome and result controls */
.panel{
  position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:clamp(10px,2.2dvh,20px);text-align:center;padding:10px 16px;
}
#setup{
  position:absolute;top:50%;left:50%;right:auto;bottom:auto;transform:translate(-50%,-50%);
  width:min(650px,calc(100vw - 24px));height:auto;
  max-height:100%;
  overflow-y:auto;-webkit-overflow-scrolling:touch;
  justify-content:flex-start;
  padding:clamp(14px,2.2dvh,22px) clamp(16px,4vw,38px);
  gap:clamp(8px,1.35dvh,12px);
  border:2px solid rgba(21,48,82,.9);border-radius:clamp(18px,3vw,28px);
  background:
    linear-gradient(135deg,rgba(255,213,107,.22),rgba(255,255,255,.9) 34%,rgba(116,221,255,.28)),
    linear-gradient(180deg,rgba(255,255,255,.96),rgba(255,246,219,.88));
  color:var(--ink);box-shadow:var(--ui-shadow),inset 0 1px 0 rgba(255,255,255,.9);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  animation:panel-enter .78s .18s cubic-bezier(.16,.8,.24,1) both;
}
#setup::selection{background:rgba(255,213,107,.45)}
@keyframes panel-enter{from{opacity:0;transform:translate(-50%,calc(-50% + 24px)) scale(.975)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}
#setup::before,#setup::after{position:absolute;font-family:var(--mincho);pointer-events:none}
#setup::before{
  content:"";left:0;right:0;top:0;height:8px;
  background:linear-gradient(90deg,var(--coral),var(--brass),var(--green));
}
#setup::after{content:"✦";right:7%;bottom:9%;color:rgba(239,91,91,.22);font-size:clamp(28px,5vw,52px)}
#actions{justify-content:flex-start;padding-top:clamp(8px,1.5dvh,15px);gap:clamp(8px,1.4dvh,13px)}
#qrArea{
  position:fixed;inset:0;z-index:82;display:grid;place-items:center;box-sizing:border-box;
  padding:calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background:rgba(2,19,49,.58);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);
}
#qrArea[hidden]{display:none!important}
.qr-card{
  position:relative;width:min(100%,330px);box-sizing:border-box;display:flex;flex-direction:column;align-items:center;gap:8px;
  padding:26px 18px 17px;border:1px solid rgba(255,255,255,.6);border-radius:20px;
  color:var(--ink);background:
    radial-gradient(circle at 50% 0,rgba(255,213,107,.35),transparent 45%),
    linear-gradient(180deg,rgba(255,252,238,.98),rgba(234,249,255,.95));
  box-shadow:0 24px 70px rgba(0,10,36,.42),inset 0 1px 0 rgba(255,255,255,.92);
}
.qr-close{
  position:absolute;right:10px;top:10px;width:34px;height:34px;border:0;border-radius:999px;
  display:grid;place-items:center;cursor:pointer;color:var(--ink);background:rgba(255,255,255,.75);
  font:900 16px var(--maru);box-shadow:0 3px 10px rgba(21,48,82,.14);
}
.qr-close:hover{background:#fff6db}
.qr-kicker{
  margin:0;color:var(--coral);font:800 11px var(--maru);letter-spacing:.12em;text-transform:uppercase;
}
.qr-card h2{
  margin:0;color:var(--ink);font:900 clamp(24px,7vw,32px) var(--mincho);
  text-shadow:2px 2px 0 rgba(255,213,107,.6);
}
#qrCode{line-height:0}
#qrCode svg{
  display:block;width:min(210px,58vw);height:auto;background:#fff;border-radius:10px;padding:5px;
  box-shadow:0 4px 16px rgba(0,0,0,.15);
}
#qrArea:not([hidden]) .qr-card{animation:soft-pop .45s cubic-bezier(.2,.8,.2,1) both}
#qrArea .ghost{padding:.48em 1em;font-size:12px}
#actions > .row:first-child{width:100%;max-width:760px;min-width:0}
#actions > .row:first-child .ghost{flex:0 0 auto}
#actions #aiBtn{
  display:none;
  order:-1;color:#62400c;background:linear-gradient(180deg,#fff2ad,#ffd56b);
  border-color:rgba(255,255,255,.82);box-shadow:0 4px 0 #cf9633,0 9px 22px rgba(73,50,14,.2);
}
.booth-mode #actions #aiBtn{display:inline-flex}
#actions #aiBtn:hover{background:linear-gradient(180deg,#fff7ce,#ffe08a)}
.booth-mode #actions #extraBtn,
.booth-mode #actions #saveBtn,
.booth-mode #actions #copyBtn,
.booth-mode #actions #qrBtn,
.booth-mode #qrArea{display:none!important}
.booth-mode #actions > .row:first-child{max-width:360px}
.booth-mode #actions #aiBtn{width:100%}

/* question input */
.field-col{display:flex;flex-direction:column;align-items:center;gap:4px;width:100%}
.field-col label{font-size:clamp(12px,1.35vw,14px);font-weight:700;color:var(--ink);opacity:.72}
.field-col textarea{
  width:min(100%,440px);min-height:58px;font-family:var(--maru);font-size:14px;
  padding:.65em .9em;border:2px solid rgba(21,48,82,.22);border-radius:12px;
  background:rgba(255,255,255,.9);color:var(--ink);resize:none;
  box-shadow:inset 0 2px 5px rgba(35,91,145,.07),3px 3px 0 rgba(21,48,82,.1);
}
.field-col textarea:focus{outline:2px solid var(--coral);outline-offset:1px}

.mode-switch{
  display:flex;padding:4px;border-radius:999px;background:rgba(21,48,82,.1);
  border:1px solid rgba(21,48,82,.14);box-shadow:inset 0 1px 4px rgba(26,73,119,.12);
}
.mode-option{
  min-width:92px;border:0;border-radius:999px;padding:.55em 1.1em;cursor:pointer;
  color:#60728a;background:transparent;font:700 13px var(--maru);
  transition:background .2s,color .2s,box-shadow .2s,transform .15s;
}
.mode-option.selected{
  color:var(--ink);background:#fff6db;
  box-shadow:3px 3px 0 rgba(21,48,82,.82),0 6px 16px rgba(18,102,216,.12);
}
.mode-option:active{transform:scale(.97)}
.mode-option:focus-visible{outline:3px solid #fff;outline-offset:2px}
.booth-questions{width:min(100%,540px)}
.booth-heading{margin:0 0 .65em;color:var(--ink);font:900 clamp(17px,2vw,22px) var(--mincho);letter-spacing:.06em;text-shadow:2px 2px 0 rgba(255,213,107,.5)}
.booth-question-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.booth-question{
  position:relative;min-height:70px;padding:.72em 1em;cursor:pointer;
  color:var(--ink);background:rgba(255,255,255,.72);border:1.5px solid rgba(21,48,82,.18);border-radius:14px;
  font:700 clamp(13px,1.5vw,16px)/1.45 var(--maru);box-shadow:4px 4px 0 rgba(21,48,82,.12);
  transition:transform .16s,background .2s,border-color .2s,box-shadow .2s;
}
.booth-question:hover{transform:translateY(-2px);background:rgba(255,246,219,.92)}
.booth-question.selected{
  color:#5b2f16;background:linear-gradient(145deg,#fff6db,#ffd56b);
  border-color:#153052;box-shadow:4px 4px 0 rgba(239,91,91,.86),0 10px 22px rgba(112,76,17,.18);
}
.booth-question.selected::after{
  content:"✓";position:absolute;top:7px;right:9px;width:20px;height:20px;display:grid;place-items:center;
  border-radius:50%;color:#fff;background:var(--coral);font-size:12px;
}
.booth-question:focus-visible{outline:3px solid #fff;outline-offset:3px}
.booth-mode #setup{
  max-height:calc(100% - 10px);overflow:hidden;
  padding:clamp(10px,1.8dvh,16px) clamp(12px,3vw,28px);
  gap:clamp(6px,1.15dvh,10px);
}
.booth-mode .mode-switch{padding:3px}
.booth-mode .mode-option{padding-block:.42em}
.booth-mode .rules-link{padding-block:.2em}
.booth-mode .booth-heading{margin-bottom:.4em;font-size:clamp(15px,1.8vw,19px)}
.booth-mode .booth-question-list{gap:7px}
.booth-mode .booth-question{min-height:56px;padding:.5em .75em;font-size:clamp(12px,1.35vw,14px)}
.booth-mode .info-box summary{font-size:12px}
.booth-mode #setup > .note{font-size:10px;line-height:1.4;max-width:46em}
.booth-mode #startBtn{
  width:auto;max-width:100%;white-space:normal;overflow:visible;
  padding:.72em clamp(1.25em,5vw,2.2em);line-height:1.35;
  font-size:clamp(15px,2.2vw,21px);text-align:center;
}
.booth-mode #startBtn::before{display:none}

/* info box (precautions, spread intro) */
.info-box{
  width:min(100%,420px);text-align:left;font-size:clamp(11px,1.2vw,13px);
  color:var(--ink);opacity:.75;line-height:1.6;
}
.info-box summary{
  cursor:pointer;font-weight:700;font-size:clamp(12px,1.3vw,14px);
  list-style:none;text-align:center;
}
.info-box summary::before{content:"▸ ";font-size:.8em}
.info-box[open] summary::before{content:"▾ "}
.info-box[open] > :not(summary){animation:detail-enter .35s ease-out both}
.info-box ul{margin:.4em 0;padding-left:1.2em}
.info-box li{margin-bottom:.2em}
.info-box p{margin:.3em 0}
.field{display:flex;align-items:center;gap:12px;flex-wrap:wrap;justify-content:center;font-size:clamp(14px,1.8vw,17px);font-weight:700}
.stepper{
  display:flex;align-items:center;border:2px solid rgba(21,48,82,.28);border-radius:999px;
  background:#fffaf0;box-shadow:inset 0 2px 8px rgba(35,91,145,.08),3px 3px 0 rgba(21,48,82,.12);
}
.stepper button{
  width:clamp(40px,5vw,50px);height:clamp(40px,5vw,50px);
  border:0;background:transparent;color:var(--coral);font-size:24px;font-weight:700;
  cursor:pointer;border-radius:999px;
  transition:transform .18s ease,background .18s ease,color .18s ease;
}
.stepper button:not(:disabled):hover{transform:scale(1.16);background:rgba(255,213,107,.28)}
.stepper button:not(:disabled):active{transform:scale(.9)}
.stepper button:disabled{opacity:.28;cursor:default}
.stepper output{min-width:2em;font-family:var(--mincho);font-weight:900;font-size:clamp(21px,2.5vw,29px);color:var(--ink);font-variant-numeric:tabular-nums}
body:not(.booth-mode) #setup > .note{font-size:10px;line-height:1.45;max-width:48em}
body:not(.booth-mode) #startBtn{font-size:clamp(17px,2vw,21px);padding:.68em 2em}

@media(min-width:601px){
  #setup > .rules-link{position:absolute;top:15px;right:18px}
  body:not(.booth-mode) #setup{padding-top:clamp(18px,2.8dvh,28px)}
}
.btn{
  position:relative;overflow:hidden;white-space:nowrap;
  font-family:var(--maru);font-weight:900;font-size:clamp(18px,2.4vw,24px);letter-spacing:.08em;
  color:#fff;background:linear-gradient(90deg,var(--coral),var(--orange));
  border:2px solid var(--ink);border-radius:999px;padding:.75em 2.2em;cursor:pointer;
  box-shadow:5px 5px 0 rgba(21,48,82,.92),0 11px 28px rgba(87,63,24,.22);
  transition:transform .12s,box-shadow .12s,filter .2s;
}
.btn::before{
  content:"";position:absolute;inset:-40% auto -40% -45%;width:32%;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.75),transparent);
  transform:skewX(-18deg);transition:left .48s ease;pointer-events:none;
}
.btn:hover::before{left:115%}
.btn:hover{filter:brightness(1.04)}
.btn:active{transform:translate(4px,4px);box-shadow:1px 1px 0 rgba(21,48,82,.92),0 6px 16px rgba(87,63,24,.18)}
.btn:focus-visible,.ghost:focus-visible,.stepper button:focus-visible{outline:3px solid #fff;outline-offset:3px}
.ghost{
  font-family:var(--maru);font-weight:700;font-size:clamp(12px,1.4vw,15px);white-space:nowrap;
  color:var(--ink);background:rgba(255,250,240,.9);border:2px solid rgba(21,48,82,.82);
  border-radius:999px;padding:.64em 1.3em;cursor:pointer;text-decoration:none;
  box-shadow:3px 3px 0 rgba(21,48,82,.86),0 6px 18px rgba(8,35,72,.12);transition:background .2s,transform .15s;
}
.ghost:hover{background:#fff6db;transform:translateY(-1px)}
.ghost:active{transform:translateY(1px) scale(.98)}
.ghost:disabled{opacity:.35;cursor:default;transform:none}
.row{display:flex;gap:9px;flex-wrap:wrap;justify-content:center;align-items:center}
.note{font-size:clamp(11px,1.2vw,13px);color:#315a82;max-width:40em;line-height:1.7;margin:0}
#actions .note{color:var(--muted)}

/* Result reveal: the reading becomes the stage, while the movie lockup recedes. */
body:has(#actions:not([hidden])){
  background:
    linear-gradient(90deg,rgba(15,47,91,.9),rgba(239,91,91,.4) 48%,rgba(255,213,107,.26)),
    url("/images/movie-key-visual-bg.png") center/cover no-repeat,
    linear-gradient(180deg,#bde9fb 0,#60b2de 25%,#245b99 64%,#0c2856 100%);
}
body:has(#actions:not([hidden]))::before{
  top:7%;height:54%;opacity:.72;
  background:
    radial-gradient(circle at 50% 42%,rgba(255,247,201,.9) 0 1px,transparent 2px),
    radial-gradient(circle at 40% 58%,rgba(255,255,255,.75) 0 1.5px,transparent 2.5px),
    radial-gradient(circle at 62% 22%,rgba(255,224,122,.85) 0 2px,transparent 3px);
  background-size:74px 74px,113px 113px,151px 151px;
  filter:none;
}
body:has(#actions:not([hidden]))::after{
  bottom:-24%;height:49%;opacity:.64;
  background:
    radial-gradient(ellipse at 18% 62%,rgba(118,170,217,.68) 0 22%,transparent 23%),
    radial-gradient(ellipse at 55% 72%,rgba(85,142,199,.76) 0 30%,transparent 31%),
    radial-gradient(ellipse at 88% 52%,rgba(135,183,224,.68) 0 22%,transparent 23%);
}
body:has(#actions:not([hidden])) header{
  padding-top:clamp(7px,1.2dvh,12px);padding-bottom:4px;
}
body:has(#actions:not([hidden])) .film{width:clamp(150px,22vw,245px);opacity:.78}
body:has(#actions:not([hidden])) h1{
  font-size:clamp(20px,2.7vw,31px);margin-top:0;color:#fffaf0;
  text-shadow:3px 3px 0 rgba(239,91,91,.58),0 10px 24px rgba(7,27,62,.44);
}
body:has(#actions:not([hidden])) .guide{
  margin-top:.28em;padding:.22em .9em;
  color:#fff6db;background:rgba(21,48,82,.66);
  border:1px solid rgba(255,224,126,.55);
}
body:has(#actions:not([hidden])) .spread{
  position:relative;padding-top:clamp(10px,2dvh,19px);
  filter:drop-shadow(0 24px 28px rgba(3,21,52,.32));
}
body:has(#actions:not([hidden])) .slot{
  animation:result-reveal .75s cubic-bezier(.16,.84,.25,1) both;
}
body:has(#actions:not([hidden])) .slot-frame{
  border:2px solid rgba(255,230,142,.9);
  background:rgba(255,243,190,.09);
  box-shadow:
    0 0 0 5px rgba(255,226,129,.08),
    0 0 38px rgba(255,226,129,.4),
    6px 6px 0 rgba(21,48,82,.9),
    0 24px 45px rgba(3,24,59,.42);
}
body:has(#actions:not([hidden])) .face{
  box-shadow:0 12px 34px rgba(2,18,48,.5),0 0 0 1px rgba(255,243,199,.65);
}
body:has(#actions:not([hidden])) .slot-name{
  margin-top:6px;font-size:clamp(13px,1.7vw,19px);line-height:1.32;
  color:#fff8d5;text-shadow:0 2px 10px rgba(2,19,49,.9);
}
body:has(#actions:not([hidden])) .slot-name small{font-size:clamp(10px,1.15vw,13px)}
body:has(#actions:not([hidden])) #actions{
  justify-content:flex-start;padding-top:clamp(14px,2.4dvh,24px);
  background:linear-gradient(180deg,transparent 0,rgba(6,31,72,.1) 48%,rgba(5,25,60,.3) 100%);
}
@keyframes result-reveal{
  from{opacity:0;transform:translateY(22px) scale(.9);filter:brightness(1.7) blur(3px)}
  to{opacity:1;transform:none;filter:none}
}

/* Rules live in their own layer, so their length never changes the setup layout. */
.rules-link{
  border:0;background:transparent;color:var(--coral);font:800 clamp(12px,1.35vw,14px) var(--maru);
  padding:.35em .8em;cursor:pointer;border-radius:999px;text-decoration:underline;
  text-decoration-color:rgba(239,91,91,.42);text-underline-offset:4px;
}
.rules-link:hover{background:rgba(255,213,107,.22);text-decoration-color:currentColor}
.rules-link:focus-visible,.rules-skip:focus-visible{outline:3px solid #fff;outline-offset:3px}
.rules-overlay{
  position:fixed;inset:0;z-index:70;display:grid;place-items:center;
  padding:calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  overflow:auto;background:rgba(7,27,62,.76);
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
}
.rules-overlay::before{
  content:"";position:fixed;inset:0;pointer-events:none;
  background:
    linear-gradient(90deg,rgba(21,48,82,.68),rgba(239,91,91,.24)),
    url("/images/movie-key-visual-bg.png") center/cover no-repeat,
    radial-gradient(circle at 18% 20%,rgba(255,225,123,.24) 0 1px,transparent 2px);
  background-size:auto,cover,34px 34px;
}
.rules-card{
  position:relative;width:min(620px,100%);max-height:calc(100dvh - 32px);overflow:auto;
  padding:clamp(24px,5dvh,48px) clamp(18px,5vw,48px);text-align:center;
  color:var(--paper);border:2px solid rgba(255,213,107,.9);border-radius:24px;
  background:
    linear-gradient(135deg,rgba(239,91,91,.2),transparent 42%),
    linear-gradient(145deg,rgba(21,48,82,.96),rgba(7,27,62,.97));
  box-shadow:8px 8px 0 rgba(255,213,107,.42),0 24px 80px rgba(0,10,36,.48),inset 0 1px rgba(255,255,255,.2);
}
.rules-kicker{margin:0;color:var(--brass);font-size:11px;letter-spacing:.24em;text-transform:uppercase}
.rules-card h2{margin:.18em 0 .8em;font:900 clamp(26px,5vw,42px) var(--mincho);letter-spacing:.12em;color:#fff6db;text-shadow:3px 3px 0 rgba(239,91,91,.6)}
.rules-list{margin:0 auto;padding:0;max-width:31em;list-style:none;text-align:left}
.rules-list li{position:relative;margin:.72em 0;padding-left:1.5em;font-size:clamp(12px,1.7vw,15px);line-height:1.6}
.rules-list li::before{content:"✦";position:absolute;left:0;color:var(--brass)}
.rules-closing{margin:1.4em 0 1em;color:#d9edff;font-weight:700;letter-spacing:.04em}
.rules-close{font-size:clamp(15px,2vw,20px)}
.rules-skip{
  position:fixed;z-index:1;top:calc(12px + env(safe-area-inset-top));right:calc(14px + env(safe-area-inset-right));
  border:1px solid rgba(255,255,255,.55);border-radius:999px;padding:.55em 1em;cursor:pointer;
  color:#fff;background:rgba(21,48,82,.82);font:700 12px var(--maru);
}
.rules-overlay.intro .rules-card{animation:rules-card-in .6s cubic-bezier(.2,.8,.2,1) both}
.rules-overlay.intro .rules-kicker,.rules-overlay.intro h2,.rules-overlay.intro .rules-list li,
.rules-overlay.intro .rules-closing,.rules-overlay.intro .rules-close{opacity:1;animation:rules-line-in .35s ease-out both}
.rules-overlay.intro .rules-kicker{animation-delay:.08s}.rules-overlay.intro h2{animation-delay:.12s}
.rules-overlay.intro .rules-list li:nth-child(1){animation-delay:.16s}
.rules-overlay.intro .rules-list li:nth-child(2){animation-delay:.19s}
.rules-overlay.intro .rules-list li:nth-child(3){animation-delay:.22s}
.rules-overlay.intro .rules-list li:nth-child(4){animation-delay:.25s}
.rules-overlay.intro .rules-list li:nth-child(5){animation-delay:.28s}
.rules-overlay.intro .rules-list li:nth-child(6){animation-delay:.31s}
.rules-overlay.intro .rules-closing{animation-delay:.34s}.rules-overlay.intro .rules-close{animation-delay:.37s}
@keyframes rules-card-in{from{opacity:0;transform:scale(.96)}to{opacity:1;transform:none}}
@keyframes rules-line-in{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}

/* AI overlay */
.ai-overlay{
  position:fixed;inset:0;z-index:60;display:flex;align-items:center;justify-content:center;
  padding:16px;background:rgba(7,27,62,.82);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
}
.ai-modal{
  width:min(600px,100%);max-height:calc(100dvh - 32px);display:flex;flex-direction:column;
  background:linear-gradient(145deg,rgba(21,48,82,.96),rgba(7,27,62,.98));
  border:2px solid rgba(255,213,107,.66);border-radius:22px;
  box-shadow:7px 7px 0 rgba(239,91,91,.72),0 24px 80px rgba(0,10,36,.5);overflow:hidden;
}
.ai-modal-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 20px;border-bottom:1px solid rgba(255,255,255,.1);
  color:#fff4bd;font-family:var(--mincho);font-weight:900;font-size:16px;letter-spacing:.08em;
}
.ai-modal-close{border:0;background:transparent;color:rgba(255,255,255,.6);font-size:18px;cursor:pointer;padding:4px 8px;border-radius:6px;line-height:1}
.ai-modal-close:hover{background:rgba(255,255,255,.1);color:#fff}
.ai-key-row{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid rgba(255,255,255,.08)}
.ai-key-input{flex:1;font-family:var(--maru);font-size:13px;padding:.5em .8em;border:1.5px solid rgba(255,224,132,.4);border-radius:10px;background:rgba(255,255,255,.08);color:#fff}
.ai-key-input::placeholder{color:rgba(255,255,255,.35)}
.ai-key-input:focus{outline:2px solid var(--brass);outline-offset:1px}
.ai-result{flex:1;min-height:120px;overflow-y:auto;padding:16px 20px;-webkit-overflow-scrolling:touch}
.ai-result-text{color:#e8f4ff;font-family:var(--maru);font-size:clamp(13px,1.5vw,15px);line-height:1.85;white-space:pre-wrap;margin:0;user-select:text;-webkit-user-select:text}
.ai-modal-foot{padding:10px 20px 14px;border-top:1px solid rgba(255,255,255,.08)}
.ai-modal-foot .note{color:rgba(200,225,255,.6);font-size:11px}

/* Saved-image preview */
.overlay{
  position:fixed;inset:0;z-index:50;background:rgba(11,42,82,.86);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:14px;
}
.overlay img{max-width:100%;max-height:74dvh;border:3px solid rgba(255,213,107,.82);border-radius:12px;box-shadow:7px 7px 0 rgba(239,91,91,.75),0 18px 50px rgba(3,22,49,.48);user-select:auto;-webkit-touch-callout:default}
.overlay:not([hidden]) img{animation:overlay-enter .5s cubic-bezier(.2,.8,.2,1) both}
.overlay .note{color:#e7f5ff}
@keyframes soft-pop{from{opacity:0;transform:translateY(12px) scale(.97)}to{opacity:1;transform:none}}
@keyframes detail-enter{from{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:none}}
@keyframes overlay-enter{from{opacity:0;transform:translateY(18px) scale(.96)}to{opacity:1;transform:none}}

@media(max-width:600px){
  .movie-back-link{
    top:calc(8px + env(safe-area-inset-top));
    left:calc(8px + env(safe-area-inset-left));
    min-height:34px;
    box-shadow:3px 3px 0 rgba(21,48,82,.78),0 8px 18px rgba(21,48,82,.12);
    font-size:11px;
    padding:.62em .85em;
  }
  header{padding-top:8px;padding-bottom:5px}
  .film{width:min(76vw,300px)}
  header::after{width:58px;left:auto;right:12px;top:30%}
  h1{font-size:clamp(22px,7vw,29px)}
  .guide{font-size:11px;margin-top:.48em}
  .spread{gap:var(--spread-gap);padding:2px 6px 4px}
  .slot{gap:2px}
  .slot-name{width:var(--sw)}
  #setup{
    width:calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right));
    padding:14px 12px 12px;border-radius:18px;gap:7px
  }
  .mode-switch{margin-bottom:1px}
  .field-col textarea{min-height:52px}
  #setup .note{max-width:31em}
  #actions{padding-inline:10px}
  #actions > .row:first-child{
    display:grid;grid-template-columns:minmax(0,1fr);gap:7px;
  }
  #actions > .row:first-child .ghost{
    width:100%;min-width:0;white-space:normal;padding:.62em .65em;line-height:1.3;
  }
  #actions #aiBtn{grid-column:1/-1}
  #actions > .row:last-child{width:100%;min-width:0;gap:8px}
  #actions > .row:last-child .btn{font-size:clamp(16px,5vw,20px);padding-inline:1.5em}
  #actions > .row:last-child .ghost{white-space:normal;padding-inline:1em}
  .rules-overlay{
    display:flex;
    align-items:center;
    justify-content:flex-start;
    padding:calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
      calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }
  .rules-card{
    box-sizing:border-box!important;
    flex:0 1 min(320px,calc(100vw - 56px));
    width:min(320px,calc(100vw - 56px));
    max-width:min(320px,calc(100vw - 56px));
    min-width:0;
    max-height:calc(100dvh - 28px);
    margin:0 auto;
    overflow-x:hidden;
    padding:24px 18px;
    border-radius:22px;
  }
  .rules-card h2{
    font-size:clamp(25px,7.2vw,32px);
    line-height:1.22;
  }
  .rules-list{
    width:100%;
    max-width:100%;
  }
  .rules-list li{
    display:block;
    max-width:100%;
    min-width:0;
    font-size:12px;
    line-height:1.55;
    white-space:normal;
    word-break:break-all;
    overflow-wrap:anywhere;
  }
  .rules-overlay.intro .rules-card,
  .rules-overlay.intro .rules-kicker,
  .rules-overlay.intro h2,
  .rules-overlay.intro .rules-list li,
  .rules-overlay.intro .rules-closing,
  .rules-overlay.intro .rules-close{
    animation:none;
    opacity:1;
  }
  .fan{inset:2px 4px 5px}
}

@media(max-height:650px){
  header{padding-top:6px;padding-bottom:4px}
  h1{font-size:clamp(20px,3vw,30px)}
  .guide{margin-top:.12em;font-size:11px}
  #setup{padding-block:12px;gap:8px}
  #setup .note{line-height:1.4}
  .stepper button{width:36px;height:36px}
  .btn{padding-block:.58em}
  .booth-mode #setup{padding-block:8px;gap:5px}
  .booth-mode .booth-question{min-height:48px;padding-block:.38em}
  .booth-mode #setup > .note{display:none}
}

/* Wide monitors: keep the interface comfortably grouped instead of stretching. */
@media(min-width:1440px){
  header{padding-top:clamp(16px,2.5dvh,30px)}
  .spread{max-width:1440px;width:100%;margin-inline:auto}
  .fan{left:max(14px,calc((100vw - 1440px)/2));right:max(14px,calc((100vw - 1440px)/2))}
}

/* Short laptop windows and landscape phones need vertical space more than decoration. */
@media(max-height:560px){
  header{padding:4px 10px 2px}
  .film{width:clamp(170px,28vw,310px)}
  h1{font-size:clamp(17px,4.5dvh,25px);margin-top:0}
  .guide{font-size:10px;padding:.18em .7em;margin-top:.1em}
  #setup{gap:6px;padding-block:9px}
  #setup .info-box:not([open]){display:none}
  .field-col{gap:2px}
  .field-col textarea{min-height:40px;padding:.35em .7em}
  .btn{font-size:clamp(14px,3.5dvh,18px);padding:.55em 1.6em}
  .note{line-height:1.35}
}

@media(max-width:720px) and (orientation:landscape){
  #setup{width:min(680px,calc(100vw - 20px));max-height:calc(100dvh - 12px);padding-inline:18px}
  #setup .info-box:not([open]),#setup .note{display:none}
  #actions{gap:6px;padding-block:5px}
}

/* Tablet portrait (601–900px) */
@media(min-width:601px) and (max-width:900px){
  h1{font-size:clamp(24px,3.8vw,36px)}
  .guide{font-size:clamp(12px,1.7vw,15px)}
  #setup{padding:clamp(16px,3dvh,30px) clamp(16px,4vw,36px);gap:clamp(8px,1.8dvh,16px)}
  .field{font-size:clamp(14px,2vw,17px)}
  .info-box{font-size:clamp(11px,1.4vw,13px)}
}

/* Extra-small phones (< 380px) */
@media(max-width:380px){
  header{padding-top:5px;padding-bottom:3px}
  .film{width:min(72vw,260px)}
  header::after{display:none}
  h1{font-size:19px}
  .guide{font-size:10px;margin-top:.3em;padding:.2em .7em}
  .spread{gap:var(--spread-gap);padding:2px 4px 3px}
  #setup{padding:11px 10px;border-radius:18px;gap:7px}
  .btn{font-size:14px;padding:.6em 1.5em}
  .ghost{font-size:11px;padding:.55em 1em}
  .info-box{font-size:10px}
  .info-box summary{font-size:11px}
  .field{font-size:13px;gap:8px}
  .stepper button{width:34px;height:34px;font-size:20px}
  .stepper output{font-size:19px}
  .note{font-size:10px}
  .rules-card{padding:22px 15px;border-radius:20px}
  .rules-list li{margin:.48em 0;line-height:1.45}
  .mode-option{min-width:80px;padding:.48em .9em;font-size:12px}
  .booth-question-list{gap:7px}
  .booth-question{min-height:60px;padding:.55em .6em;font-size:12px;border-radius:13px}
  .booth-mode #startBtn{width:min(100%,250px);font-size:15px;padding-inline:1em}
}

@media(max-width:320px){
  #setup{width:calc(100vw - 10px);padding-inline:8px}
  .film{width:min(68vw,220px)}
  .row{gap:6px}
  .btn{white-space:normal;text-align:center;line-height:1.25}
  .ghost{white-space:normal;line-height:1.25}
}

@media(prefers-reduced-motion:reduce){
  .card,.fcard,.slot-name,.btn,.ghost{transition-duration:.01s}
  .card.flipping{animation:none;transform:rotateY(180deg)}
  .card.flipping .back{visibility:hidden}
  .card.flipping .front{backface-visibility:visible;-webkit-backface-visibility:visible}
  .card.flipping .front::after{display:none}
  .slot .card.ready{animation:none}
  .film,h1,.guide,#setup,.slot-name.on,#qrArea:not([hidden]),.overlay:not([hidden]) img,.info-box[open] > :not(summary){animation:none}
  .rules-overlay.intro .rules-card,.rules-overlay.intro .rules-kicker,.rules-overlay.intro h2,
  .rules-overlay.intro .rules-list li,.rules-overlay.intro .rules-closing,.rules-overlay.intro .rules-close{animation:none;opacity:1}
  body:has(#actions:not([hidden])) .slot{animation:none}
  body.is-shuffling .table::after{animation:none}
  .btn::before{display:none}
}
