/* ==========================================================================
   カオスサバイバー — スタイル
   ダークファンタジー（闇＋混沌の紫＋亀裂の金）。スマホ縦持ちを基準に、
   広い画面では中央寄せ・多カラムに広がる。
   ========================================================================== */

:root {
  --bg:        #0b0814;
  --bg2:       #120c20;
  --panel:     rgba(38, 26, 62, 0.72);
  --panel2:    rgba(24, 16, 42, 0.86);
  --border:    rgba(157, 107, 255, 0.24);
  --border2:   rgba(157, 107, 255, 0.45);
  --text:      #ece7f8;
  --dim:       #a99ec4;
  --dim2:      #7d739a;
  --chaos:     #9d6bff;
  --chaos2:    #c79bff;
  --gold:      #ffd84d;
  --gold2:     #ffefad;
  --danger:    #ff4d6d;
  --good:      #56e08a;
  --water:     #4de1ff;
  --fire:      #ff5a3c;
  --radius:    16px;
  --radius-sm: 11px;
  --shadow:    0 10px 34px rgba(0, 0, 0, 0.5);
  --tabh:      58px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  background-image:
    radial-gradient(900px 620px at 78% -8%, rgba(157, 107, 255, 0.2), transparent 70%),
    radial-gradient(700px 520px at 12% 8%, rgba(255, 90, 60, 0.09), transparent 70%);
  background-attachment: fixed;
}

body.in-battle {
  overflow: hidden;
  touch-action: none;
}

h1, h2, h3, h4, p, ul { margin: 0; }
ul { padding-left: 1.15em; }
button { font-family: inherit; color: inherit; }
img { max-width: 100%; }
a { color: var(--chaos2); }

.hidden { display: none !important; }
.muted { color: var(--dim); }
.small { font-size: 12px; line-height: 1.5; }
.center { text-align: center; }
.b { font-weight: 800; }
.block { display: block; }
.warn { color: var(--gold); }
.lack .srow-v { color: var(--danger); }

/* ============================== レイアウト ============================== */

#app {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: calc(var(--tabh) + 18px + var(--ad-space, 0px));
}

/* --- ヘッダー --- */
#topbar {
  position: sticky;
  top: var(--sgh-top, 0px);
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "home logo btns" "cur cur cur";
  align-items: center;
  gap: 4px 8px;
  padding: 7px 10px 8px;
  background: linear-gradient(180deg, rgba(16, 10, 30, 0.97), rgba(16, 10, 30, 0.9));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#btn-home { grid-area: home; }
#logo {
  grid-area: logo;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, #fff, var(--chaos2) 55%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#topbar-buttons { grid-area: btns; display: flex; gap: 2px; }
#currencies {
  grid-area: cur;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cur {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.cur-i { font-size: 12px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: rgba(157, 107, 255, 0.2); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn-sm { width: 28px; height: 28px; font-size: 13px; border-radius: 8px; }

/* --- 画面 --- */
#screens { position: relative; }
.screen { display: none; padding: 12px 12px 4px; }
.screen.active { display: block; animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

#s-battle.active { display: block; padding: 0; }

/* 戦闘中だけ拠点用の 720px カラムを解除し、画面を広く使う。
   広すぎると遠くの敵まで見えて簡単になりすぎるので 1100px で止める */
body.in-battle #app {
  max-width: none;
  padding-bottom: 0;
}
#battle-wrap {
  max-width: 1100px;
  margin: 0 auto;
}

/* --- タブバー --- */
#tabbar {
  position: fixed;
  left: 0; right: 0;
  bottom: var(--ad-space, 0px);
  z-index: 40;
  display: flex;
  max-width: 720px;
  margin: 0 auto;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px) * 0);
  background: linear-gradient(180deg, rgba(18, 11, 32, 0.94), rgba(11, 7, 20, 0.99));
  border-top: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
/* 広告が無いとき（PC幅・横向き・広告が畳まれたとき）は --ad-space にセーフエリアが入らないので、
   タブバー自身がホームインジケータのぶんを空ける（広告があるときは --ad-space 側で空けている） */
html:not(.has-ad-banner) #tabbar { padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
html:not(.has-ad-banner) #app { padding-bottom: calc(var(--tabh) + 18px + env(safe-area-inset-bottom, 0px)); }
html:not(.has-ad-banner) body.in-battle #app { padding-bottom: 0; }
.tab {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-height: 50px;
  padding: 5px 2px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--dim2);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.tab-i { font-size: 19px; line-height: 1; }
.tab-n { font-size: 10.5px; font-weight: 800; }
.tab.on { color: var(--gold2); background: rgba(157, 107, 255, 0.16); }
.tab:active { transform: scale(0.95); }
.tab-b {
  position: absolute;
  top: 2px; right: 12px;
  min-width: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 16px;
}

/* --- フッター --- */
#footer {
  padding: 18px 12px 10px;
  text-align: center;
  font-size: 11px;
  color: var(--dim2);
  line-height: 1.8;
}
#footer a { color: var(--dim); }
.ver-label { opacity: .7; }

/* ============================== 共通部品 ============================== */

