:root {
  --bg0: #0b0920;
  --bg1: #141036;
  --panel: rgba(24, 19, 60, 0.94);
  --panel2: #221b52;
  --panel3: #2c2468;
  --line: #4d3f97;
  --line2: #6f5fc4;
  --text: #f1ecff;
  --muted: #a49ad0;
  --dim: #6f66a0;
  --gold: #ffd76a;
  --gold2: #f3a83c;
  --pink: #ff9fd6;
  --lav: #bca9ff;
  --mint: #7ff0d0;
  --moon: #a9d8ff;
  --ok: #8ff0a8;
  --tab-h: 58px;
  --top-h: 64px;
  font-family: 'DotGothic16', 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg0); color: var(--text); overflow: hidden; }
body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(120, 80, 220, .25), transparent 60%),
    radial-gradient(ellipse at 100% 100%, rgba(255, 120, 200, .12), transparent 60%),
    var(--bg0);
  -webkit-font-smoothing: none;
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ドットっぽい角欠け */
.pxc {
  clip-path: polygon(0 6px, 2px 6px, 2px 4px, 4px 4px, 4px 2px, 6px 2px, 6px 0,
    calc(100% - 6px) 0, calc(100% - 6px) 2px, calc(100% - 4px) 2px, calc(100% - 4px) 4px, calc(100% - 2px) 4px, calc(100% - 2px) 6px, 100% 6px,
    100% calc(100% - 6px), calc(100% - 2px) calc(100% - 6px), calc(100% - 2px) calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) calc(100% - 2px), calc(100% - 6px) calc(100% - 2px), calc(100% - 6px) 100%,
    6px 100%, 6px calc(100% - 2px), 4px calc(100% - 2px), 4px calc(100% - 4px), 2px calc(100% - 4px), 2px calc(100% - 6px), 0 calc(100% - 6px));
}

/* アイコン(6×4 アトラス, 1コマ48px) */
.icon {
  display: inline-block; flex: none;
  width: 48px; height: 48px;
  background: url(../assets/img/icons.webp) no-repeat;
  background-size: 600% 400%;
  background-position: calc(var(--ix) * 20%) calc(var(--iy) * 33.3333%);
  image-rendering: pixelated;
}
.icon.s20 { width: 20px; height: 20px; image-rendering: auto; }
.icon.s24 { width: 24px; height: 24px; image-rendering: auto; }
.icon.s32 { width: 32px; height: 32px; image-rendering: auto; }
.icon.s40 { width: 40px; height: 40px; image-rendering: auto; }
.icon.s72 { width: 72px; height: 72px; }
.icon.s96 { width: 96px; height: 96px; }
.portrait {
  display: inline-block; flex: none;
  width: 96px; height: 96px;
  background: url(../assets/img/portraits.webp) no-repeat;
  background-size: 400% 200%;
  background-position: calc(var(--px) * 33.3333%) calc(var(--py) * 100%);
  image-rendering: pixelated;
}
.portrait.s144 { width: 144px; height: 144px; }

