:root {
  --bg: #0d0a1c;
  --ink: #1a1020;
  --paper: #f3ead6;
  --paper2: #ddd0b4;
  --gold: #e8c16a;
  --gold2: #ffdf8a;
  --shu: #e0443a;
  --text: #efe6d4;
  --muted: #a99fbf;
  --line: rgba(232, 193, 106, 0.28);
  --panel: rgba(22, 16, 40, 0.86);
  --r0: #b8c2d0;
  --r1: #4aa8ff;
  --r2: #c46bff;
  --r3: #ffc83a;
  --pow: #ff5a3c;
  --def: #e0a84a;
  --spd: #3fd8ff;
  --luk: #ffd84a;
  --hp: #5ce08a;
  --serif: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --col: min(100vw, 520px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: var(--serif); overscroll-behavior: none; -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%;
}
canvas#game { position: fixed; inset: 0; display: block; }
button { font-family: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

/* ---------- 共通部品 ---------- */
.btn {
  position: relative; border: 1px solid var(--gold); background: linear-gradient(180deg, rgba(60, 40, 90, 0.9), rgba(25, 15, 45, 0.95));
  color: var(--gold2); padding: 12px 22px; border-radius: 10px; font-size: 17px; font-weight: 700; letter-spacing: 0.08em;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6) inset, 0 4px 14px rgba(0, 0, 0, 0.45); transition: transform 0.08s, filter 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; filter: grayscale(0.7); cursor: default; }
.btn-primary {
  background: linear-gradient(180deg, #e2554a, #9c1e24); border-color: #ffcf8a; color: #fff8e8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); box-shadow: 0 0 22px rgba(224, 68, 58, 0.45), 0 4px 14px rgba(0, 0, 0, 0.5);
}
.btn-small { padding: 8px 14px; font-size: 14px; }
.heading {
  margin: 0 0 14px; text-align: center; font-size: 26px; font-weight: 900; letter-spacing: 0.2em; color: var(--gold2);
  text-shadow: 0 0 18px rgba(232, 193, 106, 0.4);
}
.heading small, .subheading small { display: block; font-family: Cinzel, serif; font-size: 11px; letter-spacing: 0.35em; color: var(--muted); }
.subheading { margin: 22px 0 8px; font-size: 16px; color: var(--gold); border-left: 3px solid var(--shu); padding-left: 8px; }
.subheading small { display: inline; margin-left: 8px; font-family: var(--serif); letter-spacing: 0; }

.screen {
  position: absolute; left: 50%; transform: translateX(-50%); width: var(--col);
  top: calc(var(--safe-top) + 52px); bottom: calc(var(--safe-bottom) + 64px); padding: 8px 14px 24px;
}
.screen.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.screen.scroll::-webkit-scrollbar { width: 4px; }
.screen.scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

/* ---------- 上部バー ---------- */
.topbar {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: var(--col);
  padding: calc(var(--safe-top) + 10px) 14px 6px; display: flex; justify-content: flex-end; pointer-events: none;
}
.coin-box, .hud-coins {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(10, 6, 20, 0.75); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 14px 4px 4px; font-weight: 900; font-size: 17px; color: var(--gold2);
  font-variant-numeric: tabular-nums;
}
.coin-icon {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 14px; font-weight: 900;
  color: #5a3a00; background: radial-gradient(circle at 35% 30%, #fff2b0, #e8b23a 60%, #a8720e); box-shadow: 0 0 8px rgba(255, 200, 80, 0.6);
}
.coin-box.bump { animation: bump 0.35s; }
@keyframes bump { 40% { transform: scale(1.15); } }

/* ---------- 下部タブ ---------- */
.tabbar {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: var(--col); display: flex;
  padding: 6px 8px calc(var(--safe-bottom) + 6px); background: linear-gradient(180deg, rgba(13, 10, 28, 0.6), rgba(8, 5, 18, 0.96));
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); padding: 4px 0;
}
.tab-ic {
  display: grid; place-items: center; width: 30px; height: 30px; font-size: 19px; font-weight: 900; border-radius: 8px;
  border: 1px solid transparent; transition: 0.2s;
}
.tabbar button.active { color: var(--gold2); }
.tabbar button.active .tab-ic { background: var(--paper); color: var(--ink); border-color: var(--gold); box-shadow: 0 0 12px rgba(232, 193, 106, 0.5); }

/* ---------- ホーム ---------- */
#screen-home { display: flex; flex-direction: column; align-items: center; text-align: center; overflow-y: auto; }
/* ロゴ: 和紙の札に載せる（元画像の背景色のまま） */
.logo {
  margin: 5vh 0 26px; width: min(88%, 380px); padding: 0; border-radius: 10px; overflow: hidden; line-height: 0;
  background: #f4efe6; border: 2px solid var(--gold);
  box-shadow: 0 0 36px rgba(232, 193, 106, 0.35), 0 0 0 5px rgba(0, 0, 0, 0.45), 0 10px 24px rgba(0, 0, 0, 0.6);
  animation: logo-in 0.7s cubic-bezier(.2, .9, .3, 1.2), float 5s ease-in-out 0.7s infinite;
}
.logo img { width: 100%; height: auto; display: block; }
@keyframes logo-in { from { transform: scale(0.85) rotate(-2deg); opacity: 0; } }
@keyframes float { 50% { transform: translateY(-6px); } }
.btn-sortie { width: 220px; padding: 12px 0 10px; display: flex; flex-direction: column; align-items: center; }
.btn-sortie .btn-main { font-size: 28px; font-weight: 900; letter-spacing: 0.3em; margin-right: -0.3em; }
.btn-sortie .btn-sub { font-family: Cinzel, serif; font-size: 11px; letter-spacing: 0.4em; opacity: 0.8; }
.home-party { display: flex; gap: 6px; margin: 18px 0 6px; min-height: 48px; }
.home-party .kcard { width: 46px; }
.home-party .empty { font-size: 13px; color: var(--muted); align-self: center; }
.home-records { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; max-width: 380px; margin: 12px 0; }
.home-records div { background: rgba(10, 6, 20, 0.6); border: 1px solid var(--line); border-radius: 8px; padding: 6px 4px; }
.home-records dt { font-size: 11px; color: var(--muted); }
.home-records dd { margin: 0; font-size: 18px; font-weight: 900; color: var(--gold2); font-variant-numeric: tabular-nums; }
.home-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.app-version { font-size: 10px; color: rgba(169, 159, 191, 0.6); margin-top: auto; padding-top: 12px; }

/* ---------- 漢字カード ---------- */
.kcard {
  --rc: var(--r0); position: relative; aspect-ratio: 1; border-radius: 9px; border: 2px solid var(--rc); padding: 0;
  background: linear-gradient(180deg, var(--paper), var(--paper2)); color: var(--ink); display: grid; place-items: center;
  box-shadow: 0 0 8px color-mix(in srgb, var(--rc) 50%, transparent), 0 2px 4px rgba(0, 0, 0, 0.5); overflow: hidden;
}
.kcard.r1 { --rc: var(--r1); }
.kcard.r2 { --rc: var(--r2); }
.kcard.r3 { --rc: var(--r3); }
.kcard.r3::before {
  content: ''; position: absolute; inset: 0; border-radius: 7px; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.55) 45%, transparent 60%) -150% 0 / 250% 100% no-repeat;
  animation: shine 3s infinite;
}
@keyframes shine { 60%, 100% { background-position: 150% 0; } }
.kc-ch { font-size: 1em; font-weight: 900; line-height: 1; font-size: calc(var(--s, 56px) * 0.62); }
.kc-lv {
  position: absolute; left: 3px; top: 2px; font-size: 10px; font-weight: 900; color: #5a4630; line-height: 1;
}
.kc-lv.max { color: var(--shu); }
.kc-rar {
  position: absolute; right: 0; bottom: 0; font-family: Cinzel, serif; font-size: 8px; font-weight: 900; padding: 1px 3px;
  background: var(--rc); color: #10081c; border-top-left-radius: 5px; line-height: 1.1;
}
.kc-badge {
  position: absolute; right: 2px; top: 2px; font-size: 9px; font-weight: 900; background: var(--shu); color: #fff; padding: 0 3px;
  border-radius: 3px; line-height: 1.4;
}
.kcard.locked { background: rgba(30, 22, 50, 0.9); border-color: rgba(255, 255, 255, 0.1); box-shadow: none; color: rgba(255, 255, 255, 0.12); }
.kcard.locked .kc-rar { opacity: 0.35; }
.kcard.in-party::after {
  content: '陣'; position: absolute; right: 2px; top: 2px; font-size: 9px; font-weight: 900; background: var(--ink); color: var(--gold2);
  padding: 0 2px; border-radius: 3px;
}

