/* =========================================================
   深淵の入口：アイコンをどかすと穴 → 「深淵を覗きますか？」→ ステージへ
   ========================================================= */

/* ---------- アイコンと穴 ---------- */
.abyss { position: relative; width: 100px; height: 100px; margin: 0 auto 22px; }
.abyss .head__avatar {
  position: absolute; inset: 0; z-index: 2;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-drag: none;
  transition: transform .6s cubic-bezier(.3, 1.35, .45, 1);
  will-change: transform;
}
.abyss.is-dragging .head__avatar { cursor: grabbing; transition: none; }

/* 穴：ページに開いた真っ黒な穴。上の縁に影を落として、深さを出す */
.abyss__hole {
  position: absolute; inset: 6px; z-index: 1; border-radius: 50%;
  /* 中心は黒、縁に向かって背景よりかなり濃い深緑へ。縁がはっきり見えて「穴」だと分かる */
  background: radial-gradient(circle at 50% 56%, #000 0 34%, #000d07 52%, #001a10 74%, #00241a 100%);
  border: 2px solid #002116;
  box-shadow:
    inset 0 9px 14px rgba(0, 0, 0, .9),
    inset 0 -3px 5px rgba(0, 66, 43, .35),
    0 1px 0 rgba(255, 255, 255, .05);
  pointer-events: none; cursor: pointer;
  transition: transform .4s cubic-bezier(.25, .75, .3, 1), box-shadow .4s;
}
/* 穴の奥でうっすら渦を巻く */
.abyss__hole::after {
  content: ""; position: absolute; inset: 18%; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, rgba(98, 136, 119, .12), transparent 40%, rgba(98, 136, 119, .08), transparent 75%);
  animation: abyssSwirl 6s linear infinite; opacity: 0; transition: opacity .6s;
}
@keyframes abyssSwirl { to { transform: rotate(360deg); } }
.abyss.is-open .abyss__hole { pointer-events: auto; }
.abyss.is-open .abyss__hole::after { opacity: 1; }
/* 乗せると吸い込まれるように少し深くなる */
.abyss.is-open .abyss__hole:hover, .abyss.is-open .abyss__hole:focus-visible {
  transform: scale(.94);
  box-shadow: inset 0 13px 22px rgba(0, 0, 0, 1), inset 0 -3px 5px rgba(0, 66, 43, .3), 0 1px 0 rgba(255, 255, 255, .05);
}
.abyss__hole:focus-visible { outline: 2px solid var(--meta-hover); outline-offset: 4px; }

/* ---------- ゲーム風のメッセージ枠 ---------- */
.rpg {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  font-family: "DotGothic16", "LINE Seed JP", monospace; letter-spacing: .08em;
}
.rpg__dim { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .25s; }
.rpg.is-open .rpg__dim { opacity: 1; }
.rpg__box {
  position: relative; width: min(440px, 100%); padding: 22px 26px 18px;
  background: #000; color: #fff;
  /* ドット絵の二重枠 */
  border: 4px solid #fff; border-radius: 6px;
  box-shadow: 0 0 0 4px #000, 0 0 0 6px rgba(255, 255, 255, .35), 0 18px 40px rgba(0, 0, 0, .6);
  image-rendering: pixelated;
  transform: scale(.85); opacity: 0;
  transition: transform .22s steps(4), opacity .22s steps(4);
}
.rpg.is-open .rpg__box { transform: none; opacity: 1; }
.rpg__text { min-height: 1.6em; font-size: 18px; line-height: 1.6; }
/* 文字送りの途中で点滅する▼ */
.rpg__text::after { content: "▼"; display: inline-block; margin-left: 6px; font-size: 12px; animation: rpgBlink .8s steps(2) infinite; }
.rpg.is-choosing .rpg__text::after { content: none; }
@keyframes rpgBlink { 50% { opacity: 0; } }
.rpg__choices { display: flex; gap: 36px; justify-content: center; margin-top: 18px; visibility: hidden; }
.rpg.is-choosing .rpg__choices { visibility: visible; }
.rpg__choice {
  position: relative; padding: 2px 4px 2px 22px; font: inherit; font-size: 18px; color: #fff; letter-spacing: .12em;
}
.rpg__choice::before { content: "▶"; position: absolute; left: 0; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: 0; }
.rpg__choice.is-on::before { opacity: 1; animation: rpgNudge .5s steps(2) infinite; }
@keyframes rpgNudge { 50% { transform: translate(3px, -50%); } }

