:root{
  --bg: #0b0e14;
  --ui-font: system-ui,-apple-system,Segoe UI,Roboto,Arial;
  --ui-text: #e8eefc;
  --text-on-dark: #fff;
  --ui-shadow: 0 1px 0 rgba(0,0,0,.35);
  --overlay-bg: rgba(0,0,0,.55);
  --panel-bg: rgba(15,18,28,.92);
  --surface-1: rgba(255,255,255,.06);
  --surface-2: rgba(255,255,255,.08);
  --surface-3: rgba(255,255,255,.10);
  --surface-4: rgba(255,255,255,.12);
  --border-1: rgba(255,255,255,.08);
  --border-2: rgba(255,255,255,.10);
  --border-3: rgba(255,255,255,.12);
}
html, body { margin:0; padding:0; background:var(--bg); overflow:hidden; }
canvas { display:block; width:100vw; height:100vh; image-rendering: pixelated; touch-action:none; }

.hud{
  position:fixed; left:12px; top:10px; right:12px;
  font:14px/1.35 var(--ui-font);
  color:var(--ui-text); pointer-events:none;
  text-shadow:var(--ui-shadow);
  z-index: 2;
}
.row{display:flex; gap:10px; align-items:center; flex-wrap:wrap;}
.badge{
  display:inline-flex; gap:10px; align-items:center; flex-wrap:wrap;
  padding:6px 10px; border-radius:10px;
  background:var(--surface-1); box-shadow:inset 0 0 0 1px var(--border-1);
}
.barWrap{display:flex; gap:10px; align-items:center; margin-top:8px;}
.barWrap.small{ margin-top:6px; }
.barWrap.small span{ width:56px; font-size:12px; opacity:.85; }
.bar{
  width:260px; height:12px; border-radius:999px;
  background:var(--surface-4); overflow:hidden;
  box-shadow: inset 0 0 0 1px var(--border-1);
  position:relative;
}
.bar.hpBar,
.bar.xpBar{
  width: min(400px, calc(100vw - 160px));
}
.bar.small{ width:180px; height:8px; }
.bar .fill{
  position:absolute; left:0; top:0; height:100%; width:0;
  background:rgba(255,255,255,.65);
}
.bar.hpBar .fill{
  background:#98e06a;
}
.bar.xpBar .fill{
  background:#e7c24f;
}
.bar.bossHp .fill{
  background:rgba(255,120,120,0.78);
}
.bar .pulse{
  position:absolute; left:0; top:0; height:100%; width:0;
  background:rgba(140,255,170,.35);
  opacity:.7; pointer-events:none;
  animation: hpPulse 0.55s ease-in-out infinite;
}
.bar.hpBar .pulse{
  background:rgba(152,224,106,.35);
}
@keyframes hpPulse{
  0%{ opacity:.35; }
  50%{ opacity:.85; }
  100%{ opacity:.35; }
}
.bossWrap{ margin-top:10px; display:none; }
.bossList{ display:flex; flex-direction:column; gap:8px; }
.bossRow{ display:flex; flex-direction:column; }
.bossName{ opacity:.9; margin-bottom:6px; }
.bossRow .bossName{ margin-bottom:4px; }
.hint{opacity:.85; font-size:13px; margin-top:10px;}
.activeItems{
  position:fixed; right:16px; bottom:12px;
  font:12px/1.35 var(--ui-font);
  color:var(--ui-text); pointer-events:none;
  text-shadow:var(--ui-shadow);
  z-index: 2;
  text-align:right;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
}
.activeItems .actionHint{
  font-weight:800;
  font-size:11px;
  letter-spacing:0.6px;
  text-transform:uppercase;
  opacity:.85;
  margin-bottom:6px;
}
.activeItems .title{
  font-weight:800;
  font-size:11px;
  letter-spacing:0.6px;
  text-transform:uppercase;
  opacity:.75;
  margin-bottom:6px;
}
.activeItems .item{
  margin-right:-4px;
  display:flex;
  align-items:center;
  gap:6px;
  padding:4px 8px;
  border-radius:999px;
  background:var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-2);
  margin-bottom:6px;
}
.activeItems .item:last-child{ margin-bottom:0; }
.totemTimer{
  position:fixed;
  left:50%;
  top:18vh;
  transform:translateX(-50%);
  font:800 64px/1.1 var(--ui-font);
  color:rgba(255,170,80,0.98);
  text-shadow:0 2px 14px rgba(120,70,20,.55), 0 1px 0 rgba(0,0,0,.45);
  letter-spacing:1px;
  text-align:center;
  pointer-events:none;
  display:none;
  z-index: 3;
}
.totemTimer .sub{
  display:block;
  margin-top:8px;
  font-size:0.38em;
  letter-spacing:0.5px;
  color:rgba(255,210,170,0.95);
  text-shadow:0 2px 10px rgba(120,70,20,.35), 0 1px 0 rgba(0,0,0,.35);
}
.totemWarning{
  position:fixed; inset:0;
  display:flex; align-items:flex-start; justify-content:center;
  text-align:center;
  font:900 34px/1.2 var(--ui-font);
  color:rgba(255,210,245,0.98);
  text-shadow:0 2px 14px rgba(90,0,70,.55), 0 1px 0 rgba(0,0,0,.55);
  background:
    radial-gradient(circle at 50% 45%, rgba(170,40,130,.18) 0%, rgba(120,0,90,.30) 45%, rgba(80,0,60,.42) 100%);
  opacity:0;
  transition: opacity 0.2s ease;
  padding-top:16vh;
  pointer-events:none;
  z-index: 4;
}
.totemWarning.show{ opacity:1; }

