/* =========================================================
   ゲピサバイバーズ / styles.css
   ========================================================= */
:root {
  --bg: #141018;
  --ink: #f4eefb;
  --sub: #b9aecb;
  --line: rgba(255, 255, 255, .14);
  --card: rgba(28, 22, 38, .92);
  --gold: #ffd257;
  --cyan: #5ad7ff;
  --green: #7dffb0;
  --red: #ff6b6b;
  --purple: #b6a2ff;
  --ink-line: #3a2410;   /* 絵と同じ焦げ茶の主線 */
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  /* ページ自体を固定し、引っぱってもゴムのように伸びないようにする */
  position: fixed; inset: 0; width: 100%;
  /* 指の操作はゲームが全部受け取る。ブラウザ側の拡大・スクロールはさせない。
     （縦に読ませたい所だけ、下で pan-y に戻している） */
  touch-action: none;
  -webkit-touch-callout: none;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; touch-action: none; overscroll-behavior: none; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #241c2e; }

/* 絵をつかんで持ち出せてしまうのを止める（PC でのドラッグ） */
img, canvas { -webkit-user-drag: none; user-select: none; pointer-events: none; }
.charcard img, .titlelogo, .chatimg { pointer-events: none; }

/* 動きの速さの表示。?fps を付けたときだけ。 */
#fps {
  position: absolute; z-index: 40;
  left: 8px; bottom: calc(8px + var(--safe-b));
  padding: 5px 9px; border-radius: 8px;
  background: rgba(0, 0, 0, .66); color: #7dffb0;
  font: 700 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre; pointer-events: none;
}
#fps[hidden] { display: none; }

/* ---------------- ボス登場 ---------------- */
#bossintro {
  position: absolute; inset: 0; z-index: 7;
  display: grid; place-content: center;
  pointer-events: none; overflow: hidden;
}
#bossintro[hidden] { display: none; }

/* 上下から迫る、斜めしまの赤い帯 */
.bi-band {
  position: absolute; left: -10%; right: -10%; height: 74px;
  background:
    repeating-linear-gradient(-45deg,
      #ff3b52 0 22px, #3a2410 22px 44px);
  border-top: 5px solid var(--ink-line);
  border-bottom: 5px solid var(--ink-line);
  opacity: .95;
}
.bi-band.top { top: 16%; animation: biBandL 1.9s cubic-bezier(.2, .9, .3, 1.1) both; }
.bi-band.bottom { bottom: 16%; animation: biBandR 1.9s cubic-bezier(.2, .9, .3, 1.1) both; }
@keyframes biBandL {
  0% { transform: translateX(-120%); }
  18%, 74% { transform: translateX(0); }
  100% { transform: translateX(120%); }
}
@keyframes biBandR {
  0% { transform: translateX(120%); }
  18%, 74% { transform: translateX(0); }
  100% { transform: translateX(-120%); }
}

.bi-mid { position: relative; text-align: center; display: grid; gap: 4px; }
.bi-word {
  font-family: "Arial Black", "Impact", system-ui, sans-serif;
  font-size: clamp(56px, 21vw, 140px); font-weight: 900; line-height: 1;
  color: #ff3b52;
  -webkit-text-stroke: 14px var(--ink-line);
  paint-order: stroke fill;
  transform: rotate(-6deg) skewX(-10deg);
  text-shadow: 0 8px 0 #7d1020;
  animation: biWord 1.9s cubic-bezier(.2, .9, .3, 1.7) both;
}
.bi-name {
  font-size: clamp(19px, 6.4vw, 34px); font-weight: 900; letter-spacing: .12em;
  color: #fff;
  -webkit-text-stroke: 7px var(--ink-line);
  paint-order: stroke fill;
  transform: rotate(-6deg) skewX(-10deg);
  animation: biWord 1.9s .08s cubic-bezier(.2, .9, .3, 1.7) both;
}
@keyframes biWord {
  0% { opacity: 0; transform: rotate(-6deg) skewX(-10deg) scale(.3); }
  14% { opacity: 1; transform: rotate(-6deg) skewX(-10deg) scale(1.18); }
  22%, 74% { opacity: 1; transform: rotate(-6deg) skewX(-10deg) scale(1); }
  100% { opacity: 0; transform: rotate(-6deg) skewX(-10deg) scale(1.7); }
}

/* 最後のボスは、長く・大きく・脈打つように */
#bossintro.last::before, #bossintro.warn::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 40, 60, 0) 32%, rgba(110, 0, 16, .62) 100%);
}
#bossintro.last::before { animation: biPulse .42s ease-in-out 9 alternate both; }
#bossintro.last .bi-band { height: 92px; animation-duration: 3.8s; }
#bossintro.last .bi-word {
  font-size: clamp(40px, 13.5vw, 108px); white-space: nowrap;
  color: #ffd257;
  text-shadow: 0 7px 0 #b4101f;
  animation: biLast 3.8s cubic-bezier(.2, .9, .3, 1.5) both;
}
#bossintro.last .bi-name { font-size: clamp(21px, 7vw, 36px); animation-duration: 3.8s; }
/* 文字の後ろの煙。ぼかした影は動かすと四角く切れて見えるので、
   箱の端に届く前に完全に透明になるグラデーションだけで作る。 */
#bossintro.last .bi-mid::before {
  content: ""; position: absolute; z-index: -1;
  left: -45%; right: -45%; top: -130%; bottom: -130%;
  background:
    radial-gradient(closest-side at 32% 56%, rgba(255, 110, 60, .6), rgba(255, 110, 60, .25) 55%, rgba(255, 110, 60, 0)),
    radial-gradient(closest-side at 68% 44%, rgba(255, 50, 70, .55), rgba(255, 50, 70, .2) 55%, rgba(255, 50, 70, 0)),
    radial-gradient(closest-side at 50% 50%, rgba(70, 10, 24, .6), rgba(70, 10, 24, 0));
  pointer-events: none;
  animation: biSmoke 3.8s ease-out both;
}
@keyframes biSmoke {
  0% { opacity: 0; transform: scale(.4) rotate(-8deg); }
  12% { opacity: 1; transform: scale(1.05) rotate(0deg); }
  80% { opacity: .9; transform: scale(1.2) rotate(6deg); }
  100% { opacity: 0; transform: scale(1.6) rotate(10deg); }
}
@keyframes biPulse { from { opacity: .2; } to { opacity: 1; } }
@keyframes biLast {
  0% { opacity: 0; transform: rotate(-6deg) skewX(-10deg) scale(3); }
  8% { opacity: 1; transform: rotate(-6deg) skewX(-10deg) scale(.9); }
  12%, 26%, 40%, 54%, 68% { transform: rotate(-6deg) skewX(-10deg) scale(1.1); }
  19%, 33%, 47%, 61%, 76% { opacity: 1; transform: rotate(-6deg) skewX(-10deg) scale(1); }
  86% { opacity: 1; transform: rotate(-6deg) skewX(-10deg) scale(1); }
  100% { opacity: 0; transform: rotate(-6deg) skewX(-10deg) scale(1.8); }
}

/* 最後のボスの前ぶれ。帯のしまが流れ、WARNING が点滅する。 */
#bossintro.warn::before { animation: biPulse .35s ease-in-out infinite alternate; }
#bossintro.warn .bi-band { animation: biStripe .5s linear infinite; transform: none; }
#bossintro.warn .bi-band.bottom { animation-direction: reverse; }
#bossintro.warn .bi-word {
  font-size: clamp(46px, 16.5vw, 120px); white-space: nowrap;
  text-shadow: 0 7px 0 #5a0010;
  animation: biBlink .5s steps(1) infinite;
}
#bossintro.warn .bi-name {
  font-size: clamp(16px, 5.2vw, 25px); letter-spacing: .06em; white-space: nowrap;
  animation: none;
}
@keyframes biStripe { from { background-position: 0 0; } to { background-position: 62.2px 0; } }
@keyframes biBlink { 0% { opacity: 1; } 50% { opacity: .2; } }

