/* 1坪ダンジョン - 1 Tsubo Dungeon */

:root {
  --bg-deep: #0a0910;
  --bg-mid: #15121d;
  --panel: #1d1928;
  --panel-light: #2a2438;
  --line: #3b3350;
  --text: #f1ece3;
  --text-dim: #a1988c;
  --accent: #ffb63d;
  --accent-strong: #ff8a1f;
  --danger: #ff5560;
  --hp-a: #7ee36a;
  --hp-b: #37b24d;
  --soul: #86dcff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  height: calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  display: flex;
  flex-direction: column;
  /* 上のセーフエリアは共通ヘッダー（--sgh-top）が確保済みなので、ここでは空けない */
  padding: 0 env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
}

/* ---------- ヘッダー ---------- */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 2px;
  flex: none;
}

#logo {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #ffe1a3, var(--accent-strong));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#topbar-buttons {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- HUD ---------- */

#hud {
  flex: none;
  display: flex;
  align-items: stretch;
  gap: 5px;
  padding: 4px 8px 6px;
}

.hud-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.hud-hp {
  flex: 1 1 auto;
}

.hud-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 700;
}

.hud-value {
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.hud-floor .hud-value {
  color: var(--accent);
}

.hud-gold .hud-value {
  color: #ffd24a;
}

/* ---------- レリック帯 ---------- */

.relic-strip {
  flex: none;
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 0 10px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.relic-strip::-webkit-scrollbar {
  display: none;
}

.relic-chip {
  flex: none;
  font-size: 14px;
  line-height: 1;
  padding: 4px 5px;
  border-radius: 8px;
  background: rgba(255, 182, 61, 0.12);
  border: 1px solid rgba(255, 182, 61, 0.45);
}

.hp-bar {
  position: relative;
  width: 100%;
  height: 16px;
  border-radius: 8px;
  background: #120f19;
  border: 1px solid #372f4a;
  overflow: hidden;
}

.hp-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: linear-gradient(180deg, var(--hp-a), var(--hp-b));
  transition: width 0.28s ease;
}

.hp-fill.low {
  background: linear-gradient(180deg, #ff8a8a, #d63b3b);
}

.hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* ---------- ゲーム画面 ---------- */

#game-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  max-width: min(100%, 520px);
  object-fit: contain;
  touch-action: none;
}

#banner {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translate(-50%, -50%);
  padding: 8px 22px;
  border-radius: 12px;
  background: rgba(10, 8, 16, 0.82);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 18px rgba(255, 182, 61, 0.5);
  animation: banner-pop 0.3s ease;
}

@keyframes banner-pop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.86); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#tip {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(10, 8, 16, 0.8);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

/* スキルの範囲を見せているあいだ、行動バーと入れ替わる確認帯 */
.skill-confirm {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 6px;
  min-height: 52px;
}

.sc-info {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid rgba(255, 182, 61, 0.55);
  background: rgba(255, 182, 61, 0.08);
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sc-head {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}

.sc-icon {
  font-size: 13px;
  line-height: 1;
}

.sc-name {
  font-size: 12.5px;
  font-weight: 900;
  color: var(--accent);
  white-space: nowrap;
}

.sc-effect {
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-pick {
  margin-left: auto;
  flex: none;
  font-size: 9.5px;
  font-weight: 800;
  color: var(--soul);
  border: 1px solid rgba(134, 220, 255, 0.5);
  border-radius: 999px;
  padding: 0 6px;
}

.sc-text {
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-dim);
  margin-top: 1px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sc-actions {
  flex: none;
  display: flex;
  gap: 7px;
  align-self: stretch;
}

.sc-btn {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 900;
  min-width: 66px;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-light), var(--panel));
  color: var(--text);
  cursor: pointer;
}

.sc-btn:active {
  transform: translateY(1px);
}

.sc-btn.sc-ok {
  border: 0;
  color: #2a1a04;
  background: linear-gradient(180deg, #ffe1a3, var(--accent-strong));
}

.hidden {
  display: none !important;
}

/* ---------- 行動バー ---------- */

#actionbar {
  flex: none;
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 4px 10px 6px;
  min-height: 52px;
}

/* スキルは最大8個まで増えるので、詰めずに横スクロールで並べる。
   （縮めて並べると1つ29pxまで潰れて、何のスキルか読めなくなる）
   上下の padding は「構え中」の光る枠が切れないぶんの余白。負のマージンで見た目の位置は元のまま */
