* {
  box-sizing: border-box;
}

:root {
  --bg: #eaf4ff;
  --panel: #ffffff;
  --accent: #4a90d9;
  --accent-dark: #2e6ba8;
  --text: #2b3a4a;
  --item-color: #4a90d9;
  --main-color: #f2994a;
  --special-color: #f2c94c;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background: linear-gradient(180deg, #d7ecff 0%, #f5fbff 100%);
  color: var(--text);
}

#app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 640px;
}
#game-screen.screen {
  max-width: 960px;
}

.hidden {
  display: none !important;
}

/* フルサイズ背景を敷く画面共通（#appのpaddingを打ち消して画面いっぱいに広げる） */
.screen-spread {
  /* 他の画面（ゲーム画面など）と縦のスクロール量を揃えるため、
     高さは常にビューポート基準に統一する（背景は cover でクロップされる） */
  position: relative;
  min-height: calc(100vh - 48px);
  margin: -24px;
  width: calc(100% + 48px);
  max-width: none;
  padding: 32px 24px;
  box-sizing: border-box;
  gap: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* タイトル画面 */
.title-screen-bg {
  background-image: url("assets/TITEL01.jpg");
}
.dp-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(43, 58, 74, 0.72);
  color: #ffd54f;
  font-weight: 900;
  font-size: 1rem;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  z-index: 2;
}
.sound-toggle-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(43, 58, 74, 0.72);
  color: #fff;
  border: none;
  font-size: 1.1rem;
  line-height: 1;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 2;
}
.sound-toggle-btn:hover {
  background: rgba(43, 58, 74, 0.9);
}
.sound-toggle-btn.muted {
  color: #9aa8b6;
}
.title-top,
.title-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 480px;
}
.title-top {
  gap: 0; /* ロゴとスタートボタンの間隔は下のmargin-topで個別に調整するため */
}
.title-bottom {
  margin-top: auto;
  padding-bottom: 8px;
}
#start-btn {
  font-size: 1.65rem;
  padding: 18px 48px;
}
.title-start-btn {
  position: relative;
  z-index: 2;
  /* ロゴを追加で上に動かした分（67px）を打ち消し、スタートボタン自体の画面上の位置は
     変更しない（-72pxだったが、ロゴのmargin-topが-48px→-115pxになった分だけ+67pxして相殺） */
  margin-top: -35px;
}
.title-logo {
  margin: 0;
  margin-top: -81px; /* 前回の移動量（67px）の半分（約34px）だけ下に戻した */
}
.title-logo img {
  display: block;
  width: 100%;
  max-width: 416px; /* 320px時代の1.3倍 */
  height: auto;
}
.btn {
  font-size: 1.1rem;
  padding: 12px 32px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: bold;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dark);
}
.btn-secondary {
  background: #fff;
  color: var(--accent-dark);
  border: 2px solid var(--accent);
  box-shadow: 0 4px 0 rgba(74, 144, 217, 0.25);
}
.btn-secondary:hover {
  background: #eaf4ff;
}
.btn-danger {
  background: #fff;
  color: #d3453e;
  border: 2px solid #e5847e;
  box-shadow: 0 4px 0 rgba(211, 69, 62, 0.25);
}
.btn-danger:hover {
  background: #fdecea;
}
.title-btn-row {
  display: flex;
  gap: 10px;
}
.title-btn-row-edge {
  /* ルールの説明は常に中央。デバッグボタン（通常モードではページから削除される）は
     行の右端に重ねて置き、ルールの説明の位置には影響させない（2026-09-20） */
  position: relative;
  width: 100%;
  justify-content: center;
}
.manual-link-row {
  display: flex;
  justify-content: center;
}
.manual-link {
  font-size: 0.82rem;
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 0.8;
}
.manual-link:hover {
  opacity: 1;
}
.title-btn-row-edge #debug-btn {
  position: absolute;
  right: -40px; /* ルールの説明（中央）と重ならないよう、行の外側へ少しはみ出して右寄せ */
  top: 0;
}

.ranking-box, #ranking-result {
  background: var(--panel);
  border-radius: 16px;
  padding: 16px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.ranking-box h2, #ranking-result h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--accent-dark);
  text-align: center;
}
.ranking-list {
  margin: 0;
  padding: 0 0 0 1.6em;
  font-size: 0.95rem;
}
.ranking-list li {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px dashed #ddd;
}
.ranking-list li span.name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}
.ranking-list .empty {
  color: #999;
  list-style: none;
  margin-left: -1.6em;
}

/* ゲーム画面 */
.game-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.board-wrap {
  position: relative;
  overflow: hidden;
}
.board-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 2px;
}
.score-badge {
  background: var(--panel);
  border-radius: 14px;
  padding: 2px 18px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
  text-align: left;
  flex: none;
}
/* スキル発動中、スコアの右隣に流れるお知らせ（掲示板のように左から右へゆっくり流れる） */
.skill-ticker {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 36px;
  overflow: hidden;
  background: var(--panel);
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}
.skill-ticker.hidden {
  display: none;
}
.skill-ticker-track {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--accent-dark);
}
.score-badge-label {
  font-size: 0.7rem;
  color: #8a9aac;
}
.score-badge-value {
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--accent-dark);
  line-height: 1.1;
}
#board {
  background: #ffffff;
  border: 2px solid var(--accent-dark);
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  display: block;
}
.pause-hint {
  margin-top: 0;
  text-align: center;
  font-size: 0.68rem;
  color: #6a7a8a;
}

.danger-banner {
  position: absolute;
  top: -22px;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: bold;
  color: #fff;
  background: #e5484d;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.85rem;
  animation: danger-blink 0.6s steps(1) infinite;
  box-shadow: 0 2px 8px rgba(229, 72, 77, 0.5);
}

