/* ============================================================
   ゲーム開始前フロー（Figma node 20-3 / 32-87 / 50-140 / 136-67 / 158-94）
   タイトル→ルール設定→CPU強さ選択→開戦カットイン→対局
   ※ゲームのルール・ロジックには一切関与しない純粋なUI層。
     選択値は既存 G（gameLength/timeCfg/clearCount/cpuLevel/rules）へ書き込み、
     既存の create→start 経路でゲームを開始する。
   ============================================================ */

#setup-flow {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #1a0d0a url("../assets/setup/scene-bg.png?v=3") center/cover no-repeat;
  overflow: hidden;
  font-family: "Shippori Mincho B1", "Yu Mincho", serif;
}
/* カットイン画面は専用の暗い背景（scene-bgは出さない） */
#setup-cutin { background: #0a0e1c; }
#setup-flow.hidden { display: none; }

/* 各画面は 1920x1080 の固定ステージを JS で cover/contain スケール */
.setup-screen { position: absolute; inset: 0; }
.setup-screen.hidden { display: none; }
.setup-stage {
  position: absolute;
  left: 50%; top: 50%;
  width: 1920px; height: 1080px;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(1);
}

/* ---- 共通パーツ ---- */
.setup-back {
  position: absolute;
  left: 33px; top: 19px;
  width: 114px; height: 120px;
  background: url("../assets/setup/back.png?v=2") center/contain no-repeat;
  border: 0; padding: 0; cursor: pointer;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.6));
  transition: transform .12s ease, filter .12s ease;
  /* 「ルーム作成に戻る」のぼかし背景(.back-label = 5)が左へにじんで矢印に
     かぶるので、矢印は常にその上に置く */
  z-index: 6;
}
.setup-back:hover { transform: scale(1.06); filter: drop-shadow(0 0 12px rgba(120,180,255,.7)); }
.setup-back:active { transform: scale(.97); }

/* 下部の大ボタン（作成 / 開戦） */
.setup-bigbtn {
  position: absolute;
  border: 0; padding: 0; cursor: pointer; background: none;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.55));
  transition: transform .12s ease, filter .12s ease;
}
.setup-bigbtn img { display: block; width: 100%; height: 100%; }
.setup-bigbtn:hover { transform: translateX(-50%) scale(1.035); filter: drop-shadow(0 0 24px rgba(240,200,110,.6)); }
.setup-bigbtn:active { transform: translateX(-50%) scale(.99); }

/* =====================  画面0: モード選択（ルーム作成/参加）  ===================== */
.mode-char {
  position: absolute;
  left: 100px; top: 15px;
  width: 681px; height: 1072px;
  object-fit: contain; object-position: bottom center;
  filter: drop-shadow(0 8px 22px rgba(0,0,0,.5));
  pointer-events: none; user-select: none; -webkit-user-drag: none;
}
.mode-btn {
  position: absolute;
  border: 0; padding: 0; cursor: pointer;
  background: url("../assets/setup/btn-room.png?v=2") center/100% 100% no-repeat;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.5));
  transition: transform .12s ease, filter .12s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.mode-btn span {
  color: #f4c371;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 700; font-size: 96px; letter-spacing: .06em;
  text-shadow: 0 3px 6px rgba(0,0,0,.6), 0 0 4px rgba(80,20,8,.55);
}
.mode-btn:hover { transform: scale(1.02); filter: drop-shadow(0 0 24px rgba(240,200,110,.55)); }
.mode-btn:active { transform: scale(.99); }
/* 矢印キーで選択中(.kb-focus)：金枠リングで「選択中」を明示。
   .kb-item を付けた将来の画面（プロフィール等）でも共通で効く汎用スタイル */
.kb-item.kb-focus { outline: 4px solid #f0c86e; outline-offset: 3px; border-radius: 8px; }
/* モード選択ボタンはホバーと同じ拡大＋金グローで馴染ませる（既定のフォーカス枠は消す） */
.mode-btn.kb-focus { transform: scale(1.02); filter: drop-shadow(0 0 30px rgba(240,200,110,.8)); outline: none; }
.mode-btn:focus-visible { outline: none; }
/* 「CPU」はラテン系フォントで（Figma 59-222 の Rubik One 風） */
.mode-lat { font-family: "Rubik", "Arial Black", "Segoe UI", sans-serif; font-weight: 900; margin-right: .05em; }
/* 友人戦ボタン：「友人戦」大＋「ルーム作成/参加」小 を横並び。
   Figma 59-222 更新でボタンが 1022→883 幅に狭まり、「友人戦」も 96→80px になった */
.mode-btn-sub { gap: 44px; }
.mode-btn-sub .mode-main { font-size: 80px; }
.mode-btn-sub .mode-sub { font-size: 64px; }

/* 左下：自分の名札（Figma node625:228。ロビーの席名札と同じ素材） */
.mode-plate {
  position: absolute;
  left: 100px; top: 881px; width: 548px; height: 155px;
  background: url("../assets/setup/plate-name.png?v=2") center/100% 100% no-repeat;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .5));
  pointer-events: none;
}
/* 名前は「黒い板の中央」に置く。板の内側はプレート左上から 151.5,22 の 385×93.5
   （素材の実測。Figma素材と同じ絵なので図と一致する）。
   Figma の文字の中心 (342.5, 66.6) は板の中心 (344, 68.8) とほぼ一致していて、
   左端218px揃えではない。中央基準にしてあるので名前の長さが変わっても寄らない */
.mode-plate span {
  position: absolute;
  left: 151.5px; top: 22px; width: 385px; height: 93.5px;
  box-sizing: border-box; padding: 0 10px;
  line-height: 93.5px; text-align: center;
  color: #f3d99d;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 700; font-size: 48px; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 5px rgba(0, 0, 0, .7);
}
/* 右上：お知らせバナー（Figma 59-222 node615:177。文字焼き込み画像をやめ、
   板・区切り線・▶ をベクタで描いて文字は実テキストにした）＋アイコン */
.mode-news {
  position: absolute;
  pointer-events: none;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .45));
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 700; font-size: 24px; line-height: 28.293px; white-space: nowrap;
}
.mode-news .news-plate { position: absolute; inset: 0; width: 100%; height: 100%; }
.mode-news span { position: absolute; }
/* 位置は .mode-news の左上(1920x1080ステージの 822.3, 37.1)からの相対 */
.mode-news .news-title { left: 102.4px; top: 13.8px; color: #f1ca87; }
.mode-news .news-text  { left: 47px;    top: 70.4px; color: #efc378; }
.mode-news .news-arrow { position: absolute; left: 300.5px; top: 70.4px; width: 22.1px; height: 31.8px; }
.mode-icon {
  position: absolute; border: 0; padding: 0; cursor: pointer;
  background: center/contain no-repeat;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.5));
  transition: transform .12s ease, filter .12s ease;
}
.mode-icon:hover { transform: scale(1.06); filter: drop-shadow(0 0 12px rgba(240,200,110,.6)); }
.mode-icon:active { transform: scale(.97); }
#mode-profile { background-image: url("../assets/setup/mode-profile.png?v=2"); }
#mode-option  { background-image: url("../assets/setup/mode-option.png?v=2"); }
#mode-manual  { background-image: url("../assets/setup/mode-manual.png?v=2"); }