/* ---------------- レイアウト ---------------- */
#app { position: fixed; inset: 0; display: grid; grid-template-rows: var(--top-h) 1fr; }
#topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: linear-gradient(#1d1748, #140f36);
  border-bottom: 2px solid var(--line);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .4);
  z-index: 5; min-width: 0;
}
.brand { display: flex; align-items: center; gap: 6px; min-width: 0; }
.brand-name { font-size: 12px; line-height: 1.2; color: var(--lav); white-space: nowrap; }
.brand-name b { display: block; font-size: 17px; color: var(--text); font-weight: normal; letter-spacing: .08em; }
.res { display: flex; align-items: center; gap: 6px; padding: 3px 12px 3px 6px; background: rgba(0, 0, 0, .25); border: 2px solid var(--line); border-radius: 4px; min-width: 0; }
.res-val { font-size: 22px; line-height: 1.1; color: var(--gold); text-shadow: 0 2px 0 #5b3a10; white-space: nowrap; font-variant-numeric: tabular-nums; }
.res-moon .res-val { color: var(--moon); text-shadow: 0 2px 0 #1d3b6b; }
.res-rate { font-size: 12px; color: var(--muted); white-space: nowrap; }
.res-star { min-width: 200px; }
#buffs { display: flex; gap: 6px; flex: 1; min-width: 0; overflow: hidden; }
.buff { display: flex; align-items: center; gap: 4px; padding: 2px 8px 2px 2px; border-radius: 4px; background: rgba(255, 159, 214, .15); border: 2px solid rgba(255, 159, 214, .5); font-size: 12px; white-space: nowrap; animation: pulse 1.6s infinite; }
.buff b { color: var(--pink); font-weight: normal; }
.top-btns { display: flex; gap: 6px; margin-left: auto; }
.iconbtn { width: 40px; height: 40px; border-radius: 4px; background: var(--panel2); border: 2px solid var(--line); font-size: 18px; }
.iconbtn.off { opacity: .45; text-decoration: line-through; }

#main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 540px); min-height: 0; }
#stage { position: relative; overflow: hidden; min-height: 0; background: #0d0a28; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; display: block; }
#panel { display: flex; flex-direction: column; min-height: 0; background: rgba(14, 11, 38, .97); border-left: 2px solid var(--line); }
#tabs { display: flex; gap: 2px; padding: 6px 6px 0; background: #120e30; border-bottom: 2px solid var(--line); flex: none; }
.tab {
  position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 4px 2px 3px; background: transparent; border: 2px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0;
  color: var(--muted); font-size: 12px; white-space: nowrap;
}
.tab .icon { opacity: .7; }
.tab.active { background: var(--panel); border-color: var(--line); color: var(--text); margin-bottom: -2px; padding-bottom: 5px; }
.tab.active .icon { opacity: 1; }
.tab.locked { opacity: .35; }
.tab .badge {
  position: absolute; top: 2px; right: 8px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--pink); color: #3a0d2c; font-size: 12px; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px #120e30;
  animation: bob 1.2s infinite;
}
#tabBody { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px; overscroll-behavior: contain; scrollbar-color: var(--line) transparent; }

/* ---------------- 共通パーツ ---------------- */
.btn {
  border: none; padding: 8px 14px; border-radius: 4px; background: var(--panel3); color: var(--text);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .35), 0 0 0 2px var(--line); transition: transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .35), 0 0 0 2px var(--line); }