/* ---------------- あそびかた ---------------- */
/* 実際の画面の上に赤い枠を重ねて、どこを見ればよいか示す。 */
.screen.tut {
  background: rgba(10, 8, 16, .72);
  display: block; padding: 0;
}
.tuthead {
  position: absolute; left: 0; right: 0; top: 17%;
  text-align: center;
  font-family: "Arial Black", system-ui, sans-serif;
  font-size: clamp(22px, 7vw, 34px); font-weight: 900; letter-spacing: .12em;
  color: #fff; -webkit-text-stroke: 9px var(--ink-line); paint-order: stroke fill;
  transform: rotate(-3deg);
}

.tutbox {
  position: absolute;
  border: 3.5px solid #ff3b52;
  border-radius: 10px;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .45);
  animation: tutPulse 1.2s ease-in-out infinite;
}
@keyframes tutPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.tutnum {
  position: absolute; left: -12px; top: -13px;
  width: 24px; height: 24px; border-radius: 999px;
  background: #ff3b52; color: #fff;
  font: 900 14px/24px system-ui, sans-serif; text-align: center;
}
/* 説明は中央にまとめて並べる。枠のとなりに置くと重なってしまう。 */
.tutlist {
  position: absolute; left: 5%; right: 5%;
  bottom: calc(96px + var(--safe-b));
  margin: 0; padding: 14px 14px 14px 12px; list-style: none;
  background: rgba(20, 14, 26, .82);
  border: 3px solid var(--ink-line); border-radius: 14px;
}
.tutlist li {
  position: relative; padding-left: 30px; margin: 0 0 8px;
  font-size: 12.5px; font-weight: 800; line-height: 1.55; color: #fff;
  text-align: left;
}
.tutlist li:last-child { margin-bottom: 0; }
.tutlist b { color: #ffd257; }
.tutlist i {
  position: absolute; left: 0; top: 1px;
  width: 21px; height: 21px; border-radius: 999px;
  background: #ff3b52; color: #fff;
  font: 900 12px/21px system-ui, sans-serif; text-align: center; font-style: normal;
}

/* 位置は layoutTutorial() が実際の HUD を測って入れる。
   ここは、測る前に画面の外へ出しておくための初期値。 */
.b-xp, .b-hp, .b-clock, .b-slot { left: -9999px; top: -9999px; width: 10px; height: 10px; }
.b-move {
  left: 12%; right: 12%; top: 26%; height: 22%;
  border-style: dashed; border-radius: 22px;
}

/* あそびかたのスタートは、ほかのボタンと同じ「太い輪郭＋袋文字」にそろえる。
   中央寄せは translate に任せ、transform は動きのために空けておく。 */
.screen.tut .tutgo {
  position: absolute; left: 50%; bottom: calc(18px + var(--safe-b));
  translate: -50% 0; transform: none;
  min-width: 200px; min-height: 56px;
  font-weight: 900; font-size: clamp(17px, 5vw, 22px);
  letter-spacing: .14em; text-indent: .14em;
  color: #fff; -webkit-text-stroke: 5px var(--ink-line); paint-order: stroke fill;
  background: linear-gradient(180deg, #ffe37a, #ffb43a);
  border: 4px solid var(--ink-line); border-radius: 999px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .42);
  animation: tutGoPulse 1.4s ease-in-out infinite;
}
.screen.tut .tutgo:active {
  opacity: 1; transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .42);
}
@keyframes tutGoPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ---------------- カウントダウン ---------------- */
#countdown {
  position: absolute; inset: 0; z-index: 25;
  display: grid; place-content: center; pointer-events: none;
}
#countdown[hidden] { display: none; }
#cdNum {
  font-family: "Arial Black", "Impact", system-ui, sans-serif;
  font-size: clamp(72px, 26vw, 170px); font-weight: 900; line-height: 1;
  color: #ffd257;
  -webkit-text-stroke: 16px var(--ink-line); paint-order: stroke fill;
  text-shadow: 0 9px 0 #b4671c;
  animation: cdPop .62s cubic-bezier(.2, .9, .3, 1.5) both;
}
@keyframes cdPop {
  0% { opacity: 0; transform: scale(2.1); }
  22% { opacity: 1; transform: scale(1); }
  78% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.7); }
}

/* ---------------- 画面転換（波線） ---------------- */
/* 前後 2 枚をずらして走らせ、アメコミ調の二重の波にする。 */
#wipe {
  /* どの画面よりも前に出す（画面そのものを覆って入れかえるため） */
  position: absolute; inset: 0; z-index: 30;
  pointer-events: none; overflow: hidden;
}
#wipe[hidden] { display: none; }
.wipesvg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* 閉じきったあと、ここで 1.5 秒ためる。
   ロゴのすかしが斜めにゆっくり流れる。 */
.wipehold {
  position: absolute; inset: 0; opacity: 0;
  background: var(--ink-line) url(assets/wipe-bg.webp) repeat;
  background-size: 330px auto;
  transition: opacity .12s linear;
}
#wipe.hold .wipehold { opacity: 1; animation: wipeFlow 14s linear infinite; }
@keyframes wipeFlow {
  from { background-position: 0 0; }
  to { background-position: 330px 237px; }
}
.wipeload {
  position: absolute;
  right: max(18px, env(safe-area-inset-right, 0px));
  bottom: calc(18px + var(--safe-b));
  font: 900 15px/1 "Arial Black", system-ui, sans-serif;
  letter-spacing: .12em;
  color: #ffd257;
  -webkit-text-stroke: 5px rgba(0, 0, 0, .45); paint-order: stroke fill;
}
#wipe.hold .wipeload { animation: loadBlink 1s steps(1, end) infinite; }
@keyframes loadBlink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: .35; } }
.wv { will-change: transform; }
.wv.back { fill: #ffd257; }
.wv.front { fill: var(--ink-line); }
#wipe.close .wv.back { animation: wipeClose .5s cubic-bezier(.5, 0, .3, 1) both; }
#wipe.close .wv.front { animation: wipeClose .5s .07s cubic-bezier(.5, 0, .3, 1) both; }
/* 開くときは金色を先に逃がす。あとに残る層が金色だと、左側に黄色い帯が見えてしまう。
   幕は画面 3 枚ぶんの長さ（-300〜0）にしてあり、閉じきった位置（122）で
   左端（-178）まで必ず覆う。開くときは左端が画面の右へ抜ける 420 まで動かす。 */
#wipe.open .wv.back { animation: wipeOpen .55s cubic-bezier(.5, 0, .3, 1) both; }
#wipe.open .wv.front { animation: wipeOpen .55s .07s cubic-bezier(.5, 0, .3, 1) both; }
@keyframes wipeClose {
  from { transform: translateX(0); }
  to { transform: translateX(122px); }
}
@keyframes wipeOpen {
  from { transform: translateX(122px); }
  to { transform: translateX(420px); }
}

/* ---------------- ステージの切りかわり文字 ---------------- */
/* アメコミの見出しのように、傾けた極太の袋文字を中央に出す。 */
#stageword {
  position: absolute; inset: 0; z-index: 6;
  display: grid; place-content: center; gap: 6px;
  pointer-events: none; text-align: center;
}
#stageword[hidden] { display: none; }
.sw-main {
  font-family: "Arial Black", "Impact", system-ui, sans-serif;
  font-size: clamp(26px, 10vw, 68px); font-weight: 900;
  letter-spacing: .01em; line-height: 1; white-space: nowrap;
  padding: 0 10px;
  color: #ffd257;
  -webkit-text-stroke: 12px var(--ink-line);
  paint-order: stroke fill;
  transform: rotate(-5deg) skewX(-9deg);
  text-shadow: 0 7px 0 #b4671c;
  animation: swIn .42s cubic-bezier(.2, .9, .3, 1.7) both;
}
.sw-sub {
  font-family: "Arial Black", "Impact", system-ui, sans-serif;
  font-size: clamp(12px, 4vw, 20px); font-weight: 900;
  letter-spacing: .3em; text-indent: .3em; white-space: nowrap;
  color: #fff;
  -webkit-text-stroke: 6px var(--ink-line);
  paint-order: stroke fill;
  transform: rotate(-5deg) skewX(-9deg);
  animation: swIn .42s .1s cubic-bezier(.2, .9, .3, 1.7) both;
}
#stageword.out .sw-main, #stageword.out .sw-sub { animation: swOut .3s ease-in both; }
@keyframes swIn {
  0% { opacity: 0; transform: rotate(-5deg) skewX(-9deg) scale(.35); }
  70% { opacity: 1; transform: rotate(-5deg) skewX(-9deg) scale(1.14); }
  100% { opacity: 1; transform: rotate(-5deg) skewX(-9deg) scale(1); }
}
@keyframes swOut {
  from { opacity: 1; }
  to { opacity: 0; transform: rotate(-5deg) skewX(-9deg) scale(1.5); }
}