/* =====================  画面2b: ルーム参加（テンキー）  ===================== */
.join-panel {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 808px; height: 829px;
  background: url("../assets/setup/join-panel.png") center/100% 100% no-repeat;
  filter: drop-shadow(0 12px 34px rgba(0,0,0,.55));
  user-select: none;
}
/* 入力中のルームID表示（パネル画像の暗い入力枠に重ねる） */
.join-display {
  position: absolute;
  left: 15%; top: 15.5%; width: 70%; height: 11.5%;
  display: flex; align-items: center; justify-content: center;
  color: #f4c371;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 700; font-size: 66px; letter-spacing: .28em;
  text-shadow: 0 2px 6px rgba(0,0,0,.75);
  pointer-events: none;
}
/* テンキー（3列×4行）の当たり判定を描き込み済みキーに重ねる */
.join-pad {
  position: absolute;
  left: 12.8%; top: 31.5%; width: 74.4%; height: 49.5%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 1.6% 1.8%;
}
.join-pad button {
  background: transparent; border: 0; padding: 0;
  color: transparent; cursor: pointer;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s ease;
}
.join-pad button:hover { background: rgba(255,220,140,.14); }
.join-pad button:active { background: rgba(255,220,140,.28); }
.join-close {
  position: absolute; left: 85%; top: 3.5%; width: 11%; height: 7.5%;
  background: transparent; border: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.join-ok {
  position: absolute; left: 33%; top: 85.5%; width: 34%; height: 9.5%;
  background: transparent; border: 0; cursor: pointer;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s ease;
}
.join-ok:hover { background: rgba(255,220,140,.16); }
.join-ok:active { background: rgba(255,220,140,.30); }
.join-msg {
  position: absolute;
  left: 8%; right: 8%; bottom: -3%;
  text-align: center;
  color: #ffd7a0; font-size: 24px; font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,.7);
  min-height: 28px;
}

/* =====================  画面1: ルール設定  ===================== */
#setup-panel {
  position: absolute;
  left: 167px; top: 64px; width: 1587px; height: 835px;
  background: url("../assets/setup/panel.png") center/100% 100% no-repeat;
}
#setup-rows {
  position: absolute;
  left: 90px; right: 70px; top: 76px; bottom: 60px;
  /* 右の余白はスクロールバー(10px)ぶんだけ。30pxだと配給減点の行
     （小1＋中4＋間隔20×4＝1078px）が入りきらず折り返す */
  padding: 4px 12px 4px 6px;
  overflow-y: auto;
  overflow-x: hidden;
}
#setup-rows::-webkit-scrollbar { width: 10px; }
#setup-rows::-webkit-scrollbar-thumb { background: rgba(244,195,113,.5); border-radius: 6px; }
#setup-rows::-webkit-scrollbar-track { background: rgba(0,0,0,.2); }

.srow {
  display: flex;
  align-items: center;
  gap: 22px;
  /* Figma の行ピッチは 126〜139。詳細設定ONの時は #setup-rows が
     スクロールして 46-353 / 50-140 の状態になる */
  min-height: 130px;
}
/* 行ラベル: 共通の赤プレート画像＋左に重なるアイコン＋統一フォントのテキスト
   （Figma 20-3/50-140。以前の文字焼き込み画像 lbl-*.png を置き換え） */
.srow-label {
  flex: 0 0 auto;
  position: relative;
  height: 78px;
  width: 288px;
}
.srow-label::before {
  content: "";
  position: absolute;
  left: 14px; top: 50%; transform: translateY(-50%);
  width: 252px; height: 68px;
  background: url("../assets/setup/lbl-plate.png") center/100% 100% no-repeat;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .4));
}
.srow-icon {
  position: absolute;
  left: 0; top: 50%; transform: translateY(-54%);
  height: 74px; width: auto;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .45));
  z-index: 1;
}
.srow-label span {
  position: absolute;
  /* Figma 50-140: 文字は「アイコンの右側に残るプレート領域」の中央。
     プレートは 14〜266px、アイコンは最大 87px まで来るので、
     86〜266px の中央（=175px）に置く。これより左だとアイコンに文字が食い込む */
  left: 86px; right: 24px; top: 50%; transform: translateY(-50%);
  text-align: center;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 800; font-size: 36px; letter-spacing: .06em;
  color: #f4c371;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .65);
  white-space: nowrap;
}
.sopts {
  display: flex;
  align-items: center;
  gap: 38px;   /* Figma のピル間隔（大の行=40 / 小の行=37）*/
  flex-wrap: wrap;
}
/* 配給減点だけは 小1＋中4＝998px と幅を食うので間隔を詰める。
   Figma も この行だけ間隔25・開始xを他の行より左（572 vs 589）にして収めている */
#sset-start { gap: 20px; }
/* Figma 20-3 / 46-353 / 50-140 のピルは「文字幅に合わせた3種類」。
   大   250x95  … 2〜3択の行（モード・局数・詳細設定・飛び・赤ドラ・縛り・便利表示・喰い断）
   小   174x84  … 短い選択肢（なし/1〜4枚/自動/3+5秒 など）
   中   206x85  … 小に収まらない選択肢（300+0秒・25000〜100000）
   どれを使うかは行ではなく**選択肢ごと**（長考時間は300+0秒だけ中、
   配給減点は自動だけ小）なので、setup.js 側で `size` を指定する */
.sopt {
  position: relative;
  width: 250px;
  height: 95px;
  padding: 0 18px;
  border: 0;
  cursor: pointer;
  background: url("../assets/setup/pill-off.png") center/100% 100% no-repeat;
  color: #f4c371;
  font-family: "Shippori Mincho B1", serif;
  font-weight: 800;
  font-size: 32px;   /* Figmaのオプション文字サイズ。3種類とも同じ */
  letter-spacing: .04em;
  white-space: nowrap;
  display: flex; align-items: center; justify-content: center;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
  transition: transform .1s ease;
  flex: none;
}
.sopt:hover { transform: translateY(-2px); }
.sopt.on {
  background-image: url("../assets/setup/pill-on.png");
  color: #300a03;
  text-shadow: 0 1px 1px rgba(255,236,190,.4);
}
.sopt.sopt-s { width: 174px; height: 84px; padding: 0 10px; background-image: url("../assets/setup/pill-s-off.png"); }
.sopt.sopt-s.on { background-image: url("../assets/setup/pill-s-on.png"); }
.sopt.sopt-m { width: 206px; height: 85px; padding: 0 12px; background-image: url("../assets/setup/pill-m-off.png"); }
.sopt.sopt-m.on { background-image: url("../assets/setup/pill-m-on.png"); }

/* 詳細設定の区切り（金の下線＋下向き矢印） */
#setup-detail { }
#setup-detail.hidden { display: none; }
.setup-divider {
  position: relative;
  height: 40px;
  margin: 6px 8px 10px;
}
.setup-divider::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 14px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #d9a441 12%, #f4c371 50%, #d9a441 88%, transparent);
  box-shadow: 0 0 6px rgba(244,195,113,.5);
}
.setup-divider::after {
  content: "";
  position: absolute; left: 50%; top: 14px;
  transform: translateX(-50%);
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-top: 20px solid #f4c371;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.4));
}

#setup-create { left: 50%; top: 915px; width: 576px; height: 124px; transform: translateX(-50%); }

