.hb{--ink:#23264A;--muted:#7C7F9E;--accent:#FF6B5B;--accent-d:#E2493A;--mint:#2EC4B6;--soft:#F4F1FB;--line:#E8E3F3;--card:#fff;
  position:relative;font-family:'Rubik',system-ui,sans-serif;color:var(--ink);background:var(--card);border-radius:28px;
  box-shadow:0 1px 0 var(--line),0 20px 60px -20px rgba(35,38,74,.25);padding:28px;box-sizing:border-box}
.hb *,.hb *::before,.hb *::after{box-sizing:border-box}
.hb :where(button){font:inherit;color:inherit;border:0;background:none;cursor:pointer;padding:0}
.hb-title{margin:0 0 4px;font-size:clamp(22px,2.6vw,32px);font-weight:700;letter-spacing:-.3px}
.hb-sub{margin:0 0 22px;color:var(--muted);font-size:15px}
.hb-grid{display:grid;grid-template-columns:minmax(280px,380px) 1fr;gap:28px;align-items:start}

/* сцена */
.hb-stagecol{position:sticky;top:20px;display:flex;flex-direction:column;gap:14px}
.hb-stage{position:relative;aspect-ratio:240/350;max-height:560px;width:100%;border-radius:24px;overflow:hidden;background:var(--soft);
  display:grid;place-items:center}
.hb-stage.is-avatar{aspect-ratio:1/1;background:var(--soft)}
.hb-figure{width:100%;height:100%;display:grid;place-items:center}
.hb-figure svg{width:100%;height:100%;display:block}
.hb-stage.is-avatar .hb-figure{width:84%;height:84%}
.hb-figure.bump{animation:hbBump .3s ease}
@keyframes hbBump{40%{transform:scale(1.025)}}
.hb-figure.saved{animation:hbSaved .7s ease}
@keyframes hbSaved{30%{transform:translateY(-10px) scale(1.03)}60%{transform:translateY(2px)}}