/* ---------------- HUD ---------------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud[hidden] { display: none; }

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 8px 56px 0 10px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
}

/* ゲージ類は絵に合わせて「太い焦げ茶の輪郭線 + つや」で統一する。
   絵柄がアメコミ調の太線なので、UI だけ細い線だと浮いてしまう。 */
.xpwrap { display: flex; align-items: center; gap: 8px; padding-right: 26px; }
.xpbar {
  flex: 1; height: 14px; border-radius: 999px;
  background: #2a1e18;
  border: 2.5px solid var(--ink-line);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  overflow: hidden; position: relative;
}
.xpbar i {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(180deg, #8be9ff 0%, #35b6ef 55%, #1d86c9 100%);
  border-radius: 999px;
  transform: scaleX(0); transform-origin: left center;
  transition: transform .12s linear;
  will-change: transform;
}
/* バーの上半分に白いつやを乗せる（キャンディの照り） */
.xpbar::after, .hp::after, .bossbar::after {
  content: ""; position: absolute; left: 3px; right: 3px; top: 2px; height: 34%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.lv {
  font-weight: 900; font-size: 17px; letter-spacing: .02em;
  color: #fff;
  -webkit-text-stroke: 5px #000;
  paint-order: stroke fill;
  padding: 0 2px; min-width: 54px; text-align: left;
  white-space: nowrap;
}

.hud-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

.hpwrap { display: flex; align-items: center; gap: 6px; }
.hplabel {
  font-size: 12px; font-weight: 800; letter-spacing: .1em; color: #fff;
  -webkit-text-stroke: 3.5px var(--ink-line);
  paint-order: stroke fill;
}
.hp {
  position: relative; width: 168px; max-width: 38vw; height: 22px;
  background: #2a1e18;
  border: 2.5px solid var(--ink-line);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  border-radius: 999px; overflow: hidden;
}
.hp i {
  position: absolute; inset: 0; width: 100%;
  background: linear-gradient(180deg, #ff9db4 0%, #f2445f 55%, #c22440 100%);
  border-radius: 999px;
  transform-origin: left center;
  transition: transform .15s ease-out;
  will-change: transform;
}
.hp span {
  position: relative; z-index: 1; display: block; text-align: center;
  font-size: 12px; line-height: 17px; font-weight: 800;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .55);
}

.clock {
  flex: 1; text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 23px; font-weight: 800; white-space: nowrap;
  color: #fff;
  -webkit-text-stroke: 4px var(--ink-line);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}
.kills {
  font-size: 14px; font-weight: 800; white-space: nowrap;
  background: linear-gradient(180deg, #fffaf0, #ffe6b8);
  color: #3a2410;
  border: 2.5px solid var(--ink-line);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  padding: 2px 10px; border-radius: 999px;
}
.kills .ic { font-size: 12px; margin-right: 5px; filter: saturate(0) contrast(1.6); }

.bosswrap { margin: 9px auto 0; max-width: 520px; }
.bossname {
  text-align: center; font-size: 12px; font-weight: 800;
  letter-spacing: .12em; color: #fff;
  -webkit-text-stroke: 3.5px var(--ink-line);
  paint-order: stroke fill;
}
.bossbar {
  position: relative;
  height: 15px; margin-top: 4px; border-radius: 999px;
  background: #2a1e18;
  border: 2.5px solid var(--ink-line);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  overflow: hidden;
}
.bossbar i {
  display: block; height: 100%; width: 100%; transform-origin: left center; will-change: transform;
  background: linear-gradient(180deg, #ffd08a 0%, #ff6a3d 50%, #d8341f 100%);
  border-radius: 999px;
  transition: width .1s linear;
}

.hud-bottom {
  position: absolute; right: 10px;
  bottom: calc(12px + var(--safe-b));
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
}
.slots { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; max-width: 46vw; }
.slot {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(180deg, #fffaf0, #ffe6b8);
  border: 2.5px solid var(--ink-line);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  display: grid; place-items: center; position: relative;
  font-size: 17px;
}
.slots.small .slot { width: 30px; height: 30px; font-size: 13px; border-radius: 9px; }
.slot b {
  position: absolute; right: -4px; bottom: -5px;
  font-size: 10px; font-weight: 800; color: #3a2410;
  background: var(--gold); border: 2px solid var(--ink-line);
  border-radius: 999px; padding: 0 4px; line-height: 13px;
}
.slot.max b { background: #7dffb0; }

/* icons.webp（4列 x 4行）から 1 枚だけ切り出して出す。
   画像がなければ絵文字のまま。 */
.icn {
  display: block; width: 100%; height: 100%;
  background-image: var(--icons);
  background-repeat: no-repeat;
  background-size: 400% 400%;
  image-rendering: auto;
}
.offer .oi .icn { width: 42px; height: 42px; }

/* ヘッダーの中身（安全領域を除いた部分）の、上下まんなかに置く */
.pausebtn {
  position: absolute; right: 10px;
  top: calc(50% + (8px + env(safe-area-inset-top, 0px)) / 2);
  transform: translateY(-50%);
  pointer-events: auto;
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(180deg, #fffaf0, #ffe6b8);
  border: 2.5px solid var(--ink-line);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  color: #3a2410; font-size: 13px; font-weight: 800; cursor: pointer;
}

/* ---------------- 画面スティック ---------------- */
/* 触った場所に出るスティック。中心が指の位置になる。 */
#pad {
  position: absolute; left: 0; top: 0;
  width: 136px; height: 136px; margin: -68px 0 0 -68px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .10), rgba(255, 255, 255, .03) 62%, transparent 70%);
  border: 3px solid rgba(58, 36, 16, .55);
  pointer-events: none; z-index: 5;
  opacity: 0; transition: opacity .12s;
}
#pad.on { opacity: .85; }
#pad[hidden] { display: none; }
#knob {
  position: absolute; left: 50%; top: 50%;
  width: 56px; height: 56px; transform: translate(-28px, -28px);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff8, #fff2 60%, transparent);
  border: 3px solid rgba(58, 36, 16, .6);
  pointer-events: none;
}

/* ---------------- 画面（オーバーレイ） ---------------- */
.screen {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 20px;
  background: radial-gradient(circle at 50% 30%, #241c33, #100c17 70%);
  text-align: center;
  /* 既定では指の操作を一切ブラウザに渡さない。
     中身があふれた時だけ .canscroll が付いて、縦スクロールだけ許可される。 */
  overflow-y: auto;
  touch-action: none;
  overscroll-behavior: none;
}

/* あふれている時だけ縦スクロール。つまむ拡大とダブルタップ拡大は入らない。 */
.canscroll.canscroll { touch-action: pan-y; }
.screen[hidden] { display: none; }
/* 背後の絵をぼかす指定は入れない。
   動き続ける絵をぼかし直すのは、スマホで極端に重くなる。 */
.screen.dim { background: rgba(10, 8, 16, .88); }

.panel {
  width: min(560px, 100%);
  background: linear-gradient(180deg, #2c2338, #1b1526);
  border: 3.5px solid var(--ink-line);
  border-radius: 22px; padding: 22px 18px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .45), 0 18px 50px rgba(0, 0, 0, .5);
}
.panel .head {
  color: #fff; font-size: clamp(20px, 5.6vw, 26px);
  -webkit-text-stroke: 5px var(--ink-line);
  paint-order: stroke fill;
}

.brand {
  font-size: 26px; margin: 0; letter-spacing: .06em;
  background: linear-gradient(180deg, #fff, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand.big { font-size: clamp(30px, 8vw, 52px); }
.tag { margin: -4px 0 6px; color: var(--sub); font-size: 14px; }
.head { margin: 0 0 12px; font-size: 20px; letter-spacing: .04em; }
.lvhead { color: var(--gold); text-shadow: 0 2px 10px rgba(255, 210, 87, .35); }

.titlelogo { width: min(460px, 86vw); max-height: 38vh; object-fit: contain; }

/* 背景にゲーム画面をすかして見せる */
.screen.see-through { background: rgba(10, 8, 16, .55); }
/* タイトルの背景画像。中央を基準に、画面いっぱいに広げる。 */
.screen.hasbg { background-position: center; background-size: cover; background-repeat: no-repeat; }

/* キャラクター選択は、同じ絵を白でうすめて敷く。
   カードと文字を主役にしたいので、絵はうっすら透ける程度にとどめる。 */
#scr-select {
  background:
    linear-gradient(rgba(255, 255, 255, .84), rgba(255, 255, 255, .84)),
    url(assets/title-bg.webp) center / cover no-repeat,
    #f6eef6;
}

/* タイトルの PRESS START */
/* 明るい背景の上でも読めるように、濃い色の台の上に置く。 */
.pressstart {
  appearance: none; cursor: pointer;
  font: inherit; font-weight: 900;
  font-size: clamp(15px, 4.2vw, 22px);
  letter-spacing: .18em; text-indent: .18em; color: #fff;
  -webkit-text-stroke: 4.5px var(--ink-line);
  paint-order: stroke fill;
  padding: 9px 21px; margin-top: 10px;
  background: rgba(52, 32, 14, .72);
  border: 4px solid var(--ink-line);
  border-radius: 999px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .45);
  /* 点滅で台ごと薄くすると読みにくいので、ふくらませて誘う。 */
  animation: pressPulse 1.5s ease-in-out infinite;
}
@keyframes pressPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 0 rgba(0, 0, 0, .45); }
  50% { transform: scale(1.05);
        box-shadow: 0 4px 0 rgba(0, 0, 0, .45), 0 0 0 7px rgba(255, 214, 87, .38); }
}
.pressstart:active { transform: scale(.96); }
@keyframes blink { 0%, 62% { opacity: 1; } 63%, 100% { opacity: .3; } }

/* プライバシーポリシーへの案内。タイトルとポーズから開ける。 */
.policy {
  margin-top: 14px; padding: 10px 14px; min-height: 44px;
  display: inline-flex; align-items: center;
  font-size: 12.5px; font-weight: 800; letter-spacing: .04em;
  color: #fff; text-decoration: underline;
  -webkit-text-stroke: 4px var(--ink-line); paint-order: stroke fill;
}
.policy.inpanel {
  margin-top: 10px; color: var(--sub); -webkit-text-stroke: 0;
  font-weight: 700; font-size: 12px;
}
.policy:active { opacity: .7; }

/* 右上に置く丸ボタン（音のオン・オフ） */
.iconbtn {
  appearance: none; cursor: pointer;
  width: 52px; height: 52px; border-radius: 999px;
  background: linear-gradient(180deg, #fffaf0, #ffe6b8);
  border: 3px solid var(--ink-line);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .38);
  font-size: 22px; line-height: 1; color: #3a2410;
  padding: 0;
}
.iconbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .38); }
/* 機種によってはボタンの中身の並べ方が効かず、アイコンが片寄る。位置は直接決める。 */
.iconbtn svg {
  position: absolute; left: 50%; top: 50%;
  width: 26px; height: 26px; margin: -13px 0 0 -13px;
  display: block;
}
.iconbtn .spk { fill: #3a2410; stroke: #3a2410; stroke-width: 1.6; stroke-linejoin: round; }
.iconbtn .wave {
  fill: none; stroke: #3a2410; stroke-width: 2; stroke-linecap: round;
  transition: opacity .12s;
}
.iconbtn .slash {
  fill: none; stroke: #3a2410; stroke-width: 2.4; stroke-linecap: round;
  opacity: 0; transition: opacity .12s;
}
.iconbtn.off .wave { opacity: 0; }
.iconbtn.off .slash { opacity: 1; }
.iconbtn.corner {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px;
}

.btn {
  appearance: none;
  border: 3px solid var(--ink-line);
  background: linear-gradient(180deg, #fffaf0, #ffe6b8);
  color: #3a2410;
  font: inherit; font-weight: 800;
  padding: 14px 26px; border-radius: 999px; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .38);
  transition: transform .08s, box-shadow .08s;
  min-height: 52px;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .38); }