/* =====================  画面2: CPU強さ選択 兼 ルーム作成後ロビー  ===================== */
/* 画面2だけ夜の茶房の暗い専用背景（Figma 329-145）。全面に敷く */
#setup-flow:has(#setup-cpu:not(.hidden)) {
  background: #0d0705 url("../assets/setup/scene-room.png") center/cover no-repeat;
}
/* 戻るボタン横の「ルーム作成に戻る」（Figma 136-67 node329:117:
   #4e0e0e の 309x120 にレイヤーブラー10px。板ではなく縁のぼけた敷き影） */
.back-label {
  position: absolute;
  left: 137px; top: 19px; width: 309px; height: 120px;
  display: flex; align-items: center; justify-content: center;
  color: #f0c987;
  font-family: "BIZ UDMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 700; font-size: 32px; letter-spacing: .02em; white-space: nowrap;
  cursor: pointer; z-index: 5;
}
/* 背景だけを疑似要素に分けてぼかす（要素ごと blur すると文字までぼける）。
   .back-label は z-index:5 で重なり文脈を作るので、z-index:-1 は文字の下に収まる */
.back-label::before {
  content: "";
  position: absolute; inset: 0;
  z-index: -1;
  background: #4e0e0e;
  filter: blur(10px);
  pointer-events: none;
}
.back-label:hover { color: #ffe3a8; }
/* ルームID（Figma node 336-461）: プレート画像に「ルームID：」焼き込み済み、番号を右に重ねる */
.room-id {
  position: absolute;
  left: 764px; top: 35px; width: 394px; height: 89px;
  background: url("../assets/setup/roomid-plate.png") center/100% 100% no-repeat;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.5));
  z-index: 4;
}
.room-id.hidden { display: none; }
.room-id #cpu-roomid {
  position: absolute;
  left: 205px; right: 16px; top: 50%;
  transform: translateY(-50%);
  text-align: center;
  color: #f4c371;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 700; font-size: 38px; letter-spacing: .12em;
  text-shadow: 0 2px 5px rgba(0,0,0,.6);
}
.cpu-cards {
  position: absolute;
  left: 82px; top: 157px;   /* Figma 349-360: カード x82〜, 間隔28 */
  display: flex; gap: 28px;
}
/* 暗転は**準備完了を押した席**に出す（ハンコと同じ条件）。
   以前は座っただけ（.joined）で暗くなっていたため、まだ準備していない人が
   準備済みに見えていた（ユーザー指摘 2026-08-08） */
.cpu-card.is-ready::before {
  content: "";
  position: absolute; inset: 0; z-index: 4;
  background: rgba(16, 7, 5, .55);
  pointer-events: none;
}
/* ハンコは「準備完了を押した人」にだけ出す。座っただけで押されて見えると、
   ゲストに準備完了ボタンを付けた意味がなくなる（2026-08-08） */
.cpu-card.is-ready::after {
  content: "";
  position: absolute; left: 50%; top: 261px; transform: translateX(-50%);
  width: 321px; height: 145px; z-index: 5;
  background: url("../assets/setup/stamp-ready.png") center/contain no-repeat;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .5));
  pointer-events: none;
}

/* 4番目の空きスロット（友人招待/CPU追加）Figma 136-67 node329:133 */
.cpu-card.empty-slot { cursor: default; }
.cpu-card.empty-slot .cpu-char,
.cpu-card.empty-slot .cpu-plate { display: none; }
.slot-actions { display: none; }
/* Figma 349-360 更新: 友人招待/CPU追加をカード内に出す（ボタン上端410/495・横中央）。
   カード内の小さいQRは廃止（ユーザー指示 2026-08-08）。QRは「友人招待」を押したときだけ
   大きい招待パネルに出す。top は QR(166)+余白(42)+gap(30) を足した位置に置き換えてある */
.cpu-card.empty-slot .slot-actions {
  position: absolute; left: 0; right: 0; top: 410px;
  display: flex; flex-direction: column; align-items: center; gap: 30px;
}
.slot-btn {
  min-width: 181px; padding: 16px 24px;
  background: #191919; border: 1px solid #f5f5f5; color: #f5f5f5;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
  font-weight: 800; font-size: 24px; letter-spacing: .04em;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.slot-btn:hover { background: #3a2b12; border-color: #f4c371; color: #f4c371; }
.slot-btn:active { transform: translateY(1px); }
.cpu-card {
  position: relative;
  width: 364px; height: 647px;
  /* 装飾入りの赤カード画像（金枠・竹・円窓）Figma 136-67 node68b2c466 */
  background: url("../assets/setup/card-bg.png") center/100% 100% no-repeat, #4e0e0e;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
  /* クリック時の青い選択/タップハイライトを抑止 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cpu-card .cpu-char { -webkit-user-drag: none; user-drag: none; pointer-events: none; }
.cpu-card.selectable { cursor: pointer; }
.cpu-card.selectable:hover { box-shadow: 0 0 22px rgba(244,195,113,.55), 0 6px 18px rgba(0,0,0,.5); }
/* 空きスロットのカードは少し暗く（Figma: opacity .88） */
.cpu-card.empty-slot { filter: brightness(.9); }
.cpu-card .cpu-char {
  position: absolute;
  left: 50%; bottom: 60px;
  transform: translateX(-50%);
  height: 560px;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.5));
}
.cpu-card.player .cpu-char { height: 575px; }
/* ステージ右上の3アイコン（全画面 / 設定 / 退出）。対局中の #topright と同じもの。
   .icon-btn は cqmin で組んであり 1920x1080 のステージに載らないので、
   ここでは設計pxで同じ見た目を作る。96px なら画面上は対局中の71pxとほぼ同寸になる */
.stage-topright {
  position: absolute; right: 30px; top: 30px;
  display: flex; gap: 16px; z-index: 6;
}
.stage-icon {
  width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(150, 180, 240, .35);
  border-radius: 14px;
  background: linear-gradient(160deg, rgb(48, 60, 92), rgb(20, 27, 45));
  color: #cddcff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
  transition: filter .12s ease, transform .12s ease;
}
.stage-icon svg { width: 42px; height: 42px; }
.stage-icon:hover { filter: brightness(1.25); transform: translateY(-2px); }
.stage-icon:active { transform: translateY(0) scale(.97); }

/* 名前プレート: 全席共通の黒金バー＋段位バッジ（Figma 349-360 node594:159） */
.cpu-plate {
  position: absolute;
  left: 50%; bottom: 33px;
  transform: translateX(-50%);
  width: 309px; height: 87px;
  background: url("../assets/setup/plate-name.png?v=2") center/100% 100% no-repeat;
  pointer-events: none;
}
/* プレート上の名前/難易度テキスト（左のバッジを避けて右側領域の中央） */
.cpu-plate .cpu-diff {
  position: absolute;
  /* **縦は 50% ではなく 44.2%。** 名札画像(plate-name.png 1096x310)の黒い枠は
     画像の y22〜252＝中心 44.19% にあり、画像の中央より上にある。
     50% に置くと枠の中で 5px ぶん下にずれて見える（ユーザー指摘 2026-08-08） */
  left: 96px; right: 14px; top: 44.2%;
  transform: translateY(-50%);
  text-align: center;
  color: #f2e5d1;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
  font-weight: 800; font-size: 26px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .8);
}
#setup-flow.mode3 #cpu-card-3 { display: none; }
#setup-flow.mode3 .cutin-fig.cpu3,
#setup-flow.mode3 .cutin-plate.cpu3 { display: none; }