.card {
  margin: 0 0 12px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.card-t { font-size: 14px; font-weight: 900; margin-bottom: 8px; }

.sec { margin: 2px 0 12px; }
.sec-t {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: .03em;
}
.sec-s { font-size: 12px; color: var(--dim); margin-top: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border2);
  border-radius: 12px;
  background: rgba(157, 107, 255, 0.14);
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
  transition: filter .15s, transform .1s, background .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: .42; cursor: default; }
.btn-primary {
  border: 0;
  background: linear-gradient(135deg, #b57bff, #7b3fe4 60%, #5a23bd);
  color: #fff;
  box-shadow: 0 6px 20px rgba(123, 63, 228, 0.4);
}
.btn-sub { background: rgba(255, 255, 255, 0.07); }
.btn-ghost { border-color: transparent; background: none; color: var(--dim); }
.btn-danger { border-color: rgba(255, 77, 109, 0.5); background: rgba(255, 77, 109, 0.14); color: #ffb7c2; }
.btn-sm { width: auto; min-height: 34px; padding: 5px 12px; font-size: 12.5px; border-radius: 9px; margin-top: 6px; }
.btn-big { min-height: 56px; font-size: 17px; margin-top: 14px; }

.row { display: flex; gap: 8px; }
.row > .btn { flex: 1; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-tight { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.srow {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 2px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: none;
  font-size: 13px;
  text-align: left;
}
.srow:last-child { border-bottom: 0; }
.srow-k { flex: 1; min-width: 0; color: var(--dim); }
.srow-v { font-weight: 800; font-variant-numeric: tabular-nums; }
.srow-e { font-size: 20px; }
.srow-btn { cursor: pointer; border-radius: 10px; padding: 8px; }
.srow-btn:hover:not(:disabled) { background: rgba(157, 107, 255, 0.12); }
.srow-btn.locked, .srow-btn:disabled { opacity: .45; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chip-n { font-size: 13px; }
.chip-s { font-size: 10px; color: var(--dim2); font-weight: 700; }
.chip.on { border-color: var(--chaos); background: rgba(157, 107, 255, 0.26); color: var(--gold2); }
.chip.on .chip-s { color: var(--gold2); opacity: .85; }
.chips-sm .chip { padding: 5px 12px; font-size: 12px; }

.rtag {
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
}
.rtag-R { background: rgba(143, 163, 189, 0.28); color: #cfdcea; }
.rtag-SR { background: rgba(92, 199, 255, 0.25); color: #b6e6ff; }
.rtag-SSR { background: linear-gradient(90deg, #ffcb4d, #ff8f4d); color: #3a2200; }
.rtag-LG {
  background: linear-gradient(90deg, #ff6bd6, #9d6bff 45%, #4de1ff);
  color: #1a0a20;
  box-shadow: 0 0 8px rgba(255, 107, 214, 0.5);
}

/* ============================== ホーム ============================== */

.hero {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  padding: 13px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 22% 30%, rgba(157, 107, 255, 0.32), transparent 62%),
    linear-gradient(150deg, rgba(46, 28, 78, 0.9), rgba(18, 11, 32, 0.94));
  box-shadow: var(--shadow);
}
.hero-art {
  flex-shrink: 0;
  width: 96px; height: 96px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border2);
  border-radius: 14px;
  background: radial-gradient(circle at 50% 40%, rgba(157, 107, 255, 0.3), rgba(0, 0, 0, 0.4));
}
.hero-img { width: 88px; height: 88px; }
.hero-info { flex: 1; min-width: 0; }
.hero-top { display: flex; align-items: center; gap: 6px; }
.hero-el { font-size: 11px; color: var(--gold2); font-weight: 800; }
.hero-name { font-size: 21px; font-weight: 900; line-height: 1.25; }
.hero-title { font-size: 11.5px; color: var(--dim); }
.hero-lv { font-size: 12px; font-weight: 700; margin-top: 3px; }
.hero-power { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.hero-power-k { font-size: 11px; color: var(--dim); }
.hero-power-v {
  font-size: 20px; font-weight: 900; color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px rgba(255, 216, 77, 0.4);
}

.idle-card { background: linear-gradient(150deg, rgba(30, 44, 62, 0.8), rgba(18, 11, 32, 0.9)); }
.idle-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.idle-t { font-size: 14px; font-weight: 900; }
.idle-time { font-size: 12px; color: var(--water); font-weight: 800; }

.bag { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.bag-i {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 12px;
}
.bag-e { font-size: 13px; }
.bag-n { color: var(--dim); }
.bag-v { font-weight: 900; font-variant-numeric: tabular-nums; }
.bag-ic { width: 22px; height: 22px; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 12px;
}
.hbtn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 11px 4px 9px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel);
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.hbtn:hover { background: rgba(157, 107, 255, 0.2); }
.hbtn:active { transform: scale(0.96); }
.hbtn-i { font-size: 23px; line-height: 1.1; }
.hbtn-n { font-size: 12px; font-weight: 900; }
.hbtn-s { font-size: 9px; color: var(--dim2); text-align: center; line-height: 1.3; }
.hbtn-b {
  position: absolute;
  top: 4px; right: 5px;
  min-width: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 17px;
}

.lore {
  margin-bottom: 12px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.24);
}
.lore-s { font-size: 13px; font-weight: 800; cursor: pointer; color: var(--dim); }
.lore-b { margin-top: 8px; font-size: 12.5px; color: var(--dim); }
.lore-b p { margin-bottom: 7px; }

/* ============================== 出撃 ============================== */

.chap {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel2);
  overflow: hidden;
}
.chap-s {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 13px;
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}
.chap-s::-webkit-details-marker { display: none; }
.chap-s::before { content: '▸'; margin-right: 6px; color: var(--chaos2); transition: transform .2s; }
.chap[open] .chap-s::before { transform: rotate(90deg); display: inline-block; }
.chap-n { flex: 1; font-size: 14px; }
.chap-p { font-size: 11px; color: var(--gold); font-weight: 900; }
.chap-b { padding: 0 10px 10px; }
.chap-b > .muted { margin-bottom: 8px; }

.stg {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin-bottom: 5px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.26);
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.stg:hover:not(:disabled) { background: rgba(157, 107, 255, 0.16); border-color: var(--border2); }
.stg:active:not(:disabled) { transform: scale(0.99); }
.stg.locked { opacity: .42; cursor: default; }
.stg.cleared { border-color: rgba(86, 224, 138, 0.3); }
.stg-no {
  flex-shrink: 0;
  width: 34px;
  font-size: 12px;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.stg-t { flex: 1; min-width: 0; }
.stg-n { display: block; font-size: 13.5px; font-weight: 800; }
.stg-m { display: flex; flex-wrap: wrap; gap: 8px; font-size: 10.5px; color: var(--dim2); }
.stg-boss { color: var(--danger); font-weight: 800; }
/* 戦闘時間。10分・15分の長いステージだけ目立たせる */
.stg-dur { font-variant-numeric: tabular-nums; }
.stg-dur.x2 { color: var(--water); font-weight: 800; }
.stg-dur.x3 { color: var(--gold); font-weight: 900; }
.chap-next {
  margin: 2px 0 12px;
  padding: 10px 13px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--dim2);
  text-align: center;
}
.stg-r { flex-shrink: 0; }
.stg-clear { font-size: 11px; color: var(--good); font-weight: 900; }
.stg-go { font-size: 11px; color: var(--chaos2); font-weight: 900; }
.stg-lock { font-size: 13px; }

/* ============================== 出撃準備 ============================== */

.prep-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.prep-head .btn { width: auto; flex-shrink: 0; margin-top: 0; }
.prep-info { flex: 1; min-width: 0; }
.prep-t { font-size: 18px; font-weight: 900; }
.prep-dur { margin-top: 3px; font-size: 12px; font-weight: 800; color: var(--dim); }
.prep-dur.long { color: var(--gold2); }

.char-strip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.cchip {
  flex-shrink: 0;
  width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cchip.on { border-color: var(--gold); background: rgba(255, 216, 77, 0.14); }
.cchip-img { width: 46px; height: 46px; }
.cchip-n { font-size: 11px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cchip-lv { font-size: 10px; color: var(--dim2); }

.det-h { display: flex; gap: 11px; margin-bottom: 8px; }
.det-img {
  flex-shrink: 0;
  width: 72px; height: 72px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: radial-gradient(circle at 50% 40%, rgba(157, 107, 255, 0.26), rgba(0, 0, 0, 0.35));
}
.det-t { flex: 1; min-width: 0; }
.det-pw { font-size: 13px; font-weight: 900; color: var(--gold); }
.det-pw.warn { color: var(--danger); }

.irow {
  display: flex;
  gap: 9px;
  padding: 7px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.irow-img { flex-shrink: 0; width: 34px; height: 34px; }
.irow-e { flex-shrink: 0; width: 34px; text-align: center; font-size: 20px; }
.irow-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.irow-l { font-size: 10px; color: var(--dim2); font-weight: 800; letter-spacing: .06em; }
.irow-n { font-size: 13.5px; font-weight: 900; }
.irow-d { font-size: 11.5px; color: var(--dim); line-height: 1.5; }

.eq-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.eq-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.3);
}
.eq-mini-img { width: 34px; height: 34px; }
.eq-mini-e { font-size: 24px; line-height: 34px; }
.eq-mini-n { font-size: 10.5px; font-weight: 800; text-align: center; line-height: 1.3; }
.eq-mini-lv { font-size: 10px; color: var(--gold); font-weight: 800; }

.mon-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.mon {
  width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 2px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
}
.mon-img { width: 38px; height: 38px; }
.mon-n { font-size: 9.5px; font-weight: 700; text-align: center; line-height: 1.25; }
.mon-e { font-size: 9px; color: var(--dim2); }
.mon-boss { border-color: rgba(255, 77, 109, 0.5); background: rgba(255, 77, 109, 0.1); width: 74px; }
.mon-boss .mon-img { width: 48px; height: 48px; }
.mon-boss .mon-e { color: var(--danger); font-weight: 900; }

.hazard {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  background: rgba(255, 216, 77, 0.1);
  font-size: 12px;
  color: var(--gold2);
}

/* ============================== 戦闘画面 ============================== */

#battle-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  height: calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  overflow: hidden;
  background: #0b0814;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#battle-canvas { display: block; width: 100%; height: 100%; }

#b-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 6px 8px 0;
  pointer-events: none;
}
#b-bars { display: flex; flex-direction: column; gap: 3px; }
.bar {
  position: relative;
  height: 15px;
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3ce07a, #8bf5b0);
  transition: width .12s linear;
}
.bar-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .9);
  font-variant-numeric: tabular-nums;
}
.bar-thin { height: 7px; }
.bar-thin .bar-fill { background: linear-gradient(90deg, #2fa8ff, #7ef0ff); }

#b-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.bstat {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 11.5px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}
.bstat-i { font-size: 10px; }
#b-lv { color: var(--gold2); }
#b-pause { pointer-events: auto; margin-left: auto; background: rgba(0, 0, 0, 0.5); }

#b-boss { margin-top: 5px; }
#b-boss-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}
#b-boss-name { color: #ffb7c2; }
#b-boss-phase { color: var(--gold); font-size: 10.5px; }
.bar-boss { height: 11px; }
.bar-boss .bar-fill { background: linear-gradient(90deg, #ff2d4d, #ff8fa3); transition: width .2s; }

#b-mini {
  position: absolute;
  /* ボスHPバーが出たときに重ならない高さに置く */
  top: 116px; right: 8px;
  width: 84px; height: 84px;
  border: 1px solid rgba(157, 107, 255, 0.4);
  border-radius: 10px;
  opacity: .78;
  pointer-events: none;
}

#b-actions {
  position: absolute;
  right: 12px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.act {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(20, 12, 36, 0.78);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.act:active:not(:disabled) { transform: scale(0.93); }
.act:disabled { opacity: .35; }
.act-sm { width: 48px; height: 48px; font-size: 21px; }
.act-sm .cnt {
  position: absolute;
  right: -2px; bottom: -2px;
  min-width: 19px;
  padding: 0 3px;
  border-radius: 999px;
  background: #1a1030;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 11px;
  font-weight: 900;
  line-height: 18px;
}
.act-ult {
  width: 84px; height: 84px;
  overflow: hidden;
  border-color: rgba(255, 216, 77, 0.4);
}
#b-ult-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, rgba(157, 107, 255, 0.75), rgba(255, 216, 77, 0.55));
  transition: height .15s linear;
}
.act-ult-i { position: relative; font-size: 26px; line-height: 1; filter: grayscale(1) opacity(.6); }
.act-ult-n {
  position: relative;
  margin-top: 1px;
  font-size: 9px;
  font-weight: 900;
  text-align: center;
  line-height: 1.15;
  padding: 0 3px;
  text-shadow: 0 1px 3px #000;
  color: var(--dim);
  max-width: 100%;
  overflow-wrap: break-word;
  hyphens: auto;
}
.act-ult.ready { border-color: var(--gold); animation: ultPulse 1.1s ease-in-out infinite; }
.act-ult.ready .act-ult-i { filter: none; }
.act-ult.ready .act-ult-n { color: var(--gold2); }
@keyframes ultPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 216, 77, 0.55); }
  50% { box-shadow: 0 0 0 10px rgba(255, 216, 77, 0); }
}

#b-stick {
  position: absolute;
  width: 108px; height: 108px;
  margin: -54px 0 0 -54px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}
#b-stick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(157, 107, 255, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.45);
}

/* --- レベルアップ選択 --- */
#lv-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(6, 3, 14, 0.86);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  overflow-y: auto;
}
#lv-panel { width: 100%; max-width: 460px; }
#lv-title {
  text-align: center;
  font-size: 19px;
  font-weight: 900;
  color: var(--gold2);
  text-shadow: 0 0 18px rgba(255, 216, 77, .45);
}
#lv-rest { text-align: center; font-size: 11.5px; color: var(--dim); margin-bottom: 8px; }
#lv-cards { display: flex; flex-direction: column; gap: 8px; }
.lv-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border2);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(46, 28, 78, 0.95), rgba(18, 11, 32, 0.95));
  text-align: left;
  cursor: pointer;
  animation: lvIn .22s ease backwards;
  transition: transform .12s, border-color .15s;
}
.lv-card:nth-child(1) { animation-delay: .02s; }
.lv-card:nth-child(2) { animation-delay: .08s; }
.lv-card:nth-child(3) { animation-delay: .14s; }
@keyframes lvIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.lv-card:hover, .lv-card:focus-visible { border-color: var(--gold); transform: translateX(3px); outline: none; }
.lv-card:active { transform: scale(0.99); }
.lv-tag {
  position: absolute;
  top: -8px; left: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #2a1b48;
  border: 1px solid var(--border2);
  font-size: 10px;
  font-weight: 900;
  color: var(--dim);
}
.lv-icon { flex-shrink: 0; width: 52px; height: 52px; }
.lv-icon-ph { display: grid; place-items: center; font-size: 30px; }
.lv-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lv-name { font-size: 15.5px; font-weight: 900; line-height: 1.3; }
.lv-sub { font-size: 11px; color: var(--gold2); font-weight: 800; }
.lv-desc { font-size: 11.5px; color: var(--dim); line-height: 1.45; margin-top: 2px; }

