:root {
  --bg: #0b0a10;
  --panel: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .12);
  --text: #f6f1e7;
  --muted: #a59fb3;
  --gold: #e7c37b;
  --gold2: #b8893e;
  --rose: #ff4f8b;
  --rose2: #c2185b;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --display: "Dela Gothic One", "Zen Kaku Gothic New", sans-serif;
  --latin: "Playfair Display", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
html { scroll-behavior: smooth; }
body {
  background: radial-gradient(110% 55% at 50% -10%, rgba(255, 79, 139, .18), transparent 60%), var(--bg);
  color: var(--text);
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, a { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.wrap { max-width: 560px; margin: 0 auto; padding: 18px 18px calc(28px + var(--safe-b)); }

.screen { display: none; }
.screen.active { display: block; animation: enter .4s ease both; }
@keyframes enter { from { opacity: 0; } }

.brand { letter-spacing: .3em; font-size: 10px; color: rgba(255,255,255,.7); margin: 0 0 10px; }
.brand b { color: var(--rose); font-weight: 700; }
.eyebrow { font-family: var(--latin); font-style: italic; font-weight: 700; color: var(--gold); margin: 0; font-size: 15px; }

/* ---- 読み込み ---- */
#screen-loading.active { display: grid; place-items: center; min-height: 100svh; }
.loading-box { text-align: center; width: min(78vw, 320px); }
.beat { width: 72px; margin: 18px auto 14px; filter: drop-shadow(0 8px 24px rgba(255, 45, 111, .6)); animation: beat 1.1s ease-in-out infinite; }
.beat svg { display: block; width: 100%; }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.18); } 30% { transform: scale(1); } 45% { transform: scale(1.1); } }
.loading-title { font-family: var(--display); font-size: 30px; margin: 0 0 22px;
  background: linear-gradient(180deg, #fff 20%, #ffc2d6 60%, var(--rose)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.loading-title span { font-size: .75em; background: linear-gradient(180deg, #fff6df, var(--gold)); -webkit-background-clip: text; background-clip: text; }
.meter { height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.meter-bar { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--rose)); transition: width .25s ease; }
.loading-text { color: var(--muted); font-size: 12px; margin: 12px 0 0; font-variant-numeric: tabular-nums; }

/* ---- トップ ---- */
.hero { position: relative; height: min(92svh, 760px); overflow: hidden; }
.marquee { --h: clamp(150px, 24svh, 230px); position: absolute; left: -30%; right: -30%; top: -6%; display: grid; grid-auto-rows: var(--h); gap: 10px; transform: rotate(-8deg); }
.lane { display: flex; gap: 10px; width: max-content; height: var(--h); animation: lane 60s linear infinite; }
.lane.reverse { animation-direction: reverse; animation-duration: 70s; }
.lane img { height: var(--h); width: calc(var(--h) * .75); flex: none; object-fit: cover; object-position: center 20%; border-radius: 14px; background: #1a1622; }
@keyframes lane { to { transform: translateX(-50%); } }
.hero-shade { position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11,10,16,.35) 0%, rgba(11,10,16,.55) 45%, rgba(11,10,16,.96) 82%, var(--bg) 100%),
              radial-gradient(90% 60% at 50% 60%, rgba(11,10,16,.2), rgba(11,10,16,.7)); }