.hb-seg{display:flex;background:var(--soft);border-radius:14px;padding:4px;gap:4px}
.hb-seg button{flex:1;height:38px;border-radius:10px;font-size:14px;font-weight:500;color:var(--muted);transition:background .2s,color .2s}
.hb-seg button.on{background:#fff;color:var(--ink);box-shadow:0 2px 6px rgba(35,38,74,.1)}

.hb-actions{display:flex;gap:10px}
.hb-btn{height:50px;border-radius:14px;display:flex;align-items:center;justify-content:center;gap:8px;font-weight:600;font-size:15px;transition:transform .12s,background .2s}
.hb-btn:active{transform:scale(.96)}
.hb-btn svg{width:20px;height:20px;flex:none}
.hb-btn.ghost{width:50px;background:var(--soft)}
.hb-btn.ghost:hover{background:var(--line)}
.hb-btn.save{flex:1;background:var(--accent);color:#fff;box-shadow:0 8px 18px -8px var(--accent)}
.hb-btn.save:hover{background:var(--accent-d)}

/* редактор */
.hb-editor{min-width:0}
.hb-tabs{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:18px}
.hb-tab{display:flex;align-items:center;gap:6px;height:40px;padding:0 13px 0 10px;border-radius:20px;background:var(--soft);font-weight:500;font-size:14px;color:var(--ink);transition:background .2s,color .2s}
.hb-tab svg{width:20px;height:20px}
.hb-tab:hover{background:var(--line)}
.hb-tab.on{background:var(--ink);color:#fff}
.hb-panel{display:flex;flex-direction:column;gap:20px;animation:hbFade .25s ease}
@keyframes hbFade{from{opacity:0;transform:translateY(6px)}}
.hb-sec-t{font-size:13px;font-weight:600;text-transform:uppercase;letter-spacing:.6px;color:var(--muted);margin:0 0 10px}
.hb-tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(74px,1fr));gap:10px}
.hb-tile{position:relative;aspect-ratio:1;border-radius:18px;background:var(--soft);overflow:hidden;display:flex;flex-direction:column;align-items:center;justify-content:center;
  outline:3px solid transparent;outline-offset:-3px;transition:outline-color .15s,transform .15s}
.hb-tile:hover{transform:translateY(-2px)}
.hb-tile.on{outline-color:var(--accent);background:#fff}
.hb-tile svg{width:100%;height:100%;flex:1;min-height:0}
.hb-tile.lbl{aspect-ratio:auto;height:96px;padding:6px 4px 0}
.hb-tile .none{width:34%;height:34%;border:3px solid #C9C4DA;border-radius:50%;position:relative}
.hb-tile .none::after{content:"";position:absolute;left:50%;top:-10%;height:120%;width:3px;background:#C9C4DA;transform:translateX(-50%) rotate(45deg)}
.hb-tile small{flex:none;font-size:11px;color:var(--muted);text-align:center;line-height:1;padding:4px 2px 7px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.hb-tile.on small{color:var(--accent-d);font-weight:500}
.hb-colors{display:flex;flex-wrap:wrap;gap:10px}
.hb-color{width:36px;height:36px;border-radius:50%;background:var(--c);box-shadow:inset 0 0 0 1px rgba(0,0,0,.08);transition:transform .15s}
.hb-color:hover{transform:scale(1.1)}
.hb-color.on{box-shadow:0 0 0 3px #fff,0 0 0 5px var(--accent)}
.hb-sliders{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px 24px}
.hb-slider{display:flex;flex-direction:column;gap:8px;font-size:14px;font-weight:500}
.hb-slider input{-webkit-appearance:none;appearance:none;width:100%;height:6px;border-radius:6px;outline:none;
  background:linear-gradient(90deg,var(--accent) var(--p,50%),var(--line) var(--p,50%))}
.hb-slider input::-webkit-slider-thumb{-webkit-appearance:none;width:22px;height:22px;border-radius:50%;background:#fff;border:3px solid var(--accent);cursor:grab}
.hb-slider input::-moz-range-thumb{width:16px;height:16px;border-radius:50%;background:#fff;border:3px solid var(--accent);cursor:grab}
.hb-toggle{display:inline-flex;align-items:center;gap:8px;height:40px;padding:0 14px;border-radius:12px;background:var(--soft);font-weight:500;font-size:14px}
.hb-toggle.on{background:var(--ink);color:#fff}
.hb-toggle svg{width:18px;height:18px}
.hb-note{font-size:14px;color:var(--muted);background:var(--soft);border-radius:14px;padding:14px 16px}
.hb-toast{position:absolute;left:50%;top:18px;transform:translate(-50%,-12px);opacity:0;pointer-events:none;z-index:5;
  background:var(--ink);color:#fff;font-weight:500;padding:10px 18px;border-radius:14px;transition:all .25s;white-space:nowrap}
.hb-toast.show{opacity:1;transform:translate(-50%,0)}

.hb-start{position:absolute;inset:0;z-index:6;border-radius:inherit;background:rgba(255,255,255,.97);display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:22px;padding:min(20vh,170px) 20px 24px;text-align:center;animation:hbFade .3s ease}
.hb-start[hidden]{display:none}
.hb-start h3{margin:0;font-size:clamp(24px,3vw,34px);font-weight:700}
.hb-start p{margin:-12px 0 0;color:var(--muted)}
.hb-pick{display:flex;gap:18px;flex-wrap:wrap;justify-content:center}
.hb .hb-pick button{width:200px;border-radius:24px;background:var(--soft);padding:16px 16px 14px;display:flex;flex-direction:column;align-items:center;gap:10px;font-size:18px;font-weight:600;transition:transform .15s,box-shadow .15s}
.hb .hb-pick button:hover{transform:translateY(-4px);box-shadow:0 0 0 3px var(--accent)}
.hb-pick svg{width:150px;height:150px}
@media (max-width:820px){
  .hb-stagecol{position:sticky!important;top:0;z-index:4;background:#fff;margin:0 -18px;padding:8px 18px 10px;box-shadow:0 8px 14px -12px rgba(35,38,74,.35)}
  .hb-stage{height:36vh!important;max-height:none;width:auto;aspect-ratio:240/350!important;margin:0 auto}
  .hb-stage.is-avatar{height:36vh!important;width:auto!important;aspect-ratio:1/1}
  .hb-seg button{height:34px}
  .hb-btn{height:42px}.hb-btn.ghost{width:42px}
  .hb .hb-pick button{width:140px;padding:12px}.hb-pick svg{width:104px;height:104px}.hb-pick{gap:12px}
  .hb{padding:18px;border-radius:22px}
  .hb-grid{grid-template-columns:1fr;gap:18px}
  .hb-stage{max-height:52vh;aspect-ratio:auto;height:52vh}
  .hb-stage.is-avatar{height:auto;aspect-ratio:1/1;max-height:none;width:min(100%,340px);margin:0 auto}
  .hb-tabs{flex-wrap:nowrap;overflow-x:auto;margin:0 -18px 16px;padding:0 18px;scrollbar-width:none}
  .hb-tabs::-webkit-scrollbar{display:none}
  .hb-tab{flex:none}
  .hb-tiles{grid-template-columns:repeat(auto-fill,minmax(64px,1fr));gap:8px}
}

/* стан «Мій герой»: налаштування згорнуті, праворуч рюкзак */
.hb-right{min-width:0}
.hb-editor[hidden],.hb-pack[hidden]{display:none}
.hb-mine-actions{display:none}
.hb.is-mine .hb-actions{display:none}
.hb.is-mine .hb-mine-actions{display:flex}
.hb.is-mine [data-ref=view]{display:none}
.hb.is-mine .hb-grid{align-items:center}
.hb.is-mine .hb-stagecol{position:static}
.hb-btn.ghost.wide{width:auto;flex:1;padding:0 16px}
.hb-pack{display:flex;flex-direction:column;align-items:center;gap:10px;animation:hbFade .4s ease}
.hb-pack-art{position:relative;width:min(100%,440px);aspect-ratio:400/460;container-type:inline-size}
.hb-pack-art>svg{position:absolute;inset:0;width:100%;height:100%;display:block}
.hb-pack-t{position:absolute;left:18.5%;width:63%;top:25.2%;text-align:center;font-weight:700;font-size:3.6cqw;color:#C0462F;letter-spacing:.2px}
.hb-pack-row{position:absolute;left:20%;width:60%;height:12.6%;display:flex;justify-content:space-between;align-items:flex-end}
.hb-pack-row.r0{top:31.4%}.hb-pack-row.r1{top:52.2%}
.hb-slot{height:100%;aspect-ratio:1;border-radius:50%;border:2px dashed #D9CBB0;display:grid;place-items:center;background:rgba(255,255,255,.55)}
.hb-slot-ghost{width:62%;height:62%;color:#B9B2A6;opacity:.35;display:block}
.hb-slot-ghost svg{width:100%;height:100%;display:block}
.hb-slot.on{border:3px solid #FFD166;background:#fff;box-shadow:0 4px 10px -4px rgba(35,38,74,.35)}
.hb-slot-ico{font-size:7cqw;line-height:1}
.hb-pack-stars{position:absolute;left:24%;width:52%;top:77.6%;height:15.6%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.4cqw}
.hb-pack-st{font-size:3.4cqw;font-weight:700;color:#8A5A00;text-transform:uppercase;letter-spacing:.8px}
.hb-pack-num{display:flex;align-items:center;gap:1.6cqw;font-size:9.5cqw;font-weight:800;line-height:1;color:var(--ink)}
.hb-pack-num svg{width:1em;height:1em;display:block}
.hb-pack-note{margin:0;text-align:center;color:var(--muted);font-size:15px;max-width:440px}
.hb .pop{animation:hbPop .6s cubic-bezier(.3,1.6,.5,1)}
@keyframes hbPop{0%{transform:scale(.4);opacity:0}55%{transform:translateY(-8%) scale(1.18);opacity:1}100%{transform:none}}
@media (prefers-reduced-motion:reduce){.hb .pop,.hb-pack{animation:none}}
@media (max-width:820px){
  .hb.is-mine .hb-stagecol{position:static!important;margin:0;padding:0;box-shadow:none;background:none}
  .hb.is-mine .hb-stage{height:46vh!important}
  .hb-pack-art{width:min(100%,380px)}
  .hb-mine-actions .hb-btn{white-space:nowrap;font-size:14px;padding:0 12px;gap:6px}
}

/* стрілка між героєм і рюкзаком: відкриває / згортає налаштування (лише комп'ютер) */
.hb-stagewrap{position:relative}
.hb-grid{column-gap:40px}
.hb .hb-fold{position:absolute;top:50%;right:-40px;z-index:3;width:40px;height:40px;margin-top:-20px;border-radius:50%;
  background:var(--accent);color:#fff;display:grid;place-items:center;box-shadow:0 0 0 4px #fff,0 8px 18px -6px rgba(226,73,58,.6);
  transition:transform .2s,background .2s}
.hb .hb-fold[hidden]{display:none}
.hb-fold svg{width:22px;height:22px;display:block;transition:transform .4s cubic-bezier(.3,.8,.25,1)}
.hb .hb-fold:hover{background:var(--accent-d);transform:scale(1.08)}
.hb .hb-fold:focus-visible{outline:3px solid var(--ink);outline-offset:3px}
.hb-fold.back svg{transform:rotate(180deg)}
@media (prefers-reduced-motion:reduce){.hb-fold,.hb-fold svg{transition:none}}
@media (max-width:820px){.hb .hb-fold{display:none}}