.lv-new { border-color: rgba(92, 199, 255, 0.5); }
.lv-new .lv-tag { color: #b6e6ff; border-color: rgba(92, 199, 255, 0.6); }
.lv-evo {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(84, 60, 18, 0.95), rgba(32, 20, 10, 0.95));
  box-shadow: 0 0 22px rgba(255, 216, 77, 0.22);
}
.lv-evo .lv-tag { color: #3a2200; background: linear-gradient(90deg, #ffcb4d, #ff8f4d); border: 0; }
.lv-chaos {
  border-color: #ff6bd6;
  background: linear-gradient(135deg, rgba(84, 20, 78, 0.96), rgba(28, 12, 46, 0.96));
  box-shadow: 0 0 26px rgba(255, 107, 214, 0.3);
  animation: lvIn .22s ease backwards, chaosGlow 1.8s ease-in-out infinite .3s;
}
@keyframes chaosGlow {
  0%, 100% { box-shadow: 0 0 26px rgba(255, 107, 214, 0.25); }
  50% { box-shadow: 0 0 38px rgba(255, 107, 214, 0.55); }
}
.lv-chaos .lv-tag { color: #fff; background: linear-gradient(90deg, #ff6bd6, #9d6bff); border: 0; }
.lv-chaos .lv-name { color: #ffd2f4; }

/* --- 一時停止 --- */
#pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 21;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 3, 14, 0.88);
}
#pause-panel {
  width: 100%;
  max-width: 320px;
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 16px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--panel2);
  text-align: center;
}
#pause-panel h2 { font-size: 18px; font-weight: 900; margin-bottom: 6px; }
/* 一時停止中に見せる、いま持っている武器・能力の一覧。
   数が増えても「続ける」「撤退する」が画面外へ押し出されないよう、一覧だけを先に縮めてスクロールさせる */