#skill-slots {
  display: flex;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px;
  margin: -3px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  /* スクロールバーは出さない。「次のボタンが半分見えている」ことが動く合図になる */
  scrollbar-width: none;
}

#skill-slots::-webkit-scrollbar {
  display: none;
}

.act-btn {
  position: relative;
  flex: 0 0 auto;
  min-width: 74px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel-light), var(--panel));
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
}

/* スクロールするので縮めない。文字が読める幅を必ず確保する */
.act-btn.skill {
  flex: 1 0 auto;    /* 空きがあれば広げる。ただし縮めはしない（＝はみ出したらスクロール） */
  min-width: 68px;
  scroll-margin: 8px;
}

.act-btn:active {
  transform: translateY(1px);
}

.act-btn[disabled] {
  opacity: 0.45;
  cursor: default;
}

.act-btn.armed {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 182, 61, 0.35);
}

.act-icon {
  font-size: 17px;
  line-height: 1;
}

.act-name {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.act-cd {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 12, 0.72);
  color: var(--accent);
  font-size: 17px;
  font-weight: 900;
}

/* ---------- フッター ---------- */

#footer {
  flex: none;
  text-align: center;
  font-size: 10px;
  line-height: 1.6;
  color: var(--text-dim);
  padding: 2px 8px calc(4px + env(safe-area-inset-bottom, 0px));
}

/* 広告表示中は --ad-space（広告＋セーフエリア）ぶん #app が縮むので、下のセーフエリアを二重に取らない */
html.has-ad-banner #footer { padding-bottom: 4px; }

#footer a {
  color: var(--text-dim);
}

/* ---------- オーバーレイ共通 ---------- */

.overlay {
  position: fixed;
  inset: var(--sgh-top, 0px) 0 0 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + var(--ad-space, 0px));
  background: rgba(6, 5, 10, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.overlay-box {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--panel), var(--bg-mid));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px 16px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  animation: box-in 0.24s ease;
}

/* 中身が画面より高いとき（小さい画面・横向きの商人の間など）は上端から並べてスクロールで読めるようにする。
   align-items: center のままだと上にはみ出したぶんがスクロールでも戻せない。収まるときは今までどおり中央 */
.overlay > .overlay-box {
  margin: auto 0;
}

/* 遊び方・図鑑は、リザルトやメニューの上から開くことがある（共通ヘッダーの「遊び方」など）ので一段上に出す */
#overlay-howto,
#overlay-codex {
  z-index: 61;
}

@keyframes box-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.overlay-title {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.btn {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-top: 10px;
  border: 0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #1a1206;
  cursor: pointer;
  background: linear-gradient(180deg, #ffd07a, var(--accent-strong));
  box-shadow: 0 4px 0 #a1550c;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #a1550c;
}

.btn-sub {
  background: var(--panel-light);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
  font-size: 13px;
  padding: 10px 12px;
}

.btn-sub:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-wide {
  margin-top: 8px;
}

.overlay-actions {
  display: flex;
  gap: 8px;
}

.overlay-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  padding-left: 6px;
  padding-right: 6px;
  font-size: 13.5px;
  white-space: nowrap;
}

.stat-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.rstat {
  flex: 1 1 0;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.rstat-label {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 700;
}

/* ---------- 強化選択 ---------- */

.upgrade-title {
  color: var(--accent);
  margin-bottom: 4px;
}

.upgrade-floor {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.upgrade-sub {
  font-size: 11.5px;
  color: var(--text-dim);
  margin: 6px 0 12px;
}

#upgrade-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ucard {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--panel-light), var(--panel));
  color: var(--text);
  cursor: pointer;
}

.ucard:active {
  transform: scale(0.985);
}

.ucard.r-rare {
  border-color: #7d6bff;
  box-shadow: 0 0 0 1px rgba(125, 107, 255, 0.35), 0 0 20px rgba(125, 107, 255, 0.18) inset;
}

.ucard.r-epic {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 182, 61, 0.4), 0 0 22px rgba(255, 182, 61, 0.16) inset;
}

.ucard-icon {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}

.ucard-body {
  flex: 1 1 auto;
  min-width: 0;
}

.ucard-name {
  font-size: 14px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ucard-lv {
  font-size: 10px;
  font-weight: 800;
  color: var(--accent);
  border: 1px solid rgba(255, 182, 61, 0.5);
  border-radius: 999px;
  padding: 1px 7px;
}

.ucard-desc {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
  margin-top: 3px;
}

/* ---------- 強化一覧・図鑑 ---------- */

.build-head,
.howto-head {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-align: left;
  margin: 12px 0 6px;
}

.howto-note {
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-dim);
  text-align: left;
  margin-top: 8px;
}

.build-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  min-height: 22px;
}

