:root {
  --bg: #06060c;
  --panel: rgba(16, 16, 28, 0.72);
  --panel-2: rgba(255, 255, 255, 0.035);
  --line: rgba(255, 255, 255, 0.08);
  --text: #ececf4;
  --muted: #8a8aa3;
  --accent: #8b7bff;
  --eq: #8b7bff;
  --c1: #fff; --c2: #fff; --c3: #fff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 Inter, system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }

/* ---------- фон и слои ---------- */
#bg {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(1200px 700px at 50% 45%, color-mix(in srgb, var(--eq) 14%, transparent), transparent 70%),
    radial-gradient(800px 600px at 10% 100%, rgba(80, 40, 160, 0.18), transparent 70%),
    radial-gradient(800px 600px at 90% 0%, rgba(20, 90, 160, 0.14), transparent 70%),
    var(--bg);
  transition: background 1s;
}
#bg::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,.35), transparent),
    radial-gradient(1px 1px at 70% 80%, rgba(255,255,255,.25), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,.2), transparent),
    radial-gradient(1px 1px at 85% 25%, rgba(255,255,255,.3), transparent),
    radial-gradient(1px 1px at 55% 15%, rgba(255,255,255,.2), transparent);
  background-size: 340px 340px, 420px 420px, 290px 290px, 510px 510px, 380px 380px;
  opacity: .7;
}
#fx { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
#fx.rainbow { animation: hueSpin 4s linear infinite; }
#app { position: relative; z-index: 2; height: 100vh; display: flex; flex-direction: column; }
#app.glitch { animation: appGlitch .18s steps(2) 1; }
/* эффекты интерфейса: оттенки и вспышки поверх сайта */
#uifx { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.uiwash { position: absolute; inset: 0; opacity: 0; }
html { overflow-x: hidden; }
main { overflow: clip; overflow-clip-margin: 60px; }
body.ui-boom main, body.ui-boom .stage, body.ui-boom .display { overflow: visible; }
body.ui-boom { overflow: hidden; }
#flash { position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: 0; background: #fff; }