.hero-copy { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 22px 34px; max-width: 560px; margin: 0 auto; text-align: center; }
.hero-copy h1 { font-family: var(--display); font-weight: 400; font-size: clamp(44px, 13vw, 64px); line-height: 1.05; margin: 8px 0 14px; letter-spacing: .02em;
  background: linear-gradient(180deg, #fff 20%, #ffc2d6 60%, var(--rose)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 20px rgba(255, 79, 139, .35)); }
.hero-copy h1 span { font-size: .72em; background: linear-gradient(180deg, #fff6df, var(--gold)); -webkit-background-clip: text; background-clip: text; }
.lead { color: rgba(255,255,255,.82); font-size: 14px; line-height: 1.9; margin: 0 0 20px; }
.cta { display: inline-block; text-decoration: none; padding: 15px 30px; border-radius: 99px; font-weight: 900; letter-spacing: .08em;
  background: linear-gradient(180deg, #ff7aa6, var(--rose) 50%, var(--rose2)); box-shadow: 0 10px 30px rgba(255, 79, 139, .45); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04); box-shadow: 0 12px 40px rgba(255, 79, 139, .6); } }

.label { font-size: 18px; font-weight: 900; margin: 6px 0 14px; display: flex; align-items: baseline; gap: 10px; }
.label span { font-family: var(--latin); font-style: italic; color: var(--rose); font-size: 26px; }
.label em { font-style: normal; color: var(--gold); }

.regions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.region { position: relative; aspect-ratio: 1 / 1.1; border-radius: 20px; overflow: hidden; text-align: left; padding: 0; border: 1px solid var(--line);
  background: linear-gradient(160deg, #2a1d33, #150f1b); transition: transform .15s; }
.region:active { transform: scale(.97); }
.region img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; transition: transform .6s; }
.region:hover img { transform: scale(1.06); }
.region .shade { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 35%, rgba(0,0,0,.85)); }
.region .txt { position: absolute; left: 14px; right: 14px; bottom: 12px; }
.region b { display: block; font-family: var(--display); font-weight: 400; font-size: 20px; letter-spacing: .02em; }
.region small { color: rgba(255,255,255,.75); font-size: 12px; }
.region .go { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.3); color: #fff; font-size: 16px; }
.foot { text-align: center; color: var(--muted); font-size: 11px; margin-top: 18px; }
.loading, .error { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 14px; padding: 30px 0; }

/* ---- 都道府県: 顔写真の帯を背景にした横長のカード ---- */
.back { color: var(--muted); font-size: 13px; padding: 6px 0 10px; }
.region-sum { color: var(--muted); font-size: 12px; margin: -8px 0 16px; }
.prefs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.pref { position: relative; height: 104px; border-radius: 18px; overflow: hidden; text-align: left; padding: 0; border: 1px solid var(--line);
  background: #17121e; transition: transform .15s, border-color .15s, box-shadow .15s; animation: rise .45s cubic-bezier(.2, 1, .3, 1) both; animation-delay: calc(var(--i) * 55ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.pref:active { transform: scale(.98); }
.pref:hover { border-color: rgba(255, 79, 139, .6); box-shadow: 0 10px 30px rgba(255, 79, 139, .18); }
.pref .strip { position: absolute; inset: 0 0 0 34%; display: flex; }
.pref .strip img { flex: 1; min-width: 0; object-fit: cover; object-position: center 20%; opacity: 0; transition: opacity .5s; }
.pref .strip img.ok { opacity: 1; }
.pref .strip.loading { background: linear-gradient(100deg, #1d1726 30%, #2a2135 50%, #1d1726 70%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.pref .shade { position: absolute; inset: 0; background: linear-gradient(90deg, #17121e 30%, rgba(23,18,30,.75) 48%, rgba(23,18,30,.15) 75%, rgba(23,18,30,.5)); }
.pref .meta { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); }
.pref .meta b { display: block; font-family: var(--display); font-weight: 400; font-size: 26px; letter-spacing: .02em; }
.pref .meta small { color: var(--gold); font-size: 13px; font-weight: 700; }
.pref .meta small em { font-style: normal; color: var(--muted); font-weight: 500; margin-left: 2px; }
.pref .go { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(180deg, #ff7aa6, var(--rose)); color: #fff; font-size: 18px; box-shadow: 0 6px 16px rgba(255, 79, 139, .45); }
.pref .heat { position: absolute; left: 0; bottom: 0; height: 3px; width: var(--w); background: linear-gradient(90deg, var(--gold), var(--rose)); }
.pref.top::after { content: "人気"; position: absolute; left: 18px; top: 10px; font-size: 10px; font-weight: 900; padding: 2px 8px; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), #fff6df); color: #2b1d08; }
.pref.top .meta { top: 58%; }

/* ---- 人数 ---- */
.setup-card { text-align: center; background: linear-gradient(160deg, rgba(255,255,255,.08), rgba(255,255,255,.02)); border: 1px solid var(--line); border-radius: 22px; padding: 22px 18px 18px; margin-bottom: 18px; }
.faces { display: flex; justify-content: center; margin-bottom: 12px; min-height: 54px; }
.faces img { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; object-position: center 20%; border: 2px solid var(--bg); margin-left: -12px; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.faces img:first-child { margin-left: 0; }
.setup-pref { font-family: var(--display); font-size: 28px; margin: 0; }
.setup-total { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.counts button { padding: 14px 0 10px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.04); font-family: var(--display); font-size: 22px; }
.counts button small { display: block; font-family: "Zen Kaku Gothic New", sans-serif; font-size: 10px; color: var(--muted); margin-top: 2px; }
.counts button.on { border-color: var(--rose); background: rgba(255, 79, 139, .18); box-shadow: 0 0 0 1px var(--rose) inset; }
.note { color: var(--muted); font-size: 12px; margin: 14px 0 0; }

.btn { display: block; width: 100%; text-align: center; text-decoration: none; padding: 16px; border-radius: 16px; font-weight: 900; letter-spacing: .06em; }
.btn-main { background: linear-gradient(180deg, #ff7aa6, var(--rose) 50%, var(--rose2)); color: #fff; box-shadow: 0 10px 26px rgba(255, 79, 139, .35); }
.btn-sub { background: rgba(255,255,255,.1); border: 1px solid var(--line); font-size: 14px; padding: 13px; font-weight: 700; }
.btn-ghost { background: none; border: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 12px; font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

/* ---- 対戦 ---- */
#screen-game.active { display: flex; flex-direction: column; height: 100dvh; padding: calc(10px + var(--safe-t)) 12px calc(10px + var(--safe-b)); max-width: 1100px; margin: 0 auto; }
.game-head { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; margin-bottom: 10px; }
.undo { grid-row: 1 / 3; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; }
.undo:disabled { opacity: .3; }
.round { display: flex; justify-content: space-between; align-items: baseline; }
.round b { font-family: var(--latin); font-style: italic; font-size: 18px; color: var(--gold); }
.round span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress { height: 5px; background: rgba(255,255,255,.08); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--rose)); border-radius: 99px; transition: width .4s ease; }

.arena { position: relative; flex: 1; min-height: 0; display: grid; grid-template-rows: 1fr 1fr; gap: 12px; }
.fighter { position: relative; padding: 0; border-radius: 20px; overflow: hidden; min-height: 0; background: #16121c; border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0,0,0,.45); isolation: isolate; transition: box-shadow .2s; }
/* 写真は切らずに全部見せ、余りには同じ写真をぼかして敷く */
.fighter::before { content: ""; position: absolute; inset: -30px; z-index: -1; background-image: var(--bgimg); background-size: cover; background-position: center;
  filter: blur(24px) brightness(.55) saturate(1.2); transform: translateZ(0); }
.fighter img { width: 100%; height: 100%; object-fit: contain; display: block; }
.fighter .plate { position: absolute; left: 0; right: 0; bottom: 0; padding: 36px 14px 12px; text-align: left; background: linear-gradient(180deg, transparent, rgba(0,0,0,.85)); }
.fighter .plate b { display: block; font-family: var(--display); font-weight: 400; font-size: 22px; letter-spacing: .02em; }
.fighter .plate small { display: block; font-size: 11px; color: rgba(255,255,255,.75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 90px; }
.fighter .pick { position: absolute; right: 12px; bottom: 14px; padding: 7px 14px; border-radius: 99px; font-weight: 900; font-size: 13px;
  background: linear-gradient(180deg, #ff7aa6, var(--rose)); box-shadow: 0 6px 16px rgba(255, 79, 139, .5); }
.fighter:hover { box-shadow: 0 0 0 2px var(--rose), 0 16px 40px rgba(0,0,0,.45); }
.streak { position: absolute; top: 12px; left: 12px; padding: 5px 11px; border-radius: 99px; font-size: 12px; font-weight: 900; display: none;
  background: rgba(0,0,0,.6); border: 1px solid rgba(255, 79, 139, .7); }
.streak.show { display: inline-block; }
.streak.fire { background: linear-gradient(90deg, #ff4f8b, #ffb13b); border: 0; color: #2b0712; animation: flame .8s ease-in-out infinite; }
@keyframes flame { 50% { box-shadow: 0 0 16px rgba(255, 150, 60, .8); } }

.vs { position: absolute; left: 50%; top: 50%; z-index: 5; width: 64px; height: 64px; transform: translate(-50%, -50%); pointer-events: none;
  display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6df, var(--gold) 50%, var(--gold2));
  box-shadow: 0 0 0 4px rgba(11,10,16,.9), 0 8px 24px rgba(0,0,0,.6); }
.vs span { font-family: var(--latin); font-style: italic; font-weight: 900; font-size: 24px; color: #2b1d08; }
.vs.clash { animation: clash .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes clash { 0% { transform: translate(-50%, -50%) scale(2.2) rotate(-20deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }

/* 選んだカード: 光が横切る(ハートはタップ位置から fx.js が出す) */
.fighter::after { content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; transform: translateX(-120%);
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.55) 48%, rgba(255, 190, 215, .35) 52%, transparent 70%); }
.fighter.win { z-index: 2; animation: win .6s ease; }
.fighter.win::after { animation: shine .6s ease-out; }
@keyframes shine { to { transform: translateX(120%); } }
@keyframes win { 30% { transform: scale(1.025); box-shadow: 0 0 0 3px var(--rose), 0 0 50px rgba(255, 79, 139, .65); } 100% { box-shadow: 0 0 0 2px var(--rose), 0 16px 40px rgba(0,0,0,.45); } }
/* 選ばれなかったカード: 色が抜け、傾きながら外へはける */
.fighter.lose { animation: lose .42s cubic-bezier(.5, 0, .75, 0) forwards; }
#cardLeft.lose { --dx: -30%; --dr: -7deg; } #cardRight.lose { --dx: 30%; --dr: 7deg; }
@keyframes lose { 30% { transform: scale(.97); } to { opacity: 0; transform: translateX(var(--dx)) rotate(var(--dr)) scale(.9); } }
.fighter.lose img { filter: grayscale(1) brightness(.75); }
.fighter.in-a { animation: in-a .5s cubic-bezier(.2, 1.2, .4, 1); }
.fighter.in-b { animation: in-b .5s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes in-a { from { opacity: 0; transform: translateY(-50px) scale(.95); } }
@keyframes in-b { from { opacity: 0; transform: translateY(50px) scale(.95); } }

.rotate-hint { text-align: center; color: var(--muted); font-size: 11px; margin: 8px 0 0; display: flex; justify-content: center; align-items: center; gap: 8px; }
.phone { width: 10px; height: 16px; border: 1.5px solid var(--muted); border-radius: 3px; display: inline-block; animation: turn 2.4s ease-in-out infinite; }
@keyframes turn { 40%, 70% { transform: rotate(-90deg); } }

/* 横持ち: 左右に並べ、画面の高さいっぱいを使う */
@media (orientation: landscape) {
  .arena { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  .fighter.in-a { animation-name: in-l; }
  .fighter.in-b { animation-name: in-r; }
  .rotate-hint { display: none; }
}
@media (orientation: landscape) and (max-height: 700px) {
  #screen-game.active { padding-top: calc(6px + var(--safe-t)); }
  .game-head { margin-bottom: 6px; }
}
@keyframes in-l { from { opacity: 0; transform: translateX(-40px); } }
@keyframes in-r { from { opacity: 0; transform: translateX(40px); } }

/* ---- 結果 ---- */
.reveal-intro { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: #000; pointer-events: none; opacity: 0; }
.reveal-intro p { font-family: var(--display); font-size: 22px; letter-spacing: .06em; opacity: 0; }
.reveal-intro.run { animation: intro 2.1s ease forwards; }
.reveal-intro.run p { animation: introtext 2.1s ease forwards; }
@keyframes intro { 0% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes introtext { 0% { opacity: 0; transform: translateY(8px); } 25%, 65% { opacity: 1; transform: none; } 80%, 100% { opacity: 0; } }
.result-wrap { padding-top: calc(14px + var(--safe-t)); }
.result-card { position: relative; border-radius: 26px; overflow: hidden; aspect-ratio: 3 / 4; margin: 0 0 16px; isolation: isolate;
  border: 1px solid rgba(255, 79, 139, .5); box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 0 70px rgba(255, 79, 139, .22); }
.result-card::before { content: ""; position: absolute; inset: -30px; z-index: -1; background-image: var(--bgimg); background-size: cover; background-position: center; filter: blur(24px) brightness(.5); }
.result-card img { width: 100%; height: 100%; object-fit: contain; display: block; }
.result-card.show img { animation: zoom 1.6s cubic-bezier(.2, .8, .2, 1); }
@keyframes zoom { from { transform: scale(1.25); filter: brightness(2) blur(6px); } }
.result-top { position: absolute; left: 0; right: 0; top: 0; padding: 18px 18px 60px; background: linear-gradient(180deg, rgba(0,0,0,.7), transparent); }
.result-q { margin: 4px 0 0; font-size: 14px; }
.result-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 80px 18px 20px; background: linear-gradient(180deg, transparent, rgba(0,0,0,.9)); }
.result-name { font-family: var(--display); font-weight: 400; font-size: clamp(36px, 11vw, 52px); margin: 0; letter-spacing: .03em;
  background: linear-gradient(180deg, #fff 30%, #ffd1e0); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-card.show .result-name { animation: namedrop .7s .5s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes namedrop { from { opacity: 0; transform: translateY(-20px) scale(1.3); } }
.result-shop { color: rgba(255,255,255,.82); font-size: 13px; margin: 6px 0 0; }
.result-stat { display: inline-block; margin: 10px 0 0; padding: 5px 12px; border-radius: 99px; font-size: 12px; font-weight: 900;
  background: linear-gradient(90deg, #ff4f8b, #ffb13b); color: #2b0712; }
.result-stat:empty { display: none; }
.sparkles { position: absolute; inset: 0; pointer-events: none; }
.sparkles i { position: absolute; width: 10px; height: 10px; background: #fff; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: twinkle 1.8s ease-in-out infinite; opacity: 0; }
@keyframes twinkle { 50% { opacity: 1; transform: scale(1.6) rotate(45deg); } }

@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; } }