.build-chip {
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
}

.build-chip:active {
  transform: scale(0.97);
}

.build-chip.on {
  border-color: var(--accent);
  background: rgba(255, 182, 61, 0.22);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 14px rgba(255, 182, 61, 0.25);
}

.build-detail {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 12px;
  margin: -6px 0 14px;
}

.build-detail-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 900;
}

.build-detail-icon {
  font-size: 16px;
  line-height: 1;
}

.build-detail-tag {
  margin-left: auto;
  flex: none;
  font-size: 10px;
  font-weight: 800;
  color: var(--accent);
  border: 1px solid rgba(255, 182, 61, 0.5);
  border-radius: 999px;
  padding: 1px 7px;
}

.build-detail-body {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-dim);
  margin-top: 5px;
}

.build-detail-note {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  margin-top: 5px;
}

.build-empty {
  font-size: 11.5px;
  color: var(--text-dim);
}

.howto-body {
  text-align: left;
  max-height: min(58vh, 460px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.howto {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.howto li {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.howto b {
  color: var(--accent);
}

.bestiary {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.best-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
}

.best-row canvas {
  flex: none;
  width: 34px;
  height: 34px;
}

.best-name {
  font-size: 12px;
  font-weight: 900;
}

.best-desc {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-dim);
  margin-top: 1px;
}

/* ---------- 図鑑 ---------- */

.codex-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 9px;
}

.codex-tab {
  flex: 1 1 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  padding: 7px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text-dim);
  cursor: pointer;
}

.codex-tab.on {
  border-color: var(--accent);
  background: rgba(255, 182, 61, 0.2);
  color: var(--accent);
}

.codex-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: min(54vh, 440px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.codex-row {
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--panel-light), var(--panel));
  color: var(--text);
}

.codex-tag {
  margin-left: auto;
  flex: none;
  font-size: 9.5px;
  font-weight: 800;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 6px;
}

/* 3×3 の部屋の図 */
.rangegrid {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 13px);
  grid-template-rows: repeat(3, 13px);
  gap: 2px;
}

.rg-cell {
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  font-size: 8px;
  font-weight: 900;
  line-height: 11px;
  text-align: center;
  color: var(--text);
}

.rg-me {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.22);
}

.rg-foe {
  border-color: rgba(255, 107, 107, 0.7);
  background: rgba(255, 107, 107, 0.28);
}

.rg-hit {
  border-color: rgba(255, 182, 61, 0.85);
  background: rgba(255, 182, 61, 0.45);
}

.rg-move {
  border-color: rgba(134, 220, 255, 0.8);
  background: rgba(134, 220, 255, 0.18);
}

.rg-legend-me { color: #fff; }
.rg-legend-foe { color: #ff6b6b; }
.rg-legend-hit { color: var(--accent); }
.rg-legend-move { color: var(--soul); }

/* ---------- 祭壇 ---------- */

.altar-lead {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.altar-lead b {
  color: var(--soul);
}

.altar-soul {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 900;
  color: var(--soul);
  margin-bottom: 10px;
}

.altar-progress {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
}

.altar-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: min(56vh, 460px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

/* 区画の見出し（刻印／加護／秘儀） */
.altar-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 6px 0 -1px;
  padding: 0 2px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.altar-head:first-child {
  margin-top: 0;
}

.altar-head-title {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.altar-head-sub {
  font-size: 10px;
  color: var(--text-dim);
}

.altar-head-bless .altar-head-title { color: #7ee36a; }
.altar-head-rite .altar-head-title { color: var(--soul); }

.altar-row {
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--panel-light), var(--panel));
  color: var(--text);
  cursor: pointer;
}

.altar-row[disabled] {
  opacity: 0.5;
  cursor: default;
}

.altar-row.done {
  opacity: 0.75;
  border-color: rgba(255, 214, 122, 0.35);
}

.altar-icon {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}

/* 図鑑の魔物・ボスは絵をそのまま小さく描く */
.altar-icon canvas {
  width: 28px;
  height: 28px;
}

.altar-body {
  flex: 1 1 auto;
  min-width: 0;
}

.altar-name {
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 6px;
}

.altar-desc {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-dim);
  margin-top: 2px;
}

.altar-now {
  font-size: 10px;
  line-height: 1.4;
  color: var(--soul);
  margin-top: 3px;
}

.altar-cost {
  flex: none;
  font-size: 12px;
  font-weight: 900;
  color: var(--soul);
  white-space: nowrap;
}

.altar-cost.max {
  color: var(--accent);
}

.pips {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}

.pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.pip.on {
  background: var(--soul);
}

/* ---------- リザルト ---------- */

.result-new {
  font-size: 12px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

#result-score-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin: 6px 0 12px;
}

#result-score {
  font-size: 40px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1;
}

.result-unit {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-dim);
}

#result-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

#result-stats .rstat {
  font-size: 15px;
}