/* 難易度・透明牌数ドロップダウン（Figma 136-67 node583:172 / node336:467 実測:
   暗いパネル rgba(25,26,26,.9) の上に、黒箱＋白枠の行が間隔をあけて並ぶ） */
#cpu-dropdown, #clear-dropdown {
  position: absolute;
  /* ピル(.clear-sel = z-index 3)より下・カードより上。透明牌数のパネルは
     ピルを抱えるので、パネルがピルを隠さないこの重なり順でなければならない */
  z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  background: rgba(25, 26, 26, .9);
}
#cpu-dropdown.hidden, #clear-dropdown.hidden { display: none; }
#cpu-dropdown button, #clear-dropdown button {
  min-width: 0;
  padding: 0;
  background: #191919;
  border: 1px solid #f5f5f5;
  color: #f5f5f5;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
  font-weight: 800; font-size: 24px; letter-spacing: .04em;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
#cpu-dropdown button:hover, #clear-dropdown button:hover {
  background: #2a2015; border-color: #f4c371; color: #f4c371;
}

/* 透明牌数（Figma node583:172）: パネル233幅・行187x51・間隔9。
   パネル下端はピル(.clear-sel)の下5pxまで伸ばし、ピルを内側に抱える */
#clear-dropdown {
  width: 233px;
  gap: 9px;
  padding: 12px 0 73px;
}
#clear-dropdown button { width: 187px; height: 51px; }
/* 選択肢とピルの間の金の区切り線＋上向き▲（Figma node583:173 の書き出し） */
#clear-dropdown::after {
  content: "";
  width: 190.5px; height: 12.8px;
  margin-top: -2px;
  background: url("../assets/setup/dd-divider.svg") center/100% 100% no-repeat;
}

/* CPU難易度（Figma node336:467）: パネル212幅・行170x41・間隔17。
   先頭に現在の強さを金枠で見せ（Figma node593:254）、残り2つを下に並べる */
#cpu-dropdown {
  width: 212px;
  gap: 17px;
  padding: 9px 0 16px;
}
#cpu-dropdown button { width: 170px; height: 41px; }
#cpu-dropdown button.cur {
  order: -1;                  /* 現在値は常に先頭 */
  height: 46px; width: 172px;
  background: transparent;
  border-color: #f4c371;
  color: #f3d99d;
  cursor: default;
}
#cpu-dropdown button.cur:hover { background: transparent; border-color: #f4c371; color: #f3d99d; }

/* 透明牌数セレクタ: 黒地に金縁のピル画像（Figma 349-360 node573:134） */
.clear-sel {
  position: absolute; left: 50%; bottom: 123px; transform: translateX(-50%);
  width: 220px; height: 56px; padding: 0;
  background: url("../assets/setup/pill-clear.png") center/100% 100% no-repeat;
  border: none; color: #f2e5d1;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
  font-weight: 800; font-size: 24px; letter-spacing: .02em; white-space: nowrap;
  cursor: pointer; z-index: 3;
  transition: color .12s ease, filter .12s ease;
}
.clear-sel:hover { color: #f4c371; filter: drop-shadow(0 0 10px rgba(244, 195, 113, .5)); }
.cpu-card.empty-slot .clear-sel { display: none; } /* 空きスロットでは非表示 */
/* 選択肢のスタイルは #cpu-dropdown と共通（上の定義を参照） */

/* 右側の設定サマリ */
/* ルール確認サマリ（Figma 136-67 node334:334）: 暗いパネル＋橙ヘッダ＋暗い行 */
/* キャラ選択枠の右上×: CPUを外して空き枠（友人追加/CPU追加）に戻す。
   CPU状態のカードにだけ表示（空き枠・参加済みの席には出さない） */
.cpu-card .slot-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 44px; height: 44px;
  display: none;
  align-items: center; justify-content: center;
  border: 2px solid rgba(240, 195, 113, .8);
  border-radius: 50%;
  background: rgba(20, 12, 8, .82);
  color: #f4c371;
  font-size: 28px; line-height: 1;
  cursor: pointer;
  z-index: 3;
}
.cpu-card.selectable:not(.empty-slot):not(.joined) .slot-close { display: flex; }
.cpu-card .slot-close:hover { background: rgba(70, 30, 15, .9); border-color: #f4c371; }

#cpu-summary {
  position: absolute;
  left: 1636px; top: 157px;
  width: 232px; height: 883px;   /* 下端をステージいっぱい(1040)まで使い全行を見せる */
  background: rgba(24, 20, 24, .7);
  padding: 22px 25px;
  display: flex; flex-direction: column; gap: 11px;
  color: #f5f5f5;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
}
#cpu-summary::-webkit-scrollbar { width: 6px; }
#cpu-summary::-webkit-scrollbar-thumb { background: rgba(160,140,120,.5); border-radius: 4px; }
#cpu-summary::-webkit-scrollbar-track { background: rgba(0,0,0,.25); }
.cs-head {
  flex: 0 0 auto;
  position: sticky; top: -22px; z-index: 1;
  height: 37px; display: flex; align-items: center; justify-content: center;
  background: #c57930; color: #f0f0f0;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
  font-weight: 800; font-size: 24px; letter-spacing: .04em;
}
.cs-item {
  flex: 0 0 auto; min-height: 67px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 4px;
  background: rgba(25,25,25,.85);
  border: 3px solid rgba(57,57,57,.31);
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
}
.cs-item .k { font-size: 22px; font-weight: 400; color: #f5f5f5; line-height: 1.15; }
.cs-item .v { font-size: 22px; font-weight: 800; color: #f5f5f5; line-height: 1.15; }
/* 先頭行の下・最終行の下に入る金の区切り線（Figma 136-67 node334:350/334:351 の書き出し）。
   まだ上/下に続きがあることを示す三角つき */
.cs-div {
  flex: 0 0 auto;
  height: 12.8px; margin: 1px 0;
  background: url("../assets/setup/summary-divider.svg") center/100% 100% no-repeat;
}
.cs-div.up { transform: rotate(180deg); }

/* 準備完了ボタン: 金の飾りプレート（Figma 349-360 node350:464）＋墨字 */
#setup-kaisen {
  left: 50%; top: 906px; width: 671px; height: 131px; transform: translateX(-50%);
  background: url("../assets/setup/btn-ready.png") center/100% 100% no-repeat;
  border: none;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .55));
}
#setup-kaisen .kaisen-label {
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
  font-weight: 800; font-size: 62px; letter-spacing: .08em;
  color: #2a1204;
  transform: translateY(2px);
}
#setup-kaisen:hover { filter: drop-shadow(0 0 20px rgba(244, 195, 113, .75)); }
#setup-kaisen:active { transform: translateX(-50%) scale(.99); }
/* ゲストが準備完了を押したあと（もう一度押すと解除）。押し済みだと一目で分かるよう落とす */
#setup-kaisen.done { filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .55)) saturate(.5) brightness(.78); }
#setup-kaisen.done .kaisen-label { color: #4a3a28; }
#setup-kaisen.done:hover { filter: drop-shadow(0 0 14px rgba(244, 195, 113, .45)) saturate(.6) brightness(.85); }