#pause-build { margin: 12px 0 4px; max-height: 30vh; overflow-y: auto; }
.pause-build-t { font-size: 12px; font-weight: 800; color: var(--dim); margin-bottom: 2px; }
.pause-build-s { font-size: 10px; font-weight: 800; color: var(--dim); margin-top: 8px; letter-spacing: .08em; }
#pause-build .build-grid { justify-content: center; gap: 5px; }
#pause-build .build-i { width: 52px; padding: 4px 2px; }
#pause-build .build-img { width: 28px; height: 28px; }

/* ============================== リザルト ============================== */

.result-box { text-align: center; }
.res-icon { font-size: 46px; line-height: 1.1; animation: pop .4s ease; }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } to { transform: none; opacity: 1; } }
.res-t {
  font-size: 25px;
  font-weight: 900;
  background: linear-gradient(90deg, var(--gold2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.res-sub { font-size: 13px; color: var(--dim); }
.res-big { margin: 6px 0; }
.res-big-v {
  font-size: 40px;
  font-weight: 900;
  color: var(--water);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px rgba(77, 225, 255, .45);
}
.res-big-u { font-size: 14px; color: var(--dim); margin-left: 4px; }
.res-record {
  display: inline-block;
  margin: 6px 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffcb4d, #ff8f4d);
  color: #3a2200;
  font-size: 12.5px;
  font-weight: 900;
}
.res-newchap {
  margin: 4px auto 6px;
  padding: 7px 14px;
  max-width: 340px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: rgba(157, 107, 255, 0.16);
  color: var(--chaos2);
  font-size: 13px;
  font-weight: 900;
}
.res-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
}
.res-stat {
  display: flex;
  flex-direction: column;
  padding: 7px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
}
.res-stat-k { font-size: 9.5px; color: var(--dim2); }
.res-stat-v { font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }

.res-chaos {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid #ff6bd6;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(84, 20, 78, 0.6), rgba(28, 12, 46, 0.6));
  text-align: left;
}
.res-chaos-t { font-size: 13.5px; font-weight: 900; color: #ffd2f4; margin-bottom: 6px; }
.res-chaos-row { display: flex; align-items: center; gap: 9px; padding: 4px 0; }
.res-chaos-img { width: 40px; height: 40px; flex-shrink: 0; }

.res-reward { margin-top: 12px; text-align: left; }
.drops { margin-top: 8px; }
.drops-t { font-size: 12px; font-weight: 900; color: var(--dim); margin-bottom: 4px; }
.res-build { margin-top: 12px; text-align: left; font-size: 12.5px; color: var(--dim); }
.res-build summary { cursor: pointer; font-weight: 800; padding: 4px 0; }
.build-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.build-i {
  width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
}
.build-img { width: 34px; height: 34px; }
.build-n { font-size: 9px; font-weight: 700; text-align: center; line-height: 1.2; color: var(--text); max-width: 100%; overflow-wrap: break-word; hyphens: auto; }
.build-lv { font-size: 9px; color: var(--gold); font-weight: 900; }
.build-i.evo { border-color: var(--gold); }
.build-i.chaos { border-color: #ff6bd6; background: rgba(84, 20, 78, 0.4); }
.res-btns { margin-top: 14px; }
.res-btns .btn { width: 100%; }

/* ============================== 召喚 ============================== */

.gacha-banner {
  border-color: var(--border2);
  background:
    radial-gradient(circle at 80% 10%, rgba(255, 107, 214, 0.28), transparent 60%),
    linear-gradient(150deg, rgba(52, 24, 82, 0.95), rgba(16, 10, 30, 0.95));
  text-align: center;
}
.gb-t {
  font-size: 22px;
  font-weight: 900;
  background: linear-gradient(90deg, #ff6bd6, var(--chaos2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.gb-s { font-size: 12px; color: var(--dim); margin-bottom: 8px; }
.pity {
  height: 8px;
  margin: 6px 0 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.pity-fill { height: 100%; background: linear-gradient(90deg, var(--chaos), var(--gold)); }
/* LEGEND 側の天井ゲージ */
.pity-lg .pity-fill { background: linear-gradient(90deg, #4de1ff, #9d6bff 50%, #ff6bd6); }

.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 7px;
}
.ctile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: radial-gradient(circle at 50% 30%, rgba(157, 107, 255, 0.18), rgba(0, 0, 0, 0.34));
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.ctile:hover { border-color: var(--border2); }
.ctile:active { transform: scale(0.97); }
.ctile-img { width: 52px; height: 52px; }
.ctile-n { font-size: 11.5px; font-weight: 900; }
.ctile-el { font-size: 10px; color: var(--dim2); }
.ctile-pw { font-size: 10px; color: var(--gold); font-weight: 900; font-variant-numeric: tabular-nums; }
.ctile.un { opacity: .42; }
.ctile-lock { font-size: 9.5px; color: var(--dim2); }
.ctile.lead { border-color: var(--gold); background: radial-gradient(circle at 50% 30%, rgba(255, 216, 77, 0.2), rgba(0, 0, 0, 0.34)); }
.ctile-lead { font-size: 9.5px; color: var(--gold); font-weight: 900; }

.pull-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 7px;
  margin-bottom: 8px;
}
.pull {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.34);
  animation: pullIn .34s cubic-bezier(.2, 1.5, .5, 1) backwards;
}
@keyframes pullIn { from { opacity: 0; transform: scale(0.5) rotate(-8deg); } to { opacity: 1; transform: none; } }
.pull-img { width: 50px; height: 50px; }
.pull-n { font-size: 11px; font-weight: 900; }
.pull-tag { font-size: 9.5px; font-weight: 900; color: var(--gold); }
.pull-SR { border-color: rgba(92, 199, 255, 0.6); box-shadow: 0 0 14px rgba(92, 199, 255, 0.24); }
.pull-SSR {
  border-color: var(--gold);
  background: radial-gradient(circle at 50% 30%, rgba(255, 203, 77, 0.3), rgba(0, 0, 0, 0.4));
  box-shadow: 0 0 24px rgba(255, 203, 77, 0.45);
}
.pull-LG {
  border-color: #ff6bd6;
  background: radial-gradient(circle at 50% 30%, rgba(255, 107, 214, 0.34), rgba(77, 225, 255, 0.14) 60%, rgba(0, 0, 0, 0.45));
  box-shadow: 0 0 30px rgba(255, 107, 214, 0.6);
  animation: pullIn .34s cubic-bezier(.2, 1.5, .5, 1) backwards, lgGlow 1.6s ease-in-out infinite;
}
@keyframes lgGlow {
  0%, 100% { box-shadow: 0 0 30px rgba(255, 107, 214, 0.6); }
  50% { box-shadow: 0 0 44px rgba(157, 107, 255, 0.85); }
}

/* ============================== 強化 ============================== */

.mat-card { display: flex; gap: 7px; flex-wrap: wrap; }
.mat {
  flex: 1;
  min-width: 96px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
}
.mat-i { font-size: 17px; }
.mat-n { flex: 1; font-size: 10.5px; color: var(--dim); }
.mat-v { font-size: 14px; font-weight: 900; font-variant-numeric: tabular-nums; }

.cd-head { display: flex; gap: 11px; margin-bottom: 10px; }
.cd-img {
  flex-shrink: 0;
  width: 84px; height: 84px;
  border: 1px solid var(--border2);
  border-radius: 13px;
  background: radial-gradient(circle at 50% 40%, rgba(157, 107, 255, 0.3), rgba(0, 0, 0, 0.4));
}
.cd-t { flex: 1; min-width: 0; }
.cd-el { font-size: 11px; color: var(--gold2); font-weight: 800; }
.cd-title { font-size: 12px; color: var(--dim); }
.cd-lv { font-size: 13px; font-weight: 900; }
.cd-pw { font-size: 13px; font-weight: 900; color: var(--gold); }
.cd-story {
  margin: 8px 0;
  padding: 9px 11px;
  border-left: 3px solid var(--border2);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.26);
  font-size: 12px;
  color: var(--dim);
  line-height: 1.65;
}

.grow-box {
  margin-top: 10px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.26);
}
.grow-t { font-size: 12.5px; font-weight: 900; color: var(--gold2); margin-bottom: 5px; }
.stars { display: flex; gap: 3px; margin-bottom: 6px; }
.star { font-size: 17px; color: rgba(255, 255, 255, 0.16); line-height: 1; }
.star.on { color: var(--gold); text-shadow: 0 0 10px rgba(255, 216, 77, .6); }
.star-aw.on { color: #ff6bd6; text-shadow: 0 0 10px rgba(255, 107, 214, .6); }

/* ============================== 装備 ============================== */

.eq-slot { margin-bottom: 9px; }
.eq-slot-h { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.eq-slot-i { font-size: 14px; }
.eq-slot-n { font-size: 11.5px; font-weight: 900; color: var(--dim); }
.eq-total { margin-top: 8px; font-size: 12px; }
.eq-total summary { cursor: pointer; color: var(--dim); font-weight: 800; padding: 4px 0; }

.eqrow {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin-bottom: 5px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}
.eqrow:hover:not(:disabled) { background: rgba(157, 107, 255, 0.14); }
.eqrow:disabled { cursor: default; }
.eqrow-R { border-left-color: #8fa3bd; }
.eqrow-SR { border-left-color: #5cc7ff; }
.eqrow-SSR { border-left-color: var(--gold); background: rgba(255, 203, 77, 0.08); }
.eqrow.on { border-color: var(--good); }
.eqrow-img { flex-shrink: 0; width: 38px; height: 38px; }
.eqrow-t { flex: 1; min-width: 0; }
.eqrow-l1 { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.eqrow-n { font-size: 13px; font-weight: 900; }
.eqrow-lv { font-size: 11px; color: var(--gold); font-weight: 900; }
.eqrow-l2 { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.eff {
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 9.5px;
  color: var(--dim);
  font-weight: 700;
}
.eqrow-on { flex-shrink: 0; font-size: 10px; color: var(--good); font-weight: 900; }

/* ============================== ミッション ============================== */

.mrow {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.mrow:last-child { border-bottom: 0; }
.mrow.claimed { opacity: .5; }
.mrow-t { flex: 1; min-width: 0; }
.mrow-n { display: block; font-size: 12.5px; font-weight: 800; }
.mbar { height: 5px; margin: 4px 0 2px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); overflow: hidden; }
.mbar-f { height: 100%; background: linear-gradient(90deg, var(--chaos), var(--gold)); transition: width .3s; }
.mrow-p { font-size: 10px; color: var(--dim2); font-variant-numeric: tabular-nums; }
.mrow-r { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.mrow-rw { font-size: 11.5px; font-weight: 900; color: var(--gold); }
.mrow-ok { font-size: 10.5px; color: var(--good); font-weight: 900; }
.mrow-r .btn { margin-top: 0; }
.mrow-bonus { border-top: 1px solid var(--border); border-bottom: 0; }
.mrow-bonus .mrow-n { color: var(--gold2); }

.login-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.ltile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.3);
  text-align: left;
  cursor: default;
}
.ltile-d { font-size: 10px; font-weight: 900; color: var(--dim2); }
.ltile-l { font-size: 10.5px; font-weight: 800; line-height: 1.35; }
.ltile.ready {
  border-color: var(--gold);
  background: rgba(255, 203, 77, 0.13);
  cursor: pointer;
  animation: readyPulse 1.6s ease-in-out infinite;
}
@keyframes readyPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 216, 77, .35); }
  50% { box-shadow: 0 0 0 6px rgba(255, 216, 77, 0); }
}
.ltile.claimed { opacity: .42; }
.ltile-c {
  position: absolute;
  top: 4px; right: 6px;
  color: var(--good);
  font-size: 14px;
  font-weight: 900;
}
.login-list { border-top: 1px solid var(--border); padding-top: 6px; }
.lrow {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
}
.lrow.claimed { opacity: .45; }
.lrow-d { flex-shrink: 0; width: 48px; font-weight: 900; color: var(--dim2); font-size: 11px; }
.lrow-l { flex: 1; min-width: 0; }
.lrow .btn { margin-top: 0; }

/* ============================== 図鑑 ============================== */

.crow {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.crow:last-child { border-bottom: 0; }
.crow.un { opacity: .48; }
.crow.un .crow-img { filter: grayscale(1) brightness(.6); }
.crow-img { flex-shrink: 0; width: 42px; height: 42px; }
.crow-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.crow-n { font-size: 13.5px; font-weight: 900; }
.crow-r { font-size: 10.5px; color: var(--gold2); font-weight: 800; }
.crow-d { font-size: 11.5px; color: var(--dim); line-height: 1.5; margin-top: 2px; }
.crow-c { flex-shrink: 0; font-size: 11px; font-weight: 900; color: var(--gold); }

/* ============================== 交換所 ============================== */

.shoprow {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.shoprow:last-child { border-bottom: 0; }
.shoprow-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.shoprow-n { font-size: 13px; font-weight: 900; }
.shoprow-c { font-size: 11.5px; color: var(--gold); font-weight: 800; }
.shoprow .btn { margin-top: 0; flex-shrink: 0; }

/* ============================== 設定 ============================== */

.trow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.trow:last-child { border-bottom: 0; }
.trow-l { font-size: 13.5px; font-weight: 700; }
.toggle {
  flex-shrink: 0;
  position: relative;
  width: 50px; height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.toggle .knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--dim2);
  transition: transform .2s, background .2s;
}
.toggle.on { background: rgba(157, 107, 255, 0.35); border-color: var(--chaos); }
.toggle.on .knob { transform: translateX(22px); background: var(--gold); }

.howto { font-size: 13px; line-height: 1.75; color: var(--text); }
.howto li { margin-bottom: 7px; }
.howto b { color: var(--gold2); }

/* ============================== モーダル ============================== */

#modal {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: rgba(5, 3, 12, 0.82);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
#modal-panel {
  width: min(430px, 100%);
  max-height: min(84vh, 720px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border2);
  border-radius: 18px;
  background: linear-gradient(160deg, #241636, #120c20);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .6);
  animation: modalIn .22s ease;
}
#modal.modal-wide #modal-panel { width: min(560px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
#modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 13px 8px;
  border-bottom: 1px solid var(--border);
}
#modal-title { font-size: 16.5px; font-weight: 900; }
#modal-box {
  padding: 13px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================== ロード・トースト ============================== */

#loading {
  position: fixed;
  inset: 0;
  z-index: 2147483100;
  display: grid;
  place-items: center;
  background: rgba(6, 3, 14, 0.94);
}
#loading-box { text-align: center; color: var(--dim); font-size: 13px; }
#loading-spin {
  width: 46px; height: 46px;
  margin: 0 auto 12px;
  border: 3px solid rgba(157, 107, 255, 0.25);
  border-top-color: var(--chaos2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabh) + 22px + var(--ad-space, 0px));
  transform: translateX(-50%);
  z-index: 2147483200;
  max-width: min(92vw, 460px);
  padding: 9px 16px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: rgba(24, 15, 42, 0.96);
  font-size: 12.5px;
  font-weight: 800;
  text-align: center;
  box-shadow: var(--shadow);
  animation: toastIn .24s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translateX(-50%); } }
.toast-good { border-color: var(--good); color: #b8f5cd; }
.toast-warn { border-color: var(--gold); color: var(--gold2); }
.toast-boss { border-color: var(--danger); color: #ffc0ca; }
body.in-battle .toast { bottom: calc(110px + var(--ad-space, 0px)); }

/* ============================== 画面幅の調整 ============================== */

@media (min-width: 560px) {
  #topbar {
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas: "home logo cur btns";
  }
  #logo { font-size: 18px; }
  .home-grid { grid-template-columns: repeat(4, 1fr); }
  .res-stats { grid-template-columns: repeat(3, 1fr); }
  .screen { padding: 14px 16px 4px; }
}

@media (min-width: 768px) {
  #b-actions { right: 22px; bottom: 22px; }
  .act-ult { width: 96px; height: 96px; }
  #lv-cards { gap: 10px; }
  .lv-card { padding: 13px 14px; }
}

/* PCではタブバーを少し細く、ホバー可能に */
@media (hover: hover) {
  .tab:hover { color: var(--text); background: rgba(157, 107, 255, 0.1); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   全国ランキング（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(5, 3, 12, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sgr-panel {
  width: min(430px, 100%);
  max-height: min(82vh, 660px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 18px;
  border: 1px solid var(--border2);
  border-radius: 18px;
  background: linear-gradient(160deg, #241636, #120c20);
  color: var(--text);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .6);
}
.sgr-title { margin: 0; font-size: 19px; font-weight: 900; text-align: center; }
.sgr-tabs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.sgr-tab {
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.sgr-tab-active { border-color: var(--chaos); background: rgba(157, 107, 255, 0.24); color: var(--gold2); }
.sgr-register-msg { margin: 0 0 6px; font-size: 13.5px; font-weight: 800; color: var(--gold2); text-align: center; }
.sgr-form { display: flex; gap: 8px; }
.sgr-name {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
}
.sgr-name:focus { outline: none; border-color: var(--chaos); }
.sgr-submit {
  padding: 8px 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #b57bff, #7b3fe4);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(123, 63, 228, .4);
}
.sgr-submit:hover { filter: brightness(1.1); }
.sgr-submit:disabled { opacity: .5; cursor: default; }
.sgr-error { margin: 4px 0 0; font-size: 12px; font-weight: 700; color: var(--danger); }
.sgr-status { margin: 0; font-size: 13px; color: var(--dim); text-align: center; }
.sgr-list {
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sgr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13.5px;
}
.sgr-row:nth-child(even) { background: rgba(255, 255, 255, 0.05); }
.sgr-row.sgr-row-me { background: rgba(157, 107, 255, 0.3); color: #fff; }
.sgr-rank { width: 2em; text-align: right; font-weight: 900; flex-shrink: 0; }
.sgr-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sgr-row-score {
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.sgr-row.sgr-row-me .sgr-row-score { color: #fff; }
.sgr-close {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.sgr-close:active { transform: scale(0.98); }
.sgr-cta { margin: 0 0 14px; text-align: center; }
.sgr-cta-msg { margin: 0 0 6px; font-size: 13.5px; font-weight: 900; color: var(--gold2); }
.sgr-cta-btn {
  padding: 10px 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffe08a, #ffb648);
  color: #4a3200;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 209, 102, .35);
}
.sgr-cta-btn:active { transform: scale(0.98); }
.sgr-cta-link {
  padding: 6px;
  border: 0;
  background: none;
  color: var(--dim);
  font-family: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

/* ==========================================================================
   フッター固定バナー広告（スマホ表示時のみ / 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 {
  box-sizing: content-box;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  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);
  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; }
}