/* ---------- PC 向け ---------- */

@media (min-width: 768px) {
  #logo { font-size: 20px; }
  .hud-value { font-size: 18px; }
  #footer { font-size: 11px; }
  /* PC ではゲーム画面の幅に合わせて上下のバーもまとめる */
  #topbar,
  #hud,
  #actionbar {
    width: min(560px, calc(100% - 24px));
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
  }
  #game { max-width: 560px; }
}

@media (max-height: 620px) {
  .start-lead { display: none; }
  .overlay-box { padding: 14px 14px 12px; }
  .overlay-start .overlay-box { padding: 0 2px 2px; }
  .start-sub { margin-top: 6px; }
  .start-best { margin: 8px 0 2px; padding: 5px 10px; }
  .sb-value { font-size: 14px; }
  .overlay-start .start-asc { margin: 8px 0 2px; }
  .overlay-start .asc-trials { max-height: 62px; }
  .btn-dive { margin-top: 9px; padding: 11px 14px; font-size: 15px; }
  .btn-altar { margin-top: 7px; }
  .start-actions { margin-top: 6px; }
}

/* ---------- 全国ランキング（SGRanking 共通モジュール） ---------- */
.sgr-hidden {
  display: none !important;
}

.sgr-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(6, 5, 10, 0.86);
}

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(160deg, var(--panel-light), var(--panel));
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 20px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.sgr-title {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
}

.sgr-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.sgr-tab {
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  font-family: inherit;
  background: var(--bg-mid);
  color: var(--text);
  cursor: pointer;
}

.sgr-tab-active {
  background: var(--accent);
  color: #3a2200;
}

.sgr-register-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  color: var(--accent);
}

.sgr-form {
  display: flex;
  gap: 8px;
}

.sgr-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-family: inherit;
  padding: 8px 10px;
  border: 2px solid var(--panel-light);
  border-radius: 8px;
  background: var(--bg-deep);
  color: var(--text);
}

.sgr-name:focus {
  outline: none;
  border-color: var(--accent);
}

.sgr-submit {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: bold;
  font-family: inherit;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #3a2200;
  cursor: pointer;
}

.sgr-submit:hover {
  filter: brightness(1.07);
}

.sgr-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

.sgr-error {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--danger);
}

.sgr-status {
  margin: 0;
  font-size: 13px;
  text-align: center;
  color: var(--text-dim);
}

.sgr-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.sgr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 14px;
}

.sgr-row:nth-child(even) {
  background: rgba(0, 0, 0, 0.2);
}

.sgr-row.sgr-row-me {
  background: var(--accent);
  color: #3a2200;
}

.sgr-rank {
  width: 2em;
  text-align: right;
  font-weight: bold;
  flex-shrink: 0;
}

.sgr-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sgr-row-score {
  font-weight: bold;
  flex-shrink: 0;
}

.sgr-close {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: bold;
  font-family: inherit;
  background: var(--bg-mid);
  color: var(--text);
  cursor: pointer;
}

.sgr-close:hover {
  background: var(--panel-light);
}

.sgr-cta {
  margin: 0 0 14px;
  text-align: center;
}

.sgr-cta-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: bold;
  color: var(--accent);
}

.sgr-cta-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: bold;
  font-family: inherit;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #3a2200;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(255, 179, 71, 0.35);
}

.sgr-cta-link {
  border: none;
  background: none;
  padding: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-dim);
  text-decoration: underline;
  cursor: pointer;
}

.sgr-cta-link:hover {
  color: var(--text);
}

/* ==========================================================================
   フッター固定バナー広告（スマホ表示時のみ / js/ad-banner.js が挿入する）
   --ad-h    : 広告そのものの高さ。広告なしのときは 0px
   --ad-space: レイアウトが空けるべき高さ（広告 + セーフエリア）
   ========================================================================== */