@keyframes danger-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.25; }
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 260px;
}
.panel-block {
  background: var(--panel);
  border-radius: 14px;
  padding: 10px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.panel-block .label {
  font-size: 0.85rem;
  color: #8a9aac;
  margin-bottom: 6px;
}
.panel-block .value {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--accent-dark);
}
#next-canvas {
  display: block;
  background: #f4f8fc;
  border-radius: 10px;
  margin: 0 auto;
}
.stage-hud {
  text-align: center;
}
.stage-hud-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 8px;
}
.stage-hud-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.stage-hud .label {
  font-size: 1.1rem;
  font-weight: bold;
  color: #6a7a8a;
}
.stage-hud .value {
  font-size: 2.2rem;
}
.stage-hud-sub {
  font-size: 0.85rem;
  color: #8a9aac;
}
.stage-hud-remaining {
  font-size: 1.4rem;
  font-weight: bold;
  color: #e5844d;
  white-space: nowrap;
}
.remaining-infinity {
  display: inline-block;
  font-size: 2.4rem; /* 2026-09-16、視認性向上のため拡大（1.7rem→2.4rem） */
  line-height: 1;
  font-weight: 900;
  background: linear-gradient(90deg, #ff3b3b, #ff9a3b, #ffe83b, #3bff6e, #3bc6ff, #7a3bff, #ff3bd6, #ff3b3b);
  background-size: 400% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: remaining-infinity-shift 3s linear infinite;
}
@keyframes remaining-infinity-shift {
  0% { background-position: 0% 50%; }
  100% { background-position: 400% 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .remaining-infinity { animation: none; }
}
.corr-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.corr-panel .label {
  font-size: 0.9rem;
}
.corr-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #f4f8fc;
  border-radius: 10px;
  padding: 7px 8px;
}
.corr-row img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e0e8f0;
}
.corr-eq {
  font-weight: bold;
  color: var(--accent-dark);
  font-size: 1.1rem;
}
.corr-special {
  background: #fff9e0;
}
.corr-note {
  font-size: 0.8rem;
  color: #7a6a2a;
  line-height: 1.3;
}

/* 体験版終了画面 */
.demo-end-card {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: rgba(43, 58, 74, 0.72);
  padding: 32px 36px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.demo-end-title {
  font-size: 1.5rem;
  color: #fff;
  margin: 0;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.demo-end-link {
  display: inline-block;
  text-decoration: none;
}
.demo-end-sub {
  font-size: 1.1rem;
  color: #ffd54f;
  margin: 0;
  font-weight: bold;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.btn-disabled,
.btn-disabled:hover {
  background: #c7ced6 !important;
  color: #6b7580 !important;
  border-color: #c7ced6 !important;
  box-shadow: none !important;
  cursor: not-allowed;
}

/* ゲームオーバー画面 */
.gameover-screen-bg {
  background-image: url("assets/GAMEOVER3.jpg");
}
.gameover-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 480px;
  margin-top: 20vh; /* 背景画像の「配信終了」の文字の下まで下げる（2026-09-14、9vh→20vh） */
}
.gameover-retry-btn {
  font-size: 1.65rem;
  padding: 18px 48px;
  white-space: nowrap;
}
.final-score {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-height: 60px;
}
.final-score-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
#final-score-text {
  font-size: 2.8rem;
  font-weight: bold;
  line-height: 1.15;
  text-align: right;
  white-space: nowrap;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}
.final-score-dp {
  font-size: 1.3rem;
  font-weight: 900;
  white-space: nowrap;
  color: #ffd54f;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

.new-high-score-badge {
  background: linear-gradient(135deg, #ffd54f, #ff9800);
  color: #4a2600;
  font-weight: 900;
  font-size: 1rem;
  padding: 6px 16px;
  border-radius: 999px;
  margin-bottom: 8px;
  box-shadow: 0 0 18px rgba(255, 213, 79, 0.9), 0 4px 10px rgba(0, 0, 0, 0.3);
  animation: new-high-score-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), new-high-score-glow 1.4s ease-in-out infinite 0.5s;
}
@keyframes new-high-score-pop {
  0% { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes new-high-score-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 213, 79, 0.7), 0 4px 10px rgba(0, 0, 0, 0.3); }
  50% { box-shadow: 0 0 26px rgba(255, 213, 79, 1), 0 4px 10px rgba(0, 0, 0, 0.3); }
}
#gameover-screen #ranking-entry p,
#gameover-screen #ranking-entry h2,
#gameover-screen #ranking-result h2 {
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  margin: 0;
}
#ranking-entry, #ranking-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
#name-input {
  font-size: 1rem;
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid #ccc;
  width: 220px;
  text-align: center;
}
.redeem-input {
  font-size: 1rem;
  padding: 10px 14px;
  border-radius: 8px;
  border: 2px solid #ccc;
  width: 220px;
  text-align: center;
  display: block;
  margin: 14px auto;
  letter-spacing: 0.05em;
}
.redeem-message {
  font-size: 0.9rem;
  color: #d3453e;
  text-align: center;
  margin: 4px 0 0;
}