.overlay{
  position:fixed; inset:0; display:none; place-items:center;
  background:var(--overlay-bg);
  font:16px/1.35 var(--ui-font);
  color:var(--text-on-dark);
  z-index: 5;
}
.panel{
  width:min(920px, calc(100vw - 24px));
  border-radius:18px;
  background:var(--panel-bg);
  box-shadow:0 12px 40px rgba(0,0,0,.45), inset 0 0 0 1px var(--border-2);
  padding:18px;
}
.panel h2{margin:0 0 10px; font-size:18px;}
.menuPanel{
  width:min(520px, calc(100vw - 32px));
  text-align:center;
}
.menuTitle{
  font-size:28px;
  font-weight:900;
  letter-spacing:0.6px;
  margin:2px 0 4px;
}
.menuSubtitle{
  opacity:.75;
  font-size:13px;
  margin-bottom:14px;
}
.menuButtons{
  display:flex;
  flex-direction:column;
  gap:10px;
  max-width:360px;
  margin:0 auto;
}
.menuButtons .btn{ width:100%; }
.choices{display:grid; grid-template-columns:repeat(3,1fr); gap:12px;}
.choice{
  text-align:left; border-radius:14px; padding:12px;
  background:var(--surface-1);
  box-shadow:inset 0 0 0 1px var(--border-2);
  cursor:pointer; user-select:none;
}
.choice:hover{background:var(--surface-3);}
.choice .t{font-weight:800; margin-bottom:6px; display:flex; gap:8px; align-items:baseline; flex-wrap:wrap;}
.choice .d{opacity:.85; font-size:13px;}
.pill{
  font-size:11px; padding:2px 8px; border-radius:999px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border-3);
  opacity:.95;
}
.pill.common{ background: var(--surface-3); }
.pill.rare{ background: rgba(120,220,255,.14); }
.pill.epic{ background: rgba(210,120,255,.16); }

.toolbar{ display:flex; gap:10px; flex-wrap:wrap; margin-top:12px; }
.toolbar.center{ justify-content:center; }
.btn{
  pointer-events:auto;
  border:0; cursor:pointer;
  padding:10px 12px;
  border-radius:12px;
  background:var(--surface-3);
  color:#fff;
  box-shadow: inset 0 0 0 1px var(--border-3);
}
.btn.primary{
  background: linear-gradient(180deg, rgba(130,230,255,.32), rgba(120,255,170,.24));
  box-shadow: inset 0 0 0 1px rgba(150,240,255,.35), 0 10px 26px rgba(60,180,160,.25);
}
.btn:hover{ background:rgba(255,255,255,.14); }
.btn.primary:hover{
  background: linear-gradient(180deg, rgba(150,245,255,.40), rgba(140,255,185,.30));
}
.btn:disabled{ opacity:.45; cursor:not-allowed; }
.btn.danger{
  background: rgba(255,100,100,.16);
  box-shadow: inset 0 0 0 1px rgba(255,140,140,.25);
}
.btn.danger:hover{ background: rgba(255,100,100,.24); }