:root {
  --ad-h: 0px;
  --ad-space: 0px;
}
html.has-ad-banner {
  --ad-space: calc(var(--ad-h, 0px) + env(safe-area-inset-bottom, 0px));
}

.ad-banner {
  /* height は広告そのものの高さ。セーフエリアぶんの padding は外側に足す */
  box-sizing: content-box;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  /* ランキング・リザルト等の全画面オーバーレイ（2147483000）よりは下に置く */
  z-index: 2147482000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  height: var(--ad-h, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  background: rgba(14, 16, 20, 0.86);
  /* border ではなく inset shadow にして、枠線ぶん高さがずれないようにする */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.ad-banner__frame {
  display: block;
  width: 100%;
  height: var(--ad-h, 0px);
  border: 0;
  color-scheme: light;
}

@media print {
  .ad-banner { display: none; }
}

/* ---------- 部屋選び・レリック・商店・未知の間 ---------- */

#room-cards,
#relic-cards,
#shop-list,
#event-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room-card.room-elite {
  border-color: #ffd24a;
  box-shadow: 0 0 0 1px rgba(255, 210, 74, 0.35), 0 0 20px rgba(255, 210, 74, 0.14) inset;
}

.room-card.room-shop {
  border-color: #7ee36a;
  box-shadow: 0 0 0 1px rgba(126, 227, 106, 0.3), 0 0 20px rgba(126, 227, 106, 0.12) inset;
}

.room-card.room-event {
  border-color: #7d6bff;
  box-shadow: 0 0 0 1px rgba(125, 107, 255, 0.35), 0 0 20px rgba(125, 107, 255, 0.16) inset;
}

.shop-gold {
  font-size: 12px;
  font-weight: 800;
  color: #ffd24a;
  margin: 6px 0 12px;
}

.shop-item {
  position: relative;
}

.shop-cost {
  flex: none;
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #ffd24a;
  border: 1px solid rgba(255, 210, 74, 0.45);
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
}

.shop-cost.short {
  color: var(--text-dim);
  border-color: var(--line);
}

.shop-cost.sold {
  color: var(--text-dim);
  border-color: var(--line);
}

.shop-item.sold {
  opacity: 0.42;
  cursor: default;
}

#btn-shop-leave {
  margin-top: 14px;
}

.event-icon {
  font-size: 34px;
  line-height: 1;
  margin-bottom: 6px;
}

.event-text {
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-dim);
  margin: 8px 0 14px;
  text-align: left;
}

.event-opt.short {
  opacity: 0.55;
}

.event-result {
  font-size: 12.5px;
  line-height: 1.7;
  font-weight: 700;
  text-align: left;
  color: var(--text);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.build-chip.is-relic {
  color: var(--accent);
  border-color: rgba(255, 182, 61, 0.5);
  background: rgba(255, 182, 61, 0.1);
}

/* ---------- 難易度（アセンション） ---------- */

.hud-floor-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

/* 難易度は「深度」のラベル横に小さく添える（HPバーの幅を削らないため） */
.hud-asc {
  flex: none;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
  color: var(--danger);
  border: 1px solid rgba(255, 85, 96, 0.5);
  background: rgba(255, 85, 96, 0.12);
  border-radius: 999px;
  padding: 1px 4px;
}

/* この階に残っている魔物の数。あと何体で終わるかが見えると、湧きが「作業」に見えない */
.hud-foe {
  flex: none;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
  color: #ffb066;
  border: 1px solid rgba(255, 176, 102, 0.45);
  background: rgba(255, 176, 102, 0.12);
  border-radius: 999px;
  padding: 1px 4px;
  font-variant-numeric: tabular-nums;
}

.start-asc {
  margin: 12px 0 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.24);
  padding: 8px 10px 10px;
}

.asc-head {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  font-weight: 800;
  color: var(--text-dim);
}

.asc-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.asc-arrow {
  flex: none;
  width: 34px;
  height: 34px;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  color: var(--text);
  background: var(--panel-light);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.asc-arrow:disabled {
  opacity: 0.32;
  cursor: default;
}

.asc-main {
  flex: 1 1 auto;
  min-width: 0;
}

.asc-name {
  font-size: 14px;
  font-weight: 900;
  color: var(--accent);
}

.asc-note {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-dim);
  margin-top: 2px;
}