/* ---------- шапка ---------- */
.top {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: rgba(8, 8, 16, 0.7);
  transition: opacity .6s;
}
.brand {
  font-family: Unbounded, sans-serif; font-weight: 900; font-size: 18px; letter-spacing: .04em;
  display: flex; flex-direction: column; line-height: 1;
}
.brand span { font-size: 10px; letter-spacing: .5em; color: var(--muted); margin-top: 4px; font-weight: 600; }
.plate-wrap { min-width: 0; flex: 1; text-align: center; }
.plate-label { font-size: 10px; text-transform: uppercase; letter-spacing: .2em; color: var(--muted); }
.plate { font-family: Unbounded, sans-serif; font-weight: 800; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 2px 8px; }
.plate .crown { -webkit-text-fill-color: initial; margin-right: 6px; filter: drop-shadow(0 0 6px gold); }
.stats { display: flex; gap: 18px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; }
.stat b { font-family: Unbounded, sans-serif; font-size: 15px; font-weight: 600; }
.stat span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.08); }
.mode-btn {
  height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); color: inherit; font: 600 12px Inter, sans-serif; cursor: pointer; white-space: nowrap;
}
.mode-btn:hover { background: rgba(255,255,255,.08); }
.mode-btn.on { border-color: #ffd23f; color: #ffd23f; box-shadow: 0 0 12px rgba(255,210,63,.25); }

/* ---------- раскладка ---------- */
main {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 300px minmax(0, 1fr) 330px; gap: 16px; padding: 16px;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; overflow-y: auto;
  transition: opacity .6s;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
.panel h2 {
  font-family: Unbounded, sans-serif; font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .12em; margin: 4px 2px 12px;
}
.panel section { margin-top: 20px; }
body.cinematic .panel, body.cinematic .top, body.cinematic .log-wrap,
body.cinematic .sub-controls, body.cinematic .luck-line, body.cinematic .roll { opacity: .06; }

/* ---------- сцена ---------- */
.stage { display: flex; flex-direction: column; align-items: center; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.stage::-webkit-scrollbar { display: none; }
.display {
  flex: 1 0 auto; min-height: 300px; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 20px 10px; position: relative;
}
.tname-wrap { width: 100%; display: flex; justify-content: center; position: relative; }


.tname {
  display: inline-block; position: relative; max-width: 100%;
  font-family: Unbounded, sans-serif; font-weight: 700; font-size: 40px; line-height: 1.15;
  padding: .1em .15em; overflow-wrap: normal;
}
.tname .w { display: inline-block; white-space: nowrap; }
.tname .ch { display: inline-block; }
.trar {
  margin-top: 14px; font-family: Unbounded, sans-serif; font-size: 13px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted); min-height: 1.4em;
}
.trar b { font-weight: 800; }
.tdesc { margin-top: 8px; color: var(--muted); font-style: italic; min-height: 1.4em; opacity: 0; transition: opacity .6s .3s; }
.tdesc.on { opacity: 1; }
.tnew {
  font-family: Unbounded, sans-serif; font-weight: 800; font-size: 12px; letter-spacing: .3em;
  color: #111; background: linear-gradient(90deg, #ffe66b, #ffb52e); padding: 4px 12px; border-radius: 99px;
  margin-bottom: 14px; opacity: 0; transform: scale(.5);
}
.tnew.on { animation: newPop .6s cubic-bezier(.2, 1.6, .4, 1) .2s forwards; }

.tname.spinflash { font-size: 44px; animation: spinPunch .16s ease-out; }
/* «почти выпал» */
.tname.nearhold { font-size: 52px; animation: nearHold .38s cubic-bezier(.2, 1.4, .4, 1); }
.tname.nearhold.slip { animation: slip .2s ease-in forwards; }
@keyframes nearHold { from { transform: scale(1.25); filter: brightness(2) blur(2px); } }
@keyframes slip { to { transform: translateY(46px) scale(.85); filter: blur(6px); opacity: 0; } }
/* праздник каждого броска */
.tname-wrap { position: relative; }
.gain {
  position: absolute; right: 8%; top: -6px; pointer-events: none;
  font-family: Unbounded, sans-serif; font-weight: 800; font-size: 15px; color: #ff9af5; text-shadow: 0 0 10px #ff9af5;
  animation: gainUp 1.4s ease-out forwards;
}
@keyframes gainUp { 0% { opacity: 0; transform: translateY(10px) scale(.6); } 15% { opacity: 1; transform: translateY(0) scale(1.15); } 100% { opacity: 0; transform: translateY(-34px) scale(1); } }
.trar .nth { color: #fff; display: inline-block; animation: newPop .5s cubic-bezier(.2, 1.6, .4, 1) .15s backwards; }
.tnew.milestone { background: linear-gradient(90deg, #7df9ff, #c58bff, #ff6b9a); }
/* события на экране */
#events { position: fixed; inset: 0; z-index: 45; pointer-events: none; overflow: hidden; }
.ev {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  background: none; border: 0; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: Unbounded, sans-serif; line-height: 1; will-change: transform;
}
.ev i { font-style: normal; display: block; animation: evSpin 2.4s linear infinite; }
.ev small { font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; color: #fff; opacity: .85; }
.ev-star i { font-size: 40px; color: #ffe066; text-shadow: 0 0 10px #ffe066, 0 0 28px #ffb000, -30px 0 22px rgba(255, 224, 102, .35); }
.ev-star.small { padding: 8px; }
.ev-star.small i { font-size: 24px; }
.ev-crystal i { font-size: 38px; color: #ff9af5; text-shadow: 0 0 10px #ff9af5, 0 0 30px #c58bff; animation: evPulse 1s ease-in-out infinite; }
.ev-dice i { font-size: 46px; color: #ffd166; text-shadow: 0 0 10px #ffd166, 0 0 30px #ff8a1a; animation: evWobble .9s ease-in-out infinite; }
.ev:hover i { filter: brightness(1.4); }
.ev.caught { animation: evCatch .45s ease-out forwards; pointer-events: none; }
.ev.gone { transition: opacity .4s; opacity: 0 !important; pointer-events: none; }
@keyframes evSpin { to { rotate: 360deg; } }
@keyframes evPulse { 50% { scale: 1.2; } }
@keyframes evWobble { 25% { rotate: -14deg; } 75% { rotate: 14deg; } }
@keyframes evCatch { to { scale: 2.4; opacity: 0; filter: brightness(2); } }
.ev-pop {
  position: absolute; transform: translate(-50%, -50%); text-align: center; pointer-events: none; white-space: nowrap;
  font-family: Unbounded, sans-serif; font-weight: 900; font-size: 18px; text-shadow: 0 0 12px currentColor;
  animation: evPopUp 1.8s ease-out forwards;
}
.ev-pop small { font-size: 11px; font-weight: 600; opacity: .85; }
@keyframes evPopUp { 0% { opacity: 0; translate: 0 10px; scale: .6; } 12% { opacity: 1; translate: 0 0; scale: 1.15; } 100% { opacity: 0; translate: 0 -50px; scale: 1; } }
.luck-line .star { color: #ffe066; font-weight: 700; }
.sm-btns button.free { flex: 1 1 100%; border-color: rgba(255, 209, 102, .8); background: linear-gradient(90deg, rgba(255, 209, 102, .25), rgba(255, 138, 26, .18)); color: #fff1c2; animation: freeGlow 1.4s ease-in-out infinite; }
.sm-btns button.free b { color: #ffd166; }
@keyframes freeGlow { 50% { box-shadow: 0 0 22px rgba(255, 209, 102, .55); } }

/* серия */
.streak {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%) scale(var(--s, 1)); transform-origin: top center;
  display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: none;
  opacity: 0; transition: opacity .5s;
}
.streak.on, .streak.broke { opacity: 1; }
.streak b {
  font-family: Unbounded, sans-serif; font-weight: 900; font-size: 20px; letter-spacing: .06em; white-space: nowrap;
  color: #ffd166; text-shadow: 0 0 8px #ff8a1a, 0 0 22px #ff3d00;
}
.streak small { font-size: 11px; color: #ffcf9a; white-space: nowrap; }
.streak small em { font-style: normal; font-weight: 700; color: #fff; }
.streak.hot b { color: #fff3c4; text-shadow: 0 0 8px #ffb347, 0 0 24px #ff5a00, 0 0 44px #ff2a00; }
.streak.blue b { color: #e6faff; text-shadow: 0 0 8px #6fd6ff, 0 0 24px #2a8cff, 0 0 46px #1440c8; }
.streak.blue small { color: #9fe6ff; }
.streak.violet b { color: #fff0ff; text-shadow: 0 0 8px #ff6bf0, 0 0 26px #b04bff, 0 0 50px #6a1ad0; }
.streak.violet small { color: #f0b8ff; }
.streak.bump b { animation: streakBump .55s cubic-bezier(.2, 1.8, .4, 1); }
.streak.broke b { color: #8a8a99; text-shadow: none; font-size: 14px; }
.streak.broke small { color: var(--muted); }
.streak.broke { animation: streakFade 2.6s ease-in forwards; }
@keyframes streakBump { from { transform: scale(1.8); filter: brightness(2); } }
@keyframes streakFade { 70% { opacity: 1; } to { opacity: 0; } }

/* почти собранная коллекция */
.goal {
  display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--muted);
  width: min(100%, 480px); transition: opacity .6s;
}
.goal[hidden] { display: none; }
.goal .g-l { white-space: nowrap; }
.goal .g-bar { flex: 1; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; min-width: 50px; }
.goal .g-bar i { display: block; height: 100%; background: var(--c); box-shadow: 0 0 10px var(--c); animation: goalPulse 1.6s ease-in-out infinite; }
.goal .g-r { color: #ffd166; font-weight: 700; white-space: nowrap; }
body.cinematic .goal { opacity: .06; }
@keyframes goalPulse { 50% { filter: brightness(1.5); } }
.tier-h.near { animation: nearGlow 1.8s ease-in-out infinite; }
.tier-h .left { font-style: normal; letter-spacing: .05em; color: #ffd166; margin-left: 6px; }
@keyframes nearGlow { 50% { background: rgba(255, 209, 102, .09); } }
.ci.locked.hint { outline: 1px dashed rgba(255, 209, 102, .4); }
.ci.locked.hint .n { color: #9b8f6a; letter-spacing: .12em; }

.tname.decoding { font-size: 48px; letter-spacing: .04em; }
.tname.decoding .dc { display: inline-block; min-width: .3em; color: color-mix(in srgb, var(--c1) 45%, #555); text-shadow: none; }
.tname.decoding .dc.lock { animation: dcLock .35s cubic-bezier(.2, 1.8, .4, 1); text-shadow: 0 0 10px currentColor, 0 0 26px currentColor; }
.tname.building {
  color: var(--c1); font-size: calc(36px + 26px * var(--k, 0));
  text-shadow: 0 0 calc(40px * var(--k, 0)) var(--c1);
  animation: buildPulse calc(0.9s - 0.7s * var(--k, 0)) ease-in-out infinite;
  letter-spacing: .3em;
}

/* ---------- кнопки ---------- */
.controls { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 6px 0 14px; }
.roll {
  position: relative; cursor: pointer; border-radius: 999px; padding: 0; overflow: hidden;
  border: 2px solid #8b7bff; background: #12121e;
  animation: rollGlow 6s linear infinite;
  transition: transform .1s, opacity .6s, filter .3s;
}
.roll span {
  display: block; padding: 18px 64px; border-radius: 999px; background: #12121e;
  font-family: Unbounded, sans-serif; font-weight: 900; font-size: 22px; letter-spacing: .14em;
}
.roll:hover span { background: #1a1a2b; }
.roll:active { transform: scale(.96); }
.roll::after {
  content: ''; position: absolute; left: 22%; right: 22%; bottom: 7px; height: 3px; border-radius: 99px;
  background: rgba(255, 255, 255, .55); transform: scaleX(0); pointer-events: none;
}
.roll.cooling::after { animation: rollCd var(--cd, .8s) linear; }
@keyframes rollCd { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.roll:disabled { filter: grayscale(.8) brightness(.7); cursor: default; }
.sub-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; transition: opacity .6s; }
.toggle {
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 7px 14px; cursor: pointer;
  font-size: 13px;
}
.toggle.on { border-color: #7cfc9a; color: #7cfc9a; box-shadow: 0 0 14px rgba(124, 252, 154, .25); }
.luck-line { font-size: 12px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; min-height: 1.4em; transition: opacity .6s; }
.luck-line .hot { color: #ffd166; font-weight: 700; }
.luck-line .pot { color: #7df9ff; font-weight: 700; }

/* ---------- несколько титулов за бросок ---------- */
/* Лишние титулы броска живут в своей полосе фиксированной высоты: кнопка «Бросок»
   никуда не съезжает, а длинный список прокручивается внутри полосы. */
.multi {
  display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; align-items: center; gap: 6px;
  width: 100%; max-width: 760px; height: 72px; margin-bottom: 8px; padding: 2px 4px;
  overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .2) transparent; flex-shrink: 0;
}
.multi.long { -webkit-mask-image: linear-gradient(to bottom, #000 80%, transparent); mask-image: linear-gradient(to bottom, #000 80%, transparent); padding-bottom: 14px; }
.multi .echo {
  font-family: Unbounded, sans-serif; font-weight: 900; font-size: 11px; letter-spacing: .25em; color: #7df9ff;
  text-shadow: 0 0 10px #7df9ff, 0 0 24px #7df9ff; animation: echoIn .6s cubic-bezier(.2, 1.6, .4, 1) both;
}
.chip {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line); background: rgba(10, 10, 20, .6); font-size: 13px;
  animation: chipIn .35s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(min(var(--i), 14) * 70ms + .15s);
}
.chip .n { font-family: Unbounded, sans-serif; font-weight: 700; }
.chip small { color: var(--muted); font-size: 10px; }
.chip.isnew::after { content: "NEW"; font-size: 9px; font-weight: 800; color: #ffd166; letter-spacing: .1em; }
@keyframes chipIn { from { opacity: 0; transform: scale(.4) translateY(10px); } }
@keyframes echoIn { from { opacity: 0; transform: scale(2.2); letter-spacing: .8em; } }

/* ---------- лог ---------- */
.log-wrap { width: 100%; max-width: 560px; transition: opacity .6s; padding-bottom: 10px; }
.log-wrap h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 600; margin: 4px 0 8px; text-align: center; }
#log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
#log li {
  display: flex; justify-content: space-between; gap: 10px; padding: 5px 12px; border-radius: 8px;
  background: var(--panel-2); font-size: 13px; animation: logIn .3s ease-out;
}
#log li .n { font-family: Unbounded, sans-serif; font-weight: 600; font-size: 12px; }
#log li small { color: var(--muted); white-space: nowrap; }

/* ---------- прокачка ---------- */
.up-stage.folded { margin-bottom: 2px; }
.up {
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; margin-bottom: 7px;
  background: var(--panel-2); position: relative;
}
.up .h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.up .nm { font-weight: 700; font-size: 13px; }
.up .rq { font-family: Unbounded, sans-serif; font-size: 10px; padding: 2px 7px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.up .ds { color: var(--muted); font-size: 12px; margin-top: 3px; }
.up.on { border-color: rgba(124, 252, 154, .3); }
.up.on .nm::before { content: "✓ "; color: #7cfc9a; }
.up.locked { opacity: .45; }
.up.locked .ds { display: none; }
.up .gate { font-size: 11px; color: #ffd166; margin-top: 4px; }
.up.gated .ds { display: block; }
.up.next { opacity: 1; border-style: dashed; border-color: rgba(255, 255, 255, .25); }
.up.next .ds { display: block; }
.up.next .nm::before { content: "🔒 "; }
.up.fresh { animation: upFresh 1.6s ease-out; }

.summon-bar {
  width: 100%; max-width: 560px; margin: 2px 0 16px; padding: 12px 16px;
  background: var(--panel); border: 1px solid rgba(255, 154, 245, .22); border-radius: 16px;
  transition: opacity .6s;
}
body.cinematic .summon-bar { opacity: .06; }
.sm-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; cursor: help; }
.sm-title { font-family: Unbounded, sans-serif; font-weight: 800; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: #ffc4fa; }
.sm-sub { font-size: 11px; color: var(--muted); }
.sm-have { margin-left: auto; font-family: Unbounded, sans-serif; font-size: 13px; font-weight: 600; }
.sm-pity { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 10px; }
.pity { display: grid; grid-template-columns: auto auto; grid-template-areas: "l v" "b b"; align-items: baseline; gap: 3px 6px; font-size: 11px; }
.pity .pl { grid-area: l; font-weight: 700; white-space: nowrap; }
.pity .pv { grid-area: v; justify-self: end; color: var(--muted); font-variant-numeric: tabular-nums; }
.pity .pb { grid-area: b; display: block; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.pity .pb i { display: block; height: 100%; border-radius: 99px; transition: width .4s; }
.sm-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.sm-auto { margin-left: 10px; font: inherit; font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: 999px; cursor: pointer; background: transparent; color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.sm-auto.on { color: #7cfc9a; border-color: #7cfc9a; box-shadow: 0 0 12px rgba(124, 252, 154, .25); }
.sm-btns button.all { flex: 1 1 100%; border-color: rgba(125, 249, 255, .5); background: linear-gradient(90deg, rgba(125, 249, 255, .1), rgba(197, 139, 255, .14)); color: #c8fbff; }
.sm-btns button.all b { color: #7df9ff; }
.chip.more { color: var(--muted); font-size: 12px; }
.sm-btns button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  border: 1px solid rgba(255, 154, 245, .45); background: rgba(255, 154, 245, .08); color: #ffc4fa;
  border-radius: 999px; padding: 9px 18px; cursor: pointer; font-weight: 700; font-size: 13px;
}
.sm-btns button:hover:not(:disabled) { background: rgba(255, 154, 245, .16); }
.sm-btns button .cost { font-weight: 500; color: var(--muted); font-size: 12px; }
.sm-btns button:disabled { opacity: .35; cursor: default; }
.sm-btns button.pack { flex: 1.6; border-color: rgba(255, 209, 102, .6); background: linear-gradient(90deg, rgba(255, 209, 102, .14), rgba(255, 154, 245, .1)); color: #ffe7a8; box-shadow: 0 0 14px rgba(255, 209, 102, .18); }
.sm-btns button.pack b { color: #ffd166; }
.sm-btns button.pack s { opacity: .6; }
.sm-btns button.pack em { font-style: normal; font-size: 11px; font-weight: 700; color: #c78bff; }
@media (max-width: 560px) {
  .sm-btns { flex-direction: column; }
  .sm-pity { gap: 8px; }
}

/* ---------- коллекция ---------- */
.tier-h {
  font-family: Unbounded, sans-serif; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .2em;
  margin: 14px 2px 6px; display: flex; justify-content: space-between;
}
.tier-h:first-child { margin-top: 0; }
.tier-h.folded { margin-bottom: 2px; }
.tier-h { cursor: pointer; user-select: none; padding: 4px 2px; border-radius: 6px; }
.tier-h:hover { background: rgba(255, 255, 255, .04); }
.tier-h .chev { font-style: normal; display: inline-block; width: 1.1em; transition: transform .2s; }
.tier-h.folded .chev { transform: rotate(-90deg); }
.tier-h .tb { font-size: 9px; letter-spacing: .05em; padding: 1px 6px; border-radius: 99px; border: 1px solid currentColor; margin-right: 4px; }
.tier-h .tb.off { opacity: .35; border-style: dashed; }
.ci {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 9px; background: var(--panel-2); margin-bottom: 4px;
}
.ci .n { font-family: Unbounded, sans-serif; font-weight: 700; font-size: 12.5px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 0; }
.ci .n:hover { text-decoration: underline dotted; }
.ci.locked .n { color: #4a4a5e; cursor: default; letter-spacing: .2em; }
.ci.locked .n:hover { text-decoration: none; }
.ci .cnt { font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; }
.ci .eq { width: 14px; font-size: 13px; text-align: center; }
.ci .eq b { color: #ffd166; text-shadow: 0 0 8px #ffd166; font-weight: 400; }

/* ---------- тосты ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  background: rgba(16, 16, 30, .95); border: 1px solid rgba(255, 209, 102, .45); border-radius: 12px;
  padding: 10px 14px; max-width: 320px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  animation: toastIn .4s cubic-bezier(.2, 1.4, .4, 1);
}
.toast b { color: #ffd166; display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 2px; }
.toast.out { animation: toastOut .4s forwards; }

#debug { position: fixed; left: 10px; bottom: 10px; z-index: 70; background: #000c; padding: 8px; border-radius: 8px; display: flex; gap: 6px; font-size: 12px; align-items: center; }
#debug select, #debug button { background: #222; border: 1px solid #444; border-radius: 4px; padding: 2px 6px; }

/* =========================================================
   СТИЛИ ТИТУЛОВ: .s0 … .s9
   С эпического и выше текст разбит на буквы (.ch), цвет каждой буквы
   задаёт JS по палитре титула. Свечение — через text-shadow.
   ========================================================= */
.s0 { color: var(--c1); font-family: Unbounded, sans-serif; font-weight: 600; }
.s1 { color: var(--c1); font-family: Unbounded, sans-serif; font-weight: 700; }
.s2 {
  color: var(--c1); font-family: Unbounded, sans-serif; font-weight: 800;
  text-shadow: 0 0 6px var(--c1), 0 0 18px var(--c1);
}
.tname.s2 { animation: glowPulse 2.4s ease-in-out infinite; }
.s3 { color: var(--c1); font-family: 'Russo One', sans-serif; font-weight: 400; text-shadow: 0 0 8px var(--c1); }
.s4 { color: var(--c1); font-family: 'Russo One', sans-serif; font-weight: 400; text-shadow: 0 0 6px var(--c1), 0 0 22px var(--c2); }
.s5 { color: var(--c1); font-family: 'Yeseva One', serif; font-weight: 400; text-shadow: 0 0 8px var(--c1), 0 0 28px var(--c2); }
.s6 { color: #fff; font-family: 'Yeseva One', serif; font-weight: 400; text-shadow: 0 0 8px #fff, 0 0 24px var(--c2), 0 0 54px var(--c2); }
.s7 { color: var(--c1); font-family: Unbounded, sans-serif; font-weight: 900; letter-spacing: .06em; text-shadow: 0 0 10px var(--c2), 0 0 30px var(--c1); }
.s8 { color: #ffb030; font-family: 'Ruslan Display', serif; font-weight: 400; text-shadow: 0 0 4px #ffdd55, 0 -4px 12px #ff8800, 0 -10px 26px #ff3300, 0 0 50px #ff2200; }
.s9 { color: #fff; font-family: Unbounded, sans-serif; font-weight: 900; text-shadow: 0 0 8px #fff, 0 0 26px #ff00cc; animation: hueSpin 3s linear infinite; }

/* мелкие места: чипы, лог, коллекция, шапка — свечение скромнее */
:is(.chip, #log, .ci, .plate) :is(.s3, .s4, .s5, .s7), .plate:is(.s3, .s4, .s5, .s7) { text-shadow: 0 0 6px var(--c1); }
:is(.chip, #log, .ci, .plate) .s6, .plate.s6 { text-shadow: 0 0 6px #fff, 0 0 12px var(--c2); }
:is(.chip, #log, .ci, .plate) .s8, .plate.s8 { text-shadow: 0 0 4px #ffaa00, 0 -2px 8px #ff3300; }
:is(.chip, #log, .ci, .plate) .s9, .plate.s9 { text-shadow: 0 0 6px #fff; }

/* размеры большого титула по уровню */
.tname.s0 { font-size: 36px; }
.tname.s1 { font-size: 40px; }
.tname.s2 { font-size: 44px; }
.tname.s3 { font-size: 50px; }
.tname.s4 { font-size: 58px; }
.tname.s5 { font-size: 64px; }
.tname.s6 { font-size: 70px; }
.tname.s7 { font-size: 72px; }
.tname.s8 { font-size: 78px; }
.tname.s9 { font-size: 86px; }

/* ---------- появление: целиком ---------- */
.tname.enter.s0 { animation: fadeUp .35s ease-out; }
.tname.enter.s1 { animation: popIn .4s cubic-bezier(.2, 1.6, .4, 1); }
.tname.enter.s2 { animation: popIn .45s cubic-bezier(.2, 1.6, .4, 1), glowPulse 2.4s ease-in-out .45s infinite; }
.tname.enter.s3 { animation: zoomBlur .55s cubic-bezier(.2, 1.3, .4, 1); }
.tname.enter.s4 { animation: slam .7s cubic-bezier(.3, 1.5, .5, 1); }

/* ---------- буквы ---------- */
.tname.split .ch {
  animation:
    var(--in) var(--ind, .9s) cubic-bezier(.2, 1.2, .4, 1) backwards,
    chFloat 3.2s ease-in-out infinite,
    chShine 2.8s ease-in-out infinite;
  animation-delay:
    calc(var(--i) * var(--step, 50ms)),
    calc(var(--i) * 0.14s + 1.2s),
    calc(var(--i) * 0.09s + 1.4s);
}
.tname.s3, .tname.s4 { --in: none; }
.tname.s3.split .ch { animation: chShine 3s ease-in-out infinite; animation-delay: calc(var(--i) * 0.08s + .6s); }
.tname.s4.split .ch { animation: chShine 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * 0.07s + .8s); }
.tname.s5 { --in: chFly; }
.tname.s6 { --in: chDescend; --ind: 1.3s; --step: 70ms; }
.tname.s7 { --in: chCosmic; --ind: 1.1s; --step: 60ms; animation: cosmicHue 8s linear infinite; }
.tname.s8 { --in: chBurn; --ind: 1s; --step: 60ms; }
.tname.s8.split .ch {
  animation:
    chBurn 1s cubic-bezier(.2, 1.2, .4, 1) backwards,
    chFloat 2.4s ease-in-out infinite,
    chFire 1.3s ease-in-out infinite;
  animation-delay: calc(var(--i) * 60ms), calc(var(--i) * 0.12s + 1.2s), calc(var(--i) * -0.23s);
}
.tname.s9 { --in: chGlitch; --ind: 1.3s; --step: 45ms; }

/* глитч-слои для запредельного */
.tname.s9::before, .tname.s9::after {
  content: attr(data-text); position: absolute; inset: 0; padding: inherit;
  pointer-events: none; mix-blend-mode: screen; opacity: .65; text-shadow: none;
}
.tname.s9::before { color: #ff0050; animation: glitchA 2.3s steps(1) infinite; }
.tname.s9::after  { color: #00e5ff; animation: glitchB 1.9s steps(1) infinite; }

/* ---------- ключевые кадры ---------- */
@keyframes gradShift { from { background-position: 0% 50%; } to { background-position: 200% 50%; } }
@keyframes fireShift { from { background-position: 50% 0%; } to { background-position: 50% 150%; } }
@keyframes hueSpin { to { filter: hue-rotate(360deg); } }
@keyframes hueGlow {
  from { filter: drop-shadow(0 0 8px #fff) drop-shadow(0 0 30px #ff00cc) hue-rotate(0deg); }
  to   { filter: drop-shadow(0 0 8px #fff) drop-shadow(0 0 30px #ff00cc) hue-rotate(360deg); }
}
@keyframes cosmicHue { 50% { filter: hue-rotate(40deg); } }
@keyframes chFire { 0%, 100% { filter: brightness(1); } 30% { filter: brightness(1.45); } 65% { filter: brightness(.8); } }
@keyframes glowPulse {
  50% { text-shadow: 0 0 10px var(--c1), 0 0 34px var(--c1); }
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }
@keyframes popIn { from { opacity: 0; transform: scale(.6); } }
@keyframes zoomBlur { from { opacity: 0; transform: scale(1.8); filter: blur(12px); } }
@keyframes slam {
  0% { opacity: 0; transform: scale(4); filter: blur(20px) brightness(3); }
  60% { opacity: 1; transform: scale(.94); filter: blur(0) brightness(1.6); }
}
@keyframes chFly {
  from { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.2); filter: blur(10px); }
}
@keyframes chDescend {
  0% { opacity: 0; transform: translateY(-120px) scale(1.6); filter: blur(14px) brightness(4); }
  70% { opacity: 1; filter: blur(0) brightness(2.5); }
}
@keyframes chCosmic {
  0% { opacity: 0; transform: scale(0) rotate(-260deg); filter: brightness(5) blur(6px); }
  70% { opacity: 1; transform: scale(1.25) rotate(10deg); filter: brightness(2); }
}
@keyframes chBurn {
  0% { opacity: 0; transform: translateY(60px) scaleY(2.2) scaleX(.5); filter: blur(8px) brightness(3); }
  60% { opacity: 1; transform: translateY(-6px) scaleY(1.1); filter: brightness(2); }
}
@keyframes chGlitch {
  0% { opacity: 0; transform: translate(-40px, 0) skewX(50deg) scaleY(.2); }
  15% { opacity: 1; transform: translate(30px, -8px) skewX(-30deg); }
  30% { opacity: .2; transform: translate(-14px, 6px) scale(1.6, .6); }
  45% { opacity: 1; transform: translate(8px, 0) skewX(20deg) scale(.8, 1.4); }
  60% { opacity: .5; transform: translate(-4px, -3px); }
  80% { opacity: 1; transform: translate(2px, 1px) scale(1.15); }
}
@keyframes chFloat { 0%, 100% { translate: 0 0; } 50% { translate: 0 -7px; } }
@keyframes chShine { 0%, 70%, 100% { filter: brightness(1); } 80% { filter: brightness(1.9); } }
@keyframes chFlicker { 0%, 100% { opacity: 1; } 33% { opacity: .82; } 66% { opacity: .95; } }
@keyframes glitchA {
  0%   { transform: translate(0); clip-path: inset(0 0 0 0); }
  8%   { transform: translate(-5px, 2px); clip-path: inset(10% 0 60% 0); }
  12%  { transform: translate(4px, -1px); clip-path: inset(55% 0 20% 0); }
  16%  { transform: translate(0); clip-path: inset(0 0 100% 0); }
  60%  { transform: translate(3px, 0); clip-path: inset(30% 0 45% 0); }
  64%  { transform: translate(0); clip-path: inset(0 0 100% 0); }
}
@keyframes glitchB {
  0%   { transform: translate(0); clip-path: inset(0 0 100% 0); }
  20%  { transform: translate(5px, -2px); clip-path: inset(65% 0 5% 0); }
  24%  { transform: translate(-3px, 1px); clip-path: inset(20% 0 55% 0); }
  28%  { transform: translate(0); clip-path: inset(0 0 100% 0); }
  80%  { transform: translate(-4px, 0); clip-path: inset(40% 0 30% 0); }
  84%  { transform: translate(0); clip-path: inset(0 0 100% 0); }
}
@keyframes appGlitch {
  0% { transform: translate(-8px, 2px) skewX(4deg); filter: hue-rotate(90deg) saturate(3); }
  50% { transform: translate(6px, -3px); filter: invert(.15) hue-rotate(-60deg); }
  100% { transform: none; filter: none; }
}
@keyframes buildPulse { 50% { opacity: .55; transform: scale(.94); } }
@keyframes spinPunch { from { transform: scale(1.18); filter: blur(3px) brightness(1.8); opacity: .4; } }
@keyframes dcLock { 0% { transform: scale(1.9); filter: brightness(3); } }
@keyframes newPop { to { opacity: 1; transform: scale(1); } }
@keyframes logIn { from { opacity: 0; transform: translateY(-6px); } }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
@keyframes upFresh { 0% { box-shadow: 0 0 0 0 rgba(255, 209, 102, .9); background: rgba(255, 209, 102, .2); } 100% { box-shadow: 0 0 0 14px rgba(255, 209, 102, 0); } }
@keyframes rollGlow {
  0%, 100% { border-color: #8b7bff; box-shadow: 0 0 28px rgba(139, 123, 255, .45); }
  25% { border-color: #ff6bd6; box-shadow: 0 0 28px rgba(255, 107, 214, .45); }
  50% { border-color: #ffb52e; box-shadow: 0 0 28px rgba(255, 181, 46, .45); }
  75% { border-color: #6bd0ff; box-shadow: 0 0 28px rgba(107, 208, 255, .45); }
}

/* ---------- мобильные ---------- */
@media (max-width: 1100px) {
  main { grid-template-columns: 260px minmax(0, 1fr); }
  .panel.right { grid-column: 1 / -1; max-height: 50vh; }
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; }
}
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .plate-wrap { order: 3; flex-basis: 100%; }
  .stats { gap: 12px; margin-left: auto; }
  .stat b { font-size: 13px; }
  main { grid-template-columns: minmax(0, 1fr); padding: 10px 16px; }
  .stage { order: -1; overflow: visible; }
  .panel { max-height: none; overflow: visible; }
  .panel.right { max-height: none; }
  .display { min-height: 240px; }
  .roll span { padding: 16px 44px; font-size: 19px; }
}

/* ---------- служебное и особые титулы ---------- */
.tname.measuring, .tname.measuring * { animation: none !important; transition: none !important; }
body.mono #bg { filter: grayscale(1) brightness(.6); }
.tname.tid-absolute, .tid-absolute { animation: none; text-shadow: 0 0 10px #fff, 0 0 40px #fff; }
.tname.tid-absolute::before { color: #fff; }
.tname.tid-absolute::after { color: #000; mix-blend-mode: normal; }
.plate.burning { animation: plateBurn 1.6s ease-in-out infinite; }
@keyframes plateBurn {
  0%, 100% { text-shadow: 0 0 8px #ff6a00, 0 -4px 14px #ff2200; }
  50% { text-shadow: 0 0 14px #ffcc33, 0 -8px 22px #ff5500; }
}
