/* Ioki Io Premium Pinball。--u は「台の幅の 1/560」。台の上に重ねる文字はこれで大きさを決める */
:root {
  --pink: #ff5fa2; --pink-d: #c93a7c; --lav: #b58aff; --sun: #ffd23f; --ink: #2b2350; --night: #1d1638;
  --pop: "Mochiy Pop One", "Hiragino Maru Gothic ProN", "M PLUS Rounded 1c", sans-serif;
  --ui: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px); --u: 0.7px;
  color-scheme: dark;
}
/* inset: 0 は使わない(iOS 14.4 以前の Safari が知らず、枠がつぶれる)。top / right / bottom / left で書く */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--night); overscroll-behavior: none; }
body { font-family: var(--ui); color: #fff; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
#app { position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; padding: calc(var(--st) + 4px) 4px calc(var(--sb) + 4px); gap: 3px; touch-action: none;
  background: radial-gradient(120% 80% at 50% 0%, #3a2a78 0%, #1d1638 70%); }

/* 上の帯 */
#hud { width: 100%; max-width: 640px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 10px; border-radius: 14px; background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px rgba(255, 210, 63, .55); }
/* 左: 上の段に SCORE・のこりのボール・ボーナス倍率、下の段に得点(せまい画面で 9 けたになっても、ボールの表示と重ならない) */
.hud-score { display: flex; flex-direction: column; gap: 3px; line-height: 1; min-width: 0; flex: 1 1 auto; }
.hud-top { display: flex; align-items: center; gap: 7px; }
.hud-score .lbl { font-size: 9px; letter-spacing: 2px; color: #cfc6ff; }
#score { font-family: var(--pop); font-weight: 400; font-size: 22px; color: var(--sun); font-variant-numeric: tabular-nums; white-space: nowrap; }
#balls { display: flex; gap: 3px; }
#balls i { width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #e7dcf3 60%, #b9a6cf); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.mult { font-family: var(--pop); font-size: 11px; line-height: 1; padding: 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, .14); color: #fff; }
.mult.hot { background: var(--sun); color: #5a3a00; }
.hud-btn { display: flex; gap: 6px; }
.hud-btn button { width: 44px; height: 36px; border-radius: 10px; background: rgba(255, 255, 255, .14); font-size: 16px; }   /* 指で押しやすい大きさ(はば 44px) */
#btn-sound.off { opacity: .45; text-decoration: line-through; }

/* 台 */
#stage { position: relative; flex: none; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 2px #c9992e, 0 10px 30px rgba(0, 0, 0, .5); background: #2b2350; }
#pf { display: block; }
#ticker { width: 100%; max-width: 640px; flex: none; height: 24px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#ticker-text { display: inline-block; flex: none; font-weight: 800; font-size: 13px; color: #fff; white-space: nowrap; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
#pads { width: 100%; max-width: 640px; flex: 1 1 auto; min-height: 30px; max-height: 170px; display: flex; gap: 6px; pointer-events: none; }
.pad { flex: 1; display: flex; align-items: center; justify-content: center; border-radius: 14px; background: rgba(255, 255, 255, .07); color: rgba(255, 255, 255, .55); font-weight: 800; font-size: 13px; }
@media (pointer: fine) { .pad.l::after { content: "  ← / Z"; white-space: pre; } .pad.r::after { content: "  → / M"; white-space: pre; } }
#rotate { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(29, 22, 56, .92); font-family: var(--pop); font-size: 18px; text-align: center; padding: 20px; pointer-events: none; }

/* 台の上に重ねるもの */
#callouts { position: absolute; left: 0; right: 0; top: 14%; display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 6); pointer-events: none; z-index: 5; }
.callout { display: flex; flex-direction: column; align-items: center; padding: calc(var(--u) * 8) calc(var(--u) * 22); border-radius: 999px; background: rgba(43, 35, 80, .88); box-shadow: 0 0 0 calc(var(--u) * 2.5) var(--sun); animation: pop .22s cubic-bezier(.2, 1.6, .4, 1), fade .3s ease-in 1.2s forwards; }
.callout b { font-family: var(--pop); font-weight: 400; font-size: calc(var(--u) * 26); color: var(--sun); white-space: nowrap; }
.callout span { font-weight: 800; font-size: calc(var(--u) * 16); color: #fff; white-space: nowrap; }
.callout.big { background: linear-gradient(180deg, #ff86bd, var(--pink)); box-shadow: 0 0 0 calc(var(--u) * 3) #fff; animation: pop .25s cubic-bezier(.2, 1.8, .4, 1), fade .3s ease-in 1.9s forwards; }
.callout.big b { font-size: calc(var(--u) * 34); color: #fff; text-shadow: 0 calc(var(--u) * 2) 0 rgba(120, 20, 70, .4); }
.callout.small b { font-size: calc(var(--u) * 20); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { to { opacity: 0; transform: translateY(calc(var(--u) * -14)); } }
#gauge { position: absolute; right: calc(var(--u) * 58); bottom: calc(var(--u) * 40); width: calc(var(--u) * 14); height: calc(var(--u) * 170); border-radius: 999px; background: rgba(43, 35, 80, .8); box-shadow: 0 0 0 calc(var(--u) * 2) #fff; overflow: hidden; z-index: 5; pointer-events: none; }
#gauge i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(0deg, var(--sun), var(--pink)); }
/* ねらいどころ: ここで はなすと 上のレーンに入る(位置は js/table.js の plunger.sweet) */
#gauge .zone { position: absolute; left: 0; right: 0; background: rgba(255, 255, 255, .22); box-shadow: inset 0 calc(var(--u) * 2.5) 0 #fff, inset 0 calc(var(--u) * -2.5) 0 #fff; }

/* 画面(読みこみ・タイトル・あそびかた・一時停止・結果) */
#scr-title { background: linear-gradient(180deg, rgba(38, 24, 78, .84), rgba(38, 24, 78, .64) 50%, rgba(38, 24, 78, .86)) !important; }
.screen { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 16); padding: calc(var(--u) * 24); background: rgba(38, 24, 78, .86); text-align: center; overflow: hidden; }
.screen h2 { margin: 0; font-family: var(--pop); font-weight: 400; font-size: calc(var(--u) * 40); color: var(--sun); }
.logo { margin: 0; font-family: var(--pop); font-weight: 400; line-height: 1.05; transform: rotate(-3deg); }
.logo .l1 { display: block; font-size: calc(var(--u) * 46); color: #fff6c9; text-shadow: calc(var(--u) * 3) calc(var(--u) * 3) 0 var(--lav), calc(var(--u) * -3) calc(var(--u) * 3) 0 var(--lav), calc(var(--u) * 3) calc(var(--u) * -3) 0 var(--lav), calc(var(--u) * -3) calc(var(--u) * -3) 0 var(--lav), 0 calc(var(--u) * 8) 0 #5b2f9a; }
.logo .l2 { display: block; font-size: calc(var(--u) * 58); color: #fff; text-shadow: calc(var(--u) * 4) calc(var(--u) * 4) 0 var(--pink), calc(var(--u) * -4) calc(var(--u) * 4) 0 var(--pink), calc(var(--u) * 4) calc(var(--u) * -4) 0 var(--pink), calc(var(--u) * -4) calc(var(--u) * -4) 0 var(--pink), 0 calc(var(--u) * 11) 0 #8a2a66; }
.tag { margin: 0; padding: calc(var(--u) * 8) calc(var(--u) * 22); border-radius: 999px; background: #fff; color: var(--pink-d); font-family: var(--pop); font-size: calc(var(--u) * 20); }
/* 台えらび(タイトル)。カード = 台の絵・名前・その台のベスト。えらんでいる台は金のわく */
.cards { display: flex; justify-content: center; gap: calc(var(--u) * 12); width: 100%; }
.card { position: relative; flex: 1 1 0; min-width: 0; max-width: calc(var(--u) * 246); display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 5); padding: calc(var(--u) * 8) calc(var(--u) * 8) calc(var(--u) * 10); border-radius: calc(var(--u) * 20); background: rgba(255, 255, 255, .12); box-shadow: inset 0 0 0 calc(var(--u) * 2) rgba(255, 255, 255, .35); color: #fff; font-family: var(--ui); }
.card.on { background: rgba(255, 255, 255, .22); box-shadow: inset 0 0 0 calc(var(--u) * 4) var(--sun), 0 calc(var(--u) * 6) calc(var(--u) * 16) rgba(0, 0, 0, .35); }
/* 絵のわくは たて:よこ = 4:5(aspect-ratio は古い Safari が知らないので、padding で高さを作る) */
.card .thumb { position: relative; display: block; width: 100%; height: 0; padding-top: 80%; border-radius: calc(var(--u) * 14); overflow: hidden; background: linear-gradient(180deg, #f6c9e6, #b58aff); }
.card[data-table="moon"] .thumb { background: linear-gradient(180deg, #1a1650, #6f58c9); }
.card .thumb img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; }
.card .thumb .cardlogo { left: 8%; top: auto; bottom: 6%; width: 84%; height: auto; object-fit: contain; filter: drop-shadow(0 calc(var(--u) * 2) calc(var(--u) * 3) rgba(0, 0, 0, .55)); }
.card .name { display: flex; align-items: center; min-height: 2.3em; font-family: var(--pop); font-weight: 400; font-size: calc(var(--u) * 17); line-height: 1.15; text-align: center; word-break: keep-all; }
.card .best { font-weight: 800; font-size: calc(var(--u) * 15); color: #cfc6ff; }
.card .new { position: absolute; left: calc(var(--u) * -6); top: calc(var(--u) * -8); padding: calc(var(--u) * 3) calc(var(--u) * 10); border-radius: 999px; background: var(--pink); color: #fff; font-family: var(--pop); font-size: calc(var(--u) * 14); transform: rotate(-10deg); box-shadow: 0 0 0 calc(var(--u) * 2) #fff; }
.card .state { display: none; position: absolute; left: 0; right: 0; top: 30%; font-weight: 800; font-size: calc(var(--u) * 15); text-align: center; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); }
.card.loading .state { display: block; }
.card.loading .thumb { opacity: .45; }
.btn:disabled { opacity: .5; }
.best, .note { margin: 0; font-weight: 800; font-size: calc(var(--u) * 18); }
.best b { font-family: var(--pop); font-weight: 400; color: var(--sun); }
.note { color: #cfc6ff; font-size: calc(var(--u) * 15); }
@media (pointer: coarse) { .note.pc { display: none; } }
.btn { display: inline-flex; align-items: center; justify-content: center; padding: .55em 1.5em; border-radius: 999px; font-family: var(--pop); font-size: calc(var(--u) * 26); background: #fff; color: var(--ink); box-shadow: 0 calc(var(--u) * 6) 0 #c9b8ec; }
.btn:active { transform: translateY(calc(var(--u) * 4)); box-shadow: 0 calc(var(--u) * 2) 0 #c9b8ec; }
.btn.primary { font-size: calc(var(--u) * 36); background: linear-gradient(180deg, #ff86bd, var(--pink)); color: #fff; box-shadow: 0 calc(var(--u) * 7) 0 var(--pink-d); min-width: calc(var(--u) * 300); }
.btn.small { font-size: calc(var(--u) * 22); }
.row { display: flex; gap: calc(var(--u) * 12); }
.bar { width: 60%; height: calc(var(--u) * 16); border-radius: 999px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--sun)); transition: width .15s; }
.howto { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: calc(var(--u) * 12); width: 100%; }
.howto li { display: flex; align-items: center; gap: calc(var(--u) * 14); padding: calc(var(--u) * 12) calc(var(--u) * 14); border-radius: calc(var(--u) * 20); background: rgba(255, 255, 255, .12); text-align: left; }
/* あそびかたの絵(左)。台で使っているパーツの絵をそのまま見せる */
.howto .pic { flex: none; width: calc(var(--u) * 96); height: calc(var(--u) * 76); border-radius: calc(var(--u) * 14); background: linear-gradient(180deg, #f6e9ff, #ffd0e6); display: flex; align-items: center; justify-content: center; gap: calc(var(--u) * 4); overflow: hidden; }
.howto .pic img { height: 58%; width: auto; }
.howto .pic .big { height: 60%; }
.howto .p2 { gap: calc(var(--u) * 2); }
.howto .p2 img:not(.big) { height: 46%; }
.howto .p1 { flex-direction: column; gap: calc(var(--u) * 6); }
.howto .p1 .ball { height: 26%; }
.howto .p1 .row { display: flex; justify-content: center; gap: calc(var(--u) * 8); width: 100%; }
.howto .p1 .fl { width: 42%; height: auto; transform: rotate(22deg); }
.howto .p1 .fl.mir { transform: scaleX(-1) rotate(22deg); }
.howto .pic svg { width: 100%; height: 100%; }
.howto .pic.night { background: linear-gradient(180deg, #1a1650, #6f58c9); }   /* 月の台の あそびかた */
.howto .p1 svg { width: 88%; height: auto; }
.howto .txt { display: flex; flex-direction: column; gap: calc(var(--u) * 4); min-width: 0; }
.howto b { font-family: var(--pop); font-weight: 400; font-size: calc(var(--u) * 24); color: var(--sun); }
.howto span { font-weight: 700; font-size: calc(var(--u) * 18); line-height: 1.5; word-break: keep-all; overflow-wrap: anywhere; }   /* 文は空白の所で折る(単語の途中で折らない) */
.res-score b { font-family: var(--pop); font-weight: 400; font-size: calc(var(--u) * 64); color: var(--sun); font-variant-numeric: tabular-nums; }
.res-score, .res-rank, .res-best, .res-table { margin: 0; }
.res-table { font-family: var(--pop); font-size: calc(var(--u) * 17); color: #cfc6ff; }
.res-rank { font-weight: 800; font-size: calc(var(--u) * 20); }
.res-rank b { font-family: var(--pop); font-weight: 400; font-size: calc(var(--u) * 30); color: #fff; margin-left: .4em; }
.res-best { font-family: var(--pop); font-size: calc(var(--u) * 28); color: var(--pink); background: #fff; padding: calc(var(--u) * 4) calc(var(--u) * 20); border-radius: 999px; }
.res-stats, .res-list { margin: 0; padding: 0; list-style: none; width: 80%; font-weight: 800; font-size: calc(var(--u) * 17); }
.res-stats { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * 4) calc(var(--u) * 18); }
.res-stats li, .res-list li { display: flex; justify-content: space-between; gap: 1em; }
.res-list li.me { color: var(--sun); }

/* カットイン: ななめの帯 + いおちゃん + モード名。2.5 秒 */
#cutin { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 8; pointer-events: none; overflow: hidden; }
#cutin .band { position: absolute; left: -20%; right: -20%; top: 30%; height: 32%; transform: rotate(-7deg) scaleY(0); background: linear-gradient(90deg, #ff86bd, var(--pink) 45%, #b58aff); box-shadow: 0 0 0 calc(var(--u) * 5) #fff, 0 0 0 calc(var(--u) * 10) var(--sun); }
#cutin[data-mode="multi"] .band { background: linear-gradient(90deg, #ffd23f, #ff9a3c 45%, var(--pink)); }
#cutin[data-mode="premium"] .band { background: linear-gradient(90deg, #b58aff, #7c55c9 45%, var(--pink)); }
#cutin[data-mode="finale"] .band { background: linear-gradient(90deg, #ff5fa2, #ffd23f 33%, #6fd6ff 66%, #b58aff); }
#cutin .chara { position: absolute; right: -4%; top: 22%; height: 46%; filter: drop-shadow(0 calc(var(--u) * 8) calc(var(--u) * 8) rgba(0, 0, 0, .35)); transform: translateX(120%); }
#cutin .ttl { position: absolute; left: 5%; top: 36%; max-width: 56%; font-family: var(--pop); font-size: calc(var(--u) * 50); line-height: 1.05; color: #fff; text-align: left; text-shadow: calc(var(--u) * 3) calc(var(--u) * 3) 0 #8a2a66, calc(var(--u) * -2) calc(var(--u) * 3) 0 #8a2a66, 0 calc(var(--u) * 8) 0 rgba(90, 20, 70, .5); transform: rotate(-7deg) scale(0); transform-origin: left center; }
#cutin .sub { position: absolute; left: 7%; top: 55%; max-width: 52%; word-break: keep-all; padding: calc(var(--u) * 5) calc(var(--u) * 18); border-radius: calc(var(--u) * 22); background: #fff; color: var(--pink-d); font-family: var(--pop); font-size: calc(var(--u) * 22); line-height: 1.25; text-align: left; transform: rotate(-7deg); transform-origin: left center; opacity: 0; }
/* 月の台のカットイン(夜空の色) */
#cutin[data-mode="dream"] .band { background: linear-gradient(90deg, #6f58c9, #8fd9ff 45%, #b9a4ff); }
#cutin[data-mode="starmulti"] .band { background: linear-gradient(90deg, #ffd76a, #ffb04a 45%, #b9a4ff); }
#cutin[data-mode="livefinale"] .band { background: linear-gradient(90deg, #8fd9ff, #ffe08a 33%, #ff9ccb 66%, #b58aff); }
#cutin[data-mode="dream"] .ttl, #cutin[data-mode="starmulti"] .ttl, #cutin[data-mode="livefinale"] .ttl { text-shadow: calc(var(--u) * 3) calc(var(--u) * 3) 0 #3d2f86, calc(var(--u) * -2) calc(var(--u) * 3) 0 #3d2f86, 0 calc(var(--u) * 8) 0 rgba(30, 20, 90, .5); }
#cutin[data-mode="dream"] .sub, #cutin[data-mode="starmulti"] .sub, #cutin[data-mode="livefinale"] .sub { color: #3d2f86; }
#cutin[data-mode="starmulti"] .ttl { font-size: calc(var(--u) * 34); }
#cutin[data-mode="dream"] .ttl, #cutin[data-mode="livefinale"] .ttl { font-size: calc(var(--u) * 44); }
/* 長いモード名は小さくして、いおちゃんの顔に かからないようにする */
#cutin[data-mode="multi"] .ttl { font-size: calc(var(--u) * 38); }
#cutin[data-mode="premium"] .ttl, #cutin[data-mode="finale"] .ttl { font-size: calc(var(--u) * 44); }
#cutin.run .band { animation: cutBand 2.5s cubic-bezier(.2, 1.3, .4, 1) both; }
#cutin.run .chara { animation: cutChara 2.5s cubic-bezier(.2, 1.2, .4, 1) both; }
#cutin.run .ttl { animation: cutTtl 2.5s cubic-bezier(.2, 1.7, .4, 1) both; }
#cutin.run .sub { animation: cutSub 2.5s ease both; }
@keyframes cutBand { 0% { transform: rotate(-7deg) scaleY(0); } 8%, 86% { transform: rotate(-7deg) scaleY(1); } 100% { transform: rotate(-7deg) scaleY(0); } }
@keyframes cutChara { 0%, 4% { transform: translateX(120%); } 16%, 84% { transform: translateX(0); } 100% { transform: translateX(120%); } }
@keyframes cutTtl { 0%, 8% { transform: rotate(-7deg) scale(0); } 18%, 84% { transform: rotate(-7deg) scale(1); } 100% { transform: rotate(-7deg) scale(0); } }
@keyframes cutSub { 0%, 22% { opacity: 0; } 30%, 84% { opacity: 1; } 100% { opacity: 0; } }

/* ボーナス集計(ボールが落ちたあと) */
#bonus { position: absolute; left: 12%; right: 12%; top: 30%; z-index: 7; padding: calc(var(--u) * 18) calc(var(--u) * 24); border-radius: calc(var(--u) * 26); background: rgba(43, 35, 80, .93); box-shadow: 0 0 0 calc(var(--u) * 3) var(--sun); pointer-events: none; animation: pop .25s cubic-bezier(.2, 1.6, .4, 1); }
#bonus h3 { margin: 0 0 calc(var(--u) * 8); font-family: var(--pop); font-weight: 400; font-size: calc(var(--u) * 30); color: var(--sun); text-align: center; }
#bonus p { margin: 0; display: flex; justify-content: space-between; gap: 1em; font-weight: 800; font-size: calc(var(--u) * 19); line-height: 1.7; }
#bonus p.x { justify-content: center; color: var(--pink); font-family: var(--pop); font-weight: 400; }
#bonus p.total { justify-content: center; font-family: var(--pop); font-weight: 400; font-size: calc(var(--u) * 38); color: #fff; }

/* 結果の演出 */
#scr-result h2 { animation: pop .3s cubic-bezier(.2, 1.6, .4, 1); }
.res-best { animation: pop .4s cubic-bezier(.2, 2, .4, 1) 1.2s both, blink 1s steps(2) 1.6s infinite; }
@keyframes blink { 50% { background: var(--sun); color: #5a3a00; } }
.card.on .thumb { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(calc(var(--u) * -4)); } }
@media (prefers-reduced-motion: reduce) { .card.on .thumb, .res-best { animation: none; } }