.asc-trials {
  margin-top: 8px;
  max-height: 116px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.asc-trial {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

.asc-trial-lv {
  flex: none;
  font-weight: 900;
  color: var(--danger);
  font-variant-numeric: tabular-nums;
}

/* ---------- 金貨が足りないときの注意書き ---------- */

.gold-note {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--danger);
  background: rgba(255, 85, 96, 0.1);
  border: 1px solid rgba(255, 85, 96, 0.4);
  border-radius: 10px;
  padding: 7px 10px;
  margin-top: 10px;
  animation: gold-note-in 0.28s ease-out;
}

@keyframes gold-note-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 踏破のお知らせ ---------- */

.result-note {
  font-size: 11.5px;
  line-height: 1.7;
  font-weight: 800;
  color: var(--accent);
  background: rgba(255, 182, 61, 0.1);
  border: 1px solid rgba(255, 182, 61, 0.4);
  border-radius: 12px;
  padding: 9px 12px;
  margin: 10px 0 2px;
}

#btn-upgrade-skip {
  margin-top: 4px;
}

/* ============================================================
   タイトル画面
   ・背景は「かがり火のともる石室」。装飾レイヤーはすべて
     .ts-scene の中に入れて、操作を邪魔しないようにしている
   ・動くものは transform / opacity だけに限定する
   ============================================================ */

.overlay-start {
  background: #06050b;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  align-items: flex-start;
}

/* ---------- 背景の情景 ---------- */