/* ステージ開始画面 */
.stage-intro-screen {
  cursor: pointer;
  justify-content: center;
  border-radius: 20px;
  padding: 32px 16px;
  /* 専用背景が無いステージ用のプレースホルダー */
  background: radial-gradient(circle at 50% 30%, #e9f5ff 0%, #cfe6fb 55%, #aed2f2 100%);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,0.6);
}
.stage-intro-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}
.stage-intro-title {
  margin: 0;
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--accent-dark);
  text-shadow: 3px 3px 0 #fff, -1px -1px 0 #fff;
  animation: gameover-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes gameover-pop {
  0% { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
/* ステージ専用のイラスト（見切れないよう全体を表示する） */
.stage-intro-bg-img {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}
.corr-panel-big {
  background: rgba(255,255,255,0.9);
  border-radius: 18px;
  padding: 22px 28px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  width: 100%;
  max-width: 560px;
}
.corr-panel-big .label {
  text-align: center;
  font-size: 1rem;
  margin-bottom: 14px;
}
/* 対応表の行コンテナ：登場キャラが増えて縦一列だと1画面に収まらなくなる分、
   横に並べて折り返す（少ない時は自然に1〜2列、多い時は自動で列が増える） */
#corr-rows-intro {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.corr-panel-big .corr-row {
  flex: 0 1 auto;
  gap: 12px;
  padding: 8px 12px;
}
/* レア駒の説明行だけは文章が入るので常に1行分の幅いっぱいを使う */
.corr-panel-big .corr-row.corr-special {
  flex-basis: 100%;
  justify-content: center;
}
.corr-panel-big .corr-row img {
  width: 56px;
  height: 56px;
}
.corr-panel-big .corr-eq {
  font-size: 1.2rem;
}
.corr-panel-big .corr-note {
  font-size: 1rem;
}
/* コレクション画面（スキン選択・アイテム保持） */
.collection-title {
  margin: 0;
  font-size: 2rem;
  color: var(--accent-dark);
  text-shadow: 2px 2px 0 #fff;
}
.collection-tabs {
  display: flex;
  gap: 8px;
  background: #e3edf7;
  border-radius: 999px;
  padding: 4px;
}
.collection-tab-btn {
  border: none;
  background: transparent;
  color: #6a7a8a;
  font-weight: bold;
  font-size: 0.9rem;
  padding: 8px 22px;
  border-radius: 999px;
  cursor: pointer;
}
.collection-tab-btn.active {
  background: var(--accent);
  color: #fff;
}
.collection-box {
  background: var(--panel);
  border-radius: 16px;
  padding: 18px 22px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.collection-box h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  color: var(--accent-dark);
}
.collection-hint {
  margin: 0 0 12px;
  font-size: 0.75rem;
  color: #8a9aac;
}
/* デバッグ操作ページ */
.debug-btn-row {
  display: flex;
  gap: 8px;
}
#debug-clear-all-confirm-row {
  flex-direction: column;
  align-items: flex-start;
  margin-top: 10px;
}
#debug-clear-all-confirm-row .btn {
  padding: 8px 20px;
  font-size: 0.95rem;
}
.debug-target-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.debug-stage-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.debug-stage-select-row input {
  width: 64px;
  font-size: 1rem;
  padding: 6px 8px;
  border-radius: 8px;
  border: 2px solid #ccc;
  text-align: center;
}
.debug-stage-select-row .collection-hint {
  margin: 0;
}
.debug-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.debug-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f8fc;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
}
.debug-toggle-row input {
  width: 16px;
  height: 16px;
}
.skin-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skin-slot {
  display: flex;
  align-items: center;
  gap: 8px;
}
.skin-slot-label {
  width: 56px;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: bold;
  color: #6a7a8a;
}
.skin-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.skin-option {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 3px solid #e0e8f0;
  background: #f4f8fc;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}
.skin-option img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.skin-option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.35);
}
.skin-option:disabled {
  cursor: default;
}
.skin-option.locked {
  opacity: 0.55;
  filter: grayscale(60%);
}
.skin-debug-unlock {
  align-self: center;
  border: none;
  background: #ffb74d;
  color: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: bold;
  cursor: pointer;
}
.skin-debug-unlock:hover {
  background: #ff9800;
}
.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* スキル一覧は件数が多く縦長になりやすいため2列表示にする（2026-09-14） */
#skill-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-items: stretch;
}
.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f4f8fc;
  border-radius: 10px;
  padding: 8px 12px;
}
.item-icon-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e0e8f0;
  flex-shrink: 0;
}
.item-text-wrap {
  flex: 1;
  min-width: 0;
}
.item-label {
  font-size: 0.85rem;
  font-weight: bold;
}
.item-desc {
  font-size: 0.68rem;
  color: #8a9aac;
  line-height: 1.3;
}
.item-count {
  font-weight: bold;
  color: var(--accent-dark);
  min-width: 2em;
  text-align: right;
}
.item-add-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}
.item-add-btn:hover {
  background: var(--accent-dark);
}
.item-add-btn:disabled {
  background: #c0c8d0;
  cursor: default;
}
.item-row-permanent {
  background: #fff9e8;
}
.item-row-unrevealed {
  justify-content: center;
  position: relative;
  min-height: 56px;
}
.item-row-unrevealed .item-icon-img {
  width: 48px;
  height: 48px;
}
.item-row-unrevealed .item-add-btn,
.item-row-unrevealed .skin-debug-unlock {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}
.item-icon-img.locked {
  opacity: 0.4;
  filter: grayscale(70%);
}
.item-count-permanent {
  color: #b0b8c0;
  font-size: 0.75rem;
}
.item-count-permanent.owned {
  color: #e5a100;
}
.item-unlock-btn {
  width: auto;
  padding: 0 10px;
  border-radius: 999px;
  background: #ffb74d;
}
.item-unlock-btn:hover {
  background: #ff9800;
}

/* ゲーム内アイテムバー */
.item-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.item-bar-btn {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 2px solid var(--accent);
  background: #fff;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}
.item-bar-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.item-bar-btn .item-bar-count {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 0.65rem;
  font-weight: bold;
  color: #fff;
  background: rgba(46, 107, 168, 0.85);
  border-radius: 6px;
  padding: 0 3px;
}
.item-bar-btn:disabled,
.item-bar-btn.used-up {
  border-color: #d0d8e0;
  cursor: default;
  opacity: 0.4;
}
.item-bar-btn:not(:disabled):hover {
  border-color: var(--accent-dark);
}
.item-bar-btn.item-boost-active {
  border-color: #ffd23f;
  animation: item-boost-glow 0.9s ease-in-out infinite;
}
.item-bar-btn.used-up.item-boost-active {
  opacity: 1;
}
@keyframes item-boost-glow {
  0%, 100% {
    box-shadow: 0 0 4px 1px rgba(255, 210, 63, 0.55);
  }
  50% {
    box-shadow: 0 0 12px 5px rgba(255, 210, 63, 0.95);
  }
}
.item-bar-btn-wrap {
  position: relative;
}
.item-bar-slot-empty {
  width: 52px;
  height: 52px;
  visibility: hidden;
}
.item-bar-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 180px;
  background: #2b3a4a;
  color: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.72rem;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
}
.item-bar-tooltip strong {
  font-size: 0.78rem;
  color: #ffd54f;
}
.item-bar-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #2b3a4a;
}
.item-bar-btn-wrap:hover .item-bar-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* コンティニュー確認画面 */
/* ガチャ画面 */
.gacha-screen-bg {
  background-image: url("assets/haikeig5.jpg");
  /* 画像が縦長なため、横長の画面では上下中央だとキャラが見切れる。
     下寄せにして、はみ出しは常に上側（キャラのいない部分）だけ削る */
  background-position: center bottom;
}
/* 画像（約4:5の縦長）より横長の画面では、cover だと数倍に拡大されて4人のうち2人しか映らない。
   その場合は画像全体を高さに合わせて表示し、左右の余白は同じ画像のぼかしで埋める。 */
