/* Kanji Boost Gacha - styles (own design). Dark indigo base; escalation layers
   light up as chain level rises. */
:root {
  --bg: #141824; --bg2: #1b2133; --ink: #eef0f6; --dim: #8a92a8;
  --gold: #ffd54f; --line: #2a3149;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", "Noto Serif SC", "Songti SC", serif;
  --sans: -apple-system, "Hiragino Sans", "Yu Gothic", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }   /* class display rules must not defeat the hidden attribute */
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); overflow: hidden; }
button { font-family: inherit; color: inherit; cursor: pointer; }

/* ---------- bg escalation ---------- */
#bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; transition: opacity .6s; }
#bg > div { position: absolute; inset: -20%; opacity: 0; transition: opacity .8s; }
.bg-grid { background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 44px 44px; opacity: .35 !important; }
.bg-aurora { background: radial-gradient(60% 40% at 30% 20%, rgba(64,220,180,.16), transparent 70%), radial-gradient(50% 35% at 75% 30%, rgba(80,130,255,.18), transparent 70%); filter: blur(6px); }
.bg-rays { background: conic-gradient(from 90deg at 50% -10%, transparent 0deg, rgba(255,213,79,.10) 20deg, transparent 40deg, rgba(255,213,79,.08) 80deg, transparent 100deg); animation: rays 14s linear infinite; }
@keyframes rays { to { transform: rotate(360deg); } }
.bg-gold { background: radial-gradient(55% 45% at 50% 45%, rgba(255,200,60,.20), transparent 72%); }
.bg-rainbow { background: linear-gradient(120deg, rgba(255,80,180,.14), rgba(255,220,80,.14), rgba(80,255,180,.14), rgba(80,140,255,.16), rgba(200,90,255,.14)); filter: saturate(1.3); }
.bg-cosmos { background: radial-gradient(1.5px 1.5px at 20% 30%, #fff, transparent), radial-gradient(1px 1px at 70% 60%, #fff, transparent), radial-gradient(1.5px 1.5px at 40% 80%, #ffe, transparent), radial-gradient(1px 1px at 85% 25%, #fff, transparent), radial-gradient(1px 1px at 10% 70%, #fff, transparent), radial-gradient(60% 50% at 50% 110%, rgba(120,60,255,.28), transparent 70%); }
body[data-lv="1"] .bg-aurora { opacity: .7; }
body[data-lv="2"] .bg-aurora, body[data-lv="2"] .bg-rays { opacity: .8; }
body[data-lv="3"] .bg-aurora, body[data-lv="3"] .bg-rays, body[data-lv="3"] .bg-gold { opacity: .9; }
body[data-lv="4"] .bg-aurora, body[data-lv="4"] .bg-rays, body[data-lv="4"] .bg-gold, body[data-lv="4"] .bg-rainbow { opacity: .85; }
body[data-lv="5"] .bg-cosmos, body[data-lv="5"] .bg-rainbow, body[data-lv="5"] .bg-gold { opacity: .95; }
body[data-lv="6"] > #bg .bg-cosmos, body[data-lv="6"] #bg .bg-rainbow, body[data-lv="6"] #bg .bg-gold, body[data-lv="6"] #bg .bg-rays { opacity: 1; }
body[data-lv="7"] #bg > div { opacity: 1; }
body[data-lv="7"] #bg { animation: pulsate 1.2s ease-in-out infinite alternate; }
@keyframes pulsate { from { filter: brightness(1); } to { filter: brightness(1.35); } }

.fx { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.fx.front { z-index: 60; }
#flash { position: fixed; inset: 0; z-index: 55; opacity: 0; pointer-events: none; }

#app { position: relative; z-index: 2; height: 100%; }
.screen { height: 100%; display: flex; flex-direction: column; }

/* ---------- buttons / chips ---------- */
.btn-pop { background: linear-gradient(180deg, #ffd76a, #ffb32b); color: #3a2503; border: 0; border-radius: 14px; padding: 12px 26px; font-size: 17px; font-weight: 800; letter-spacing: .06em; box-shadow: 0 4px 0 #b97f10, 0 8px 18px rgba(255,180,40,.25); transition: transform .08s, box-shadow .08s; }
.btn-pop:active { transform: translateY(3px); box-shadow: 0 1px 0 #b97f10; }
.btn-pop.big { font-size: 20px; padding: 15px 44px; }
.btn-pop.huge { font-size: 21px; padding: 16px 48px; }
.btn-pop.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn-pop.danger { background: linear-gradient(180deg, #ff7a6a, #e5372b); color: #fff; box-shadow: 0 4px 0 #a02118; }
.btn-pop.wide, .link-btn { align-self: center; }
.btn-sm { border: 1px solid var(--line); background: #232b42; border-radius: 9px; padding: 6px 12px; font-size: 13px; color: var(--dim); }
.btn-sm.pop { background: var(--gold); color: #3a2503; border-color: transparent; font-weight: 700; }
.btn-sm:disabled { opacity: .45; }
.link-btn { background: none; border: 0; color: var(--dim); text-decoration: underline; font-size: 14px; padding: 8px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip { background: #202741; border: 1.5px solid var(--line); color: var(--dim); border-radius: 999px; padding: 7px 16px; font-size: 14px; }
.chip.on { border-color: var(--gold); color: var(--gold); background: #2a2b18; }
.chip.sm { padding: 5px 12px; font-size: 12.5px; }
.chip.tier-chip.on { color: #fff; }

/* ---------- title ---------- */
#title-screen { align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center; overflow-y: auto; }
.logo { display: flex; flex-direction: column; line-height: 1.05; }
.logo .top { color: var(--gold); font-weight: 900; letter-spacing: .5em; font-size: 15px; text-indent: .5em; }
.logo .main { font-family: var(--serif); font-size: clamp(38px, 9vw, 64px); font-weight: 800; background: linear-gradient(180deg, #fff, #ffd54f); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--dim); font-size: 14.5px; max-width: 34em; }
.title-note { color: var(--dim); font-size: 12.5px; opacity: .8; }
#title-screen .btn-pop.big { margin-top: 6px; }
.version { color: #555d75; font-size: 11.5px; }
.legal { margin-top: 4px; }
.lic-line { color: #555d75; font-size: 11px; max-width: 40em; display: inline-block; }

/* ---------- game / hud ---------- */
#game { padding: 0 0 12px; }
.hud { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; }
.back-btn { display: flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--dim); font-size: 13px; }
.rank-name { font-weight: 700; color: var(--ink); font-size: 14px; }
.rankwrap { flex: 1; max-width: 160px; }
.rank-bar { height: 7px; background: #232b42; border-radius: 4px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd54f, #ff9f43); transition: width .4s; }
.dopa { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.dopa .label { font-size: 10px; color: var(--dim); letter-spacing: .2em; }
.dopa .value { font-weight: 900; color: var(--gold); font-size: 16px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-btns { display: flex; gap: 6px; }
.icon-btn { background: #202741; border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px; font-size: 17px; position: relative; }
.badge { position: absolute; top: -4px; right: -4px; background: #e5372b; color: #fff; border-radius: 8px; font-size: 10px; padding: 1px 5px; font-style: normal; }
.subhud { display: flex; justify-content: center; gap: 8px; min-height: 26px; align-items: center; }
.tk { color: var(--gold); font-size: 13px; }
.chain-tag { background: linear-gradient(90deg, #ff4fd8, #ffd54f); color: #3a1030; font-weight: 900; padding: 3px 14px; border-radius: 999px; font-size: 13px; animation: pop .3s; }
@keyframes pop { from { transform: scale(.6); } to { transform: scale(1); } }

#stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px; min-height: 0; }
#stage.shake { animation: shk .4s; }
@keyframes shk { 20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-4px, 1px); } 80% { transform: translate(3px, -1px); } }

/* idle */
.idle { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.idle-daily-label { color: var(--dim); font-size: 13px; letter-spacing: .15em; }
.idle-daily { pointer-events: auto; }
.idle-note { color: #555d75; font-size: 11.5px; }

/* ---------- cards ---------- */
.pull-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: 100%; max-width: 560px; }
.card { --tc: #9aa0a6; aspect-ratio: 3/4.2; background: linear-gradient(180deg, #1e2438, #171c2c); border: 2px solid var(--tc); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; opacity: 0; transform: translateY(18px) scale(.85); transition: opacity .25s, transform .3s cubic-bezier(.2, 1.6, .4, 1); position: relative; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.card.in { opacity: 1; transform: none; }
.card .card-tier { font-size: 10px; font-weight: 900; color: var(--tc); letter-spacing: .12em; }
.card .card-kanji { font-family: var(--serif); font-size: clamp(30px, 7vw, 44px); color: #fff; text-shadow: 0 0 14px var(--tc); }
.card.new .card-kanji { color: var(--tc); }
.card .card-new { position: absolute; top: 5px; left: 5px; background: #e5372b; color: #fff; font-size: 9px; font-weight: 800; padding: 1px 5px; border-radius: 6px; }
.card.t4 { box-shadow: 0 4px 14px rgba(229,83,61,.35), 0 0 24px rgba(255,213,79,.15); }
.card.t5 { background: linear-gradient(180deg, #2b1e44, #171c2c); }
.card.t6 { background: linear-gradient(135deg, #3a1e44, #1c2440 40%, #44283a); animation: holo 2s linear infinite; }
@keyframes holo { to { filter: hue-rotate(360deg); } }
.card.bp-best { transform: scale(1.2); }

/* big pull */
.bigpull { width: 100%; max-width: 720px; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: pop .25s; }
.bp-head { font-size: clamp(20px, 5vw, 30px); font-weight: 900; letter-spacing: .1em; }
.bp-grid { display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr); gap: 4px; width: 100%; }
.mini { font-family: var(--serif); background: #1b2133; border: 1px solid #2a3149; border-radius: 7px; text-align: center; font-size: clamp(12px, 2.6vw, 20px); padding: 2px 0; opacity: 0; animation: fadein .3s forwards; }
@keyframes fadein { to { opacity: 1; } }
.mini.t0 { border-color: #3a4258; color: #9aa0a6; }
.mini.t1 { border-color: #57bb6a; }
.mini.t2 { border-color: #3d8af7; }
.mini.t3 { border-color: #f0b429; color: #ffd97a; }
.mini.t4 { border-color: #e5533d; color: #ff9d8a; background: #2b1a20; }
.mini.t5 { border-color: #a55eea; color: #d5a8ff; background: #241a35; }
.mini.t6 { border-color: #ff4fd8; color: #ffd6f5; background: #301229; animation: holo 1.6s linear infinite; }
.mini.more { border-style: dashed; color: var(--dim); font-size: 12px; }
.bp-line { color: var(--dim); font-size: 13px; }

/* cutscene */
.cut { position: fixed; inset: 0; z-index: 58; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: rgba(10, 12, 22, .72); backdrop-filter: blur(2px); }
.cut .cut-tier { font-size: clamp(22px, 6vw, 36px); font-weight: 900; letter-spacing: .3em; color: #fff; }
.cut .cut-char { font-family: var(--serif); font-size: clamp(90px, 30vw, 200px); color: #fff; text-shadow: 0 0 40px currentColor; }
.cut.t4 .cut-char { color: #ffd54f; } .cut.t4 .cut-tier { color: #ffd54f; }
.cut.t5 .cut-char { color: #b678ff; } .cut.t5 .cut-tier { color: #b678ff; }
.cut.t6 .cut-char { color: #ff4fd8; } .cut.t6 .cut-tier { background: linear-gradient(90deg, #ff4fd8, #ffd54f, #4fd8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* banner */
.banner { position: fixed; top: 24%; left: 0; right: 0; z-index: 57; display: flex; flex-direction: column; align-items: center; pointer-events: none; animation: pop .3s; }
.banner .b-big { font-size: clamp(26px, 7vw, 44px); font-weight: 900; letter-spacing: .12em; color: var(--gold); text-shadow: 0 0 24px rgba(255, 200, 60, .5); }
.banner.rainbow .b-big { background: linear-gradient(90deg, #ff4fd8, #ffd54f, #4fd8ff, #ff4fd8); background-size: 200%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: slide 2s linear infinite; }
@keyframes slide { to { background-position: 200%; } }
.banner .b-small { margin-top: 6px; color: #fff; font-size: 15px; font-weight: 700; text-shadow: 0 1px 8px #0008; }

/* overlay / panels / modals */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(8, 10, 18, .8); display: flex; align-items: center; justify-content: center; padding: 16px; }
.panel-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 18px; max-width: 420px; width: 100%; max-height: 86vh; overflow-y: auto; }
.chain-sum h2 { text-align: center; font-size: 20px; margin-bottom: 10px; }
.cs-rows { margin: 12px 0; }
.cs-row { display: flex; justify-content: space-between; padding: 7px 4px; border-bottom: 1px dashed var(--line); font-size: 14px; color: var(--dim); }
.cs-row b { color: var(--ink); }
.cs-top { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 8px 0; padding: 8px; border-radius: 12px; background: #171c2c; }
.cs-top .cs-tier { font-weight: 900; }
.cs-top .cs-char { font-family: var(--serif); font-size: 40px; }
.cs-top.t5 { color: #b678ff; } .cs-top.t6 { color: #ff4fd8; } .cs-top.t4 { color: #ffd54f; }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

.panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: min(420px, 100%); background: var(--bg2); border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; animation: slidein .25s; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel-head h2 { font-size: 18px; }
.icon-btn.x, .panel-head .icon-btn { width: 32px; height: 32px; font-size: 14px; }
.tro-n { color: var(--gold); font-size: 13px; font-weight: 800; }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 18, .72); display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 18px; max-width: 480px; width: 100%; max-height: 88vh; overflow-y: auto; }

/* dex */
.dex-count { color: var(--dim); font-size: 13px; margin-bottom: 8px; }
.dex-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.dex-search { width: 100%; background: #202741; border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 9px 12px; font-size: 15px; margin-bottom: 8px; font-family: var(--serif); }
.dex-info { color: #555d75; font-size: 12px; margin-bottom: 6px; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; }
.dex-cell { font-family: var(--serif); font-size: 20px; text-align: center; padding: 4px 0; border-radius: 8px; background: #1b2133; border: 1px solid var(--line); color: #fff; }
.dex-cell.no { opacity: .28; filter: grayscale(1); }
.dex-cell.t0 { border-color: #3a4258; } .dex-cell.t1 { border-color: #2a5c36; } .dex-cell.t2 { border-color: #23486e; }
.dex-cell.t3 { border-color: #7d621a; } .dex-cell.t4 { border-color: #7d2c20; } .dex-cell.t5 { border-color: #4e2e7d; }
.dex-cell.t6 { border-color: #99297d; }

/* detail */
.dt-hero { --tc: #9aa0a6; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px; border: 2px solid var(--tc); border-radius: 16px; margin-bottom: 12px; background: linear-gradient(180deg, #1e2438, #171c2c); }
.dt-tier { color: var(--tc); font-weight: 900; letter-spacing: .2em; }
.dt-kanji { font-family: var(--serif); font-size: 72px; color: #fff; text-shadow: 0 0 24px var(--tc); line-height: 1.15; }
.dt-freq { color: var(--dim); font-size: 12px; }
.dt-dup { color: var(--gold); font-size: 12px; }
.dt-row { display: flex; gap: 10px; padding: 6px 2px; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.dt-l { color: var(--dim); min-width: 74px; flex-shrink: 0; }
.dt-v { color: var(--ink); word-break: break-word; }
.dt-v.badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge-i { font-style: normal; background: #232b42; border: 1px solid var(--line); color: var(--dim); border-radius: 6px; padding: 1px 7px; font-size: 11px; }
.dt-stats { display: flex; gap: 12px; justify-content: space-between; padding: 10px 2px; }
.stat { flex: 1; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.stat-l { color: var(--dim); font-size: 11px; letter-spacing: .15em; text-transform: uppercase; }
.stat-bar { width: 100%; height: 6px; background: #232b42; border-radius: 3px; overflow: hidden; }
.stat-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffd54f, #ff9f43); }
.stat b { font-size: 14px; }
.dt-ety { padding: 8px 2px; font-size: 12.5px; color: var(--dim); line-height: 1.5; }
.dt-ety .dt-l { margin-right: 6px; }

/* missions / trophies / settings */
.mission { display: flex; align-items: center; gap: 8px; padding: 10px 4px; border-bottom: 1px dashed var(--line); }
.mission.done { opacity: .45; }
.m-label { flex: 1; font-size: 13.5px; }
.m-bar { width: 64px; height: 6px; background: #232b42; border-radius: 3px; overflow: hidden; }
.m-bar i { display: block; height: 100%; background: var(--gold); }
.m-prog { color: var(--dim); font-size: 12px; min-width: 52px; text-align: right; }
.m-note { color: #555d75; font-size: 12px; margin-top: 10px; }
.trophy { padding: 10px 4px; border-bottom: 1px dashed var(--line); display: flex; flex-direction: column; gap: 2px; opacity: .4; }
.trophy b { font-size: 14px; }
.trophy span { font-size: 12px; color: var(--dim); }
.trophy.got { opacity: 1; }
.trophy.got b { color: var(--gold); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.set-row.col { flex-direction: column; align-items: flex-start; }
.toggle { border: 1px solid var(--line); background: #232b42; color: var(--dim); border-radius: 999px; padding: 5px 14px; font-size: 12px; font-weight: 800; }
.toggle.on { background: var(--gold); color: #3a2503; border-color: transparent; }
.lic-note { color: #555d75; font-size: 11px; margin-top: 12px; line-height: 1.5; }
.wide { width: 100%; margin-top: 12px; }

/* sponsor */
.sponsor-card { text-align: center; }
.ad-slot { min-height: 180px; background: #171c2c; border: 1px dashed var(--line); border-radius: 12px; display: flex; align-items: center; justify-content: center; margin: 12px 0; }
.ad-note { color: #555d75; font-size: 12px; padding: 12px; }

/* howto */
.how-lead { font-size: 14px; line-height: 1.7; margin-bottom: 12px; color: var(--ink); }
.how-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 10px; }
.how-table th { color: var(--dim); font-weight: 600; text-align: left; padding: 4px; border-bottom: 1px solid var(--line); }
.how-table td { padding: 5px 4px; border-bottom: 1px dashed var(--line); }
.tcell { font-weight: 900; }
.tcell.t0 { color: #9aa0a6; } .tcell.t1 { color: #57bb6a; } .tcell.t2 { color: #3d8af7; }
.tcell.t3 { color: #f0b429; } .tcell.t4 { color: #e5533d; } .tcell.t5 { color: #a55eea; } .tcell.t6 { color: #ff4fd8; }
.how-note { color: #555d75; font-size: 12px; margin: 6px 0 12px; }
.howto-body p { font-size: 13.5px; line-height: 1.7; margin-bottom: 8px; }

/* toasts */
#toasts { position: fixed; top: 14px; left: 0; right: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #202741ee; border: 1px solid var(--line); color: var(--ink); padding: 9px 18px; border-radius: 999px; font-size: 13.5px; opacity: 0; transform: translateY(-12px); transition: all .3s; }
.toast.in { opacity: 1; transform: none; }
.toast.good { border-color: #2a5c36; color: #8de6a3; }
.toast.gold { border-color: var(--gold); color: var(--gold); }
.toast.bad { border-color: #7d2c20; color: #ff9d8a; }
.toast.warn { border-color: #7d621a; color: #ffd97a; }

/* controls */
.controls { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 14px 10px; }
.packs { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; }
.packs .pk { color: var(--ink); font-weight: 800; }
.pk-timer { font-size: 12px; color: #555d75; }
.ticket-btn { background: linear-gradient(180deg, #b678ff, #8a3ee8); color: #fff; border: 0; border-radius: 12px; padding: 9px 18px; font-size: 13.5px; font-weight: 800; box-shadow: 0 3px 0 #5b249e; }
.ticket-btn:active { transform: translateY(2px); box-shadow: none; }

@media (max-width: 420px) {
  .pull-row { gap: 5px; }
  .hud { flex-wrap: wrap; }
  .rankwrap { max-width: none; order: 5; flex-basis: 100%; }
}