.ts-scene {
  position: fixed;
  inset: var(--sgh-top, 0px) 0 0 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* 石壁 */
.ts-wall {
  position: absolute;
  inset: 0;
  background-color: #0a0812;
  background-image:
    linear-gradient(180deg, #191325 0%, #0d0a16 44%, #050409 100%),
    repeating-linear-gradient(0deg, rgba(190, 205, 255, 0.045) 0 1px, transparent 1px 38px),
    repeating-linear-gradient(90deg, rgba(190, 205, 255, 0.035) 0 1px, transparent 1px 66px);
  box-shadow: inset 0 0 180px 40px rgba(2, 2, 6, 0.9);
}

/* 上から差す松明あかり */
.ts-glow {
  position: absolute;
  left: 50%;
  top: -22%;
  width: 148%;
  height: 92%;
  transform: translateX(-50%);
  background:
    radial-gradient(closest-side, rgba(255, 168, 62, 0.30), rgba(255, 120, 30, 0.10) 52%, transparent 74%);
  animation: ts-glow 6.5s ease-in-out infinite alternate;
}

@keyframes ts-glow {
  from { opacity: 0.72; }
  to   { opacity: 1; }
}

/* ロゴの裏に浮かぶ 3×3 の刻印（このゲームの盤面） */
.ts-grid {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(70vw, 292px);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  opacity: 0.17;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 2%, #000 30%, #000 52%, transparent 84%);
  mask-image: linear-gradient(180deg, transparent 2%, #000 30%, #000 52%, transparent 84%);
}

.ts-grid i {
  border: 1px solid rgba(255, 205, 140, 0.8);
  border-radius: 4px;
  animation: ts-cell 5.4s ease-in-out infinite;
}

.ts-grid i:nth-child(1) { animation-delay: 0s; }
.ts-grid i:nth-child(2) { animation-delay: 0.6s; }
.ts-grid i:nth-child(3) { animation-delay: 1.2s; }
.ts-grid i:nth-child(6) { animation-delay: 1.8s; }
.ts-grid i:nth-child(9) { animation-delay: 2.4s; }
.ts-grid i:nth-child(8) { animation-delay: 3.0s; }
.ts-grid i:nth-child(7) { animation-delay: 3.6s; }
.ts-grid i:nth-child(4) { animation-delay: 4.2s; }
.ts-grid i:nth-child(5) { animation-delay: 4.8s; }

@keyframes ts-cell {
  0%, 82%, 100% { opacity: 0.35; }
  88%           { opacity: 1; }
}

/* かがり火 */
.ts-torch {
  position: absolute;
  top: 9%;
  width: 108px;
  height: 150px;
}

.ts-torch-l { left: -14px; }
.ts-torch-r { right: -14px; }

/* あかりの玉 */
.ts-torch::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(closest-side, rgba(255, 178, 74, 0.50), rgba(255, 120, 24, 0.16) 46%, transparent 72%);
  animation: ts-torch 2.7s ease-in-out infinite alternate;
}

/* 壁に打ちつけた金具 */
.ts-torch::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 51%;
  width: 14px;
  height: 34px;
  margin-left: -7px;
  border-radius: 4px 4px 7px 7px;
  background: linear-gradient(180deg, #5a4f66 0%, #372f47 32%, #1c1826 100%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.65),
    inset 1px 0 0 rgba(255, 200, 140, 0.22);
}

@keyframes ts-torch {
  from { opacity: 0.62; transform: scale(0.97); }
  to   { opacity: 1;    transform: scale(1.04); }
}

.ts-flame {
  position: absolute;
  left: 50%;
  top: 38%;
  width: 15px;
  height: 26px;
  margin-left: -7.5px;
  border-radius: 50% 50% 46% 46% / 64% 64% 36% 36%;
  background: linear-gradient(180deg, #fff4cd 6%, #ffd36a 26%, #ffb63d 52%, #ff6a1a 100%);
  filter: blur(1.2px);
  animation: ts-flame 1.45s ease-in-out infinite alternate;
}

@keyframes ts-flame {
  from { transform: scaleY(0.86) translateY(2px); opacity: 0.85; }
  to   { transform: scaleY(1.1) translateY(-2px); opacity: 1; }
}

/* 火の粉 */
.ts-embers {
  position: absolute;
  inset: 0;
}

.ts-embers i {
  position: absolute;
  bottom: -12px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffcb6b;
  box-shadow: 0 0 7px rgba(255, 150, 40, 0.85);
  opacity: 0;
  animation-name: ts-ember;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

@keyframes ts-ember {
  0%   { transform: translate3d(0, 0, 0) scale(0.5); opacity: 0; }
  12%  { opacity: 0.9; }
  70%  { opacity: 0.55; }
  100% { transform: translate3d(var(--dx, 14px), -86vh, 0) scale(1); opacity: 0; }
}

.ts-embers i:nth-child(1)  { left: 8%;  --dx: 18px;  animation-duration: 11s; animation-delay: 0s; }
.ts-embers i:nth-child(2)  { left: 17%; --dx: -14px; animation-duration: 14s; animation-delay: 1.6s; }
.ts-embers i:nth-child(3)  { left: 26%; --dx: 24px;  animation-duration: 9.5s; animation-delay: 3.4s; width: 2px; height: 2px; }
.ts-embers i:nth-child(4)  { left: 34%; --dx: -20px; animation-duration: 13s; animation-delay: 5.1s; }
.ts-embers i:nth-child(5)  { left: 43%; --dx: 12px;  animation-duration: 10.5s; animation-delay: 2.2s; width: 2px; height: 2px; }
.ts-embers i:nth-child(6)  { left: 51%; --dx: -26px; animation-duration: 15s; animation-delay: 6.8s; }
.ts-embers i:nth-child(7)  { left: 60%; --dx: 16px;  animation-duration: 12s; animation-delay: 0.9s; }
.ts-embers i:nth-child(8)  { left: 68%; --dx: -12px; animation-duration: 9s;  animation-delay: 4.3s; width: 2px; height: 2px; }
.ts-embers i:nth-child(9)  { left: 77%; --dx: 22px;  animation-duration: 13.5s; animation-delay: 7.7s; }
.ts-embers i:nth-child(10) { left: 85%; --dx: -18px; animation-duration: 11.5s; animation-delay: 2.9s; }
.ts-embers i:nth-child(11) { left: 92%; --dx: 10px;  animation-duration: 10s; animation-delay: 6.1s; width: 2px; height: 2px; }
.ts-embers i:nth-child(12) { left: 3%;  --dx: 20px;  animation-duration: 14.5s; animation-delay: 8.4s; }

/* 手前の床（下へ行くほど闇に沈む） */
.ts-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  background: linear-gradient(180deg, transparent, rgba(2, 2, 5, 0.72) 58%, #020204);
}

/* ---------- タイトルの中身 ---------- */

.overlay-start .overlay-box {
  position: relative;
  z-index: 1;
  margin: auto 0;
  max-width: 380px;
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0 4px 6px;
  animation: none;
}

.start-logo-wrap {
  position: relative;
  margin: 0;
  font-size: 0;
  line-height: 0;
}

.start-logo {
  position: relative;
  z-index: 1;
  display: block;
  width: min(100%, clamp(150px, 38vh, 330px));
  height: auto;
  margin: 0 auto;
  animation:
    logo-in 0.62s cubic-bezier(0.16, 1, 0.3, 1) both,
    logo-float 5.6s 0.62s ease-in-out infinite alternate;
}

@keyframes logo-in {
  from { opacity: 0; transform: translateY(14px) scale(0.92); }
  to   { opacity: 1; transform: none; }
}

@keyframes logo-float {
  from { transform: translateY(0); }
  to   { transform: translateY(-7px); }
}

.start-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  animation: fade-up 0.5s 0.24s ease-out both;
}

.ss-rule {
  flex: 1 1 0;
  max-width: 66px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 182, 61, 0.6));
}

.ss-rule:last-child {
  background: linear-gradient(90deg, rgba(255, 182, 61, 0.6), transparent);
}

.ss-text {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: var(--accent);
  opacity: 0.9;
  white-space: nowrap;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.start-lead {
  font-size: 12.5px;
  line-height: 1.75;
  color: #cfc5b6;
  margin: 10px 0 2px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  animation: fade-up 0.5s 0.32s ease-out both;
}

/* 最高記録の石板 */
.start-best {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 2px;
  margin: 10px 0 2px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 182, 61, 0.32);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 182, 61, 0.10), rgba(0, 0, 0, 0.34));
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.14);
  animation: fade-up 0.5s 0.4s ease-out both;
}