.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 7px; --s: 58px; }
.sentinel { height: 40px; }

/* ---------- 一覧のフィルタ ---------- */
.list-summary { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.list-summary b { color: var(--gold2); font-size: 15px; }
.list-summary .rs { padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.list-filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; position: sticky; top: -8px; z-index: 2; padding: 8px 0; background: linear-gradient(180deg, rgba(13, 10, 28, 0.97) 85%, rgba(13, 10, 28, 0)); }
.filter-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 0; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.45);
  color: var(--text); font-family: inherit; font-size: 16px; -webkit-user-select: text; user-select: text;
}
.search::placeholder { color: rgba(169, 159, 191, 0.6); }
.chip {
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.35); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 700;
}
.chip.on { background: var(--gold); color: var(--ink); border-color: var(--gold2); }
.chip.c0.on { background: var(--r0); } .chip.c1.on { background: var(--r1); } .chip.c2.on { background: var(--r2); } .chip.c3.on { background: var(--r3); }
.select {
  padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.45); color: var(--text);
  font-family: inherit; font-size: 14px;
}
.empty-msg { text-align: center; color: var(--muted); padding: 30px 0; font-size: 14px; grid-column: 1 / -1; line-height: 1.8; }

/* ---------- ガチャ ---------- */
.omikuji { position: relative; height: 210px; display: grid; place-items: center; margin: 4px 0 10px; }
.omikuji-box {
  width: 120px; height: 170px; border-radius: 14px 14px 10px 10px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(90deg, #7a1418, #c8302c 30%, #e2453a 50%, #c8302c 70%, #7a1418); border: 3px solid var(--gold);
  box-shadow: 0 0 40px rgba(224, 68, 58, 0.45), inset 0 0 20px rgba(0, 0, 0, 0.4); position: relative;
}
.omikuji-box::before { content: ''; position: absolute; top: -8px; width: 30px; height: 12px; background: #2a1a10; border-radius: 4px; border: 2px solid var(--gold); }
.omikuji-box span { font-size: 30px; font-weight: 900; color: #fff3d0; line-height: 1.25; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); }
.omikuji.shake .omikuji-box { animation: kuji-shake 0.12s 8 alternate; }
@keyframes kuji-shake { from { transform: rotate(-14deg) translateY(-6px); } to { transform: rotate(14deg) translateY(4px); } }
.omikuji-stick {
  position: absolute; top: 20px; width: 10px; height: 0; border-radius: 3px; background: linear-gradient(180deg, #f6e6c0, #c8a870);
  transition: height 0.4s cubic-bezier(.2, 1.6, .5, 1), box-shadow 0.4s;
}
.omikuji-stick.out { height: 90px; top: -70px; }
.omikuji-stick.g1 { background: linear-gradient(180deg, #bfe2ff, var(--r1)); box-shadow: 0 0 20px var(--r1); }
.omikuji-stick.g2 { background: linear-gradient(180deg, #f0d4ff, var(--r2)); box-shadow: 0 0 26px var(--r2); }
.omikuji-stick.g3 { background: linear-gradient(180deg, #fff, var(--r3), #ff7a3a); box-shadow: 0 0 40px var(--r3), 0 0 80px #ff7a3a; }
.gacha-buttons { display: flex; flex-direction: column; gap: 10px; align-items: stretch; max-width: 340px; margin: 0 auto; }
.gacha-btn { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.gacha-btn .gb-label { font-size: 20px; font-weight: 900; }
.gacha-btn .gb-note { display: block; font-size: 11px; color: rgba(255, 248, 232, 0.75); text-align: left; letter-spacing: 0; }
.gacha-btn .gb-cost { display: inline-flex; align-items: center; gap: 5px; font-size: 16px; }
.gacha-btn .coin-icon { width: 22px; height: 22px; font-size: 12px; }
.rates { margin: 18px auto 0; max-width: 380px; background: rgba(10, 6, 20, 0.6); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.rates summary { cursor: pointer; color: var(--gold); font-weight: 700; }
.rates table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.rates td, .rates th { padding: 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); text-align: left; }
.rates p { color: var(--muted); line-height: 1.7; margin: 6px 0; }

/* ガチャ結果 */
.overlay {
  position: fixed; inset: 0; background: rgba(5, 3, 12, 0.92); z-index: 20; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--safe-top) + 16px) 12px calc(var(--safe-bottom) + 16px); overflow-y: auto; animation: fadein 0.25s;
}
@keyframes fadein { from { opacity: 0; } }
.reveal-title { font-size: 22px; font-weight: 900; color: var(--gold2); letter-spacing: 0.2em; margin: 6px 0 12px; }
.reveal-grid { display: grid; gap: 8px; width: 100%; max-width: 480px; }
.reveal-grid.n1 { grid-template-columns: 160px; justify-content: center; --s: 160px; margin-top: 8vh; }
.reveal-grid.n10 { grid-template-columns: repeat(5, 1fr); --s: 80px; }
.reveal-grid.n100 { grid-template-columns: repeat(10, 1fr); gap: 4px; --s: 40px; }
.reveal-grid.n100 .kc-lv, .reveal-grid.n100 .kc-rar { display: none; }
.reveal-grid.n100 .kc-badge { font-size: 7px; padding: 0 1px; }
.flip { perspective: 600px; aspect-ratio: 1; }
.flip-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.45s; }
.flip.open .flip-inner { transform: rotateY(180deg); }
.flip-back, .flip-inner > .kcard { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; width: 100%; }
.flip-inner > .kcard { transform: rotateY(180deg); }
.flip-back {
  border-radius: 9px; border: 2px solid #8a6a2a; display: grid; place-items: center; font-weight: 900; color: rgba(255, 223, 138, 0.8);
  background: repeating-linear-gradient(45deg, #5a1418 0 6px, #6a1a1e 6px 12px); font-size: calc(var(--s) * 0.35);
}
.flip.g1 .flip-back { box-shadow: 0 0 14px var(--r1); }
.flip.g2 .flip-back { box-shadow: 0 0 18px var(--r2); border-color: var(--r2); }
.flip.g3 .flip-back { box-shadow: 0 0 26px var(--r3); border-color: var(--r3); animation: pulse 0.6s infinite alternate; }
@keyframes pulse { to { filter: brightness(1.4); } }
.flip.open.g2 .kcard, .flip.open.g3 .kcard { animation: burst 0.7s; }
@keyframes burst { 0% { box-shadow: 0 0 0 0 var(--rc); } 40% { box-shadow: 0 0 40px 14px var(--rc); } }
.reveal-summary { margin: 14px 0 4px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; font-size: 13px; color: var(--muted); }
.reveal-summary b { color: var(--gold2); }
.reveal-actions { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; justify-content: center; }
.reveal-name { text-align: center; margin-top: 12px; font-size: 15px; color: var(--text); min-height: 44px; line-height: 1.5; }
.lvup-tag { color: var(--hp); font-weight: 900; }
.rays {
  position: fixed; inset: -50%; pointer-events: none; z-index: -1; opacity: 0; transition: opacity 0.5s;
  background: repeating-conic-gradient(from 0deg, rgba(255, 210, 90, 0.12) 0 8deg, transparent 8deg 20deg); animation: spin 18s linear infinite;
}
.rays.on { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 編成 ---------- */
.formation-toggle { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; }
.formation-toggle button { border: 1px solid var(--line); background: rgba(0, 0, 0, 0.4); border-radius: 8px; padding: 7px 12px; font-size: 14px; font-weight: 700; }
.formation-toggle button.on { background: var(--shu); border-color: #ffb08a; color: #fff; }
.party-field {
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 8px; display: flex; flex-direction: column; gap: 14px;
  background: radial-gradient(ellipse at 50% 0%, rgba(224, 68, 58, 0.18), transparent 70%), rgba(10, 6, 20, 0.55);
}
.prow { display: flex; justify-content: center; gap: 10px; position: relative; }
.prow-label { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); writing-mode: vertical-rl; font-size: 12px; color: var(--muted); letter-spacing: 0.3em; }
.slot { width: 72px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot .kcard { width: 72px; --s: 72px; }
.slot-empty {
  width: 72px; aspect-ratio: 1; border-radius: 9px; border: 2px dashed rgba(232, 193, 106, 0.4); background: rgba(0, 0, 0, 0.3);
  display: grid; place-items: center; font-size: 26px; color: rgba(232, 193, 106, 0.5);
}
.slot-pw { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.party-power { text-align: center; margin: 10px 0 4px; font-size: 14px; color: var(--muted); }
.party-power b { font-size: 22px; color: var(--gold2); margin-left: 6px; font-variant-numeric: tabular-nums; }
.party-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.combo-list { display: flex; flex-direction: column; gap: 6px; }
.combo {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 9px; background: rgba(10, 6, 20, 0.6); border: 1px solid var(--line);
  font-size: 13px; animation: fadein 0.3s;
}
.combo-type { font-size: 10px; font-weight: 900; padding: 2px 6px; border-radius: 4px; background: var(--shu); color: #fff; white-space: nowrap; }
.combo-type.stroke { background: #3a6ad0; }
.combo-type.radical { background: #2a9a6a; }
.combo-name { font-weight: 900; color: var(--gold2); font-size: 15px; }
.combo-chars { color: var(--muted); }
.combo-eff { margin-left: auto; color: var(--hp); font-weight: 700; white-space: nowrap; }
.muted { color: var(--muted); font-size: 13px; }
.party-stats { display: flex; flex-direction: column; gap: 4px; }
.pstat-row { display: grid; grid-template-columns: 30px repeat(5, 1fr); gap: 4px; align-items: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.pstat-row.head { color: var(--muted); font-weight: 700; text-align: center; }
.pstat-row .pc { font-size: 20px; font-weight: 900; text-align: center; }
.pstat-row span { text-align: center; }
.pstat-row .up { color: var(--hp); }
.hint-list { display: flex; flex-wrap: wrap; gap: 6px; }
.hint { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.35); font-size: 14px; }
.hint .have { color: var(--gold2); font-weight: 900; }
.hint .need { color: var(--muted); }

/* ---------- モーダル ---------- */
.modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 2, 8, 0.7); animation: fadein 0.2s; }
.modal-panel {
  position: relative; width: var(--col); max-height: 88vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(var(--safe-bottom) + 18px);
  background: linear-gradient(180deg, #221838, #120c22); border: 1px solid var(--line); border-bottom: none; animation: slideup 0.25s cubic-bezier(.2, .9, .3, 1);
}
.modal.center { align-items: center; }
.modal.center .modal-panel { border-radius: 16px; border-bottom: 1px solid var(--line); width: min(92vw, 420px); }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } }
.modal-close { position: absolute; right: 10px; top: 8px; background: none; border: none; font-size: 24px; color: var(--muted); padding: 6px 10px; }
.modal-title { margin: 0 0 12px; font-size: 20px; color: var(--gold2); text-align: center; letter-spacing: 0.1em; }
.modal-text { line-height: 1.8; font-size: 14px; }
.modal-text h4 { margin: 14px 0 4px; color: var(--gold); }
.modal-text p { margin: 4px 0; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* 漢字の詳細 */
.detail-top { display: flex; gap: 14px; align-items: center; }
.detail-top .kcard { width: 120px; --s: 120px; flex: none; }
.detail-info { flex: 1; min-width: 0; font-size: 13px; line-height: 1.7; }
.detail-rarity { display: inline-block; font-family: Cinzel, serif; font-weight: 900; padding: 0 8px; border-radius: 4px; color: #10081c; font-size: 13px; }
.detail-lv { font-size: 22px; font-weight: 900; color: var(--gold2); }
.detail-lv small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.lv-progress { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin: 2px 0 4px; }
.lv-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); }
.readings { margin: 14px 0 8px; display: grid; grid-template-columns: 44px 1fr; gap: 4px 8px; font-size: 14px; }
.readings dt { color: var(--muted); font-size: 12px; padding-top: 2px; }
.readings dd { margin: 0; }
.stat-bars { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.sbar { display: grid; grid-template-columns: 26px 1fr 56px; gap: 8px; align-items: center; font-size: 14px; }
.sbar b { font-size: 16px; text-align: center; }
.sbar .track { height: 10px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); position: relative; overflow: hidden; }
.sbar .track i { position: absolute; inset: 0 auto 0 0; border-radius: 5px; }
.sbar .track i.max { opacity: 0.25; }
.sbar .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.detail-jukugo { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.detail-jukugo span { padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.detail-jukugo span.ok { border-color: var(--gold); color: var(--gold2); }
.link-btn { text-decoration: none; display: inline-block; }

/* 編成ピッカー */
.picker-head { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.picker-grid { max-height: 52vh; overflow-y: auto; padding: 2px; }

/* ---------- バトル ---------- */
.battle-hud {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: var(--col); display: flex; justify-content: space-between;
  padding: calc(var(--safe-top) + 10px) 12px 0; pointer-events: none;
}
.hud-stage {
  font-size: 24px; font-weight: 900; color: var(--gold2); letter-spacing: 0.08em; text-shadow: 0 0 12px rgba(232, 193, 106, 0.5), 0 2px 3px #000;
}
.hud-stage.boss { color: #ff6a6a; text-shadow: 0 0 14px rgba(255, 60, 60, 0.7), 0 2px 3px #000; }
.hud-buffs { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; max-width: 220px; }
.hud-buffs span { font-size: 11px; padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, 0.6); border: 1px solid currentColor; font-weight: 700; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.hud-kills { font-size: 12px; color: var(--muted); }
.battle-controls {
  position: absolute; bottom: calc(var(--safe-bottom) + 14px); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; z-index: 35;
}
.ctrl {
  border: 1px solid var(--line); background: rgba(10, 6, 20, 0.8); border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 900;
  color: var(--gold2); min-width: 52px; white-space: nowrap;
}
.ctrl.on { background: var(--gold); color: var(--ink); }
.stage-banner {
  position: absolute; left: 0; right: 0; top: 42%; transform: translateY(-50%); text-align: center; pointer-events: none; z-index: 5;
}
.stage-banner .band {
  display: inline-block; padding: 10px 60px; font-size: 38px; font-weight: 900; letter-spacing: 0.25em; color: #fff8e8;
  background: linear-gradient(90deg, transparent, rgba(10, 6, 20, 0.92) 18%, rgba(10, 6, 20, 0.92) 82%, transparent);
  text-shadow: 0 0 16px rgba(232, 193, 106, 0.8); animation: band 1.3s forwards;
}
.stage-banner .band small { display: block; font-size: 13px; letter-spacing: 0.5em; color: var(--gold); }
.stage-banner.boss .band { color: #ffdada; text-shadow: 0 0 20px rgba(255, 40, 40, 0.9); }
.stage-banner.boss .band small { color: #ff7a7a; }
.stage-banner.win .band { color: var(--gold2); }
@keyframes band {
  0% { clip-path: inset(0 100% 0 0); }
  25% { clip-path: inset(0 0 0 0); }
  80% { clip-path: inset(0 0 0 0); opacity: 1; }
  100% { clip-path: inset(0 0 0 0); opacity: 0; }
}

/* 選択肢 */
.choice-title { text-align: center; font-size: 20px; color: var(--gold2); margin: 0 0 4px; letter-spacing: 0.1em; }
.choice-sub { text-align: center; color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(60, 40, 90, 0.7), rgba(25, 15, 45, 0.9)); text-align: left; animation: slideup 0.3s backwards;
}
.choice:nth-child(2) { animation-delay: 0.06s; }
.choice:nth-child(3) { animation-delay: 0.12s; }
.choice:active, .choice.picked { transform: scale(0.97); border-color: var(--gold2); box-shadow: 0 0 20px rgba(232, 193, 106, 0.5); }
.choice-ic {
  flex: none; width: 54px; height: 54px; border-radius: 10px; display: grid; place-items: center; font-size: 32px; font-weight: 900;
  background: linear-gradient(180deg, var(--paper), var(--paper2)); color: var(--ink); border: 2px solid var(--cc, var(--gold));
}
.choice-name { font-size: 17px; font-weight: 900; color: var(--gold2); }
.choice-desc { font-size: 12px; color: var(--muted); white-space: pre-line; line-height: 1.5; margin-top: 2px; }
.choice-party { display: flex; gap: 4px; justify-content: center; margin-bottom: 12px; }
.choice-party .mini { width: 44px; text-align: center; font-size: 10px; }
.choice-party .mini .kcard { width: 44px; --s: 44px; }
.choice-party .kc-lv, .choice-party .kc-rar, .home-party .kc-rar { display: none; }
.mini-hp { height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.mini-hp i { display: block; height: 100%; background: var(--hp); }
.mini.dead .kcard { filter: grayscale(1) brightness(0.5); }
.auto-countdown { text-align: center; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* リザルト */
.result-head { text-align: center; }
.result-head .big { font-size: 46px; font-weight: 900; color: var(--gold2); line-height: 1.1; text-shadow: 0 0 20px rgba(232, 193, 106, 0.5); }
.result-head .new-record { display: inline-block; margin-top: 4px; background: var(--shu); color: #fff; font-weight: 900; padding: 2px 10px; border-radius: 4px; font-size: 13px; animation: pulse 0.5s infinite alternate; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 16px 0 0; }
.result-stats div { background: rgba(0, 0, 0, 0.35); border-radius: 8px; padding: 8px; text-align: center; border: 1px solid var(--line); }
.result-stats dt { font-size: 11px; color: var(--muted); }
.result-stats dd { margin: 0; font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }

/* トースト */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 84px); transform: translateX(-50%); z-index: 40; pointer-events: none;
  background: rgba(10, 6, 20, 0.95); border: 1px solid var(--gold); color: var(--gold2); padding: 10px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 700; animation: slideup 0.25s; max-width: 90vw; text-align: center;
}

.test-output { position: fixed; inset: 0; margin: 0; padding: 12px; background: #000; color: #9f9; font-size: 12px; overflow: auto; z-index: 99; white-space: pre-wrap; }
.test-output:empty { display: none; }

@media (min-height: 760px) {
  .kgrid { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); --s: 64px; }
}