.pauseBtn{
  position: fixed;
  right: 12px;
  top: 10px;
  z-index: 7;
  display:none;
  padding:12px 14px;
  border-radius:12px;
  font-weight:800;
  line-height:1;
}
.actionBar{
  position: fixed;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 180px;
  border-radius: 999px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
  overflow: hidden;
  display: none;
  z-index: 6;
  pointer-events: none;
}
.actionBar .fill{
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg, rgba(255,230,140,0.9), rgba(255,140,120,0.95));
  box-shadow: 0 -6px 16px rgba(255,180,120,0.45);
}

.grid2{ display:grid; grid-template-columns: 1.1fr 0.9fr; gap:14px; margin-top:10px; }
.box{
  border-radius:14px;
  background:var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--border-2);
  padding:12px;
}
.box h3{ margin:0 0 8px; font-size:14px; opacity:.95; }
.tabs{ display:flex; gap:8px; margin-bottom:8px; }
.tab{
  pointer-events:auto;
  border:0; cursor:pointer;
  padding:6px 10px;
  border-radius:999px;
  background:var(--surface-2);
  color:#fff;
  font-size:12px;
  font-weight:700;
  box-shadow: inset 0 0 0 1px var(--border-3);
}
.tab.active{
  background: rgba(120,220,255,.22);
  box-shadow: inset 0 0 0 1px rgba(120,220,255,.35);
}
.small{ font-size:13px; opacity:.9; }
.list{
  display:flex;
  flex-direction:column;
  gap:6px;
  max-height: 320px;
  overflow:auto;
  padding-right:6px;
}
.item{
  display:flex; justify-content:space-between; gap:10px;
  padding:8px 10px; border-radius:12px;
  background:rgba(255,255,255,.05);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  font-size:13px; opacity:.95;
}
.settingRow{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:8px 10px; border-radius:12px;
  background:rgba(255,255,255,.05);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  font-size:13px; opacity:.95;
  cursor:pointer; user-select:none;
}
.settingRow input[type="checkbox"]{
  width:18px; height:18px;
  accent-color: rgba(120,220,255,.9);
}
.invItem{ flex-direction:column; align-items:flex-start; gap:6px; }
.invHead{ display:flex; justify-content:space-between; gap:8px; width:100%; align-items:baseline; }
.invDesc{ font-size:12px; opacity:.85; }
.buildGroup{ display:flex; flex-direction:column; gap:6px; }
.buildGroupHead{ align-items:center; cursor:pointer; }
.buildGroupHead .label{ display:flex; align-items:center; gap:8px; }
.buildGroupHead .arrow{ font-size:11px; opacity:.7; transition: transform .15s ease; }
.buildGroupList{ display:none; flex-direction:column; gap:6px; padding-left:6px; }
.buildGroup.open .buildGroupList{ display:flex; }
.buildGroup.open .arrow{ transform: rotate(90deg); }
.buildGroupList .item{ background:rgba(255,255,255,.04); }
.k{ opacity:.95; }
.v{ opacity:.75; white-space:nowrap; }

.joyWrap{
  position: fixed; left: 0; top: 0;
  width: 160px; height: 160px;
  z-index: 6; pointer-events: none; touch-action: none;
  transform: translate(-50%,-50%);
  display:none;
}
.joyBase{
  position:absolute; inset:0; border-radius: 999px;
  background: rgba(255,255,255,.03);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.10);
  backdrop-filter: blur(6px);
}
.joyKnob{
  position:absolute; left:50%; top:50%;
  width: 64px; height: 64px;
  transform: translate(-50%,-50%);
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

/* аварийный экран */
#fatal {
  position:fixed; inset:0; display:none; place-items:center;
  background:var(--bg); color:var(--text-on-dark); z-index: 999;
  font:14px/1.4 var(--ui-font);
  padding:18px;
}
#fatal .panel { max-width: 920px; }
@media (max-width:900px){
  .choices{grid-template-columns:1fr;}
  .grid2{grid-template-columns: 1fr;}
  .bar:not(.hpBar):not(.xpBar){width:200px;}
  .list{max-height: 240px;}
  .totemTimer{ top:20vh; font-size:56px; }
  .totemWarning{ font-size:28px; padding:12vh 18px 0; }
}