.sb-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sb-label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.sb-value {
  font-size: 16px;
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px rgba(255, 182, 61, 0.35);
}

.sb-sep {
  flex: none;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255, 182, 61, 0.34), transparent);
}

/* 難易度（アセンション）の枠 */
.overlay-start .start-asc {
  background: rgba(10, 8, 16, 0.62);
  border-color: rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade-up 0.5s 0.46s ease-out both;
}

/* ---------- 「ダンジョンへ潜る」 ---------- */

.btn-dive {
  position: relative;
  overflow: hidden;
  margin-top: 12px;
  padding: 14px 14px;
  font-size: 17px;
  letter-spacing: 0.08em;
  border-radius: 14px;
  box-shadow: 0 5px 0 #a1550c, 0 10px 26px rgba(255, 138, 31, 0.28);
  animation: fade-up 0.5s 0.52s ease-out both;
}

.btn-dive:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #a1550c, 0 6px 16px rgba(255, 138, 31, 0.22);
}

/* 表面を流れる光 */
.btn-dive::after {
  content: "";
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: -70%;
  width: 42%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-18deg);
  animation: dive-shine 4.2s ease-in-out infinite;
}

@keyframes dive-shine {
  0%, 62%  { transform: translateX(0) skewX(-18deg); }
  92%, 100% { transform: translateX(420%) skewX(-18deg); }
}

.dive-arrow {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 10px;
  vertical-align: 1px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid #7a3f05;
  animation: dive-arrow 1.6s ease-in-out infinite;
}

@keyframes dive-arrow {
  0%, 100% { transform: translateX(-2px); opacity: 0.75; }
  50%      { transform: translateX(2px);  opacity: 1; }
}

/* ---------- 祭壇・そのほかのボタン ---------- */

.overlay-start .btn-sub {
  background: linear-gradient(180deg, rgba(46, 40, 62, 0.92), rgba(26, 22, 38, 0.92));
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.btn-altar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 9px;
  border-color: rgba(134, 220, 255, 0.4);
  color: #dff4ff;
  animation: fade-up 0.5s 0.58s ease-out both;
}

.altar-soul-chip {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--soul);
  background: rgba(134, 220, 255, 0.12);
  border: 1px solid rgba(134, 220, 255, 0.34);
  border-radius: 999px;
  padding: 2px 9px;
}

.start-actions {
  display: flex;
  gap: 7px;
  margin-top: 8px;
  animation: fade-up 0.5s 0.64s ease-out both;
}

.start-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 10px 4px;
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- PC ---------- */

@media (min-width: 768px) {
  .overlay-start { align-items: center; }
  .overlay-start .overlay-box { max-width: 420px; }
  .start-logo { width: min(100%, clamp(260px, 42vh, 380px)); }
  .ts-torch { width: 150px; height: 200px; top: 16%; }
  .ts-torch-l { left: calc(50% - 340px); }
  .ts-torch-r { right: calc(50% - 340px); }
}

/* ---------- 動きを抑える設定のとき ---------- */

@media (prefers-reduced-motion: reduce) {
  .ts-glow,
  .ts-grid i,
  .ts-torch::before,
  .ts-flame,
  .ts-embers i,
  .start-logo,
  .start-sub,
  .start-lead,
  .start-best,
  .overlay-start .start-asc,
  .btn-dive,
  .btn-dive::after,
  .dive-arrow,
  .btn-altar,
  .start-actions {
    animation: none !important;
  }
  .ts-embers { display: none; }
}