/* =====================  画面3: 開戦カットイン  ===================== */
#setup-cutin { position: absolute; inset: 0; overflow: hidden; }
#setup-cutin.hidden { display: none; }
#setup-cutin .cutin-stage { }
.cutin-bg {
  position: absolute; inset: -2%;
  width: 104%; height: 104%;
  object-fit: cover;
}
.cutin-emblem {
  position: absolute;
  left: 50%; top: 50%;
  width: 844px; height: 563px;   /* Figma 158-94 node329:122 */
  object-fit: contain;
  transform: translate(-50%, -50%) scale(.4);
  opacity: 0;
  animation: cutinEmblem .7s cubic-bezier(.2,1.4,.4,1) .15s forwards;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,.6));
}
@keyframes cutinEmblem {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(.35) rotate(-8deg); }
  100% { opacity: 1; transform: translate(-50%,-50%) scale(1) rotate(0); }
}
.cutin-fig {
  position: absolute;
  opacity: 0;
}
.cutin-fig img {
  display: block; width: 100%; height: 100%;
  object-fit: contain; object-position: bottom center;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.55));
}
.cutin-plate {
  position: absolute;
  background: center/contain no-repeat;
  opacity: 0;
}
/* Figma 158-94: CPU名札は新プレート(plate-diff)416×134、プレイヤーは588×280 */
.cutin-plate.cpu {
  background-image: url("../assets/setup/plate-diff.png");
  width: 416px; height: 134px;
}
.cutin-plate.player {
  background-image: url("../assets/setup/plate-player.png");
  width: 588px; height: 280px;
}
/* 新プレートは右側の暗いボックスに難易度テキストを配置 */
.cutin-plate.cpu .cpu-diff {
  position: absolute; left: 63%; top: 54%; transform: translate(-50%,-50%);
  color: #f3d99d; font-weight: 800; font-size: 30px; white-space: nowrap;
  text-shadow: 0 2px 4px rgba(0,0,0,.85);
}

/* 各カットインパーツのスライドイン */
.cutin-in-l { animation: cutinL .55s ease forwards; }
.cutin-in-r { animation: cutinR .55s ease forwards; }
.cutin-in-t { animation: cutinT .55s ease forwards; }
.cutin-in-b { animation: cutinB .55s ease forwards; }
@keyframes cutinL { from { opacity: 0; transform: translateX(-90px); } to { opacity: 1; transform: translateX(0); } }
@keyframes cutinR { from { opacity: 0; transform: translateX(90px); }  to { opacity: 1; transform: translateX(0); } }
@keyframes cutinT { from { opacity: 0; transform: translateY(-70px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cutinB { from { opacity: 0; transform: translateY(70px); }  to { opacity: 1; transform: translateY(0); } }

/* =====================  開戦確認モーダル（Figma 345-165 / 346-271）  ===================== */
#setup-confirm {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  background: rgba(14, 21, 34, .8);   /* #0e1522 / 80% */
}
#setup-confirm.hidden { display: none; }
/* パネル基準の絶対配置（%はパネル幅基準で解決される）。Figma座標に準拠 */
.confirm-panel {
  position: relative;
  /* 幅は「画面の62%」。PCでは 880px で頭打ちになるが、その頭打ちが効くのは
     #app が 1420px 以上のときで、実質どのPCでも 62% 前後になる。
     以前は 92cqw だったため**スマホだけ画面の92%**になり、
     ダイアログが画面を埋めてしまっていた（PCと比率が揃っていなかった） */
  width: min(880px, 62cqw); aspect-ratio: 939 / 448;
  background: url("../assets/setup/dlg-panel.png") center/100% 100% no-repeat;
}
.confirm-msg {
  position: absolute; left: 50%; top: 29%; transform: translate(-50%, -50%);
  width: 84%;
  color: #f0f0f0;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 700; font-size: clamp(15px, 3.1cqmin, 32px); line-height: 1.8;
  text-align: center; text-shadow: 0 2px 6px rgba(0,0,0,.6);
}
.confirm-yes {
  position: absolute; left: 31%; top: 70%; transform: translate(-50%, -50%);
  width: 33%; aspect-ratio: 302 / 80;
  background: url("../assets/setup/dlg-yes.svg") center/100% 100% no-repeat;
  border: 0; padding: 0; cursor: pointer;
  color: #fff; font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
  font-weight: 700; font-size: clamp(16px, 3.1cqmin, 32px);
  transition: filter .12s ease, transform .12s ease;
}
.confirm-yes:hover { filter: brightness(1.14); transform: translate(-50%, -50%) scale(1.03); }
.confirm-yes:active { transform: translate(-50%, -50%) scale(.98); }
.confirm-no {
  position: absolute; left: 69%; top: 70%; transform: translate(-50%, -50%);
  width: 33%; aspect-ratio: 302 / 80;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; padding: 0; cursor: pointer;
  color: #767676; font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
  font-weight: 700; font-size: clamp(16px, 3.1cqmin, 32px);
  transition: color .12s ease;
}
.confirm-no:hover { color: #b9b9b9; }
/* 知らせるだけのモーダル（準備完了待ち等）: 「いいえ」を消して「閉じる」を中央に */
#setup-confirm.notice .confirm-no { display: none; }
#setup-confirm.notice .confirm-yes { left: 50%; }
/* いいえ選択時：はいと同じ金枠で「選んだ」ことを示す */
.confirm-no.selected {
  background: url("../assets/setup/dlg-yes.svg") center/100% 100% no-repeat;
  color: #fff;
}

/* 参加エラーダイアログ（Figma 347-338）。確認モーダルと同じパネルを流用し、
   ボタンが無いのでメッセージを中央に置く。タップで閉じる。 */
#setup-error {
  position: fixed; inset: 0; z-index: 71;
  display: flex; align-items: center; justify-content: center;
  background: rgba(14, 21, 34, .8); cursor: pointer;
}
#setup-error.hidden { display: none; }
.error-panel { cursor: default; }
.error-panel .confirm-msg { top: 50%; }

/* 縦持ちスマホ：横スクロールを避けつつステージ縮小で対応（JSがscale）。
   小画面ではサマリ文字を少し詰める */
@media (max-width: 700px) {
  .cs-head { font-size: 22px; }
  .cs-item .k, .cs-item .v { font-size: 20px; }
}

/* =====================  ルール説明（マニュアル）  =====================
   #mode-manual / 設定モーダルの「ルール説明」から開く全画面オーバーレイ。
   ルール設定画面と同じ金枠パネル(panel.png)を同じ寸法で使い、左に章タブ、
   右にスクロールする本文を置く。中身は js/client/manual.js が構築する。 */
#manual-wrap {
  position: fixed; inset: 0;
  z-index: 80;                 /* タイトル(70)・確認ダイアログ(71)より前面 */
  background: #1a0d0a url("../assets/setup/scene-bg.png?v=3") center/cover no-repeat;
  overflow: hidden;
  font-family: "Shippori Mincho B1", "Yu Mincho", serif;
}
#manual-wrap.hidden { display: none; }

/* パネルはルール設定画面(#setup-panel)と同じ位置・寸法にして画面の作りを揃える */
#manual-panel {
  position: absolute;
  left: 167px; top: 64px; width: 1587px; height: 835px;
  background: url("../assets/setup/panel.png") center/100% 100% no-repeat;
}

