/* ===== スター育成物語 バズプロ！ ===== */
/* touch-action: manipulation でスマホのダブルタップ拡大を全要素で無効化（連打対策） */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

:root {
  --bg: #12101c;
  --bg2: #1c1930;
  --card: #241f3d;
  --card2: #2e2850;
  --text: #f0edff;
  --sub: #9c93c7;
  --accent: #ff3d8b;
  --accent2: #8b5cf6;
  --gold: #ffd34d;
  --green: #3ddc84;
  --blue: #4dc3ff;
  --danger: #ff5c5c;
  --grad: linear-gradient(135deg, #ff3d8b, #8b5cf6);
}

html, body {
  height: 100%;
  background: #000;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  overscroll-behavior: none;
  /* iOS Safariが横長スクロール要素（ティッカー等）の文字を勝手に拡大するのを防ぐ */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body { display: flex; justify-content: center; }

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: calc(100dvh - var(--sgh-top, 0px) - var(--ad-space, 0px));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  /* viewport-fit=cover 用: ノッチ・ホームバー横の切り欠きを避ける */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ===== ヘッダー ===== */
#header {
  flex-shrink: 0;
  /* ステータスバー（セーフエリア上端）は共通ヘッダー（--sgh-top）が避けているので、ここでは足さない。
     足すとホーム画面版（status-bar黒透過）で共通ヘッダーの下にもう1段空白ができる */
  padding: 10px 12px 6px;
  background: linear-gradient(180deg, #221c3f, #171327);
  border-bottom: 1px solid #322a5a;
  z-index: 10;
}

.header-top { display: flex; justify-content: space-between; align-items: center; }

.game-title {
  margin: 0; /* h1のデフォルトマージンを打ち消す */
  font-size: 16px;
  font-weight: 800;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stage-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--card2);
  border: 1px solid var(--accent2);
  color: var(--gold);
}

.header-right { display: flex; align-items: center; gap: 6px; }

/* サウンドのON/OFF（共通ヘッダーがあるときはそのメニューに集約されて隠れる） */
.hdr-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #4a4180;
  background: var(--card2);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
}
.hdr-btn.off { opacity: 0.55; }

.stats-row { display: flex; gap: 6px; margin-top: 8px; }

.stat {
  flex: 1;
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 5px 8px;
  min-width: 0;
}
.stat-label { font-size: 10px; color: var(--sub); white-space: nowrap; }
.stat-value {
  font-size: 13px; font-weight: 700; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.income-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; font-size: 12px;
}
.income-label { color: var(--sub); font-size: 11px; }
.income-value { color: var(--green); font-weight: 800; font-size: 14px; flex: 1; }
.buzzpt { color: var(--blue); font-weight: 700; }

/* 今日のトレンド: ラベル固定＋数値部分だけ電光掲示板風に横スクロール */
.trend-ticker {
  margin-top: 6px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--sub);
}
.ticker-label { flex-shrink: 0; font-weight: 700; }
.ticker-board {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: #04060c;
  border: 1px solid #1c2742;
  border-radius: 4px;
  padding: 2px 0;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9);
}
.ticker-track {
  display: inline-flex;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  animation: tickerScroll 24s linear infinite;
  will-change: transform;
}
.ticker-track .up,
.ticker-track .down { margin-right: 20px; font-weight: 800; }
.ticker-track .up {
  color: #43f597;
  text-shadow: 0 0 5px rgba(61, 220, 132, 0.9);
}
.ticker-track .down {
  color: #ff7a7a;
  text-shadow: 0 0 5px rgba(255, 92, 92, 0.9);
}
@keyframes tickerScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ===== メイン ===== */
#main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 20px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--sub);
  margin: 14px 0 8px;
  letter-spacing: 0.05em;
}
.section-title:first-child { margin-top: 0; }
.slot-info { font-weight: 400; font-size: 11px; }

/* ===== クリエイターカード ===== */
.creator-list { display: flex; flex-direction: column; gap: 8px; }

.creator-card {
  background: var(--card);
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid #37305e;
  position: relative;
  overflow: hidden;
}
.creator-card.trend-up { border-color: var(--green); }
.creator-card.trend-down { border-color: #7a3a3a; }
/* タップ応援の押下フィードバック（所属カードのみ） */
#creator-list .creator-card { cursor: pointer; transition: filter 0.08s ease; }
#creator-list .creator-card:active { filter: brightness(1.15); }
/* 遠征中のクリエイターはグレー表示 */
.creator-card.on-exped { opacity: 0.55; }
.creator-card.on-exped .cc-icon { filter: grayscale(1); }

.cc-top { display: flex; align-items: center; gap: 10px; }
.cc-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  background: var(--card2);
  border-radius: 12px;
}
.cc-info { flex: 1; min-width: 0; }