@media (min-aspect-ratio: 4/5) {
  .gacha-screen-bg {
    background-image: none;
    isolation: isolate;
    overflow: hidden;
  }
  .gacha-screen-bg::before,
  .gacha-screen-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: url("assets/haikeig5.jpg") center / cover no-repeat;
  }
  .gacha-screen-bg::before {
    filter: blur(22px) brightness(0.92);
    transform: scale(1.1);
  }
  .gacha-screen-bg::after {
    background-size: contain;
  }
}
.gacha-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 17vh;
}
#gacha-back-btn {
  margin-top: 10px;
}
.gacha-dp-display {
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--accent-dark);
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 4px 14px;
}
.gacha-dp-warning {
  font-size: 0.8rem;
  font-weight: bold;
  color: #d9534f;
}
.gacha-pull-btn {
  font-size: 1.1rem;
  padding: 14px 30px;
  background: linear-gradient(135deg, #ff9800, #ff5f6d);
}
.gacha-pull-btn:hover {
  background: linear-gradient(135deg, #f57c00, #e0455a);
}

/* ガチャ演出（動画） */
.gacha-video-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.gacha-video-overlay.hidden {
  display: none;
}
.gacha-video {
  max-width: 100%;
  max-height: 100%;
}
.gacha-video-skip-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(20, 20, 30, 0.5);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.gacha-video-skip-btn:hover {
  background: rgba(20, 20, 30, 0.75);
}

/* ライブ配信のコメント欄風演出：動画・盤面・右パネルを無視して画面全体に重ねる。
   右から左へ流れ、背景の枠は無し（文字に縁取りをつけて視認性を確保する） */
.skill-comments-overlay {
  /* top/height はスコア～盤面1段目に合わせてJS側（startSkillComments/computeSkillCommentsArea）
     で実測して設定する（ただし3レーン分の最低の高さは下回らないようにする＝文字が被る事故を防止） */
  position: fixed;
  left: 0;
  width: 100%;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  pointer-events: none;
}
.skill-comments-overlay.hidden {
  display: none;
}
.skill-comments-lane {
  position: relative;
  height: 46px;
  width: 100%;
  overflow: hidden;
}
.skill-comment-item {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  white-space: nowrap;
  line-height: 1; /* 縦方向の余白を最小にし、隣のレーンとの被りを防ぐ */
  font-weight: 800;
  font-size: 1.65rem; /* 1.1rem の1.5倍 */
  color: #fff;
  text-shadow:
    -1px -1px 0 rgba(0, 0, 0, 0.85), 1px -1px 0 rgba(0, 0, 0, 0.85),
    -1px 1px 0 rgba(0, 0, 0, 0.85), 1px 1px 0 rgba(0, 0, 0, 0.85),
    0 0 8px rgba(0, 0, 0, 0.6);
}
/* レア駒登場時の情報コメントの色分け（情報①＝青、情報②＝赤、情報③＝金） */
.skill-comment-item.skill-comment-hint-1 {
  color: #4fc3f7;
}
.skill-comment-item.skill-comment-hint-2 {
  color: #ff5252;
}
.skill-comment-item.skill-comment-hint-3 {
  color: #ffd700;
}

/* ステージクリア演出：STAGEが左から、CLEAR!!が右から飛んでくる */
.stage-clear-banner {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  pointer-events: none;
  overflow: hidden;
}
.stage-clear-banner.hidden {
  display: none;
}
.stage-clear-text {
  font-style: italic;
  font-weight: 900;
  font-size: clamp(2.2rem, 9vw, 4.5rem);
  color: #fff;
  letter-spacing: 0.02em;
  text-shadow:
    0 0 10px rgba(255, 152, 0, 0.9),
    3px 3px 0 #e0601a, -3px -3px 0 #e0601a,
    3px -3px 0 #e0601a, -3px 3px 0 #e0601a;
}
.stage-clear-text-left {
  animation: stage-clear-fly-left 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.stage-clear-text-right {
  animation: stage-clear-fly-right 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes stage-clear-fly-left {
  from { transform: translateX(-120vw) rotate(-10deg); opacity: 0; }
  to { transform: translateX(0) rotate(-6deg); opacity: 1; }
}
@keyframes stage-clear-fly-right {
  from { transform: translateX(120vw) rotate(10deg); opacity: 0; }
  to { transform: translateX(0) rotate(6deg); opacity: 1; }
}

/* いろは自動発動演出：RESTARTの文字が下から出てくる */
.restart-banner {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
}
.restart-banner.hidden {
  display: none;
}
.restart-banner-text {
  font-style: italic;
  font-weight: 900;
  font-size: clamp(2.2rem, 9vw, 4.5rem);
  color: #fff;
  letter-spacing: 0.05em;
  text-shadow:
    0 0 10px rgba(79, 195, 247, 0.9),
    3px 3px 0 #1e6fa8, -3px -3px 0 #1e6fa8,
    3px -3px 0 #1e6fa8, -3px 3px 0 #1e6fa8;
  animation: restart-banner-rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes restart-banner-rise {
  from { transform: translateY(120vh); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ガチャ排出演出 */
.gacha-reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 40, 0.75);
  cursor: pointer;
  animation: gacha-overlay-fade-in 0.2s ease;
}

/* スキル発動演出：ゲームプレイ中に出るため、ガチャ演出と違って
   盤面の駒の位置がうっすら見える薄暗さに留める（全消し演出は対象外） */
.skill-video-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(12, 14, 24, 0.55);
  animation: gacha-overlay-fade-in 0.2s ease;
}
.skill-video-overlay.hidden {
  display: none;
}
.skill-video {
  max-width: min(90vw, 780px);
  max-height: min(80vh, 930px);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
/* スキルNO.1・NO.2だけ、他のスキルより大きい画面いっぱいのサイズで再生する（2026-09-14実装） */
.skill-video.skill-video-max {
  max-width: 100%;
  max-height: 100%;
  border-radius: 0;
  box-shadow: none;
}

/* 新規発動スキルのまとめ表示：配信終了画面に重ねる（配信終了画面が背景として透けて見える） */
.new-skills-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 40, 0.82);
  animation: gacha-overlay-fade-in 0.2s ease;
}
.new-skills-overlay.hidden {
  display: none;
}
.new-skills-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 20px;
  padding: 26px 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: gacha-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: min(90vw, 480px);
  max-height: 85vh;
  box-sizing: border-box;
}
.new-skills-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--accent-dark);
  text-align: center;
  margin: 0;
}
.new-skills-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  overflow-y: auto;
  max-height: 55vh;
  padding-right: 4px;
}
.new-skill-item {
  text-align: left;
  background: #f4f8fc;
  border-radius: 14px;
  padding: 12px 16px;
}
.new-skill-label {
  font-weight: bold;
  font-size: 1rem;
  color: var(--accent-dark);
}
.new-skill-difficulty {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: #e5a100;
  margin: 2px 0 6px;
}
.new-skill-desc {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
  margin: 0;
}