/* ---------- 吸い込まれる暗転とステージ ---------- */
/* 穴の真上に置いた黒い円を拡大して、画面を飲み込む（画面の形に関係なく、必ず穴から広がる） */
.void__circle {
  position: fixed; z-index: 70; left: var(--x); top: var(--y); width: var(--d); height: var(--d);
  margin: calc(var(--d) / -2) 0 0 calc(var(--d) / -2); border-radius: 50%; background: #000;
  transform: scale(0); pointer-events: none;
}
.void {
  position: fixed; inset: 0; z-index: 71; background: #000; color: #fff; overflow: hidden;
  font-family: "DotGothic16", "LINE Seed JP", monospace; letter-spacing: .3em;
}
/* 「深淵」：最初は真ん中。0.5秒後に上端へ */
.void__title {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: clamp(26px, 5vw, 44px); margin: 0; padding-left: .3em; white-space: nowrap;
  opacity: 0; transition: top 1s cubic-bezier(.25, .75, .3, 1), font-size 1s cubic-bezier(.25, .75, .3, 1), opacity .6s;
}
.void.is-title .void__title { opacity: 1; }
.void.is-up .void__title { top: 9vh; font-size: clamp(18px, 3vw, 26px); }
/* ステージ：上から下へ、グラデーションでふわっと現れる */
@property --reveal { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
.void__stage {
  position: absolute; inset: 0;
  /* 上は黒に近い灰色、下は白に近い灰色（キャラクターが見やすいように） */
  background: linear-gradient(to bottom, #1f1f1f 0%, #e9e9e9 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(var(--reveal) - 40%), transparent var(--reveal));
          mask-image: linear-gradient(to bottom, #000 calc(var(--reveal) - 40%), transparent var(--reveal));
  transition: --reveal 1.6s cubic-bezier(.25, .75, .3, 1);
}
.void.is-up .void__stage { --reveal: 140%; }

@media (prefers-reduced-motion: reduce) {
  .abyss__hole::after { animation: none; }
}

/* ---------- ステージ（アスレチック） ---------- */
.stage__layer, .stage__fx { position: absolute; inset: 0; }
.stage__fx { pointer-events: none; letter-spacing: 0; } /* 「深淵」画面の文字間隔をキャンバスの文字に引き継がない */
.stage__layer { opacity: 0; transition: opacity .8s .2s; }
.void.is-play .stage__layer { opacity: 1; }
/* 地形（ブロック・トゲ）を描くキャンバス。輪郭はフィルターで 6fps にかすかに揺れる */
.stage__tiles { position: absolute; top: 0; pointer-events: none; filter: url(#boil); opacity: 0; transition: opacity .8s .2s; }
.void.is-play .stage__tiles { opacity: 1; }
.actor {
  position: absolute; left: 0; top: 0; user-select: none; pointer-events: none;
  will-change: transform;
}
.actor img { position: absolute; inset: 0; width: 100%; height: 100%; }
.actor img[hidden] { display: none; }
/* やられた・倒した瞬間：白く光る */
.actor.is-glow { filter: brightness(0) invert(1) drop-shadow(0 0 10px #fff) drop-shadow(0 0 22px rgba(255, 255, 255, .8)); }

/* ---------- キーの説明・やられたときの表示 ---------- */
.stage__guide, .stage__hintBtn, .stage__over { font-family: "LINE Seed JP", sans-serif; letter-spacing: 0; color: #fff; }
.stage__guide dl { display: grid; grid-template-columns: auto auto; gap: 7px 16px; margin: 0; }
.stage__guide dd { margin: 0; }
/* 始まったときの説明：真ん中のパネル */
.stage__guide {
  position: absolute; left: 50%; top: 46%; z-index: 5; transform: translate(-50%, -50%);
  padding: 22px 28px 18px; border-radius: 22px; background: rgba(21, 21, 21, .78);
  font-size: 13px; line-height: 1.5; box-shadow: 0 18px 40px rgba(0, 0, 0, .3);
  animation: guideIn .4s cubic-bezier(.25, .75, .3, 1) both; cursor: pointer;
  transition: opacity .35s, transform .35s;
}
.stage__guide.is-first { animation-delay: 1s; }
.stage__guide.is-out { opacity: 0; transform: translate(-50%, -46%); }
@keyframes guideIn { from { opacity: 0; transform: translate(-50%, -44%); } }
.stage__guide dt { font-weight: 700; text-align: right; color: #fff; }
.stage__guide dd { color: rgba(255, 255, 255, .75); }
.stage__guideTitle { margin: 0 0 12px; font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, .6); text-align: center; letter-spacing: .1em; }
.stage__guideHint { margin: 14px 0 0; font-size: 11px; color: rgba(255, 255, 255, .55); text-align: center; animation: hintBlink 1.4s ease-in-out infinite; }
@keyframes hintBlink { 50% { opacity: .35; } }
/* 左上（スコアの下）の「操作のヒント」ボタン */
.stage__hintBtn {
  position: absolute; left: 22px; top: 86px; z-index: 4;
  padding: 4px 12px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; background: rgba(21, 21, 21, .35);
  color: rgba(255, 255, 255, .8); font-size: 11px; cursor: pointer; transition: background .2s, color .2s, border-color .2s;
}
.stage__hintBtn:hover { background: rgba(255, 255, 255, .9); color: #151515; border-color: transparent; }
/* やられたとき：画面を少し暗くして案内 */
.stage__over {
  position: absolute; inset: 0; z-index: 6; display: grid; place-content: center; text-align: center;
  background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .4s;
}
.stage__over.is-on { opacity: 1; }
.stage__over p { margin: 0; }
.stage__overScore { font-size: 44px; font-weight: 800; line-height: 1.1; }
.stage__overBest { margin-top: 4px !important; font-size: 12px; color: rgba(255, 255, 255, .65); }
.stage__overKeys { display: flex; gap: 18px; justify-content: center; margin-top: 22px !important; font-size: 13px; color: rgba(255, 255, 255, .85); }
.stage__overKeys b { display: inline-block; min-width: 1.8em; padding: 1px 7px; margin-right: 4px; border: 1px solid rgba(255, 255, 255, .6); border-radius: 6px; font-weight: 700; }

/* ---------- 名前の入力（「深淵」の下） ---------- */
/* グレーがかった白の四角。ステージのブロックと同じく、輪郭が 6fps でかすかに揺れる（文字は揺らさない） */
.void__name {
  position: absolute; left: 50%; top: calc(50% + 46px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; width: min(320px, calc(100% - 32px)); height: 48px; padding: 6px 6px 6px 16px;
  font-family: "LINE Seed JP", sans-serif; letter-spacing: 0; isolation: isolate;
  opacity: 0; transition: opacity .4s .5s, transform .4s .5s;
}
.void__name::before, .void__name button::before { content: ""; position: absolute; inset: 0; z-index: -1; filter: url(#boil); }
.void__name::before { background: #d6d6d6; }
.void.is-title .void__name { opacity: 1; }
.void.is-named .void__name { opacity: 0; transform: translate(-50%, -6px); transition-delay: 0s; pointer-events: none; }
.void__name input {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: none; outline: none;
  color: #151515; font: inherit; font-size: 15px; font-weight: 700;
}
.void__name input::placeholder { color: rgba(21, 21, 21, .35); font-weight: 400; }
/* 1文字でも入ると出てくる「確定」：もう少しグレーな揺らぐ四角 */
.void__name button {
  position: relative; z-index: 0; height: 100%; padding: 0 16px; border: 0; background: none; outline: none;
  color: #151515; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  animation: nameOk .25s cubic-bezier(.25, .75, .3, 1);
}
.void__name button::before { background: #a9a9a9; transition: background .2s; }
.void__name button:hover::before, .void__name button:focus-visible::before { background: #969696; }
@keyframes nameOk { from { opacity: 0; transform: scale(.85); } }

/* ---------- ランキング ---------- */
.stage__rank, .stage__around { margin: 0; padding: 0; list-style: none; font-family: "LINE Seed JP", sans-serif; letter-spacing: 0; color: #fff; }
.stage__rank li, .stage__around li { display: grid; grid-template-columns: 1.6em 1fr auto; gap: 8px; align-items: baseline; padding: 2px 8px; border-radius: 6px; text-align: left; }
.stage__rank li.is-note, .stage__around li.is-note { display: block; text-align: center; color: rgba(255, 255, 255, .55); }
.stage__rank li.is-me, .stage__around li.is-me { background: rgba(255, 255, 255, .9); color: #151515; text-shadow: none; }
.stage__rankNo { font-weight: 800; opacity: .6; text-align: right; }
.stage__rankName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage__rankScore { font-weight: 800; font-variant-numeric: tabular-nums; }
/* 右上：いつも出ている上位10人 */
.stage__rank {
  position: absolute; right: 18px; top: 16px; z-index: 4; width: 210px;
  font-size: 11px; line-height: 1.5; text-shadow: 0 0 3px #151515, 0 0 6px rgba(21, 21, 21, .8);
  opacity: 0; transition: opacity .8s .2s;
}
.void.is-play .stage__rank { opacity: 1; }
/* やられたとき：今のランキングと、今回のスコアが入る場所を指す横からの矢印 */
.stage__board { position: relative; width: min(260px, 70vw); margin: 22px auto 0; font-family: "LINE Seed JP", sans-serif; letter-spacing: 0; }
.stage__boardList { margin: 0; padding: 0; list-style: none; font-size: 13px; color: #fff; }
.stage__boardList li { display: grid; grid-template-columns: 1.6em 1fr auto; gap: 8px; align-items: baseline; padding: 2px 8px; border-radius: 6px; text-align: left; }
.stage__boardList li.is-me { background: rgba(255, 255, 255, .9); color: #151515; }
.stage__arrow {
  position: absolute; right: calc(100% + 10px); top: var(--y); margin: 0 !important;
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 4px 3px 10px; background: #ff9d00; color: #151515; font-size: 12px; font-weight: 700;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
  padding-right: 16px; transform: translateY(-50%);
  animation: arrowIn .5s .3s cubic-bezier(.25, .75, .3, 1) both, arrowNudge 1s .8s ease-in-out infinite;
}
.stage__arrow b { font-weight: 800; font-variant-numeric: tabular-nums; }
@keyframes arrowIn { from { opacity: 0; transform: translate(-24px, -50%); } }
@keyframes arrowNudge { 50% { transform: translate(-4px, -50%); } }
/* 2人の間に入るとき：境目に線を引く */
.stage__gap { position: absolute; left: 0; right: 0; top: var(--y); height: 2px; margin-top: -1px; background: #ff9d00; border-radius: 1px; animation: gapIn .5s .3s both; }
@keyframes gapIn { from { opacity: 0; } }
/* 右上のランキング：「もっと見る」で全員。長いときはこの中だけスクロール */
.stage__rank ol { margin: 0; padding: 0; list-style: none; }
.stage__rank.is-open ol { max-height: calc(100vh - 90px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .35) transparent; }
.stage__rank.is-open { background: rgba(21, 21, 21, .55); border-radius: 10px; padding: 6px 0; }
.stage__rankMore {
  display: block; margin: 4px 0 0 auto; padding: 2px 8px; border: 0; background: none;
  color: rgba(255, 255, 255, .75); font: inherit; font-size: 11px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.stage__rankMore:hover { color: #fff; }
/* やられたとき：10位より下の回は、上位3人のあとを「⋮」で省く */
.stage__boardList li.is-dots { display: block; padding: 0; text-align: center; line-height: 1.1; color: rgba(255, 255, 255, .5); }

/* ---------- ステージ本体（スマホではこれを縮めて広く見せる） ---------- */
.stage__view { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

/* ---------- スマホ ---------- */
/* 下のボタンの帯：（＜ ＞）（↑）（☆） */
.stage__pad {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; height: 104px;
  display: flex; align-items: center; gap: 12px; padding: 0 16px calc(env(safe-area-inset-bottom) * .5);
  background: #151515; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  font-family: "LINE Seed JP", sans-serif; letter-spacing: 0;
  opacity: 0; transition: opacity .8s .2s;
}
.void.is-play .stage__pad { opacity: 1; }
.pad__stick {
  position: relative; flex: 1; max-width: 220px; height: 64px; border-radius: 999px;
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
  background: rgba(255, 255, 255, .12); touch-action: none;
}
.pad__arrow { font-size: 30px; line-height: 1; color: rgba(255, 255, 255, .45); pointer-events: none; }
.pad__knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: #e9e9e9; pointer-events: none; transition: transform .15s cubic-bezier(.3, 1.4, .5, 1);
}
.pad__stick.is-on .pad__knob { transition: none; }
.pad__btn {
  width: 64px; height: 64px; flex: none; border: 0; border-radius: 50%; margin-left: auto;
  background: rgba(255, 255, 255, .12); color: #fff; font: inherit; font-size: 28px; font-weight: 800; line-height: 1;
  touch-action: none; transition: background .1s, transform .1s;
}
.pad__btn + .pad__btn { margin-left: 0; }
.pad__btn.is-on { background: rgba(255, 255, 255, .35); transform: scale(.92); }
/* やられたとき：タップで押せるボタン */
.stage__overKeys.is-touch button {
  padding: 10px 18px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .9); color: #151515;
  font: inherit; font-size: 14px; font-weight: 700;
}
.stage__overKeys.is-touch button + button { background: rgba(255, 255, 255, .2); color: #fff; }

@media (hover: none) and (pointer: coarse) {
  /* 上の「深淵」は、名前を入れて始まったら消す */
  .void.is-up .void__title { opacity: 0; }
  .void { touch-action: none; }
  .stage__rank { right: 12px; top: 12px; width: 170px; }
  .stage__rank.is-open ol { touch-action: pan-y; max-height: calc(100vh - 200px); }
  .stage__board { width: min(220px, 58vw); margin-left: auto; margin-right: 16px; }
  .stage__arrow { font-size: 11px; }
}
