:root {
  --topbar-h: 60px;
  --tab-h: 58px;
  --bg: #000;
  --panel: #16161a;
  --panel2: #1f1f24;
  --line: #33333b;
  --text: #f2f2f2;
  --muted: #9a9aa3;
  --accent: #fff;
  --gold: #ffd94a;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ヘッダー */
.topbar {
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #0a0a0c;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-tile {
  width: 40px; height: 40px; flex: none;
  background: #fff; color: #000;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 22px;
}
.brand-ja { font-weight: 800; font-size: 17px; line-height: 1.15; white-space: nowrap; }
.brand-en { font-size: 9.5px; letter-spacing: .18em; color: var(--muted); white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.points-pill {
  background: var(--panel2); border: 1px solid var(--line); color: var(--gold);
  font-weight: 700; border-radius: 999px; padding: 6px 12px; font-size: 14px;
  white-space: nowrap; flex: none;
}
.icon-btn {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  width: 36px; height: 36px; border-radius: 10px; font-size: 16px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.lang-toggle {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  height: 36px; border-radius: 10px; padding: 0 12px; font-size: 13px;
  white-space: nowrap; flex: none;
}
@media (max-width: 640px) {
  :root { --topbar-h: 100px; }
  .brand { flex: 1 1 100%; }
  .topbar-right { margin-left: 0; flex: 1 1 100%; }
  .points-pill { margin-right: auto; }
}

/* メイン・ビュー */
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll-area { flex: 1; overflow-y: auto; padding: 14px 14px 30px; max-width: 860px; width: 100%; margin: 0 auto; }
.view-title { font-size: 19px; margin: 2px 0 12px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 14px;
}
.panel h2, .panel h3 { font-size: 15px; margin-bottom: 8px; }
.panel p, .panel li { font-size: 13.5px; line-height: 1.7; color: #d8d8de; }
.panel ul { padding-left: 18px; }

/* ガチャ画面（1画面） */
#viewGacha { overflow-y: auto; display: block; }
.gacha-stage {
  height: calc(100dvh - var(--topbar-h) - var(--tab-h) - var(--safe-b));
  min-height: 430px;
  display: flex; flex-direction: column;
  padding: 10px 12px 8px;
  max-width: 860px; margin: 0 auto; width: 100%;
}
.pack-row {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px;
  scrollbar-width: none; flex: none;
}
.pack-row::-webkit-scrollbar { display: none; }
.pack-chip {
  flex: none; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); border-radius: 999px; padding: 7px 13px; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.pack-chip.active { background: #fff; color: #000; border-color: #fff; font-weight: 700; }
.pack-chip .lock { color: var(--gold); font-size: 11.5px; }
.pack-chip.active .lock { color: #000; }
.pack-chip .cnt { color: var(--muted); font-size: 11px; }
.pack-chip.active .cnt { color: #333; }
.stage-main { flex: 1; min-height: 0; display: flex; }

/* 動画プレイヤー */
.stage-main { align-items: center; justify-content: center; }
.player {
  width: 100%; max-width: 680px;
  background: #0a0a0c; border: 1px solid #3c3c44; border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
}
.player-screen {
  position: relative; aspect-ratio: 16 / 9; background: #050507;
  overflow: hidden; flex: none;
}
.player-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.player-cover {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: blur(16px) brightness(.45); transform: scale(1.15);
}
.player-cover.noimg {
  background: repeating-linear-gradient(45deg, #101014 0 18px, #0a0a0d 18px 36px);
  filter: none; transform: none;
}
.player-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #8a8a93; font-size: 15px; padding: 20px; text-align: center; line-height: 1.6;
}
.player-next {
  position: absolute; inset: 0; background: #000; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; letter-spacing: .14em; color: #ffe98a;
}
.play-btn {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 78px; height: 78px; border-radius: 50%; z-index: 7;
  background: rgba(0,0,0,.62); border: 2.5px solid rgba(255,255,255,.9);
  color: #fff; font-size: 30px; padding-left: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease, background .12s ease;
}
.play-btn:hover { background: rgba(230,33,23,.85); transform: translate(-50%, -50%) scale(1.06); }
.player-buffer {
  position: absolute; inset: 0; z-index: 7; background: rgba(0,0,0,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  font-size: 13px; color: #d8d8de; letter-spacing: .1em;
}
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.25); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.player-info {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.88) 55%);
  padding: 26px 14px 10px;
}
.player-title {
  font-size: 15.5px; font-weight: 700; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.player-meta { font-size: 12px; color: #c9c9d1; margin-top: 3px; }
.player-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: #101014; border-top: 1px solid #26262c;
}
.player-state { font-size: 12px; color: #d8d8de; width: 16px; text-align: center; flex: none; }
.player-seek { flex: 1; height: 5px; background: #2c2c33; border-radius: 99px; overflow: hidden; }
.player-seek-fill { height: 100%; width: 0%; background: #e62117; }
.player-time { font-size: 11.5px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }

/* 弾幕 */
.danmaku-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.danmaku {
  position: absolute; white-space: nowrap; font-weight: 700;
  color: #fff; text-shadow: 1px 1px 2px #000, -1px -1px 2px #000, 0 0 6px rgba(0,0,0,.7);
  animation-name: danmakuFlow; animation-timing-function: linear; animation-fill-mode: forwards;
  font-size: 15px;
}
.danmaku.big { font-size: 21px; }
@keyframes danmakuFlow { from { transform: translateX(0); } to { transform: translateX(-130%); } }

/* 進捗・引くボタン */
.progress-wrap { flex: none; padding-top: 8px; }
.progress-text { font-size: 12px; color: var(--muted); margin-bottom: 5px; display: flex; justify-content: space-between; }
.progress-bar { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress-fill { height: 100%; background: #fff; width: 0%; transition: width .4s ease; }
.pull-row { display: flex; gap: 8px; padding-top: 10px; flex: none; }
.pull-btn {
  flex: 1; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 15px; font-weight: 700;
  padding: 13px 6px; min-height: 50px;
}
.pull-btn.main { background: #fff; color: #000; border-color: #fff; flex: 1.3; }
.pull-btn.point { color: var(--gold); }
.pull-btn:disabled { opacity: .45; cursor: not-allowed; }
.pull-btn .sub { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.pull-btn.main .sub { color: #555; }
.below-fold { max-width: 860px; margin: 0 auto; padding: 4px 12px 26px; width: 100%; }
.intro-text { font-size: 13.5px; line-height: 1.7; color: #d8d8de; margin: 6px 0 14px; }

/* タブバー */
.tabbar {
  flex: none; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: #0a0a0c; border-top: 1px solid var(--line); z-index: 30;
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 13px; font-weight: 700; padding: 6px 2px;
}
.tab.active { color: #fff; box-shadow: inset 0 2px 0 #fff; }

/* 結果 */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.78);
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.overlay-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  width: 100%; max-width: 560px; max-height: calc(100dvh - 28px); overflow-y: auto;
  padding: 16px;
}
.bonus-banner {
  background: linear-gradient(90deg, #3a2c00, #6b5310); color: #ffe98a;
  border: 1px solid #a8842c; border-radius: 10px; padding: 9px 12px;
  font-size: 13px; font-weight: 700; margin-bottom: 12px; line-height: 1.5;
}
.result-points { text-align: center; font-size: 14px; color: var(--gold); font-weight: 700; padding: 10px 0 2px; }
.result-actions { display: flex; gap: 8px; margin-top: 10px; }
.result-actions.sub { justify-content: center; align-items: center; }
.icon-action {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: #000; color: #fff; display: inline-flex; align-items: center; justify-content: center;
}
.sub-btn {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font-size: 13.5px; font-weight: 600;
}
.sub-btn.wide { width: 100%; margin: 4px 0 14px; }
.sub-btn:disabled { opacity: .45; cursor: not-allowed; }

/* 結果カード */
.result-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel2); }
.result-card .thumb-wrap { position: relative; aspect-ratio: 4 / 3; background: #000; max-height: 300px; }
.result-card .thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.result-card .thumb-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #55555e; font-size: 13px; padding: 12px; text-align: center;
}
.tier-badge {
  display: inline-block; font-weight: 800; font-size: 12.5px; border-radius: 999px;
  padding: 3px 10px; color: #000;
}
.new-badge {
  display: inline-block; font-weight: 800; font-size: 12px; border-radius: 6px;
  padding: 3px 8px; background: #e62117; color: #fff; margin-left: 6px;
}
.bonus-tag {
  display: inline-block; font-weight: 800; font-size: 11.5px; border-radius: 6px;
  padding: 3px 8px; background: #6b5310; color: #ffe98a; margin-left: 6px;
}
.result-card .rc-body { padding: 12px 14px 14px; }
.rc-title { font-size: 16.5px; font-weight: 700; line-height: 1.45; margin: 8px 0 6px; }
.rc-meta { font-size: 12.5px; color: var(--muted); line-height: 1.8; }
.rc-meta b { color: var(--text); }
.watch-btn {
  display: inline-block; margin-top: 10px; background: #fff; color: #000; text-decoration: none;
  font-weight: 700; font-size: 13.5px; border-radius: 9px; padding: 8px 14px;
}
.multi-summary { font-size: 13.5px; line-height: 1.8; margin-bottom: 12px; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.mini-card {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel2);
  display: flex; flex-direction: column;
}
.mini-card.best { outline: 2px solid var(--gold); }
.mini-card .mc-thumb { aspect-ratio: 4 / 3; background: #000; position: relative; }
.mini-card .mc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-card .mc-body { padding: 6px 8px 8px; }
.mini-card .mc-title { font-size: 11px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mini-card .mc-meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.mini-card .tier-badge { font-size: 10.5px; padding: 2px 7px; margin-bottom: 4px; }

/* 図鑑 */
.col-controls { margin-bottom: 12px; }
.text-input {
  width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.col-filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 999px; padding: 5px 11px; font-size: 12px;
}
.chip.active { background: #fff; color: #000; font-weight: 700; }
.col-row {
  display: flex; gap: 10px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); margin-bottom: 8px; align-items: center;
}
.col-row .col-thumb { width: 84px; flex: none; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #000; position: relative; }
.col-row .col-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.col-row .col-main { flex: 1; min-width: 0; }
.col-row .col-title { font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.col-row .col-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.6; }
.mylist-badge {
  display: inline-block; background: #26262c; border: 1px solid var(--line); color: var(--gold);
  border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 700; margin-top: 4px;
}
.progress-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 5px 0; }
.progress-line .pl-name { width: 108px; flex: none; color: #d8d8de; }
.progress-line .progress-bar { flex: 1; }
.progress-line .pl-num { width: 92px; flex: none; text-align: right; color: var(--muted); }
.checker-row { display: flex; gap: 8px; }
.checker-row .text-input { flex: 1; }
#checkerResult { margin-top: 10px; font-size: 13.5px; line-height: 1.7; }
.save-row { display: flex; gap: 8px; margin-bottom: 8px; }
.save-code {
  width: 100%; background: #0a0a0c; border: 1px solid var(--line); color: var(--muted);
  border-radius: 10px; padding: 8px; font-size: 11px; word-break: break-all;
}
.save-msg { font-size: 12.5px; color: #7ee787; margin-top: 6px; min-height: 16px; }

/* 実績 */
.title-panel { display: flex; align-items: center; gap: 10px; }
.title-label { font-size: 12.5px; color: var(--muted); }
.title-current { font-size: 16px; font-weight: 800; }
.ach-cat { font-size: 14.5px; margin: 16px 0 8px; color: #fff; }
.ach-row {
  border: 1px solid var(--line); background: var(--panel); border-radius: 12px;
  padding: 11px 12px; margin-bottom: 8px;
}
.ach-row.done { border-color: #6b5310; }
.ach-head { display: flex; align-items: baseline; gap: 8px; }
.ach-name { font-size: 14px; font-weight: 700; }
.ach-reward { margin-left: auto; font-size: 12px; color: var(--gold); flex: none; }
.ach-desc { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.6; }
.ach-progress { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.ach-progress .progress-bar { flex: 1; }
.ach-progress .ach-num { font-size: 11.5px; color: var(--muted); flex: none; }
.ach-title-btn { margin-top: 8px; }

/* シート */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.7);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--panel); border: 1px solid var(--line); border-bottom: none;
  border-radius: 18px 18px 0 0; width: 100%; max-width: 640px;
  max-height: 86dvh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-b);
}
.sheet-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.sheet-title { font-size: 16px; font-weight: 800; }
.sheet-points { margin-left: auto; color: var(--gold); font-weight: 700; font-size: 14px; }
.sheet-body { overflow-y: auto; padding: 6px 16px 18px; }
.sheet-section { font-size: 13px; color: var(--muted); margin: 16px 0 8px; letter-spacing: .06em; }
.shop-row {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line);
  background: var(--panel2); border-radius: 12px; padding: 11px 12px; margin-bottom: 8px;
}
.shop-main { flex: 1; min-width: 0; }
.shop-name { font-size: 14px; font-weight: 700; }
.shop-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.55; }
.shop-btn {
  flex: none; border: 1px solid var(--line); background: #fff; color: #000;
  font-weight: 800; border-radius: 10px; padding: 9px 12px; font-size: 13px; min-width: 96px;
}
.shop-btn:disabled { background: var(--panel); color: var(--muted); cursor: not-allowed; }
.shop-btn.owned { background: var(--panel); color: #7ee787; border-color: #2c5c38; }

/* トースト・フッター */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  transform: translateX(-50%); z-index: 90;
  background: #fff; color: #000; font-weight: 700; font-size: 13.5px;
  border-radius: 999px; padding: 10px 18px; box-shadow: 0 6px 24px rgba(0,0,0,.5);
  max-width: calc(100vw - 32px); text-align: center;
}
.site-footer { font-size: 11.5px; color: var(--muted); line-height: 1.8; padding: 6px 2px 10px; }
.rates-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rates-table td, .rates-table th { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.rates-table td:last-child, .rates-table th:last-child { text-align: right; }