.gacha-reveal-overlay.hidden {
  display: none;
}
.gacha-reveal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 20px;
  padding: 22px 30px 26px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  animation: gacha-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 4px solid #ccc;
  width: 300px;
  box-sizing: border-box;
}
.gacha-reveal-card.rarity-sr {
  border-color: #9b6dff;
  box-shadow: 0 0 30px rgba(155, 109, 255, 0.7), 0 10px 30px rgba(0,0,0,0.4);
}
.gacha-reveal-card.rarity-legend {
  border-color: #ff9800;
  box-shadow: 0 0 40px rgba(255, 152, 0, 0.85), 0 10px 30px rgba(0,0,0,0.4);
  animation: gacha-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), gacha-ultra-glow 1.2s ease-in-out infinite;
}
.gacha-reveal-card.rarity-ultralegend {
  border-color: #ffd54f;
  box-shadow: 0 0 50px rgba(255, 213, 79, 1), 0 10px 30px rgba(0,0,0,0.4);
  animation: gacha-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), gacha-ultralegend-glow 1s ease-in-out infinite;
}
.gacha-reveal-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  min-height: 2.3em;
  justify-content: center;
}
.gacha-reveal-rarity {
  font-weight: 900;
  font-size: 1rem;
  color: #e5a100;
  min-height: 1.2em;
}
.gacha-reveal-rarity.hidden {
  visibility: hidden;
}
.gacha-reveal-img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: 14px;
  flex: none;
}
.gacha-reveal-label {
  font-weight: bold;
  font-size: 1.2rem;
  color: var(--accent-dark);
}
.gacha-reveal-desc {
  font-size: 0.85rem;
  color: var(--text);
  text-align: center;
  line-height: 1.5;
  width: 100%;
  min-height: 2.55em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gacha-reveal-caution {
  font-size: 0.75rem;
  color: #d9534f;
  text-align: center;
  width: 100%;
  min-height: 1.1em;
}
.gacha-reveal-caution.hidden {
  visibility: hidden;
}
.gacha-reveal-hint {
  font-size: 0.75rem;
  color: #9aa8b6;
}
.stage-result-hint-highlight {
  color: #ff5252;
  font-size: 1.25em;
  font-weight: 800;
}
.skill-reveal-difficulty {
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: #e5a100;
}
.skill-difficulty {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: #e5a100;
  margin-top: 2px;
}
.skill-row {
  cursor: pointer;
  justify-content: flex-start;
}
.skill-row:hover {
  background: #eaf4ff;
}
.skill-row-label {
  font-weight: bold;
  color: var(--accent-dark);
  font-size: 0.95rem;
}
.skill-detail-video {
  width: 100%;
  max-width: 480px;
  border-radius: 12px;
  background: #000;
}
.skill-detail-label {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--accent-dark);
}
.skill-detail-box {
  text-align: left;
  max-width: 480px;
}
.skill-detail-box h2 {
  font-size: 0.9rem;
  color: var(--accent-dark);
  margin: 10px 0 4px;
}
.skill-detail-box h2:first-child {
  margin-top: 0;
}
.skill-detail-text {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0;
  line-height: 1.5;
}
.gacha-convert-title {
  font-weight: bold;
  font-size: 1.05rem;
  color: var(--accent-dark);
  text-align: center;
}
.gacha-convert-dp {
  font-weight: 900;
  font-size: 2rem;
  color: #e5a100;
}

.stage-result-card {
  width: 320px;
  gap: 14px;
}
.stage-result-title {
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--accent-dark);
  text-align: center;
}
.stage-result-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.stage-result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.95rem;
  color: #555;
  padding: 4px 2px;
  border-bottom: 1px dashed #ddd;
}
.stage-result-row span:last-child {
  font-weight: 700;
  color: #333;
  font-variant-numeric: tabular-nums;
}
.stage-result-row-total {
  border-bottom: none;
  border-top: 2px solid #ccc;
  margin-top: 4px;
  padding-top: 10px;
  font-size: 1.1rem;
  color: var(--accent-dark);
}
.stage-result-row-total span:last-child {
  font-size: 1.3rem;
  color: #e5a100;
}

@keyframes gacha-overlay-fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes gacha-pop {
  0% { transform: scale(0.3) rotate(-6deg); opacity: 0; }
  70% { transform: scale(1.12) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes gacha-ultra-glow {
  0%, 100% { box-shadow: 0 0 40px rgba(255, 152, 0, 0.85), 0 10px 30px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 60px rgba(255, 152, 0, 1), 0 10px 30px rgba(0,0,0,0.4); }
}
@keyframes gacha-ultralegend-glow {
  0%, 100% { box-shadow: 0 0 50px rgba(255, 213, 79, 1), 0 10px 30px rgba(0,0,0,0.4); }
  33% { box-shadow: 0 0 60px rgba(255, 109, 200, 1), 0 10px 30px rgba(0,0,0,0.4); }
  66% { box-shadow: 0 0 60px rgba(109, 200, 255, 1), 0 10px 30px rgba(0,0,0,0.4); }
}

/* ルール説明画面 */
#rules-screen {
  max-width: 480px;
}
.rules-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}
.rule-card {
  background: var(--panel);
  border-radius: 18px;
  padding: 18px 20px;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  text-align: left;
}
.rule-card-danger {
  background: #fff2f2;
  box-shadow: 0 4px 12px rgba(217, 83, 79, 0.18);
}
.rule-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.rule-card-header h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--accent-dark);
}
.rule-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: bold;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.rule-card-danger .rule-step {
  background: #d9534f;
}
.rule-card p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}
.rule-illust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.rule-illust img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #f4f8fc;
  border-radius: 12px;
  border: 1px solid #e0e8f0;
  padding: 4px;
}
.rule-illust-plus,
.rule-illust-arrow {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent-dark);
}
.rule-illust-poof {
  font-size: 0.85rem;
  font-weight: bold;
  color: #ff6f00;
  text-align: center;
  line-height: 1.3;
}
.rule-demo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
#rule-demo-canvas {
  background: #f4f8fc;
  border-radius: 12px;
  border: 1px solid #e0e8f0;
}