/* ---- 左：章タブ ---- */
#manual-tabs {
  position: absolute;
  left: 90px; top: 76px; width: 326px; bottom: 60px;
  display: flex; flex-direction: column; gap: 9px;
  overflow-y: auto; overflow-x: hidden;
  padding-right: 6px;
}
/* タブ列と本文のあいだの金の縦線 */
#manual-tabs::after {
  content: "";
  position: absolute; left: 344px; top: 4px; bottom: 4px;
  width: 3px;
  background: linear-gradient(180deg, transparent, #d9a441 10%, #f4c371 50%, #d9a441 90%, transparent);
  box-shadow: 0 0 6px rgba(244,195,113,.45);
}
.mn-tab {
  flex: 0 0 auto;
  height: 68px;
  padding: 0 10px;
  background: rgba(20, 10, 6, .5);
  border: 2px solid rgba(244, 195, 113, .3);
  border-radius: 6px;
  color: #e8c78f;
  font-family: "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 700; font-size: 28px; letter-spacing: .04em;
  white-space: nowrap;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.mn-tab:hover { border-color: rgba(244,195,113,.75); color: #f9dcae; background: rgba(60,26,12,.6); }
.mn-tab.on {
  background: linear-gradient(180deg, #f4c371, #d9a441);
  border-color: #ffe6b4;
  color: #3a1206;
  text-shadow: 0 1px 1px rgba(255,236,190,.45);
  box-shadow: 0 0 14px rgba(244,195,113,.4);
}

/* ---- 右：本文 ---- */
#manual-body {
  position: absolute;
  left: 462px; right: 70px; top: 76px; bottom: 60px;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  padding-right: 22px;
  color: #f2e5d1;
  font-size: 26px; line-height: 1.8;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
#manual-tabs::-webkit-scrollbar,
#manual-body::-webkit-scrollbar { width: 10px; }
#manual-tabs::-webkit-scrollbar-thumb,
#manual-body::-webkit-scrollbar-thumb { background: rgba(244,195,113,.5); border-radius: 6px; }
#manual-tabs::-webkit-scrollbar-track,
#manual-body::-webkit-scrollbar-track { background: rgba(0,0,0,.2); }

.mn-title {
  margin: 0 0 18px;
  color: #f4c371;
  font-size: 44px; font-weight: 800; letter-spacing: .06em;
  text-shadow: 0 2px 6px rgba(0,0,0,.7);
}
.mn-h {
  margin: 32px 0 12px;
  padding-bottom: 6px;
  color: #f4c371;
  font-size: 32px; font-weight: 800; letter-spacing: .04em;
  border-bottom: 2px solid rgba(244,195,113,.42);
}
.mn-title + .mn-h { margin-top: 6px; }
.mn-p { margin: 0 0 14px; }
.mn-p b, .mn-x b, .mn-ul b, .mn-t b { color: #ffdda2; font-weight: 800; }

/* このゲーム特有のルール（金の縦帯で目立たせる） */
.mn-x {
  margin: 0 0 14px;
  padding: 12px 20px;
  border-left: 7px solid #f4c371;
  background: rgba(244, 195, 113, .11);
}

.mn-ul { margin: 0 0 16px; padding: 0; list-style: none; }
.mn-ul li { position: relative; padding-left: 30px; margin-bottom: 8px; }
.mn-ul li::before {
  content: "";
  position: absolute; left: 8px; top: .72em;
  width: 10px; height: 10px;
  background: #f4c371;
  transform: rotate(45deg);
  box-shadow: 0 0 5px rgba(244,195,113,.6);
}

.mn-t {
  width: 100%;
  margin: 0 0 20px;
  border-collapse: collapse;
  font-size: 24px; line-height: 1.55;
}
.mn-t th {
  padding: 9px 16px;
  background: rgba(197, 121, 48, .8);
  color: #fff3de;
  font-weight: 800;
  text-align: left;
  border: 1px solid rgba(244,195,113,.4);
  white-space: nowrap;
}
.mn-t td {
  padding: 9px 16px;
  border: 1px solid rgba(244,195,113,.26);
  background: rgba(24, 10, 6, .38);
  vertical-align: top;
}
.mn-t tbody tr:nth-child(even) td { background: rgba(24, 10, 6, .2); }
/* 1列目は項目名なので折り返さず、残りを2列目に使わせる */
.mn-t td:first-child { white-space: nowrap; color: #f7e3c0; font-weight: 700; }

/* ---- 下部：閉じるボタン（pill-on.png を素の縦横比で使う） ---- */
#manual-close {
  position: absolute;
  left: 50%; top: 915px;
  width: 380px; height: 148px;
  transform: translateX(-50%);
  background: url("../assets/setup/pill-on.png") center/100% 100% no-repeat;
  border: 0; padding: 0; cursor: pointer;
  color: #300a03;
  font-family: "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 800; font-size: 40px; letter-spacing: .1em;
  text-shadow: 0 1px 1px rgba(255,236,190,.45);
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.5));
  transition: transform .12s ease, filter .12s ease;
}
#manual-close:hover { transform: translateX(-50%) scale(1.035); filter: drop-shadow(0 0 22px rgba(240,200,110,.6)); }
#manual-close:active { transform: translateX(-50%) scale(.99); }

/* =====================  画面0b: プロフィール（Figma 111-291）  ===================== */
/* タブ：モード選択のピル画像を流用（Figmaも pill-on/off と同一データだった） */
.pf-tab {
  position: absolute;
  border: 0; padding: 0; cursor: pointer;
  background: url("../assets/setup/pill-off.png?v=2") center/100% 100% no-repeat;
  color: #f4c371;
  font-family: "BIZ UDMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 700; font-size: 32px; letter-spacing: .04em; white-space: nowrap;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .5));
  transition: filter .12s ease, transform .12s ease;
}
.pf-tab.on {
  background-image: url("../assets/setup/pill-on.png?v=2");
  color: #300a03;
}
.pf-tab:hover { filter: drop-shadow(0 0 14px rgba(244, 195, 113, .6)); }
.pf-tab:active { transform: scale(.99); }
#pf-tab-char { left: 947px; top: 98px;  width: 347px; height: 135px; }
#pf-tab-name { left: 1274px; top: 102px; width: 350px; height: 132px; }

/* 中央の赤枠パネル */
.pf-panel {
  position: absolute;
  left: 743px; top: 186px; width: 1084px; height: 819px;
  background: url("../assets/setup/profile-panel.png") center/100% 100% no-repeat;
  filter: drop-shadow(0 10px 26px rgba(0, 0, 0, .55));
}

/* キャラ枠 4×2。座標は Figma 実測（枠209、行間345、列間259） */
.pf-grid { position: absolute; inset: 0; }
.pf-grid.hidden { display: none; }
.pf-slot {
  position: absolute;
  width: 209px; height: 209px;
  border: 0; padding: 0;
  background: #d9d9d9;
  border-radius: 3px;
  cursor: default;
  overflow: hidden;
}
.pf-slot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pf-slot.open { cursor: pointer; }
.pf-slot.open:hover { filter: brightness(1.08); }
/* 未解放：グレー地に鍵 */
.pf-lock {
  position: absolute;
  width: 128px; height: 128px;
  background: url("../assets/setup/profile-lock.png") center/contain no-repeat;
  pointer-events: none;
}
/* 名前プレート */
.pf-plate {
  position: absolute;
  width: 215px; height: 62px;
  background: url("../assets/setup/profile-name.png") center/100% 100% no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: #e3e5d9;
  font-family: "BIZ UDMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  font-weight: 700; font-size: 24px; letter-spacing: .02em; white-space: nowrap;
  pointer-events: none;
}
/* 選択中の枠（キャラ枠＋名前プレートをまとめて囲う。Figma node619:219）。
   淡い黄色を「敷く」意匠なので、キャラ絵とプレートより後ろに置く（z-index:0）。
   前に出すと 60% の塗りで顔が白く飛ぶ */
.pf-sel {
  position: absolute;
  z-index: 0;
  background: rgba(251, 255, 198, .6);
  border: 8px solid rgba(238, 251, 181, .64);
  pointer-events: none;
  transition: left .14s ease, top .14s ease;
}
.pf-slot, .pf-lock, .pf-plate { z-index: 1; }

/* プレイヤー名変更タブ */
.pf-nameedit {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px;
  font-family: "BIZ UDMincho", "Shippori Mincho B1", "Yu Mincho", serif;
}
.pf-nameedit.hidden { display: none; }
.pf-ne-label { color: #f4c371; font-size: 34px; font-weight: 700; letter-spacing: .08em; }
.pf-ne-input {
  width: 620px; height: 92px;
  padding: 0 24px;
  background: rgba(20, 10, 6, .55);
  border: 2px solid rgba(244, 195, 113, .55);
  border-radius: 6px;
  color: #f2e5d1;
  font-family: inherit; font-weight: 700; font-size: 40px; letter-spacing: .06em;
  text-align: center;
  outline: none;
}
.pf-ne-input:focus { border-color: #f4c371; box-shadow: 0 0 14px rgba(244, 195, 113, .4); }
.pf-ne-ok {
  width: 260px; height: 86px;
  border: 0; padding: 0; cursor: pointer;
  background: url("../assets/setup/pill-on.png?v=2") center/100% 100% no-repeat;
  color: #300a03;
  font-family: inherit; font-weight: 700; font-size: 32px; letter-spacing: .08em;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .5));
  transition: filter .12s ease, transform .12s ease;
}
.pf-ne-ok:hover { filter: drop-shadow(0 0 14px rgba(244, 195, 113, .65)); }
.pf-ne-ok:active { transform: scale(.98); }
.pf-ne-note { margin: 0; min-height: 30px; color: #ffd7a0; font-size: 24px; font-weight: 700; }

/* =====================  友人招待（QR）  ===================== */
#invite-qr {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 4, 3, .72);
}
#invite-qr.hidden { display: none; }
/* 枠画像(1815x866)は .confirm-panel の aspect-ratio 939/448 のまま横長で使う。
   縦に伸ばすと飾り罫が歪むので、中身は「左にQR・右に説明」の横並びで枠に収める。
   container-type:size にして中の寸法を枠の幅(cqw)基準にすると、
   ウィンドウが変わってもレイアウトが崩れない（中身が枠を押し広げることも無い）。 */
.iq-panel {
  position: relative;
  /* 高さは幅/2.0958。低いウィンドウでもはみ出さないよう cqh でも頭を押さえる */
  width: min(1120px, 92cqw, 178cqh);
  container-type: size;
  /* QRの幅と、QR〜説明の間隔。タイトルの中央合わせもこの2つから計算する */
  --iq-qr: 29.5cqw;
  --iq-gap: 4cqw;
  display: flex; flex-direction: column; align-items: center;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", "Yu Mincho", serif;
  color: #f2e5d1;
}
/* 内側の余白は padding ではなく子の margin で取る。
   padding を cqw で書くと「枠の内寸→cqw→padding→内寸」と循環してしまうため */
.iq-close {
  /* 枠の右上角に重ねる（中心が角に来るよう半分だけ外に出す）。
     はみ出す量は 2.2cqw ＝ パネルが最大幅のときの左右の余白より小さいので画面外に出ない */
  position: absolute; right: -2.8cqw; top: -2.8cqw;
  width: 5.6cqw; height: 5.6cqw;
  background: rgba(16, 8, 4, .92);
  border: .22cqw solid rgba(244, 195, 113, .75); border-radius: 50%;
  /* 隅飾りの金色に埋もれないよう、真下の影＋全周の暗い暈しでボタンを浮かせる */
  box-shadow: 0 .5cqw 1.1cqw rgba(0, 0, 0, .85), 0 0 1.6cqw rgba(0, 0, 0, .7);
  color: #ffd9a0; font-size: 3.6cqw; line-height: 1; cursor: pointer;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.iq-close:hover { color: #300a03; background: #f4c371; border-color: #ffe6b4; }
/* タイトルはパネル全体ではなく **右側の説明列の中央** に合わせる（ユーザー指示）。
   align-items:center の項目は「margin込みの箱」が中央に来るので、
   左に (QR幅 + 間隔) ぶんの margin を入れると、中身がちょうどその半分だけ右へ寄る */
.iq-title {
  margin-top: 10.4cqw;  /* 元3.9 + 50px(4.7cqw) + 20px(1.8cqw)。ユーザー指示で下げた */
  margin-left: calc(var(--iq-qr) + var(--iq-gap));
  color: #f4c371; font-weight: 800; font-size: 3.6cqw; line-height: 1.25; letter-spacing: .1em;
}
/* QRと説明の横並び。残りの高さいっぱいを使って上下中央に置く */
.iq-body {
  flex: 1; min-height: 0; width: 86cqw;
  margin: 1.4cqw 0 3.6cqw;
  display: flex; align-items: center; justify-content: center; gap: var(--iq-gap);
}
.iq-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 1.8cqw;
}
/* QRは白地でないと読めないので、余白ごと白の板に載せる */
.iq-qr {
  flex: none;
  width: var(--iq-qr); height: var(--iq-qr);
  /* QRだけパネルの上下中央に置く（ユーザー指示）。タイトルを下げたぶん .iq-body が
     下に寄っているので、その差だけ transform で戻す。レイアウトは動かさない＝
     左右の位置と説明文の配置はそのまま。中身は全部 cqw 基準なのでこの差も比率で一定 */
  transform: translateY(-6.4cqw);
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: .55cqw solid #f4c371; border-radius: 6px;
  color: #300a03; font-size: 1.9cqw; text-align: center;
}
.iq-qr img { display: block; width: 92%; height: 92%; image-rendering: pixelated; }
.iq-url {
  max-width: 100%;
  color: #e8c78f; font-size: 1.9cqw; letter-spacing: .02em;
  word-break: break-all; text-align: center;
}
.iq-switch { display: flex; flex-wrap: wrap; gap: .9cqw; justify-content: center; }
.iq-switch .iq-swlabel { width: 100%; text-align: center; color: rgba(232,199,143,.7); font-size: 1.6cqw; }
.iq-switch button {
  padding: .7cqw 1.6cqw;
  background: rgba(20, 10, 6, .5);
  border: 1px solid rgba(244, 195, 113, .35);
  color: #e8c78f; font-family: inherit; font-weight: 700; font-size: 1.8cqw;
  cursor: pointer; border-radius: 5px;
}
.iq-switch button.on {
  color: #300a03; background: linear-gradient(180deg, #f4c371, #d9a441); border-color: #ffe6b4;
}
.iq-note { margin: 0; color: #f2e5d1; font-size: 2.6cqw; line-height: 1.5; text-align: center; }
/* LAN内のIPを配っているときの但し書き。「同じWi-Fiだけ」の部分を目立たせる */
.iq-note b { color: var(--gold-bright, #f4c371); font-weight: 800; }

/* ゲスト（QRで参加）は席の操作ができない。ホストの操作だけ伏せる。
   準備完了ボタン(#setup-kaisen)はゲストにも出す＝押すと「準備完了」の表明になる
   （開戦できるのはホストだけ。ボタンの中身は setup.js が出し分ける） */
#setup-cpu.guest .slot-close,
#setup-cpu.guest .slot-actions,
#setup-cpu.guest .back-label,
#setup-cpu.guest .setup-back { display: none; }
#setup-cpu.guest .cpu-card.selectable { cursor: default; }
/* ホストがまだ決めていない席。ゲストは招待もCPU追加もできないのでボタンは出さず、
   代わりに「空席」とだけ見せる（何も無いと空の板に見えて壊れて見える） */
#setup-cpu.guest .cpu-card.empty-slot::before {
  content: "空席";
  position: absolute; left: 0; right: 0; top: 430px; z-index: 3;
  color: rgba(242, 229, 209, .8); text-align: center;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
  font-weight: 800; font-size: 40px; letter-spacing: .12em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .7);
}
#setup-cpu.guest .cpu-card.selectable:hover { box-shadow: 0 6px 18px rgba(0,0,0,.5); }
/* ゲストには「ホストの開始を待っています」を出す */
#setup-cpu.guest .cpu-cards::after {
  content: "ホストが開始するまでお待ちください";
  /* 横位置は**準備完了ボタンに合わせる**。.cpu-cards は left:82 / 幅1540 なので
     中心は設計 852px で、ステージ中央(960)＝ボタンの中心より 108px 左にずれていた。
     この擬似要素の基準は .cpu-cards なので 960-82=878 を指定する */
  position: absolute; left: 878px; top: 700px; transform: translateX(-50%);
  color: #f4c371;
  font-family: "BIZ UDPMincho", "Shippori Mincho B1", serif;
  font-weight: 700; font-size: 34px; letter-spacing: .06em; white-space: nowrap;
  text-shadow: 0 2px 6px rgba(0,0,0,.8);
}

/* ============================================================
   待機画面（ルール確認）の「全画面にしてください」案内
   ============================================================
   対局が始まってから全画面ボタンを押すと、ブラウザが必ず出す
   「終了するには…」の通知が数秒間 手牌に重なり、その間 牌が選べなくなる
   （消せない。脱出手段を保証するためのブラウザ仕様。ユーザー被害あり 2026-08-09）。
   なので**始まる前のこの画面で済ませてもらう**。対局中のボタンは有効なままにする。

   出す条件（すべてCSSで判定。JSは閉じるボタンだけ）:
     - タッチ端末（pointer: coarse）… PCは全画面必須ではないので出さない
     - まだ全画面でない（body.fs-on が付いていない。付けるのは lobby.js）
     - 全画面APIがある（body.no-fs が付いていない。iPhone Safari 等では出さない）
     - 閉じられていない（body.fs-tip-off。その場限りで、開き直せばまた出る）
     - 待機画面が表示中（#setup-cpu:not(.hidden)）
   全画面に入った瞬間 body.fs-on が付くので、案内も光りも自動で消える。 */
.fs-tip {
  position: absolute;
  /* 背景は assets/setup/fs-tip-bg.png（214×75）。実測した中身:
       三角  … x127〜131（中心＝幅の 60.28%）／ y2〜6
       本体  … y7〜72（上端＝高さの 9.33%）、色 rgb(47,27,17)・縁 rgb(145,112,70)
     三角が中央ではなく右寄りなので、**枠の中心ではなく三角が全画面ボタンを指す**
     ように左右位置を決める。ボタン中心はステージ右から302px（右上3つは
     right:30 / 96px / gap16 で、左端の全画面の中心が 1618px）。
       枠の左端 = 1618 − 0.6028×680 = 1208 → 右端 1888 ＝ right:32px
     縦は三角の頂点（上から 2/75×238 ≒ 6px）がボタン下端(126)の16px下に来る位置。
       top = 142 − 6 = 136
     画像と同じ比率（214:75）で 680×238。文言や幅を変えるときはこの計算をやり直すこと */
  right: 32px; top: 136px;
  width: 680px; height: 238px;
  padding: 30px 30px 14px;   /* 上は三角の帯（22px）を含む */
  background: url("../assets/setup/fs-tip-bg.png") center/100% 100% no-repeat;
  color: #f7e9d2;
  text-align: center;   /* 見出しも本文もまとめて中央揃え */
  z-index: 7;
  display: none;        /* 出すときは flex（下の @media 参照） */
  flex-direction: column;
  justify-content: center;
}
/* 中央揃えなので、閉じるボタンよけの padding は入れない（入れると中心がずれる）。
   見出し1行目は12字＝360pxで右端は520px、×は622〜666pxなので衝突しない。
   2行目(600px)は×より下の行なので無関係 */
.fs-tip-title {
  /* 2行目「対局を始める前に全画面表示にしてください。」は全角21字。
     30pxだと630pxで内寸620pxを超えて折り返すため28px（588px）にした。
     文言を長くするときはここか枠幅を見直すこと */
  font: 700 28px/1.45 "Zen Kaku Gothic New", sans-serif;
  color: #f4c371;
}
.fs-tip-title b { color: #ffe9b0; }
.fs-tip-note {
  margin-top: 10px;
  font: 500 23px/1.6 "Zen Kaku Gothic New", sans-serif;
  color: rgba(247, 233, 210, .85);
}
/* 三角の帯を避けて本体の中に置く */
.fs-tip-close {
  position: absolute; right: 14px; top: 26px;
  width: 44px; height: 44px;
  background: none; border: 0; padding: 0;
  color: #f4c371; font-size: 32px; line-height: 1; cursor: pointer;
}

@media (pointer: coarse) {
  body:not(.fs-on):not(.no-fs):not(.fs-tip-off) #setup-cpu:not(.hidden) .fs-tip { display: flex; }
  /* どれを押せばいいか一目で分かるよう、全画面ボタンだけ金色に脈打たせる */
  body:not(.fs-on):not(.no-fs):not(.fs-tip-off) #setup-cpu:not(.hidden) #cpu-btn-fullscreen {
    border-color: #f4c371;
    color: #ffe9b0;
    animation: fsPulse 1.6s ease-in-out infinite;
  }
}
@keyframes fsPulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(0, 0, 0, .45), 0 0 0 0 rgba(244, 195, 113, .6); }
  50%      { box-shadow: 0 4px 14px rgba(0, 0, 0, .45), 0 0 0 16px rgba(244, 195, 113, 0); }
}
/* 動きを減らす設定では脈打たせず、金枠だけで示す */
@media (prefers-reduced-motion: reduce) {
  #cpu-btn-fullscreen { animation: none !important; }
}