/* クリエイターのイラストアイコン（SVG画像） */
.cicon {
  width: 1.25em; height: 1.25em;
  vertical-align: -0.28em;
  border-radius: 50%;
}
.cc-icon .cicon { width: 38px; height: 38px; vertical-align: middle; }
.crew-icon .cicon { width: 22px; height: 22px; vertical-align: middle; }
.combo-icons .cicon { width: 24px; height: 24px; vertical-align: middle; }
.gacha-result-item .icon .cicon { width: 26px; height: 26px; vertical-align: middle; }
/* 冒険要素のイラストアイコン（神器・遠征・ライバル） */
.job-icon .cicon { width: 26px; height: 26px; vertical-align: middle; }
.ug-icon .cicon { width: 30px; height: 30px; vertical-align: middle; }
.side-name .cicon { width: 20px; height: 20px; vertical-align: -0.28em; }
.modal-title .cicon { width: 22px; height: 22px; vertical-align: -0.22em; }
.cc-name { font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.rarity { font-size: 10px; padding: 1px 6px; border-radius: 6px; font-weight: 800; flex-shrink: 0; }
.cc-meta { font-size: 11px; color: var(--sub); margin-top: 2px; }
.cc-meta b { color: var(--text); }
.cc-income { font-size: 11px; color: var(--green); font-weight: 700; margin-top: 1px; }
.cc-trend-tag { font-size: 10px; font-weight: 800; }

.cc-bottom { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

.post-bar {
  flex: 1; height: 6px;
  background: rgba(0,0,0,0.4);
  border-radius: 3px;
  overflow: hidden;
}
.post-bar-fill {
  height: 100%;
  background: var(--grad);
  border-radius: 3px;
  transition: width 0.25s linear;
}

.btn-lvup {
  flex-shrink: 0;
  min-width: 110px;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 10px;
  border: none;
  background: var(--grad);
  color: #fff;
  line-height: 1.35;
}
.btn-lvup:disabled { background: #3a3560; color: #7d76a8; }
.btn-lvup span { display: block; font-size: 10px; font-weight: 600; opacity: 0.9; }

/* 覚醒 */
.cc-stars { font-size: 10px; letter-spacing: -2px; flex-shrink: 0; }
/* 覚醒ティアごとの⭐の色（5段階毎に進化: 金→緑→青→紫→虹） */
.awk-t2 { filter: hue-rotate(65deg) saturate(1.4); }
.awk-t3 { filter: hue-rotate(165deg) saturate(1.6); }
.awk-t4 { filter: hue-rotate(230deg) saturate(1.6); }
.awk-t5 { display: inline-block; animation: awk-rainbow 3s linear infinite; }
@keyframes awk-rainbow {
  from { filter: hue-rotate(0deg) saturate(1.8) brightness(1.1); }
  to   { filter: hue-rotate(360deg) saturate(1.8) brightness(1.1); }
}
/* 超覚醒ティア（26段階目〜: 黒曜→白金→深紅→星海→特異） */
.awk-t6 { filter: grayscale(1) brightness(0.55) drop-shadow(0 0 2px #b18cff); }
.awk-t7 { filter: grayscale(1) brightness(1.7) drop-shadow(0 0 2px #fff); }
.awk-t8 { filter: hue-rotate(315deg) saturate(2.2) brightness(1.1); }
.awk-t9 { display: inline-block; animation: awk-starsea 4s ease-in-out infinite; }
@keyframes awk-starsea {
  0%, 100% { filter: hue-rotate(180deg) saturate(2) brightness(1.2); }
  50%      { filter: hue-rotate(260deg) saturate(2.2) brightness(1.5); }
}
.awk-t10 {
  display: inline-block;
  animation: awk-rainbow 1.2s linear infinite;
  text-shadow: 0 0 6px #fff, 0 0 12px #b18cff;
}
.btn-awaken {
  flex-shrink: 0;
  min-width: 72px;
  padding: 7px 8px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #e8a90c, #ff7d3d);
  color: #fff;
  line-height: 1.35;
  transition: transform 0.08s ease, filter 0.08s ease;
  touch-action: manipulation;
}
.btn-awaken:not(:disabled):active { transform: scale(0.9); filter: brightness(1.3); }
.btn-awaken:disabled { background: #4a3d2a; color: #a89670; }
.btn-awaken span { display: block; font-size: 10px; font-weight: 600; opacity: 0.9; }

/* レア度カラー */
.rarity-N { background: #5a627a; color: #dfe5f5; }
.rarity-R { background: #2f7fd3; color: #fff; }
.rarity-SR { background: #7d3fd8; color: #fff; }
.rarity-SSR { background: linear-gradient(135deg, #e8a90c, #ffdf6b); color: #4a3400; }
.rarity-UR { background: linear-gradient(135deg, #ff3d8b, #ff9d5c); color: #fff; }
.rarity-LEGEND { background: linear-gradient(135deg, #ffd34d, #ff3d8b, #8b5cf6); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.rarity-GOD {
  background: linear-gradient(135deg, #fffbe0, #ffd34d 30%, #fff 50%, #ffd34d 70%, #fffbe0);
  background-size: 200% 200%;
  color: #7a5200;
  box-shadow: 0 0 6px rgba(255, 211, 77, 0.9);
  animation: godShimmer 2s linear infinite;
}
@keyframes godShimmer {
  from { background-position: 0% 0%; }
  to { background-position: 200% 200%; }
}
/* 超越（ORIGIN）: GODを超えた存在 */
.rarity-ORIGIN {
  background: linear-gradient(135deg, #4de3ff, #b18cff 35%, #ff5c8a 65%, #ffd34d);
  background-size: 300% 300%;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 8px rgba(177, 140, 255, 0.95);
  animation: godShimmer 1.5s linear infinite;
}
.cc-skill { font-size: 10px; color: #b18cff; font-weight: 700; margin-top: 1px; }
.btn-origin { background: linear-gradient(135deg, #7d3fd8, #2a7fd4); }
.btn-origin:disabled { background: #3a3560; color: #7d76a8; }

/* スカウトカード */
.scout-card { opacity: 0.95; }
.scout-card .cc-icon { filter: grayscale(0.6); }

/* ===== ボタン共通 ===== */
.btn {
  border: none;
  border-radius: 12px;
  font-weight: 800;
  color: #fff;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  background: var(--grad);
  touch-action: manipulation;
}
.btn:not(:disabled):active { transform: scale(0.95); filter: brightness(1.2); }
.btn:disabled { opacity: 0.5; }

/* Lv UP・購入系ボタンの押下フィードバック */
.btn-lvup, .btn-buy {
  transition: transform 0.08s ease, filter 0.08s ease;
  touch-action: manipulation;
}
.btn-lvup:not(:disabled):active,
.btn-buy:not(:disabled):active {
  transform: scale(0.9);
  filter: brightness(1.35);
  box-shadow: 0 0 12px rgba(255, 61, 139, 0.7);
}
.btn-sub { background: var(--card2); border: 1px solid #4a4180; }
.btn-danger { background: #5c2333; border: 1px solid var(--danger); color: #ffb3b3; }

/* ===== 案件 ===== */
.job-list { display: flex; flex-direction: column; gap: 8px; }

.job-card {
  background: var(--card);
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid #37305e;
}
.job-top { display: flex; align-items: center; gap: 8px; }
.job-icon { font-size: 22px; }
.job-name { font-size: 13px; font-weight: 800; flex: 1; }
.job-reward { font-size: 12px; color: var(--gold); font-weight: 800; text-align: right; }
.job-reward small { display: block; color: var(--blue); font-weight: 700; }
.job-meta { font-size: 11px; color: var(--sub); margin-top: 4px; }
.job-meta.locked { color: var(--danger); }
.job-actions { margin-top: 8px; }
.btn-job { width: 100%; padding: 8px; background: var(--grad); font-size: 12px; }
.btn-collect { width: 100%; padding: 8px; background: linear-gradient(135deg, #1fa860, #3ddc84); font-size: 12px; }
.btn-cancel {
  width: 100%;
  padding: 7px;
  font-size: 11px;
  background: #3a2036;
  border: 1px solid #7a3a4a;
  color: #ff9b9b;
}

.job-progress { margin-top: 8px; }
.job-progress .post-bar { height: 8px; }
.job-progress .time-left { font-size: 11px; color: var(--sub); margin-top: 3px; text-align: right; }

/* 届いた依頼（失注カウントダウン付き） */
.offer-card {
  border-color: var(--gold);
  animation: offerPulse 1.6s infinite;
}
.offer-bar-fill { background: linear-gradient(90deg, #ff7a3d, #ffd34d); }
@keyframes offerPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 211, 77, 0); }
  50% { box-shadow: 0 0 10px 2px rgba(255, 211, 77, 0.35); }
}

.empty-note {
  font-size: 12px; color: var(--sub);
  background: rgba(0,0,0,0.2);
  border-radius: 10px; padding: 12px; text-align: center;
}

/* ===== ライブ配信 ===== */
.live-panel {
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid #37305e;
}
.live-panel .desc { font-size: 11px; color: var(--sub); margin-bottom: 8px; line-height: 1.5; }
.btn-live { width: 100%; background: linear-gradient(135deg, #d31f45, #ff3d8b); }

.live-banner {
  background: linear-gradient(135deg, #d31f45, #ff3d8b);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 800;
  animation: livePulse 1.2s infinite;
}
.live-banner .viewers { font-size: 15px; }
.live-banner .chat { font-size: 11px; font-weight: 600; opacity: 0.95; margin-top: 3px; min-height: 15px; }
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 61, 139, 0.6); }
  50% { box-shadow: 0 0 14px 3px rgba(255, 61, 139, 0.5); }
}

/* ===== ガチャ ===== */
.gacha-machine {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid #37305e;
  text-align: center;
}
.gacha-visual { font-size: 52px; }
.gacha-desc { font-size: 11px; color: var(--sub); line-height: 1.6; margin: 8px 0; }
.gacha-rates { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.gacha-rates .rate {
  font-size: 10px; padding: 2px 7px; border-radius: 6px; font-weight: 700;
}
.gacha-buttons { display: flex; gap: 8px; }
.btn-gacha {
  flex: 1;
  background: var(--grad);
  line-height: 1.4;
  padding: 10px 6px;
}
.btn-gacha span { font-size: 10px; font-weight: 600; }
.btn-gacha10 { background: linear-gradient(135deg, #e8a90c, #ff3d8b); }
.gacha-buttons + .gacha-buttons { margin-top: 8px; }
.btn-gacha100 { background: linear-gradient(135deg, #8b5cf6, #ff3d8b 50%, #ffd34d); }
.btn-gacha100:disabled { filter: grayscale(0.6); }
.pity-info { font-size: 10px; color: var(--sub); margin-top: 10px; }

.combo-list { display: flex; flex-direction: column; gap: 8px; }
.combo-card {
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #37305e;
  display: flex; align-items: center; gap: 10px;
}
.combo-card.done { border-color: var(--gold); }
.combo-icons { font-size: 20px; flex-shrink: 0; }
.combo-info { flex: 1; }
.combo-name { font-size: 12px; font-weight: 800; }
.combo-desc { font-size: 10px; color: var(--sub); margin-top: 2px; }
.combo-bonus { font-size: 12px; font-weight: 800; color: var(--gold); flex-shrink: 0; }
.combo-bonus.off { color: var(--sub); opacity: 0.6; }

/* ===== アップグレード（オフィス・社員） ===== */
.upgrade-list { display: flex; flex-direction: column; gap: 8px; }

.upgrade-card {
  background: var(--card);
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid #37305e;
  display: flex; align-items: center; gap: 10px;
}
.upgrade-card.maxed { border-color: var(--gold); }
.ug-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--card2);
  border-radius: 10px;
}
.ug-info { flex: 1; min-width: 0; }
.ug-name { font-size: 13px; font-weight: 800; }
.ug-desc { font-size: 10px; color: var(--sub); margin-top: 2px; line-height: 1.4; }
.ug-effect { font-size: 11px; color: var(--green); font-weight: 700; margin-top: 2px; }
.btn-buy {
  flex-shrink: 0;
  min-width: 92px;
  padding: 8px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 10px;
  border: none;
  background: var(--grad);
  color: #fff;
  line-height: 1.35;
}
.btn-buy:disabled { background: #3a3560; color: #7d76a8; }
.btn-buy span { display: block; font-size: 10px; font-weight: 600; }
.maxed-label { color: var(--gold); font-weight: 800; font-size: 12px; min-width: 92px; text-align: center; }

/* ===== その他タブ ===== */
.stage-panel, .rebirth-panel, .stats-panel {
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid #37305e;
  font-size: 12px;
}

.stage-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; color: var(--sub); }
.stage-item.reached { color: var(--text); }
.stage-item.current { color: var(--gold); font-weight: 800; }
.stage-item .req { margin-left: auto; font-size: 10px; }
.stage-progress-bar { margin-top: 8px; }

.rebirth-panel .desc { color: var(--sub); font-size: 11px; line-height: 1.6; margin-bottom: 8px; }
.rebirth-panel .brand-now { font-size: 13px; font-weight: 800; color: var(--gold); margin-bottom: 8px; }
.btn-rebirth { width: 100%; background: linear-gradient(135deg, #e8a90c, #ff3d8b); }

.stats-panel .row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed #37305e; }
.stats-panel .row:last-child { border-bottom: none; }
.stats-panel .row .k { color: var(--sub); }
.stats-panel .row .v { font-weight: 700; }

/* 通知設定 */
.notif-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed #37305e; }
.notif-row:last-child { border-bottom: none; }
.notif-label { font-size: 12px; }
.btn-toggle {
  min-width: 60px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 10px;
  border: 1px solid #4a4180;
  background: var(--card2);
  color: var(--sub);
  cursor: pointer;
  touch-action: manipulation;
}
.btn-toggle.on { background: linear-gradient(135deg, #1fa860, #3ddc84); border-color: transparent; color: #fff; }

/* 音量スライダー（各種設定） */
.vol-row .notif-label { flex-shrink: 0; }
.vol-range {
  flex: 1;
  min-width: 0;
  height: 24px;
  margin: 0 8px 0 14px;
  accent-color: var(--accent);
  cursor: pointer;
}
.vol-val {
  font-size: 11px;
  color: var(--sub);
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== 冒険タブ ===== */
.battle-note {
  background: var(--card);
  border: 1px solid #37305e;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 10px;
  color: var(--sub);
  line-height: 1.6;
}

.crew-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 38vh;
  overflow-y: auto;
  margin: 8px 0;
}
.crew-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid #37305e;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
}
.crew-row.sel { border-color: var(--accent); background: rgba(255, 61, 139, 0.08); }
.crew-icon { font-size: 18px; flex-shrink: 0; }
.crew-name { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crew-bonus { color: var(--gold); font-size: 10px; font-weight: 800; flex-shrink: 0; }
.crew-inc { color: var(--green); font-size: 10px; flex-shrink: 0; }

.art-frag-bar { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.art-frag-bar .post-bar { height: 5px; }
.art-frag-text { font-size: 10px; color: var(--sub); flex-shrink: 0; }
.btn-buy.equip-on { background: linear-gradient(135deg, #1fa860, #3ddc84); }

/* 実績 */
.achieve-list { display: flex; flex-direction: column; gap: 6px; }
.ach-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid #37305e;
  border-radius: 12px;
  padding: 8px 12px;
  opacity: 0.75;
}
.ach-card.done {
  opacity: 1;
  border-color: var(--gold);
  background: linear-gradient(135deg, #2e2850, #33254a);
}
.ach-icon { font-size: 22px; flex-shrink: 0; width: 28px; text-align: center; }
.ach-info { flex: 1; min-width: 0; }
.ach-name { font-size: 12px; font-weight: 800; }
.ach-card.done .ach-name { color: var(--gold); }
.ach-desc { font-size: 10px; color: var(--sub); margin-top: 1px; }
.ach-prog { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.ach-prog .post-bar { flex: 1; height: 4px; }
.ach-prog-text { font-size: 9px; color: var(--sub); white-space: nowrap; }
.ach-reward { font-size: 11px; font-weight: 800; color: var(--blue); flex-shrink: 0; }
.ach-card.done .ach-reward { color: var(--green); }

/* 事務所名変更フォーム */
.name-form { display: flex; gap: 8px; }
.name-form input {
  flex: 1;
  min-width: 0;
  background: rgba(0,0,0,0.35);
  border: 1px solid #4a4180;
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  padding: 9px 12px;
  font-family: inherit;
}
.name-form input:focus { outline: none; border-color: var(--accent); }
.name-form input::placeholder { color: var(--sub); font-weight: 400; }
.name-form .btn { flex-shrink: 0; padding: 9px 18px; }
.name-note { font-size: 10px; color: var(--sub); margin-top: 6px; }

.data-buttons { display: flex; gap: 8px; }
.data-buttons .btn { flex: 1; }
.credit { text-align: center; font-size: 10px; color: var(--sub); margin-top: 16px; }
.credit + .credit { margin-top: 4px; }
.credit a { color: var(--sub); text-decoration: underline; }

/* ===== タブバー ===== */
#tabbar {
  flex-shrink: 0;
  display: flex;
  background: #171327;
  border-top: 1px solid #322a5a;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tab-btn {
  position: relative;
  flex: 1;
  background: none;
  border: none;
  color: var(--sub);
  font-size: 10px;
  font-weight: 700;
  padding: 8px 0 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
.tab-btn.active { color: var(--accent); }
.tab-icon { font-size: 20px; }
.tab-dot {
  position: absolute;
  top: 6px; right: 24%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

/* ===== バズ演出 ===== */
.buzz-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(255,61,139,0.35), rgba(18,16,28,0.85));
  pointer-events: none;
  animation: buzzFlash 1.6s ease-out;
}
.buzz-text {
  font-size: 34px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 18px var(--accent), 0 0 40px var(--accent2);
  animation: buzzPop 1.6s ease-out;
  text-align: center;
  padding: 0 10px;
}
.buzz-sub {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(0,0,0,0.6);
}
@keyframes buzzPop {
  0% { transform: scale(0.2) rotate(-6deg); opacity: 0; }
  20% { transform: scale(1.25) rotate(2deg); opacity: 1; }
  35% { transform: scale(1); }
  80% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1.1); opacity: 0; }
}
@keyframes buzzFlash {
  0% { opacity: 0; }
  15% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== モーダル ===== */
.modal {
  position: absolute;
  inset: 0;
  z-index: 90;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  width: 100%;
  max-width: 360px;
  max-height: 76dvh;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--accent2);
  border-radius: 18px;
  padding: 18px 16px;
  text-align: center;
  animation: modalIn 0.25s ease-out;
}
@keyframes modalIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-title { font-size: 16px; font-weight: 900; margin-bottom: 12px; }
/* 数の神殿: 数詞の読み仮名ルビ */
.modal-title rt { font-size: 9px; font-weight: 400; color: var(--sub); letter-spacing: 0.1em; }
.modal-body { font-size: 12px; color: var(--sub); line-height: 1.7; }
.modal-box .btn { margin-top: 14px; width: 100%; }

.gacha-result-list { display: flex; flex-direction: column; gap: 6px; }
.gacha-result-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: left;
  animation: resultIn 0.3s ease-out backwards;
}
.gacha-result-item .icon { font-size: 22px; }
.gacha-result-item .name { font-size: 12px; font-weight: 800; flex: 1; }
.gacha-result-item .dup { font-size: 10px; color: var(--blue); font-weight: 700; }
.gacha-result-item.new-get { border: 1px solid var(--gold); }
/* 高レアの結果行は光らせる */
.gacha-result-item.rar-SSR,
.gacha-result-item.rar-UR {
  border: 1px solid var(--gold);
  box-shadow: 0 0 10px rgba(255, 211, 77, 0.45);
}
.gacha-result-item.rar-LEGEND {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(90deg, #ff5c5c, #ffd34d, #3ddc84, #4dc3ff, #b18cff) border-box;
  box-shadow: 0 0 14px rgba(255, 211, 77, 0.6);
}
.gacha-result-item.rar-GOD {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(90deg, #fffbe0, #ffd34d, #fff, #ffd34d, #fffbe0) border-box;
  box-shadow: 0 0 18px rgba(255, 235, 150, 0.9);
}
@keyframes resultIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== ガチャ開封演出 ===== */
.gacha-overlay {
  position: absolute;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 20, 0.93);
  overflow: hidden;
}
.gacha-stage { text-align: center; position: relative; z-index: 1; }
.gacha-multi-label {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 18px;
  text-shadow: 0 0 12px var(--accent);
  animation: multiPulse 0.6s ease-in-out infinite alternate;
}
@keyframes multiPulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}
/* カプセル本体（上下2つの半球を重ねたガチャカプセル。開封時にパカっと開く） */
.capsule-wrap {
  position: relative;
  display: inline-block;
}
.gacha-capsule {
  position: relative;
  display: inline-block;
  width: 88px;
  height: 88px;
  animation: capsuleShake 0.5s ease-in-out infinite;
  filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.25));
  transition: filter 0.8s ease;
}
.cap-half {
  position: absolute;
  left: 0;
  width: 88px;
  height: 44px;
}
/* 上半分は白（半透明の樹脂っぽく）、下半分の色はJSが毎回ランダムに設定する */
.cap-top {
  top: 0;
  border-radius: 44px 44px 5px 5px;
  background: linear-gradient(180deg, rgba(242, 242, 251, 0.95), rgba(212, 212, 236, 0.82));
  border: 3px solid rgba(0, 0, 0, 0.3);
  border-bottom: 2px solid rgba(0, 0, 0, 0.25);
}
.cap-bottom {
  bottom: 0;
  border-radius: 5px 5px 44px 44px;
  background: linear-gradient(180deg, #ff5c8a, #d42d72);
  border: 3px solid rgba(0, 0, 0, 0.3);
  border-top: none;
}
.capsule-shine {
  position: absolute;
  top: 9px; left: 14px;
  width: 18px; height: 12px;
  border-radius: 50%;
  background: #fff;
  transform: rotate(-25deg);
}
.capsule-badge {
  position: absolute;
  right: -12px; bottom: -6px;
  background: var(--gold);
  color: #4a3400;
  font-size: 13px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
@keyframes capsuleShake {
  0%, 100% { transform: rotate(-9deg); }
  50% { transform: rotate(9deg); }
}
/* オーラ（カプセル背面でふわっと広がって明滅する光） */
.gacha-aura {
  position: absolute;
  left: 50%; top: 50%;
  width: 280px; height: 280px;
  margin: -140px 0 0 -140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 211, 77, 0.6), rgba(255, 211, 77, 0) 70%);
  opacity: 0;
  pointer-events: none;
}
/* SSR/UR: ふわっと金色に光る */
.gacha-overlay.glow-gold .gacha-aura {
  animation: auraIn 1s ease forwards, auraPulse 1.2s ease-in-out 1s infinite alternate;
}
.gacha-overlay.glow-gold .gacha-capsule {
  animation-duration: 0.26s;
  filter: drop-shadow(0 0 24px var(--gold)) drop-shadow(0 0 60px rgba(255, 211, 77, 0.5));
}
/* LEGEND: 虹色のオーラがふわっと広がり、背面で虹が回る */
.gacha-overlay.glow-rainbow .gacha-aura {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.65), rgba(255, 211, 77, 0.25) 45%, rgba(255, 211, 77, 0) 70%);
  animation: auraIn 1s ease forwards, auraPulse 0.7s ease-in-out 1s infinite alternate;
}
.gacha-overlay.glow-rainbow .gacha-capsule {
  animation-duration: 0.16s;
  filter: drop-shadow(0 0 28px #fff) drop-shadow(0 0 70px rgba(255, 211, 77, 0.7));
}
.gacha-overlay.glow-rainbow::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 200vmax; height: 200vmax;
  margin: -100vmax 0 0 -100vmax;
  background: conic-gradient(#ff5c5c, #ffd34d, #3ddc84, #4dc3ff, #b18cff, #ff5c5c);
  opacity: 0;
  animation: rainbowIn 1s ease forwards, rainbowSpin 3s linear infinite;
}
/* GOD: 白金の後光が差し、まばゆい光条が回る */
.gacha-overlay.glow-god .gacha-aura {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 235, 150, 0.5) 45%, rgba(255, 235, 150, 0) 70%);
  animation: auraIn 1s ease forwards, auraPulse 0.45s ease-in-out 1s infinite alternate;
}
.gacha-overlay.glow-god .gacha-capsule {
  animation-duration: 0.1s;
  filter: drop-shadow(0 0 32px #fff) drop-shadow(0 0 90px rgba(255, 235, 150, 0.9));
}
.gacha-overlay.glow-god::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 200vmax; height: 200vmax;
  margin: -100vmax 0 0 -100vmax;
  background: repeating-conic-gradient(rgba(255, 251, 224, 0.9) 0deg 12deg, rgba(255, 211, 77, 0.15) 12deg 24deg);
  opacity: 0;
  animation: rainbowIn 1s ease forwards, rainbowSpin 6s linear infinite;
}
@keyframes auraIn {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes auraPulse {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}
@keyframes rainbowIn {
  from { opacity: 0; }
  to { opacity: 0.3; }
}
@keyframes rainbowSpin { to { transform: rotate(360deg); } }
.gacha-skip {
  margin-top: 26px;
  font-size: 11px;
  color: var(--sub);
}
/* 開封: 上下の殻がパカっと開き、中から光があふれる */
.gacha-capsule.burst { animation: none; }
.gacha-capsule.burst .cap-top { animation: capOpenTop 0.55s ease-out forwards; }
.gacha-capsule.burst .cap-bottom { animation: capOpenBottom 0.55s ease-out forwards; }
.gacha-capsule.burst .capsule-badge { opacity: 0; }
.gacha-capsule.burst::before {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff, rgba(255, 245, 200, 0.6) 60%, transparent 70%);
  animation: coreBurst 0.55s ease-out forwards;
}
@keyframes capOpenTop {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(-30px, -74px) rotate(-42deg); opacity: 0; }
}
@keyframes capOpenBottom {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(24px, 60px) rotate(32deg); opacity: 0; }
}
@keyframes coreBurst {
  0% { transform: scale(0.2); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: scale(3.2); opacity: 0; }
}
.gacha-overlay.flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  animation: gachaFlash 0.55s ease-out forwards;
}
@keyframes gachaFlash {
  0% { opacity: 0; }
  35% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== 投げ銭バトル演出 ===== */
.battle-overlay {
  position: absolute;
  inset: 0;
  z-index: 85;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 8, 20, 0.94);
}
.battle-stage { width: 100%; max-width: 380px; text-align: center; }
.battle-title {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 14px var(--accent);
}
.battle-timer {
  font-size: 30px;
  font-weight: 900;
  color: var(--gold);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.battle-vs-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin: 12px 0 10px;
}
.battle-side {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 8px;
}
.battle-side.me { border: 1px solid var(--green); }
.battle-side.rival { border: 1px solid var(--danger); }
/* 相手のスパチャラッシュ演出 */
.battle-side.rival.spurt { animation: spurtFlash 0.5s ease-out; }
@keyframes spurtFlash {
  0% { background: #7a2033; box-shadow: 0 0 14px rgba(255, 92, 92, 0.8); }
  100% { background: var(--card); box-shadow: none; }
}
.side-name {
  font-size: 11px;
  font-weight: 800;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-amount {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.battle-side.me .side-amount { color: var(--green); }
.battle-side.rival .side-amount { color: var(--danger); }
.battle-vs { align-self: center; font-size: 18px; font-weight: 900; color: var(--gold); }
.battle-bar {
  height: 14px;
  border-radius: 7px;
  background: #5c2333;
  overflow: hidden;
  border: 1px solid #4a4180;
}
.battle-bar-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, #1f8f5f, var(--green));
  transition: width 0.15s linear;
}
.battle-tap-btn {
  margin-top: 18px;
  width: 100%;
  padding: 24px 10px;
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  border: none;
  border-radius: 16px;
  background: var(--grad);
  box-shadow: 0 4px 18px rgba(255, 61, 139, 0.5);
  touch-action: manipulation;
  transition: transform 0.06s ease;
}
.battle-tap-btn:active { transform: scale(0.94); filter: brightness(1.25); }
.battle-note-live { margin-top: 12px; font-size: 11px; color: var(--sub); }

/* ===== トースト ===== */
#toast-area {
  position: absolute;
  top: 8px; /* #app は共通ヘッダーの下から始まるのでセーフエリアは足さない */
  left: 0; right: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: rgba(20, 16, 40, 0.95);
  border: 1px solid var(--accent2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 20px;
  animation: toastIn 3s ease-out forwards;
  max-width: 90%;
}
@keyframes toastIn {
  0% { transform: translateY(-16px); opacity: 0; }
  10% { transform: translateY(0); opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* タップ時のポップ演出 */
.money-pop {
  position: absolute;
  z-index: 60;
  font-size: 14px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8), 0 0 10px rgba(255,211,77,0.4);
  pointer-events: none;
  white-space: nowrap;
  animation: popUp 1s ease-out forwards;
}
.money-pop.pop-lv {
  color: var(--accent);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8), 0 0 10px rgba(255,61,139,0.5);
}
@keyframes popUp {
  0% { transform: translate(-50%, 0) scale(0.6); opacity: 0; }
  15% { transform: translate(-50%, -8px) scale(1.15); opacity: 1; }
  30% { transform: translate(-50%, -14px) scale(1); }
  100% { transform: translate(-50%, -52px) scale(1); opacity: 0; }
}

/* ===== 数の神殿 ===== */
.temple-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.temple-chip {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card2);
  border-radius: 8px;
  padding: 5px 2px;
  text-align: center;
  color: var(--sub);
  font-size: 10px;
  font-family: inherit;
}
.temple-chip b { display: block; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.temple-chip span { font-size: 9px; opacity: 0.7; }
.temple-chip.got {
  color: var(--gold);
  border-color: rgba(255, 211, 77, 0.6);
  background: rgba(255, 211, 77, 0.08);
}
.temple-chip:disabled { opacity: 0.6; }

/* ===== 神々の物語 ===== */
.story-body {
  max-height: 55vh;
  overflow-y: auto;
  text-align: left;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.story-line {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.65;
  opacity: 0;
  animation: storyIn 0.5s ease forwards;
}
.story-line.narr {
  background: none;
  color: var(--sub);
  font-size: 11px;
  text-align: center;
}
.story-who { display: block; font-size: 10px; color: var(--gold); margin-bottom: 2px; }
.story-who .cicon { width: 16px; height: 16px; vertical-align: middle; }
@keyframes storyIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.hidden { display: none !important; }

/* ==========================================================================
   フッター固定バナー広告（スマホ表示時のみ / 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; }
}