/* あそびかた画面はカードが多く縦に長くなりやすいため、他画面より詰めて1画面に収める */
#rules-screen.screen {
  gap: 12px;
}
#rules-screen .collection-title {
  font-size: 1.6rem;
}
#rules-screen .rules-page {
  gap: 10px;
}
#rules-screen .rule-card {
  padding: 10px 18px;
}
#rules-screen .rule-card p {
  line-height: 1.45;
}
.rule-controls-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 1rem;
}
.rule-controls-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rule-controls-combo {
  gap: 18px;
  flex-wrap: wrap;
}
.rule-control-pair {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rule-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #eaf4ff;
  border: 1px solid #b8d4f0;
  color: var(--accent-dark);
  font-weight: bold;
  font-size: 0.85rem;
}

/* ガチャ排出率リンク・一覧画面（スクロールが出ないよう上部を詰める） */
#gacha-rates-screen {
  gap: 10px;
  max-width: 720px; /* 2026-09-10：排出率一覧を3列にするため画面幅を拡大 */
}
#gacha-rates-screen .collection-title {
  font-size: 1.6rem;
}
#gacha-rates-screen .collection-hint {
  margin: 0 0 4px;
}
#gacha-rates-screen .gacha-rates-box {
  padding: 12px 18px;
}

.gacha-rates-link {
  color: var(--accent-dark);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}
.gacha-rates-link:hover {
  color: var(--accent);
}
.gacha-rates-box {
  max-width: 680px; /* 2026-09-10：3列化に合わせて拡大（旧480px） */
}
.gacha-rates-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 2026-09-10：縦に長くなりすぎるため2列→3列に変更 */
  gap: 6px;
}
.gacha-rate-row-wrap {
  position: relative;
}
.gacha-rate-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  background: #f4f8fc;
  border-radius: 14px;
  padding: 8px 10px 7px;
}
.gacha-rate-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 200px;
  max-width: 60vw;
  background: #2b3a4a;
  color: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.7rem;
  line-height: 1.4;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
}
.gacha-rate-tooltip strong {
  font-size: 0.76rem;
  color: #ffd54f;
}
.gacha-rate-tooltip-caution {
  color: #ff8a8a;
}
.gacha-rate-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #2b3a4a;
}
.gacha-rate-row-wrap:hover .gacha-rate-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.gacha-rate-row img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e0e8f0;
  flex-shrink: 0;
  margin-bottom: 1px;
}
.gacha-rate-text {
  min-width: 0;
}
.gacha-rate-label {
  font-size: 0.8rem;
  font-weight: bold;
}
.gacha-rate-kind {
  font-size: 0.64rem;
  color: #8a9aac;
}
.gacha-rate-value {
  font-weight: 900;
  font-size: 0.88rem;
  color: var(--accent-dark);
  text-align: center;
}
.gacha-rate-value.tier-sr {
  color: #9b6dff;
}
.gacha-rate-value.tier-legend {
  color: #ff9800;
}
.gacha-rate-value.tier-ultralegend {
  color: #e5a100;
}

/* ==================== スマホ（タッチ端末）用 ====================
 * すべて html.touch-ui の下にだけ書く。PC（マウス操作）では html に touch-ui が付かないので、
 * 以下は一切効かず、PCの見た目・操作には影響しない。
 * 構成（上から）：[スコア｜ステージ・残り] → 盤面 → アイテム（横長）→ [左下：つぎ＋対応表ボタン｜右下：十字キー]
 * 対応表は右側から出るドロワー。DOMの並べ替えは script.js の TOUCH_UI ブロックで行う。 */
.touch-items-slot,
.touch-bottom,
.touch-next-slot,
.touch-corr-clip,
.touch-item-clip,
.touch-mute-btn {
  display: none;
}
html.touch-ui {
  touch-action: manipulation;
}
html.touch-ui #app {
  padding: 6px;
}
/* #app の余白を24px→6pxにしたので、全面背景画面が打ち消す量もそれに合わせる
   （合わせないと左右に18pxずつはみ出す） */
html.touch-ui .screen-spread {
  margin: -6px;
  width: calc(100% + 12px);
  min-height: calc(100vh - 12px);
  padding-left: 12px;
  padding-right: 12px;
}
html.touch-ui #game-screen.screen {
  /* 盤面を画面の左右いっぱい（端から端）に使う：#appの余白6pxを打ち消す。
     高さも画面いっぱいにして、下段（アイテム＋十字キー）を画面の下端へ寄せる（下の .touch-items-slot の margin-top:auto） */
  max-width: none;
  width: calc(100% + 12px);
  margin: 0 -6px;
  min-height: calc(100vh - 12px);
  min-height: calc(100dvh - 12px);
  justify-content: stretch;
}
html.touch-ui #game-screen .game-layout {
  flex: 1;
}
html.touch-ui .game-layout {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}
html.touch-ui .board-wrap {
  width: min(100%, max(220px, calc((100dvh - 272px) * 0.8)));
  max-width: 632px;
}
html.touch-ui #board {
  width: 100%;
  height: auto;
  /* 左右の枠線と角丸をなくして、盤面の幅を画面幅いっぱい（1マス約46.9px）まで使う */
  border-width: 2px 0;
  border-radius: 0;
}
html.touch-ui .pause-hint {
  display: none;
}