.btn.primary {
  background: linear-gradient(180deg, #ffe9a8, #f2a93a);
}
.btn.ghost {
  background: linear-gradient(180deg, #efe6f5, #cfc3dd);
  color: #3a2410; padding: 11px 20px; font-size: 14px; min-height: 46px;
}
.btn.back { margin-top: 4px; }

/* 左下の戻り口。白い文字だけの控えめな見た目にする。 */
.backlink {
  position: absolute;
  left: max(14px, env(safe-area-inset-left, 0px));
  bottom: calc(14px + var(--safe-b));
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 900; font-size: 15px; letter-spacing: .12em;
  color: #fff;
  -webkit-text-stroke: 4px var(--ink-line); paint-order: stroke fill;
  padding: 10px 6px; min-height: 44px;
}
.backlink:active { transform: translateY(1px); }
.prow { display: flex; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.hint { color: var(--sub); font-size: 12px; margin: 2px 0 0; }

/* ---------------- ストーリー（チャット） ---------------- */
/* 上半分に絵とキャラ、下半分に会話。 */
#scr-story {
  justify-content: flex-start; align-items: center;
  padding: 0; gap: 0; cursor: pointer;
  overflow: hidden;   /* 立ち絵が外から入ってくるので、画面の外は隠す */
}
/* ストーリー画面は消さずに「見えなくする」だけにする。
   消してから出し直すと、出した瞬間に絵の用意が 1 コマ遅れ、
   会話エリアの上の部分が一瞬欠けたり、立ち絵が透けたりしていた。 */
#scr-story[hidden] {
  display: flex;
  visibility: hidden;
  pointer-events: none;
}
/* 子に visibility: visible があると親が隠れていても見えてしまうので、中身ごと隠す */
#scr-story[hidden] * { visibility: hidden !important; }

.storystage {
  position: relative; flex: none;
  width: 100%; height: min(44vh, 330px);
  /* 絵が入るまでは、昼のあかるい空と雲 */
  background:
    radial-gradient(38px 20px at 22% 26%, #fff 60%, rgba(255,255,255,0) 62%),
    radial-gradient(52px 26px at 30% 30%, #fff 60%, rgba(255,255,255,0) 62%),
    radial-gradient(44px 22px at 74% 18%, #fff 60%, rgba(255,255,255,0) 62%),
    radial-gradient(60px 30px at 82% 23%, #fff 60%, rgba(255,255,255,0) 62%),
    linear-gradient(180deg, #a7e6ff 0%, #dff4ff 54%, #ffeec4 78%, #f6d79b 100%);
  background-repeat: no-repeat; background-size: cover;
  overflow: hidden;
  z-index: 1;
  /* 描かれ方を最初から最後まで固定する。
     途中で切り替わると、その 1 コマだけ重なりの順番が乱れる。 */
  will-change: transform;
}

/* 場面が切りかわった合図の、白いひとまたたき */
.stageflash {
  position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none;
}
.stageflash.go { animation: flashOut .5s ease-out; }
@keyframes flashOut { from { opacity: .8; } to { opacity: 0; } }

.stagefig {
  position: absolute; bottom: 0; width: 58%; height: 100%;
  pointer-events: none;
  visibility: hidden;
  /* 登場の動きが終わる瞬間に描かれ方が切り替わると、
     そこで一瞬ちらつく。最初から固定しておく。 */
  will-change: transform;
}
/* 画面が組み上がってから出す */
.stagefig.ready { visibility: visible; }
.stagefig[hidden] { display: none; }
/* 自分の吹き出しは右に出るので、立ち絵も右にそろえる。
   相手役は左。少し小さくして、奥に立っているように見せる。 */
.stagefig.hero { right: 1.5%; }
.stagefig.other { left: 1%; width: 50%; height: 88%; }
/* 左に立つ相手は、向かい合うように左右を反転させる */
.stagefig.other .figart { transform: scaleX(-1); }

/* 画面の外から歩いて入ってくる */
.stagefig.enter.hero { animation: figInR .6s cubic-bezier(.2, .9, .3, 1.25) both; }
.stagefig.enter.other { animation: figInL .6s cubic-bezier(.2, .9, .3, 1.25) both; }
@keyframes figInL { from { transform: translateX(-135%); } to { transform: none; } }
@keyframes figInR { from { transform: translateX(135%); } to { transform: none; } }

.figbody {
  position: absolute; inset: 0; display: block;
  filter: brightness(.62) saturate(.72);
  transition: filter .2s ease;
  animation: figbob 2.6s ease-in-out infinite;
}
/* 絵そのもの。上の figbody が跳ねたり震えたりするので、
   左右の反転はこちらに掛ける（動きと取り合いにならない）。 */
.figart {
  position: absolute; inset: 0; display: block;
  background: center bottom/contain no-repeat;
}
/* いま話している方だけ明るい */
.stagefig.on .figbody { filter: none; }
@keyframes figbob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* 話しはじめに、ぴょこっと跳ねる */
.stagefig.pop .figbody { animation: figpop .46s cubic-bezier(.2, .9, .3, 1.5); }
@keyframes figpop {
  0% { transform: translateY(0) scale(1, 1); }
  28% { transform: translateY(-16px) scale(1.05, .95); }
  62% { transform: translateY(0) scale(.96, 1.04); }
  100% { transform: translateY(0) scale(1, 1); }
}

/* おどろいて震える */
.stagefig.shake .figbody { animation: figshake .5s ease-out; }
@keyframes figshake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  12% { transform: translate(-7px, -3px) rotate(-4deg); }
  26% { transform: translate(6px, -5px) rotate(4deg); }
  40% { transform: translate(-6px, -2px) rotate(-3deg); }
  56% { transform: translate(5px, -4px) rotate(3deg); }
  72% { transform: translate(-3px, -1px) rotate(-1.5deg); }
  86% { transform: translate(2px, -2px) rotate(1deg); }
}

/* おおきく跳ねる */
.stagefig.jump .figbody { animation: figjump .72s cubic-bezier(.25, .8, .3, 1.2); }
@keyframes figjump {
  0% { transform: translateY(0) scale(1, 1); }
  14% { transform: translateY(4px) scale(1.12, .86); }
  40% { transform: translateY(-42px) scale(.92, 1.12) rotate(-5deg); }
  66% { transform: translateY(0) scale(1.14, .88); }
  84% { transform: translateY(-8px) scale(.98, 1.03); }
  100% { transform: translateY(0) scale(1, 1); }
}

/* きらっ */
.figsparkle {
  position: absolute; left: 54%; top: 8%;
  width: 52px; height: 52px; margin-left: -26px;
  opacity: 0; pointer-events: none;
  background: #fff;
  clip-path: polygon(50% 0, 59% 41%, 100% 50%, 59% 59%, 50% 100%, 41% 59%, 0 50%, 41% 41%);
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, .95));
}
.figsparkle::after {
  content: ""; position: absolute; left: 62%; top: 62%;
  width: 46%; height: 46%; background: #fff;
  clip-path: inherit; opacity: .85;
}
.stagefig.pop .figsparkle { animation: sparkle .62s ease-out; }
@keyframes sparkle {
  0% { opacity: 0; transform: scale(.2) rotate(-20deg); }
  35% { opacity: 1; transform: scale(1) rotate(15deg); }
  100% { opacity: 0; transform: scale(1.45) rotate(50deg); }
}

/* ---- 下半分：白地にロゴのすかし ---- */
/* 絵と会話の切れ目はアーチ。中央がふくらんで、両端が下がる。 */
.chatpane {
  position: relative; z-index: 2;
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: flex; flex-direction: column;
  background: #fff url(assets/chat-bg.webp) top left repeat;
  background-size: 210px auto;
  padding-bottom: calc(6px + var(--safe-b));
  margin-top: -58px;
  border-top: 7px solid var(--ink-line);
  border-radius: 50% 50% 0 0 / 38px 38px 0 0;
  overflow: hidden;
  will-change: transform;
}

.chatlog {
  display: flex; flex-direction: column;
  width: 100%; flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  padding: 10px max(12px, calc((100% - 560px) / 2)) 4px;
  /* 上へ流れていく発言は、アーチの曲線に沿って隠れる */
  border-radius: 50% 50% 0 0 / 33px 33px 0 0;
  touch-action: none;
  overscroll-behavior: none;
  scroll-behavior: smooth;
}
/* 会話は下端から積み上がる（LINE と同じ見え方） */
.chatinner {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.chatlog::-webkit-scrollbar { width: 0; }

.chatrow { display: flex; align-items: flex-start; gap: 8px; }
.chatrow.me { flex-direction: row-reverse; }

.chatav {
  width: 42px; height: 42px; flex: none; border-radius: 999px;
  background: linear-gradient(180deg, #4a3826, #2a1e18) center/86% no-repeat;
  border: 3px solid var(--ink-line);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .4);
  display: grid; place-items: center;
  color: #ffd257; font-weight: 800; font-size: 18px;
  /* 丸の中の絵は左右を反転させる（吹き出しのほうを向く） */
  transform: scaleX(-1);
}
/* 丸の中は、相手が黒・自分が白。どちらの絵もはっきり浮かび上がる。 */
.chatav.mob, .chatav.king { background-color: #14100c; }
.chatav.me { background-color: #fff; }
/* 立ち絵を丸アイコンに流用するので、上のほうを大きめに写す */
.chatav.mob, .chatav.king { background-size: 150% auto; background-position: 50% 16%; }
.chatav.me { background-size: 84% auto; background-position: 50% 50%; }

.chatcol { display: flex; flex-direction: column; gap: 3px; max-width: 78%; }
.chatrow.me .chatcol { align-items: flex-end; }

.chatname {
  font-size: 10.5px; font-weight: 800; letter-spacing: .06em;
  color: #fff; -webkit-text-stroke: 3.5px var(--ink-line); paint-order: stroke fill;
  margin-left: 4px;
}

.chatbub {
  position: relative;
  padding: 9px 14px; border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #eee7f5);
  border: 3px solid var(--ink-line);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .4);
  color: #241a30; font-size: clamp(13.5px, 3.7vw, 15px);
  font-weight: 700; line-height: 1.5; text-align: left;
  animation: chatIn .18s cubic-bezier(.2, .9, .3, 1.3) both;
}
.chatrow.me .chatbub {
  background: linear-gradient(180deg, #fff2c4, #ffd257);
}

/* 吹き出しのしっぽ。外側の焦げ茶の上に、中身の色をひとまわり小さく重ねる。 */
.chatbub::before, .chatbub::after {
  content: ""; position: absolute; top: 14px;
  width: 0; height: 0; border-style: solid;
}
.chatbub::before {
  left: -15px;
  border-width: 8px 15px 8px 0;
  border-color: transparent var(--ink-line) transparent transparent;
}
.chatbub::after {
  left: -10px;
  border-width: 6px 11px 6px 0;
  border-color: transparent #f6f1fb transparent transparent;
}
.chatrow.me .chatbub::before {
  left: auto; right: -15px;
  border-width: 8px 0 8px 15px;
  border-color: transparent transparent transparent var(--ink-line);
}
.chatrow.me .chatbub::after {
  left: auto; right: -10px;
  border-width: 6px 0 6px 11px;
  border-color: transparent transparent transparent #ffd75f;
}
@keyframes chatIn {
  from { opacity: 0; transform: translateY(10px) scale(.94); }
  to { opacity: 1; transform: none; }
}

/* 写真を送ったときの見え方 */
.chatimg {
  width: min(280px, 62vw); border-radius: 16px; display: block;
  border: 3px solid var(--ink-line);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .4);
  animation: chatIn .2s cubic-bezier(.2, .9, .3, 1.3) both;
}

.storynext {
  margin-top: 6px; flex: none; font-size: 11px; font-weight: 800; letter-spacing: .3em;
  color: #fff; -webkit-text-stroke: 4px var(--ink-line); paint-order: stroke fill;
  animation: blink 1.15s steps(1, end) infinite;
}

/* ---------------- キャラ選択 ---------------- */
/* レベルアップの選択と同じ形。スマホでは横長のカードを縦に並べる。 */
.head.en {
  font-family: system-ui, "Segoe UI", sans-serif;
  letter-spacing: .22em; text-indent: .22em;
  font-size: clamp(15px, 4.4vw, 20px); color: #fff;
  -webkit-text-stroke: 5px var(--ink-line);
  paint-order: stroke fill;
}

/* ---------------- キャラクター選択 ---------------- */
/* 3 体を横に 3 列。カードは縦長で、戦っている絵がカード全体を埋める。
   選ぶまではカードがゆっくり上下にゆれ、きらめきが走る。 */
/* 縦長の画面でも上下に大きな空きが出ないよう、残りの高さを均等に配る */
#scr-select {
  justify-content: space-evenly;
  padding: max(10px, env(safe-area-inset-top, 0px)) 10px calc(56px + var(--safe-b));
  gap: 8px;
}
.selhead { position: relative; z-index: 1; margin-top: 2px; animation: selFloat 3.4s ease-in-out infinite; }
.selhead.enter { animation: selDrop .75s cubic-bezier(.2, .9, .3, 1.5) both, selFloat 3.4s .75s ease-in-out infinite; }
.sellogo { display: block; width: min(94vw, 520px); height: auto; }

/* ロゴの形に切り抜いた光が、ときどき左から右へ走る */
.selshine, .startshine {
  position: absolute; inset: 0; pointer-events: none;
  -webkit-mask: var(--m) center / contain no-repeat;
  mask: var(--m) center / contain no-repeat;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 42%, rgba(255, 255, 255, .85) 50%, rgba(255, 255, 255, 0) 58%) no-repeat;
  background-size: 260% 100%;
  animation: logoShine 3.2s ease-in-out infinite;
}
.startshine { animation-duration: 2.4s; }
.selshine[hidden], .startshine[hidden] { display: none; }
@keyframes logoShine {
  0%, 55% { background-position: 130% 0; }
  85%, 100% { background-position: -30% 0; }
}
@keyframes selDrop {
  0% { opacity: 0; transform: translateY(-70px) scale(.4) rotate(-10deg); }
  60% { opacity: 1; transform: translateY(8px) scale(1.08) rotate(3deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(-1deg); }
}

/* 背景を斜めに流れる星と、ちらちら光るきらめき */
.selsky { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.shoot {
  position: absolute; width: 120px; height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(255, 111, 139, 0), rgba(255, 150, 60, .85));
  opacity: 0; animation: shootStar 4.2s linear infinite;
}
.shoot::after {
  content: ""; position: absolute; right: -9px; top: 50%; width: 18px; height: 18px; margin-top: -9px;
  background: #ffb400;
  clip-path: polygon(50% 0, 61% 36%, 100% 38%, 69% 60%, 80% 100%, 50% 76%, 20% 100%, 31% 60%, 0 38%, 39% 36%);
}
.shoot.k1 { left: -30%; top: 6%; animation-delay: .3s; }
.shoot.k2 { left: 5%; top: 28%; animation-delay: 1.8s; animation-duration: 3.6s; }
.shoot.k3 { left: -40%; top: 55%; animation-delay: 3s; animation-duration: 4.8s; }
.shoot.k4 { left: 20%; top: 74%; animation-delay: 2.4s; }
@keyframes shootStar {
  0% { opacity: 0; transform: translate(0, 0) rotate(24deg); }
  5% { opacity: 1; }
  28% { opacity: 1; }
  34% { opacity: 0; transform: translate(300px, 134px) rotate(24deg); }
  100% { opacity: 0; transform: translate(300px, 134px) rotate(24deg); }
}
.twk {
  position: absolute; width: 16px; height: 16px;
  background: #ffc93c;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  animation: twinkle 2.2s ease-in-out infinite;
}
.twk.t1 { left: 8%; top: 12%; animation-delay: .1s; }
.twk.t2 { right: 9%; top: 9%; animation-delay: .9s; background: #ff6f8b; }
.twk.t3 { left: 5%; top: 64%; animation-delay: 1.5s; background: #5ad7ff; }
.twk.t4 { right: 6%; top: 60%; animation-delay: .5s; }
.twk.t5 { left: 46%; top: 86%; animation-delay: 1.2s; background: #ff6f8b; }
.twk.t6 { right: 30%; top: 20%; animation-delay: 1.9s; background: #5ad7ff; }
@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(.3) rotate(0deg); }
  45% { opacity: 1; transform: scale(1.1) rotate(45deg); }
  70% { opacity: .5; transform: scale(.8) rotate(80deg); }
}
.sellogo[hidden], #selHeadTx[hidden] { display: none; }

.chars {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 7px; width: min(680px, 100%);
  /* カードの高さは画面の縦の長さに合わせて伸ばす。
     ただし細長くなりすぎないよう、幅の 3.2 倍まで。9:16 より低くはしない。
     選んだときは幅だけが伸び縮みする。 */
  --cw: calc((min(680px, 100vw - 20px) - 14px) / 3);
  --ch: max(calc(var(--cw) * 16 / 9), min(calc(100vh - 320px), calc(var(--cw) * 3.2)));
  --ch: max(calc(var(--cw) * 16 / 9), min(calc(100dvh - 320px), calc(var(--cw) * 3.2)));
  transition: grid-template-columns .38s cubic-bezier(.2, .9, .3, 1.15);
}
/* 1 体選んだら、選ばれなかった方は細く・控えめにし、細かい情報は隠す */
.chars.picked .charcard:not(.on) { filter: saturate(.5) brightness(.68); }
.chars.picked .charcard:not(.on) .ct,
.chars.picked .charcard:not(.on) .cstat,
.chars.picked .charcard:not(.on) .cw { display: none; }
.chars.picked .charcard:not(.on) .cn { font-size: 9px; white-space: nowrap; -webkit-text-stroke-width: 2px; }

.charcard {
  position: relative; overflow: hidden;
  height: var(--ch); min-width: 0;
  padding: 0; cursor: pointer; color: #fff;
  border: 3px solid var(--ink-line); border-radius: 18px;
  background: #1e1428;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .42);
  transition: transform .16s cubic-bezier(.2, .9, .3, 1.4), box-shadow .16s, filter .16s;
  animation: cardBob 3.2s var(--d, 0s) ease-in-out infinite;
}
/* 枠の内側を光が一周する。回る光の上に絵を少し内側で重ね、すき間だけが光って見える。 */
.charcard .cring {
  position: absolute; left: 50%; top: 50%;
  width: 260%; aspect-ratio: 1 / 1; margin: -130% 0 0 -130%;
  background: conic-gradient(
    rgba(255, 255, 255, 0) 0deg 60deg, rgba(150, 220, 255, .7) 100deg, rgba(255, 255, 255, 0) 130deg 240deg,
    rgba(255, 236, 160, 1) 320deg, rgba(255, 255, 255, .3) 345deg, rgba(255, 255, 255, 0) 360deg);
  animation: ringSpin 3.4s linear infinite;
  animation-delay: calc(var(--d, 0s) * -3);
}
.charcard .cart {
  position: absolute; inset: 3px; border-radius: 13px; overflow: hidden;
  background: #2a1e38;
}
.charcard .cart i {
  position: absolute; inset: 0;
  background: center top / cover no-repeat;
  /* 顔の位置を中心に拡大し、名前の帯にかからないよう少し上へ寄せる */
  transform: scale(var(--z, 1)) translateY(var(--ty, -8%));
  transition: transform .38s cubic-bezier(.2, .9, .3, 1.15);
}
.charcard.on .cart i { --ty: -13%; }
/* 立ち絵しか無いときは、全身が切れないように収める */
.charcard .cart.pose i { background-size: contain; background-position: center 62%; --ty: 0%; }
@keyframes ringSpin { to { transform: rotate(360deg); } }

.charcard .cspark {
  position: absolute; width: 15px; height: 15px; pointer-events: none;
  background: radial-gradient(circle, #fff 0 20%, rgba(255, 255, 255, .6) 36%, rgba(255, 255, 255, 0) 62%);
  opacity: 0; animation: sparkTwinkle 2.6s ease-in-out infinite;
}
.charcard .s1 { left: 10%; top: 14%; animation-delay: .2s; }
.charcard .s2 { right: 8%; top: 32%; animation-delay: 1.2s; }
.charcard .s3 { left: 24%; top: 50%; animation-delay: 1.9s; }

.charcard .cplate {
  position: absolute; left: 3px; right: 3px; bottom: 3px; border-radius: 0 0 13px 13px;
  display: grid; gap: 1px; padding: 26px 5px 7px; text-align: center;
  background: linear-gradient(180deg, rgba(18, 11, 28, 0), rgba(18, 11, 28, .8) 42%, rgba(18, 11, 28, .95));
}
.charcard .ct { font-size: 9.5px; font-weight: 800; letter-spacing: .04em; color: #ffd257; }
.charcard .cn {
  font-size: clamp(12px, 3.5vw, 15px); font-weight: 900; line-height: 1.15; color: #fff;
  -webkit-text-stroke: 3px var(--ink-line); paint-order: stroke fill;
}
.charcard .cd { display: none; }
.charcard .cstat {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px; align-items: center;
  font-size: 8.5px; font-weight: 800; color: #e7dcff; letter-spacing: -.02em;
}
.charcard .cbar {
  height: 9px; border-radius: 999px; overflow: hidden;
  background: rgba(0, 0, 0, .5);
  border: 2px solid var(--ink-line);
}
.charcard .cbar i {
  display: block; height: 100%; border-radius: 999px;
  transform-origin: left center;
  animation: barFill .5s .1s cubic-bezier(.2, .9, .3, 1.3) both;
}
.charcard .cbar.hp i { background: linear-gradient(180deg, #ff9db0, #e8455a); }
.charcard .cbar.sp i { background: linear-gradient(180deg, #a9ecff, #41b6e6); }
@keyframes barFill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.charcard .cw {
  display: flex; align-items: center; justify-content: center; gap: 2px;
  width: 100%; margin-top: 4px; color: #241a30;
  font-size: 10px; font-weight: 800; line-height: 1.15;
  white-space: nowrap; letter-spacing: -.02em;
  padding: 4px 3px; border-radius: 999px;
  background: linear-gradient(180deg, #fff6d8, #ffd257);
  border: 2.5px solid var(--ink-line);
}
.charcard .cw .bi { width: 13px; height: 13px; display: block; flex: none; }
.charcard .cw .wn { min-width: 0; }

.cshine { position: absolute; inset: -40%; opacity: 0; pointer-events: none; }
.charcard.on {
  transform: translateY(-6px);
  box-shadow: 0 0 0 4px var(--gold), 0 10px 0 rgba(0, 0, 0, .42);
  animation: none;
}
.charcard.on .cshine {
  opacity: 1;
  background: linear-gradient(72deg, rgba(255, 255, 255, 0) 42%, rgba(255, 255, 255, .5) 50%, rgba(255, 255, 255, 0) 58%);
  animation: cardShine 1.6s linear infinite;
}
.charcard.hit { animation: cardHit .42s cubic-bezier(.2, .9, .3, 1.6); }
/* 選んだカードは、枠の光が金色で速く回る */
.charcard.on .cring {
  background: conic-gradient(
    rgba(255, 210, 87, .2) 0deg, rgba(255, 246, 200, 1) 60deg, rgba(255, 210, 87, .2) 120deg,
    rgba(255, 246, 200, 1) 180deg, rgba(255, 210, 87, .2) 240deg, rgba(255, 246, 200, 1) 300deg, rgba(255, 210, 87, .2) 360deg);
  animation-duration: 1.6s;
}

@keyframes cardBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes selFloat {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-4px) rotate(1deg); }
}
@keyframes sparkTwinkle {
  0%, 68%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); }
  10% { opacity: 1; transform: scale(1.15) rotate(25deg); }
  28% { opacity: .25; transform: scale(.8) rotate(45deg); }
}
@keyframes cardShine { from { transform: translateX(-55%); } to { transform: translateX(55%); } }
@keyframes cardHit {
  0% { transform: translateY(-6px); }
  35% { transform: translateY(-14px) scale(1.04) rotate(-1.5deg); }
  70% { transform: translateY(-4px) scale(.99) rotate(1deg); }
  100% { transform: translateY(-6px); }
}

/* 選んだあとに出てくる START */
.startbtn {
  position: relative; z-index: 1;
  appearance: none; border: 0; background: none; padding: 0; cursor: pointer;
  margin-top: 2px; animation: startPulse 1.1s ease-in-out infinite;
}
/* 選ぶ前から場所だけは取っておく（出てきたときに画面がずれないように） */
.startbtn[hidden] { display: block; visibility: hidden; }
.startbtn.in { animation: startIn .42s cubic-bezier(.2, .9, .3, 1.6) both, startPulse 1.1s .42s ease-in-out infinite; }
.startbtn:active { transform: translateY(3px); }
.startlogo { display: block; width: min(72vw, 340px); height: auto; }
.startlogo[hidden], #startTx[hidden] { display: none; }
.starttx {
  display: inline-block; padding: 11px 32px; border-radius: 999px;
  font-family: "Arial Black", system-ui, sans-serif;
  font-size: clamp(20px, 6.4vw, 32px); font-weight: 900; letter-spacing: .1em;
  color: #fff; background: linear-gradient(180deg, #ff6f8b, #e8455a);
  border: 3px solid var(--ink-line); box-shadow: 0 5px 0 rgba(0, 0, 0, .4);
  -webkit-text-stroke: 5px var(--ink-line); paint-order: stroke fill;
}
@keyframes startPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes startIn {
  0% { opacity: 0; transform: translateY(26px) scale(.7); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (min-width: 560px) {
  .chars { gap: 14px; --cw: calc((min(680px, 100vw - 20px) - 28px) / 3); }
  .charcard .ct { font-size: 12px; }
  .charcard .cs { font-size: 12px; }
  .charcard .cw { font-size: 12px; }
}

/* ---------------- レベルアップの選択 ---------------- */
/* スマホを主に考えて、まず「指で押しやすい横長のカードを縦に並べる」形。
   広い画面のときだけ 3〜4 枚を横に並べ替える。
   線の太さ・角丸・つやは、ゲージや絵と同じ言語でそろえる。 */
/* アメコミの効果音みたいに、傾けて重ねた袋文字にする。 */
.lvhead {
  position: relative;
  margin: 0 0 10px;
  font-family: "Arial Black", "Impact", system-ui, sans-serif;
  font-size: clamp(30px, 9.5vw, 46px); font-weight: 900;
  letter-spacing: .04em; line-height: 1;
  color: #ffd257;
  -webkit-text-stroke: 9px var(--ink-line);
  paint-order: stroke fill;
  transform: rotate(-4deg) skewX(-8deg);
  text-shadow: 0 5px 0 #b4671c;
  animation: lvpop .38s cubic-bezier(.2, .9, .3, 1.6) both;
}
@keyframes lvpop {
  0% { opacity: 0; transform: rotate(-4deg) skewX(-8deg) scale(.5); }
  70% { opacity: 1; transform: rotate(-4deg) skewX(-8deg) scale(1.12); }
  100% { opacity: 1; transform: rotate(-4deg) skewX(-8deg) scale(1); }
}

.offers {
  display: flex; flex-direction: column; gap: 12px;
  width: min(560px, 100%);
}

.offer {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 12px 16px 12px 12px; text-align: left;
  background: linear-gradient(180deg, #ffffff 0%, #fdf6ff 45%, #eadff5 100%);
  border: 3.5px solid var(--ink-line);
  border-radius: 20px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .42);
  color: #241a30; cursor: pointer;
  animation: offerIn .22s cubic-bezier(.2, .9, .3, 1.2) both;
  transition: transform .08s, box-shadow .08s;
}
.offer:nth-child(2) { animation-delay: .06s; }
.offer:nth-child(3) { animation-delay: .12s; }
.offer:nth-child(4) { animation-delay: .18s; }
@keyframes offerIn {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.offer:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .42); }
/* カード上辺のつや */

.offer .oi {
  width: 62px; height: 62px; flex: none;
  display: grid; place-items: center;
  border-radius: 16px;
  background: linear-gradient(180deg, #4a3826, #2a1e18);
  border: 3px solid var(--ink-line);
  font-size: 28px;
}
.offer .oi .icn { width: 54px; height: 54px; }

.offer .otx { flex: 1; min-width: 0; }
.offer .ol {
  font-size: 11px; font-weight: 800; letter-spacing: .08em; color: #7a6a90;
}
.offer .on {
  font-weight: 800; font-size: clamp(17px, 4.6vw, 20px); line-height: 1.2;
  color: #241a30; margin: 1px 0 4px;
}
.offer .od { font-size: 13px; color: #35293f; line-height: 1.5; font-weight: 700; }
.offer .osub {
  display: block; margin-top: 4px;
  font-size: 11.5px; color: #6d6280; line-height: 1.45; font-weight: 400;
}
.offer .otag {
  position: absolute; top: -11px; right: 14px;
  font-size: 10px; font-weight: 800; letter-spacing: .1em;
  padding: 3px 10px; border-radius: 999px;
  border: 2.5px solid var(--ink-line);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}
.offer .otag.new { background: linear-gradient(180deg, #fff0b8, #ffcf3d); color: #4a3406; }
.offer .otag.up { background: linear-gradient(180deg, #d8ffe8, #7ce5a8); color: #10502f; }

/* 広い画面なら横に並べる */
@media (min-width: 760px) and (min-height: 480px) {
  .offers { flex-direction: row; flex-wrap: wrap; justify-content: center; width: min(940px, 100%); }
  .offer {
    flex-direction: column; align-items: flex-start; gap: 8px;
    flex: 1 1 200px; max-width: 224px; padding: 16px 14px;
  }
  .offer .oi { width: 66px; height: 66px; }
  .offer .oi .icn { width: 58px; height: 58px; }
}

/* ---------------- ビルド一覧 / リザルト ---------------- */
.buildlist { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin: 12px 0 4px; }
.bchip {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 800; padding: 5px 10px; border-radius: 999px;
  background: linear-gradient(180deg, #fffaf0, #ffe6b8); color: #3a2410;
  border: 2.5px solid var(--ink-line);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .3);
}
.bchip b { color: #8a5a12; font-size: 11px; }
.bchip .bi { width: 18px; height: 18px; display: block; }

/* ---------------- リザルト ---------------- */
#scr-result { gap: 22px; }

/* アメコミ調の見出し。負けたときは赤く。 */
.reshead {
  font-family: "Arial Black", "Impact", system-ui, sans-serif;
  font-size: clamp(34px, 11vw, 64px); font-weight: 900;
  letter-spacing: .01em; line-height: 1; white-space: nowrap;
  color: #ffd257;
  -webkit-text-stroke: 13px var(--ink-line);
  paint-order: stroke fill;
  transform: rotate(-4deg) skewX(-8deg);
  text-shadow: 0 6px 0 #b4671c;
  margin: 0 0 22px;
  animation: swIn .42s cubic-bezier(.2, .9, .3, 1.7) both;
}
.reshead.lose { color: #ff4f66; text-shadow: 0 6px 0 #7d1020; }

/* スコアは白塗り・黒フチの袋文字。台は置かない。 */
.scorebox {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 0; background: none; border: 0; box-shadow: none;
}
.scorelabel {
  font-family: "Arial Black", "Impact", system-ui, sans-serif;
  font-size: 13px; font-weight: 900; letter-spacing: .38em; text-indent: .38em;
  color: #fff;
  -webkit-text-stroke: 6px #000; paint-order: stroke fill;
}
.scorenum {
  font-family: "Arial Black", "Impact", system-ui, sans-serif;
  font-size: clamp(46px, 15vw, 78px); font-weight: 900; line-height: 1.05;
  color: #fff; font-variant-numeric: tabular-nums;
  -webkit-text-stroke: 12px #000; paint-order: stroke fill;
}

/* 平らなボタン。影も艶も付けない。 */
.flatbtn {
  appearance: none; cursor: pointer; font: inherit;
  font-weight: 900; font-size: 16px; letter-spacing: .08em;
  padding: 15px 30px; min-height: 52px; min-width: 132px;
  border: 3px solid var(--ink-line);
  border-radius: 10px;
  background: #fff; color: var(--ink-line);
  box-shadow: none;
}
.flatbtn.primary { background: #ffd257; color: var(--ink-line); border-color: var(--ink-line); }
.flatbtn:active { opacity: .7; }

.help { text-align: left; font-size: 13px; color: var(--sub); line-height: 1.75; padding-left: 20px; margin: 4px 0 16px; }
.help b { color: var(--ink); }

/* 読み込み画面。装飾はせず、字間と細い線だけで見せる。 */
#scr-loading { background: #0e0b14; }
.loadbox { display: flex; flex-direction: column; align-items: center; gap: 24px; width: min(400px, 82vw); }
/* 読み込み中はゲームのロゴを出す。
   まだ届いていない間も高さが変わらないよう、場所を先に取っておく。 */
.loadmark {
  display: block; width: 100%; height: auto;
  aspect-ratio: 1200 / 650; object-fit: contain;
  max-height: 34vh;
}
.loadbar {
  width: 100%; height: 2px; border-radius: 0;
  background: rgba(255, 255, 255, .14); overflow: hidden;
}
.loadbar i {
  display: block; height: 100%; width: 0%;
  background: #fff; transition: width .25s ease-out;
}
.loadnum {
  font-size: 12px; font-weight: 500; letter-spacing: .16em;
  color: rgba(255, 255, 255, .5);
  font-variant-numeric: tabular-nums;
}
.loadnum b { font-weight: 500; margin-left: 2px; opacity: .6; }

@media (max-width: 560px) {
  .clock { font-size: 22px; -webkit-text-stroke-width: 3.5px; }
  .hp { width: 150px; height: 20px; border-width: 2px; }
  .hp span { font-size: 11px; line-height: 16px; }
  .xpbar { height: 12px; border-width: 2px; }
  .bossbar { height: 13px; border-width: 2px; }
  .lv { font-size: 15px; -webkit-text-stroke-width: 4.5px; min-width: 48px; }
  .kills { font-size: 12px; padding: 1px 8px; border-width: 2px; }
  .hud-row { gap: 7px; }
  .slots { max-width: 60vw; }
  .slot { width: 32px; height: 32px; font-size: 15px; border-radius: 10px; border-width: 2px; }
  .slots.small .slot { width: 26px; height: 26px; font-size: 11px; border-width: 2px; }
}