.btn.gold { background: linear-gradient(#ffe7a0, #f6bd52); color: #3d2306; box-shadow: inset 0 -3px 0 #c07a1c, 0 0 0 2px #7a4a12; }
.btn.moon { background: linear-gradient(#d4ecff, #8ec2ff); color: #10284f; box-shadow: inset 0 -3px 0 #4d7fd0, 0 0 0 2px #1d3b6b; }
.btn.pink { background: linear-gradient(#ffd0ec, #ff8fcf); color: #4a0f35; box-shadow: inset 0 -3px 0 #c9549a, 0 0 0 2px #6e1d50; }
.btn:disabled { background: #231d4d; color: var(--dim); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .3), 0 0 0 2px #3a3172; cursor: default; }
.btn.big { font-size: 20px; padding: 12px 36px; }
.btn.small { font-size: 12px; padding: 4px 8px; }

.section-title { display: flex; align-items: center; gap: 8px; margin: 14px 2px 8px; font-size: 14px; color: var(--lav); }
.section-title:first-child { margin-top: 0; }
.section-title::after { content: ''; flex: 1; height: 2px; background: linear-gradient(90deg, var(--line), transparent); }
.toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #120e30; border: 2px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button { border: none; background: transparent; color: var(--muted); padding: 5px 10px; font-size: 13px; }
.seg button.on { background: var(--line); color: var(--text); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 4px 8px; border: 2px solid var(--line); border-radius: 4px; background: #120e30; }
.toggle.on { color: var(--mint); border-color: #2f8f7a; }
.toggle::before { content: ''; width: 10px; height: 10px; background: #3a3172; box-shadow: 0 0 0 2px #120e30; }
.toggle.on::before { background: var(--mint); box-shadow: 0 0 6px var(--mint); }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.moon-c { color: var(--moon); }
.pink-c { color: var(--pink); }
.cost { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }

/* ---------------- 使い魔カード ---------------- */
.gen {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px 8px 8px; margin-bottom: 8px; background: var(--panel); position: relative;
  box-shadow: inset 0 0 0 2px var(--line);
}
.gen.can { box-shadow: inset 0 0 0 2px var(--line2), inset 0 0 18px rgba(255, 215, 106, .08); }
.gen.locked { opacity: .55; }
.gen.locked .icon { filter: brightness(0) drop-shadow(0 0 0 #5a4fa0); opacity: .7; }
.gen-iconwrap { position: relative; width: 64px; height: 64px; display: grid; place-items: center; background: radial-gradient(circle at 50% 55%, #3a2f80, #1a1444 70%); border-radius: 6px; box-shadow: inset 0 0 0 2px #3a3172; }
.gen-count { position: absolute; right: -4px; bottom: -6px; min-width: 26px; padding: 0 5px; background: #0d0a28; border: 2px solid var(--line2); border-radius: 4px; font-size: 14px; text-align: center; color: var(--text); }
.gen-main { min-width: 0; }
.gen-name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gen-name .mult { font-size: 12px; color: var(--pink); margin-left: 4px; }
.gen-prod { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gen-prod b { color: var(--gold); font-weight: normal; }
.gen-row { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.gen-ms { font-size: 11px; color: var(--lav); white-space: nowrap; }
.bar.thin { height: 6px; margin-top: 2px; }
.gen-desc { font-size: 11px; color: var(--dim); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { position: relative; height: 12px; margin-top: 4px; background: #0d0a28; border-radius: 2px; box-shadow: inset 0 0 0 1px #3a3172; overflow: hidden; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: repeating-linear-gradient(90deg, #ffd76a 0 4px, #ffc54a 4px 8px); transition: width .25s; }
.bar.moonbar > i { background: repeating-linear-gradient(90deg, #a9d8ff 0 4px, #8ec2ff 4px 8px); }
.bar.pinkbar > i { background: repeating-linear-gradient(90deg, #ff9fd6 0 4px, #ff86c9 4px 8px); }
.bar > span { position: relative; display: block; font-size: 10px; line-height: 12px; padding-left: 4px; color: #fff; text-shadow: 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000; }
.buy { min-width: 108px; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 6px 8px; }
.buy .n { font-size: 12px; opacity: .8; }
.buy .cost { font-size: 15px; }

/* ---------------- まほうの本 ---------------- */
.upg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.upg {
  display: grid; grid-template-columns: 48px 1fr; gap: 4px 10px; padding: 8px; background: var(--panel);
  box-shadow: inset 0 0 0 2px var(--line); text-align: left; border: none; color: var(--text);
}
.upg.can { box-shadow: inset 0 0 0 2px var(--gold2), 0 0 12px rgba(255, 200, 80, .15); }
.upg:disabled { cursor: default; }
.upg .nm { font-size: 14px; line-height: 1.25; }
.upg .ef { font-size: 12px; color: var(--mint); line-height: 1.3; }
.upg .ds { grid-column: 1 / -1; font-size: 11px; color: var(--dim); }
.upg .pr { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; font-size: 14px; padding-top: 4px; border-top: 2px dotted #2f2766; }
.upg.can .pr .cost { color: var(--gold); }
.upg:not(.can) .pr .cost { color: var(--dim); }
.owned-list { display: flex; flex-wrap: wrap; gap: 4px; }
.owned-list .icon { opacity: .85; border-radius: 4px; background-color: #1a1444; }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 13px; background: rgba(0, 0, 0, .15); border: 2px dashed #2f2766; border-radius: 6px; }

/* ---------------- 星座 ---------------- */
.starmap-wrap { position: relative; width: 100%; max-width: 520px; margin: 0 auto; }
.starmap {
  position: relative; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 6px;
  background: url(../assets/img/sky.webp) 30% 20% / cover; image-rendering: pixelated;
  box-shadow: inset 0 0 0 2px var(--line), inset 0 0 60px rgba(0, 0, 20, .8);
}
.starmap::before { content: ''; position: absolute; inset: 0; background: rgba(8, 6, 30, .55); }
.starmap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.starmap .ln { stroke: rgba(150, 140, 220, .35); stroke-width: .35; stroke-dasharray: 1 1; }
.starmap .ln.lit { stroke: rgba(255, 230, 160, .85); stroke-width: .5; stroke-dasharray: none; filter: drop-shadow(0 0 1px #ffd76a); }
.node {
  position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; padding: 0; border: none; background: transparent;
  display: grid; place-items: center;
}
.node i { display: block; width: 10px; height: 10px; background: #5a4fa0; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); transition: transform .2s; }
.node.avail i { background: #cfc4ff; width: 14px; height: 14px; animation: pulse 1.4s infinite; }
.node.can i { background: var(--moon); width: 16px; height: 16px; filter: drop-shadow(0 0 4px #a9d8ff); }
.node.lit i { background: #fff3c4; width: 18px; height: 18px; filter: drop-shadow(0 0 3px #ffd76a) drop-shadow(0 0 8px #ffb84a); }
.node.big i { width: 22px; height: 22px; }
.node.big.lit i { width: 28px; height: 28px; }
.node.sel::after { content: ''; position: absolute; inset: -2px; border: 2px solid var(--pink); border-radius: 50%; animation: spin 4s linear infinite; border-style: dashed; }
.con-label { position: absolute; transform: translate(-50%, -50%); font-size: 11px; color: rgba(220, 210, 255, .75); white-space: nowrap; pointer-events: none; text-shadow: 0 1px 0 #000; }
.con-label.done { color: var(--gold); }
.node-info { margin-top: 10px; padding: 10px 12px; background: var(--panel); box-shadow: inset 0 0 0 2px var(--line); display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.node-info .nm { font-size: 16px; }
.node-info .cn { font-size: 12px; color: var(--lav); }
.node-info .ef { font-size: 13px; color: var(--mint); grid-column: 1 / 2; }
.node-info .ds { font-size: 11px; color: var(--dim); grid-column: 1 / -1; }
.lock-overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 30px; background: rgba(8, 6, 30, .6); color: var(--lav); font-size: 14px; z-index: 2; }

/* ---------------- 夜明け ---------------- */
.dawn-card { padding: 16px; background: linear-gradient(180deg, #2a2266 0%, #3b2a6e 55%, #6b3f6e 85%, #a35d63 100%); box-shadow: inset 0 0 0 2px var(--line2); text-align: center; position: relative; overflow: hidden; }
.dawn-card .portrait { margin: 0 auto 4px; }
.dawn-gain { font-size: 38px; color: var(--moon); text-shadow: 0 3px 0 #1d3b6b, 0 0 16px rgba(169, 216, 255, .5); line-height: 1.1; }
.dawn-gain small { font-size: 15px; color: var(--text); text-shadow: none; }
.dawn-card .bar { margin: 10px auto 4px; max-width: 360px; height: 14px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; padding: 10px 12px; background: var(--panel); box-shadow: inset 0 0 0 2px var(--line); margin-top: 10px; }
.kv > :nth-child(odd) { color: var(--muted); }
.kv > :nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.tip { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.6; }

/* ---------------- 実績 ---------------- */
.ach-head { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--panel); box-shadow: inset 0 0 0 2px var(--line); margin-bottom: 10px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.ach { display: grid; grid-template-columns: 48px 1fr; gap: 0 8px; align-items: center; padding: 6px; background: var(--panel); box-shadow: inset 0 0 0 2px var(--line); }
.ach .nm { font-size: 13px; line-height: 1.25; }
.ach .ds { font-size: 10px; color: var(--muted); line-height: 1.3; }
.ach.no .icon { filter: grayscale(1) brightness(.35); }
.ach.no .nm { color: var(--dim); }
.ach.new { box-shadow: inset 0 0 0 2px var(--pink); }

/* ---------------- ステージ上の UI ---------------- */
.bubble {
  position: absolute; z-index: 3; max-width: min(300px, 70%); padding: 8px 12px; transform: translate(-50%, -100%);
  background: #fffaf0; color: #3a2a55; font-size: 14px; line-height: 1.45; border-radius: 6px;
  box-shadow: 0 0 0 2px #3a2a55, 0 4px 0 rgba(0, 0, 0, .35); animation: pop .25s ease-out; pointer-events: none;
}
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -6px; border: 6px solid transparent; border-top-color: #fffaf0; border-bottom: none; filter: drop-shadow(0 2px 0 #3a2a55); }
#floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.floater { position: absolute; transform: translate(-50%, 0); font-size: 14px; color: var(--gold); text-shadow: 0 2px 0 #3d2306, 1px 0 0 #3d2306, -1px 0 0 #3d2306; white-space: nowrap; animation: floatUp 1.6s ease-out forwards; }
.floater.big { font-size: 18px; color: var(--pink); text-shadow: 0 2px 0 #4a0f35, 1px 0 0 #4a0f35, -1px 0 0 #4a0f35; }
.floater.moon { color: var(--moon); text-shadow: 0 2px 0 #10284f, 1px 0 0 #10284f, -1px 0 0 #10284f; }
.wish-banner {
  position: absolute; z-index: 4; top: 12px; left: 50%; transform: translateX(-50%);
  display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; align-items: center; gap: 2px 8px;
  padding: 6px 16px 8px 8px; border: none; border-radius: 6px; text-align: left;
  background: linear-gradient(#ffe7f6, #ffc4e8); color: #4a0f35; box-shadow: 0 0 0 2px #6e1d50, 0 4px 0 rgba(0, 0, 0, .4), 0 0 24px rgba(255, 160, 220, .6);
  animation: bob 1.3s infinite;
}
.wish-banner .icon { grid-row: 1 / 3; }
.wish-banner b { display: block; font-size: 16px; font-weight: normal; }
.wish-banner small { font-size: 11px; }
.wb-bar { grid-column: 2; height: 4px; background: rgba(110, 29, 80, .25); border-radius: 2px; overflow: hidden; }
.wb-bar i { display: block; height: 100%; background: #c9549a; }
.goal {
  position: absolute; z-index: 3; left: 10px; bottom: 10px; max-width: min(340px, calc(100% - 20px));
  padding: 7px 10px; background: rgba(16, 12, 44, .86); box-shadow: inset 0 0 0 2px var(--line);
  font-size: 12px; display: flex; gap: 8px; align-items: center;
}
.goal .lbl { color: var(--pink); font-size: 11px; }
.goal .bar { margin-top: 3px; height: 6px; }
.goal:empty { display: none; }

/* ---------------- モーダル・トースト ---------------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(6, 4, 22, .7); animation: fade .2s; }
.modal-box { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px; background: linear-gradient(#211a54, #171140); box-shadow: inset 0 0 0 2px var(--line2), 0 8px 0 rgba(0, 0, 0, .4); animation: pop .25s ease-out; }
.modal-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.modal-head h2 { margin: 0; font-size: 20px; font-weight: normal; }
.modal-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.modal-body { font-size: 14px; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.wish-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.wish-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; text-align: center; background: var(--panel); border: none; box-shadow: inset 0 0 0 2px var(--line2); color: var(--text); transition: transform .1s; }
.wish-card:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 2px var(--pink), 0 0 18px rgba(255, 159, 214, .35); }
.wish-card .nm { font-size: 15px; color: var(--pink); }
.wish-card .ef { font-size: 12px; color: var(--mint); }
.wish-card .ds { font-size: 11px; color: var(--muted); }
.dialog { display: flex; gap: 14px; align-items: flex-start; }
.dialog .txt { flex: 1; font-size: 15px; line-height: 1.7; min-height: 96px; white-space: pre-wrap; }
.dialog .next { text-align: right; color: var(--pink); animation: bob 1s infinite; }
#toasts { position: fixed; z-index: 40; left: 12px; top: calc(var(--top-h) + 10px); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { display: flex; gap: 8px; align-items: center; padding: 6px 12px 6px 6px; background: #241c58; box-shadow: inset 0 0 0 2px var(--gold2), 0 4px 0 rgba(0, 0, 0, .35); font-size: 13px; max-width: 320px; animation: slideIn .3s ease-out, fadeOut .5s 3.6s forwards; }
.toast small { display: block; color: var(--muted); font-size: 11px; }
.toast.moon { box-shadow: inset 0 0 0 2px var(--moon), 0 4px 0 rgba(0, 0, 0, .35); }

/* ---------------- タイトル ---------------- */
.title-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; overflow: hidden; background: #0b0920; transition: opacity .8s; }
.title-screen.out { opacity: 0; pointer-events: none; }
.title-art { position: absolute; inset: -2%; background: url(../assets/img/title.webp) center / cover no-repeat; image-rendering: pixelated; animation: drift 30s ease-in-out infinite alternate; }
.title-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(rgba(10, 8, 34, .25), rgba(10, 8, 34, 0) 30%, rgba(10, 8, 34, 0) 60%, rgba(10, 8, 34, .75)); }
.title-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; padding: max(5vh, 20px) 16px max(6vh, 24px); }
.title-bottom { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.logo { filter: drop-shadow(0 4px 0 #2a1650) drop-shadow(0 0 20px rgba(255, 220, 140, .45)); }
.logo-sub { font-size: clamp(18px, 3.4vw, 30px); color: #fff3d0; letter-spacing: .2em; }
.logo-main { font-size: clamp(48px, 10vw, 104px); line-height: 1; color: #ffe08a; letter-spacing: .08em; -webkit-text-stroke: 2px #6a3a10; paint-order: stroke fill; text-shadow: 0 5px 0 #6a3a10; }
.logo-en { font-size: clamp(11px, 1.6vw, 15px); color: #e6dcff; letter-spacing: .15em; margin-top: 8px; }
.title-note { font-size: 13px; color: #efe8ff; text-shadow: 0 2px 0 #000; }
.title-note small { color: var(--lav); }

/* ---------------- アニメーション ---------------- */
@keyframes pulse { 50% { opacity: .6; } }
@keyframes bob { 50% { transform: translateY(-3px); } }
.wish-banner { animation-name: bobx; }
@keyframes bobx { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -3px); } }
@keyframes pop { from { transform: translate(var(--tx, 0), var(--ty, 0)) scale(.85); opacity: 0; } }
.bubble { --tx: -50%; --ty: -100%; }
@keyframes floatUp { from { opacity: 0; transform: translate(-50%, 6px); } 15% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -42px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-6px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drift { to { transform: scale(1.04) translate(-1%, -1%); } }
.twinkle { animation: tw 2.4s infinite; }
@keyframes tw { 50% { filter: brightness(1.3) drop-shadow(0 0 4px rgba(255, 215, 106, .7)); } }
.flash { animation: flash .4s; }
@keyframes flash { from { filter: brightness(1.8); } }

/* ---------------- スマホ ---------------- */
@media (max-width: 860px), (orientation: portrait) and (max-width: 1000px) {
  :root { --top-h: 54px; }
  #topbar { gap: 8px; padding: 0 8px; }
  .brand { display: none; }
  .res { padding: 2px 8px 2px 2px; }
  .res .icon.s40 { width: 32px; height: 32px; }
  .res-val { font-size: 18px; }
  .res-rate { font-size: 11px; }
  .res-star { min-width: 0; flex: 1 1 auto; }
  #buffs { position: absolute; top: calc(var(--top-h) + 6px); right: 6px; flex-direction: column; align-items: flex-end; z-index: 6; overflow: visible; }
  .iconbtn { width: 36px; height: 36px; }
  #main { grid-template-columns: 1fr; grid-template-rows: minmax(210px, 38vh) 1fr; }
  #panel { border-left: none; border-top: 2px solid var(--line); }
  #tabs { order: 2; padding: 0 2px env(safe-area-inset-bottom); border-bottom: none; border-top: 2px solid var(--line); }
  .tab { border-radius: 0 0 6px 6px; border-top: none; padding: 4px 0 4px; font-size: 10px; }
  .tab.active { margin-bottom: 0; margin-top: -2px; border-top: none; border-bottom: 2px solid var(--line); }
  .tab .icon.s32 { width: 28px; height: 28px; }
  .tab .badge { top: 0; right: 4px; }
  #tabBody { padding: 8px; }
  .gen { grid-template-columns: 52px 1fr auto; gap: 8px; padding: 6px 8px 6px 6px; }
  .gen-iconwrap { width: 52px; height: 52px; }
  .gen-iconwrap .icon { width: 44px; height: 44px; image-rendering: auto; }
  .gen-name { font-size: 14px; }
  .gen-row { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.gen-ms { font-size: 11px; color: var(--lav); white-space: nowrap; }
.bar.thin { height: 6px; margin-top: 2px; }
.gen-desc { display: none; }
  .buy { min-width: 92px; padding: 5px 6px; }
  .buy .cost { font-size: 13px; }
  .upg-grid { grid-template-columns: 1fr; }
  .ach-grid { grid-template-columns: 1fr 1fr; }
  .goal { left: 6px; bottom: 6px; padding: 5px 8px; font-size: 11px; }
  .goal .icon { display: none; }
  .wish-banner { top: 6px; }
  #toasts { top: calc(var(--top-h) + 6px); left: 8px; right: auto; align-items: flex-start; }
  .toast { max-width: 250px; font-size: 11px; padding: 4px 10px 4px 4px; }
  .toast .icon.s32 { width: 24px; height: 24px; }
  .toast small { display: none; }
  .wish-cards { grid-template-columns: 1fr; }
  .wish-card { display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto auto; text-align: left; align-items: center; gap: 0 10px; padding: 8px; }
  .wish-card .icon { grid-row: 1 / 4; width: 56px; height: 56px; }
  .modal-box { padding: 12px; }
  .modal-head .portrait { width: 72px; height: 72px; }
  .bubble { font-size: 12px; max-width: 64%; padding: 6px 9px; }
}
@media (max-width: 420px) {
  .res-moon .res-rate { display: none; }
  .seg button { padding: 5px 7px; font-size: 12px; }
}