/* --- 上段：スコア｜ステージ・残り（1行） --- */
html.touch-ui .board-topbar {
  position: relative;
  gap: 6px;
  margin-bottom: 4px;
  padding: 0 6px;
}
html.touch-ui .score-badge {
  padding: 0 12px;
  min-width: 74px;
  display: flex;
  align-items: center;
  height: 44px;
}
html.touch-ui .score-badge-label {
  display: none;
}
html.touch-ui .score-badge-value {
  font-size: 1.35rem;
}
html.touch-ui .board-topbar .stage-hud {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 8px;
  display: flex;
  align-items: center;
}
html.touch-ui .board-topbar .stage-hud-row {
  width: 100%;
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  flex-wrap: nowrap;
}
html.touch-ui .board-topbar .stage-hud-col {
  flex-direction: row;
  gap: 4px;
}
html.touch-ui .board-topbar .stage-hud-sub {
  display: none;
}
html.touch-ui .board-topbar .stage-hud .label {
  font-size: 0.8rem;
  white-space: nowrap;
}
html.touch-ui .board-topbar .stage-hud .value {
  font-size: 1.3rem;
  line-height: 1;
}
html.touch-ui .board-topbar .stage-hud-remaining {
  font-size: 0.95rem;
}
html.touch-ui .board-topbar .remaining-infinity {
  font-size: 1.5rem;
}
/* スキル発動中のお知らせは、上段全体に重ねて表示する */
html.touch-ui .board-topbar .skill-ticker {
  position: absolute;
  inset: 0 6px;
  height: 44px;
  z-index: 3;
}

/* --- アイテム（横長1行） --- */
html.touch-ui .touch-items-slot {
  display: block;
  width: 100%;
  max-width: 632px;
  padding: 0 6px;
  margin-top: auto; /* ここから下（アイテム＋十字キー）を画面の下端へ寄せる */
}
html.touch-ui .touch-items-slot .panel-block {
  padding: 6px 8px;
}
html.touch-ui .touch-items-slot .label {
  display: none;
}
html.touch-ui .touch-items-slot .item-bar {
  flex-wrap: nowrap;
  justify-content: space-evenly;
  gap: 6px;
  min-height: 52px;
}
html.touch-ui .touch-items-slot .item-bar-btn {
  flex: none;
}

/* --- 下段：対応表ボタン（左）｜十字キー（右下） --- */
html.touch-ui .touch-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  max-width: 632px;
  padding: 0 6px;
}
html.touch-ui .touch-bottom-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  align-self: stretch;
}
/* 右カラム：十字キーだけ */
html.touch-ui .touch-bottom-right {
  flex: none;
  width: 194px;
}
html.touch-ui .touch-next-slot .next-panel {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
}
html.touch-ui .touch-next-slot .next-panel .label {
  font-size: 0.8rem;
  margin: 0;
  white-space: nowrap;
}
html.touch-ui .touch-next-slot #next-canvas {
  width: 44px;
  height: 44px;
}
html.touch-ui .corr-open-btn {
  height: 44px;
  width: 100%;
  padding: 0 12px;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: #fff;
  color: var(--accent-dark);
  font: inherit;
  font-size: 1.05rem;
  font-weight: bold;
  box-shadow: 0 4px 0 rgba(74, 144, 217, 0.25);
}
html.touch-ui .corr-open-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(74, 144, 217, 0.25);
}
/* 十字キー：上下ボタンを縦に並べ、左右ボタンはその間（高さの中央）の両脇に置く。
   ボタン62px（従来56pxの約1.1倍）。左右は上下の隙間の高さに重なるので、全体の高さは128pxで済む。 */
html.touch-ui .touch-controls {
  position: relative;
  width: 194px;
  height: 128px;
}
html.touch-ui .touch-controls .touch-btn {
  position: absolute;
  width: 62px;
  height: 62px;
}
html.touch-ui .touch-down { left: 66px; top: 66px; }
html.touch-ui .touch-left { left: 0; top: 33px; }
html.touch-ui .touch-right { left: 132px; top: 33px; }
html.touch-ui .touch-btn {
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 1.65rem;
  font-weight: bold;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
html.touch-ui .touch-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

/* --- 対応表：十字キーの上の空きスペースに置く小さな表 ---
 * 右から滑り込み、閉じる時は右へ滑り出る。置き場所は十字キーの上のまま（画面の右側に
 * 物理的に置くわけではない）。滑り出し位置は overflow:hidden の枠で切り取るので、画面外に
 * はみ出してページ幅が広がることはない。 */
html.touch-ui .side-panel {
  display: none;
}
html.touch-ui .touch-bottom {
  position: relative;
}
html.touch-ui .touch-corr-clip {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 2px); /* アイテム表と同じ位置（下段のすぐ上。アイテム欄〜盤面に重なる） */
  overflow: hidden;
  padding: 4px;
  pointer-events: none;
}
html.touch-ui .touch-corr-clip .corr-panel {
  pointer-events: auto;
  margin: 0;
  padding: 6px 12px;
  gap: 0;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: translateX(110%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
}
html.touch-ui .touch-corr-clip .corr-panel.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.25s ease, visibility 0s;
}
html.touch-ui .touch-corr-clip .corr-panel .label {
  display: none;
}
html.touch-ui .touch-corr-clip #corr-rows-side {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
html.touch-ui .touch-corr-clip .corr-row {
  padding: 2px 2px;
  gap: 2px;
  border-radius: 8px;
}
html.touch-ui .touch-corr-clip .corr-row img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}
html.touch-ui .touch-corr-clip .corr-eq {
  font-size: 0.75rem;
}
html.touch-ui .touch-corr-clip .corr-row.corr-special {
  grid-column: 1 / -1;
  gap: 6px;
}
html.touch-ui .touch-corr-clip .corr-note {
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ホバーで出るアイテム説明は、スマホでは使えず、右端のアイテムで画面外にはみ出して
   ページ幅を広げてしまうため無効にする */
html.touch-ui .item-bar-tooltip {
  display: none;
}
html.touch-ui .touch-next-slot {
  display: block;
}

/* ==================== スマホ（タッチ端末）用：タイトル画面 ====================
 * 背景は横長（1024x572）で、縦長の画面だと cover では中央の2人しか映らない。
 * 縦向きのスマホでは、4人が横幅に収まる大きさ（幅の約225%）で表示し、上下の余白は
 * 同じ画像のぼかしで埋める。ボタンは折り返さないよう小さめにし、ロゴの上切れも直す。 */
@media (max-aspect-ratio: 1/1) {
  html.touch-ui .title-screen-bg {
    background-image: none;
    isolation: isolate;
    overflow: hidden;
  }
  html.touch-ui .title-screen-bg::before,
  html.touch-ui .title-screen-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: url("assets/TITEL01.jpg") center / cover no-repeat;
  }
  html.touch-ui .title-screen-bg::before {
    filter: blur(18px) brightness(0.95);
    transform: scale(1.1);
  }
  html.touch-ui .title-screen-bg::after {
    background-size: 225% auto;
  }
}
html.touch-ui .title-logo {
  margin-top: 8px;
}
html.touch-ui .title-btn-row .btn {
  padding: 10px 16px;
  font-size: 0.95rem;
  white-space: nowrap;
}

/* --- アイテム表：左下のボタンから、左から滑り込む --- */
html.touch-ui .touch-bottom-left {
  gap: 6px;
}
html.touch-ui .touch-bottom-left .corr-open-btn {
  width: auto;
  min-width: 0;
  font-size: 0.85rem;
  padding: 0 8px;
  white-space: nowrap;
}
/* つぎ（横並び）＋一時停止 */
html.touch-ui .touch-row-next {
  display: flex;
  align-items: center;
  gap: 4px;
}
/* アイテム表ボタンの右に並ぶ「一時停止／停止解除」ボタン */
html.touch-ui .touch-btn-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
html.touch-ui .touch-bottom-left .pause-btn {
  font-size: 0.78rem;
  padding: 0 6px;
}
html.touch-ui .pause-btn.paused {
  background: #ffe9a8;
  border-color: #e0a526;
  color: #8a5a00;
}
html.touch-ui .touch-item-clip {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 2px); /* 下段（つぎ・ボタン・十字キー）のすぐ上。アイテム欄に重なる */
  overflow: hidden;
  padding: 4px;
  pointer-events: none;
}
html.touch-ui .item-guide {
  pointer-events: auto;
  margin: 0;
  padding: 6px 12px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: translateX(-110%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
}
html.touch-ui .item-guide.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.25s ease, visibility 0s;
}
html.touch-ui .item-guide-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid #eef2f6;
}
html.touch-ui .item-guide-row:last-child {
  border-bottom: none;
}
html.touch-ui .item-guide-row img {
  flex: none;
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #e0e8f0;
  border-radius: 8px;
}
html.touch-ui .item-guide-text {
  min-width: 0;
}
html.touch-ui .item-guide-name {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--accent-dark);
}
html.touch-ui .item-guide-desc {
  font-size: 0.78rem;
  line-height: 1.35;
  color: #5a6b7a;
}

/* --- 1行目の右端：ミュートボタン --- */
html.touch-ui .touch-mute-btn {
  display: block;
  order: 5;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(43, 58, 74, 0.72);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
html.touch-ui .touch-mute-btn.muted {
  color: #9aa8b6;
}

/* --- 対応表：アイテム表と同じ幅・同じ位置。右から滑り込む --- */
html.touch-ui .touch-corr-clip .corr-panel {
  width: 100%;
}
html.touch-ui .touch-corr-clip #corr-rows-side {
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
html.touch-ui .touch-corr-clip .corr-row img {
  width: 28px;
  height: 28px;
}
html.touch-ui .touch-corr-clip .corr-eq {
  font-size: 0.85rem;
}

/* ==== スマホ：枠つき盤面を横幅いっぱいに使う最終レイアウト（後ろの指定が前を上書きする） ====
 * 盤面は横幅いっぱい（縦長なので高さ＝幅×1.25）。縦が足りない画面だけ、盤面が重ならない幅まで縮む。
 * アイテム欄と十字キー欄は画面の下端に寄せて置く（盤面の下に重なって出る対応表・アイテム表の基準もここ）。
 * 上キー（一気に落とす）は廃止し、▼のダブルタップで代用する。 */
html.touch-ui .board-wrap {
  width: min(100%, max(220px, calc((100dvh - 212px) * 0.8)));
  max-width: 632px;
}
html.touch-ui #board {
  border-width: 2px;
  border-radius: 8px;
}
html.touch-ui #game-screen.screen {
  margin-top: -4px; /* #appの上余白6pxのうち4pxを詰める */
}
html.touch-ui #game-screen .game-layout {
  position: relative;
}
html.touch-ui .touch-items-slot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 106px; /* 左下の「つぎ／ボタン」列（約102px）のすぐ上 */
  margin: 0 auto;
  z-index: 2;
}
html.touch-ui .touch-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
}
/* 上段（スコア｜ステージ・残り｜ミュート）：高さ44px→36px、上下の余白も詰める */
html.touch-ui .board-topbar {
  margin-bottom: 2px;
}
html.touch-ui .score-badge,
html.touch-ui .board-topbar .stage-hud,
html.touch-ui .board-topbar .skill-ticker {
  height: 36px;
}
html.touch-ui .touch-mute-btn {
  width: 32px;
  height: 32px;
  font-size: 0.95rem;
}
/* アイテム欄：上下の余白を詰める */
html.touch-ui .touch-items-slot .panel-block {
  padding: 3px 8px;
}
/* 十字キー：◀ ▶ を上段、▼ をその下の中央に（上キーなし） */
html.touch-ui .touch-controls {
  height: 95px;
}
html.touch-ui .touch-left,
html.touch-ui .touch-right {
  top: 0;
}
html.touch-ui .touch-down {
  left: 66px;
  top: 33px;
}

/* ---- 対応表・アイテム表はアイテム欄より前面に出す（アイテム欄の上に重ねて表示） ---- */
html.touch-ui .touch-item-clip,
html.touch-ui .touch-corr-clip {
  z-index: 5;
}
/* ---- 下段ボタンは1列：アイテム表｜一時停止｜対応表（横幅が足りないので左右の余白を詰める） ---- */
html.touch-ui .touch-bottom-left .corr-open-btn {
  padding: 0 3px;
  font-size: 0.68rem;
}
html.touch-ui .touch-btn-row {
  gap: 2px;
}
html.touch-ui .touch-bottom-left {
  flex: 1;
  min-width: 0;
}

/* ---- ルール説明の操作方法：PC用／スマホ用の表示切替 ---- */
.rule-controls-list li.rule-touch-only {
  display: none;
}
html.touch-ui .rule-controls-list li.rule-touch-only {
  display: flex;
}
html.touch-ui .rule-controls-list li.rule-pc-only {
  display: none;
}

/* ---- 掲示板リンク（完成版テストのビルドでだけ表示）：新しいお知らせがある時に「NEW」を出す ---- */
.board-dot {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e84054;
  color: #fff;
  font-size: 0.66rem;
  font-weight: bold;
  text-decoration: none;
  vertical-align: 1px;
}
